I’ll show today two examples using WebServices and integrate these with OIM11G, step by step:
First example it will check user/password against OIM11G and if match return true:
1-Java Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| public ActionResult logon(String loginID, String password) { System.out.println( "Login ID: " + loginID); System.out.println( "New Password: " + password); System.out.println( "Session ID: " + getSessionID()); ActionResult actionResult = new ActionResult(); actionResult.setSuccess( true ); actionResult.setResultMessage( "Successfully login" ); actionResult.setResultCode( 0 ); SessionToken sessionToken = new SessionToken(); sessionToken.setLoginID(loginID); sessionToken.setLastUsedTimestamp(System.currentTimeMillis()); sessionToken.setPassword(password); sessionToken.setSessionID(getSessionID()); // Login to OIM code here Hashtable env = new Hashtable(); env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory" ); oimClient = new OIMClient(env); try { oimClient.login(loginID, password.toCharArray()); } catch (LoginException e) { e.printStackTrace(); } setStringSessionAttribute(WSConstants.SESSION_LOGIN_ID_ATTRIBUTE_NAME, loginID); actionResult.setSessionToken(sessionToken); return actionResult; } |
2-Don’t Forget WebServices terminology into your class:
3-Deploy your code into WebLogic and go to testing(into your war details):
4-When you click on this link above. It will open your WebService test page below:

Red Arrow(above) is showing all ‘button methods’ that you have into your java class.
5-Le’ts test ‘Logon method’ :
6-I added(above) one user and password that already exist into my OIM environment and then it should return me ‘true’ as showed below:
As you could see. It is connecting to OIM env thru WebService and returning if the user is valid or not.
Second example will check user account status sending user_key and Resource name as you can see below:
0-Code(JNDI call) required for this above :
1
2
3
4
5
6
7
8
9
10
11
| ... Hashtable env = new Hashtable( 5 ); env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" ); ctx = new InitialContext(env); oimClient = new OIMClient(env); javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ( "myDS" ); // myDS ==> Java JNDI(Datasource Name into WebLogic) con = ds.getConnection(); ... |
1-Going to WebService test client:
2-And finally the expected result:
As you could see. It’s easy to ‘call’ OIM using webservices classes. I also did one video to make sure you will be happy with this help.
Video: http://youtu.be/1ncjF9hBrOc
I hope this helps. See you into next IDM article.
Thiago Leoncio.
No comments:
Post a Comment