/*Jar needed - wlfullclient-10.3.6.0.jar, spring.jar, oimclient.jar, jrf-api-11.1.1.0.0.jar & commons-logging-1.2.jar
Steps to run below code
Update Host, Port & password in belwo code
Get the authwl.conf file from designconsole/config folder and then run below method
Refer link to setup design console in your local.
*/
package com.test;
import java.util.Hashtable;
import oracle.iam.platform.OIMClient;
public class OIMLogin {
static OIMClient oimClient = null;
static String authFile = ".\\Input\\authwl.conf";
public static void main(String[] args) {
login( authFile, "t3://host:port/", "xelsysadm", "password", false, "");
oimClient.logout();
}
public static OIMClient login(String oimProviderURL, String userId, String password){
return login(authFile, oimProviderURL, userId, password, false, "");
}
public static OIMClient login(String authwlPath, String oimProviderURL,
String userId, String password, boolean isSSL, String trustKeystorePath){
System.setProperty("java.security.auth.login.config", authwlPath);
System.setProperty("APPSERVER_TYPE", "wls");
if(isSSL)
System.setProperty("weblogic.security.SSL.trustedCAKeyStore", trustKeystorePath);
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, oimProviderURL);
oimClient = new OIMClient(env);
try {
oimClient.login(userId, password.toCharArray());
System.out.println("Login Done!!!");
} catch (Exception e) {
e.printStackTrace();
}
return oimClient;
}
}
Steps to run below code
Update Host, Port & password in belwo code
Get the authwl.conf file from designconsole/config folder and then run below method
Refer link to setup design console in your local.
*/
package com.test;
import java.util.Hashtable;
import oracle.iam.platform.OIMClient;
public class OIMLogin {
static OIMClient oimClient = null;
static String authFile = ".\\Input\\authwl.conf";
public static void main(String[] args) {
login( authFile, "t3://host:port/", "xelsysadm", "password", false, "");
oimClient.logout();
}
public static OIMClient login(String oimProviderURL, String userId, String password){
return login(authFile, oimProviderURL, userId, password, false, "");
}
public static OIMClient login(String authwlPath, String oimProviderURL,
String userId, String password, boolean isSSL, String trustKeystorePath){
System.setProperty("java.security.auth.login.config", authwlPath);
System.setProperty("APPSERVER_TYPE", "wls");
if(isSSL)
System.setProperty("weblogic.security.SSL.trustedCAKeyStore", trustKeystorePath);
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, oimProviderURL);
oimClient = new OIMClient(env);
try {
oimClient.login(userId, password.toCharArray());
System.out.println("Login Done!!!");
} catch (Exception e) {
e.printStackTrace();
}
return oimClient;
}
}
No comments:
Post a Comment