I have a code that actually able to connect to Lab OIM but same code i am not able to connect to Prod OIM. Below is the code i am using. Did i miss anything? I have all those Jars also in my Project build path. Help and any suggestion will be appreciated. Below are the code and error i am getting after debugging the class.
public class ConnectionTest {
UserManager userManager;
public ConnectionTest() {
super();
}
public static void main(String[] arg) throws IOException, Exception {
ConnectionTest oim=new ConnectionTest();
oim.OIMConnection();
}
public void OIMConnection(){
Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, "t3://hostname:port");
System.setProperty("java.security.auth.login.config", "C:\\Documents\\authwl.conf");
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
oracle.iam.platform.OIMClient oimClient = new oracle.iam.platform.OIMClient(env);
try {
oimClient.login("username", "password".toCharArray());
logger.info("Successfully Connected with OIM!\n");
} catch (LoginException e) {
CharArrayWriter cw = new CharArrayWriter();
PrintWriter w = new PrintWriter(cw);
e.printStackTrace(w);
logger.error("Login Exception: "+ cw.toString());
}
userManager = oimClient.getService(UserManager.class);
}}
Error I am getting is here.....
Login Exception: javax.security.auth.login.LoginException: weblogic.socket.UnrecoverableConnectException: [Login failed for an unknown reason: P] at weblogic.security.auth.login.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:194) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at javax.security.auth.login.LoginContext.invoke(LoginContext.java:762) at javax.security.auth.login.LoginContext.access$000(LoginContext.java:203) at javax.security.auth.login.LoginContext$4.run(LoginContext.java:690) at javax.security.auth.login.LoginContext$4.run(LoginContext.java:688) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:687) at javax.security.auth.login.LoginContext.login(LoginContext.java:595) at Thor.API.Security.LoginHandler.weblogicLoginHandler.login(weblogicLoginHandler.java:61) at oracle.iam.platform.OIMClient.login(OIMClient.java:212) at oracle.iam.platform.OIMClient.login(OIMClient.java:196) at org.com.dis.exa.ConnectionTest.OIMConnection(ConnectionTest.java:73) at org.com.dis.exa.ConnectionTest.main(ConnectionTest.java:53)
refer my sample:
public static final String OIM_HOSTNAME = "oim.hpt.lab";
public static final String OIM_PORT = "14000";
public static final String OIM_PROVIDER_URL = "t3://"+ OIM_HOSTNAME + ":" + OIM_PORT;
public static final String OIM_USERNAME = "tungpt";
public static final String OIM_PASSWORD = "Hpt123456";
public static final String OIM_CLIENT_HOME = "F:/designconsole11gr3/config";
public static final String AUTHWL_PATH = OIM_CLIENT_HOME + "/authwl.conf";
public static void main(String[] args) {
// TODO Auto-generated method stub
OIMClient oimClient = null;
try {
//Set system properties required for OIMClient
System.setProperty("java.security.auth.login.config", AUTHWL_PATH);
System.setProperty("APPSERVER_TYPE", "wls");
// Create an instance of OIMClient with OIM environment information
Hashtable env = new Hashtable();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, OIM_PROVIDER_URL);
oimClient = new OIMClient(env);
// Login to OIM with the approriate credentials
System.out.println("Login by: "+ OIM_USERNAME);
oimClient.login(OIM_USERNAME, OIM_PASSWORD.toCharArray());
System.out.println("Login Done!");
}catch(Exception e){
e.printStackTrace();
}
}