Search This Blog

Saturday, October 1, 2016

Getting oim connection (oimclient) via programmatically (java code)

Getting oim connection in java code. This is useful when you are testing stand alone code via eclipse or any other editor. Do not use this code for production debugging.

//This method needs multiple properties to be set for the connection which is quaite standard and you will get this type of code a lot

public static OIMClient getConnection() {

Hashtable env = new Hashtable();
System.setProperty("APPSERVER_TYPE", "wls");
System.setProperty("java.security.auth.login.config", "*****\authwl.conf");
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, "t3://saurabh.test:14000");
OIMClient oimClient = new OIMClient(env);
System.out.println("Client created...Now login...");

try {
oimClient.login("adminUser", "Password".toCharArray());

} catch (LoginException e) {
e.printStackTrace();
}
return oimClient;
}

Replace :
  •  Replace *****\authwl.conf file location with actual value. You can easily find this in design console folder.
  • Replace t3://saurabh.test:14000 with actual OIM t3 login.
  • Replace "adminUser", "Password" with actual login and password.

Hope this will help OIM developers.

No comments:

Post a Comment