Below code will fetch user profile attribute value from OIM
======================================================================
For Client Code below JAR need to be added in Eclipse or JDeveloper.
1) commons-logging.jar
2) jrf-api.jar
3) oimclient.jar
4) spring.jar
5) wlfullclient.jar
===========================================================
===========================================================
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import javax.security.auth.login.LoginException;
import Thor.API.tcResultSet;
import Thor.API.Exceptions.tcAPIException;
import Thor.API.Operations.tcUserOperationsIntf;
import oracle.iam.identity.exception.NoSuchUserException;
import oracle.iam.identity.exception.UserLookupException;
import oracle.iam.platform.OIMClient;
import oracle.iam.platform.authz.exception.AccessDeniedException;
import oracle.iam.provisioning.api.ProvisioningService;
import oracle.iam.provisioning.vo.Account;
public class ProfileAttributeValue {
public static OIMClient oimClient;
public void OIMConnection(){
System.out.println("Trying to established oim client");
System.out.println("inside OIM Connection");
String oimInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";
// set up the environment for making the OIM API invocation
java.util.Hashtable<String, String> env = new java.util.Hashtable<String, String>();
env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_FACTORY_INITIAL,oimInitialContextFactory);
env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_PROVIDER_URL, "t3://localhost:14000");
//provide the authwl.conf file path from your local system. Copy the authwl.conf from designconsole\config to your local system
System.setProperty("java.security.auth.login.config", "C:\\Software\\designconsole\\designconsole\\config\\authwl.conf"); //Update path of authwl.conf file according to your environment
System.out.println("inside OIM Connection22");
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
oimClient = new OIMClient(env);
System.out.println("inside OIM Connection44");
try {
//Update password of Admin with your environment password
oimClient.login("xelsysadm","Password".toCharArray());
} catch (LoginException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print("Successfully Connected to OIM ");
}
public void searchUser(String Userid){
ProvisioningService ps = oimClient.getService(ProvisioningService.class);
tcUserOperationsIntf userintf = oimClient.getService(tcUserOperationsIntf.class);
System.out.println("inside getUserDetails method");
System.out.println("User id --->"+Userid);
HashMap userMap = new HashMap();
try {
//Fetching the User Profile attribute details
userMap.put("Users.User ID", Userid);
tcResultSet moResultSet = userintf.findUsers(userMap);
String[] CName=moResultSet.getColumnNames();
for(String cname :CName){
System.out.println(cname+"--->"+moResultSet.getStringValue(cname));
// System.out.println("Manager login is --->"+moResultSet.getStringValue("USERS.MANAGER LOGIN"));
}
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws NoSuchUserException, UserLookupException, AccessDeniedException {
// TODO Auto-generated method stub
ProfileAttributeValue findusr=new ProfileAttributeValue();
findusr.OIMConnection();
//Provide the User Login
findusr.searchUser("userLogin");
}
}
======================================================================
For Client Code below JAR need to be added in Eclipse or JDeveloper.
1) commons-logging.jar
2) jrf-api.jar
3) oimclient.jar
4) spring.jar
5) wlfullclient.jar
===========================================================
===========================================================
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import javax.security.auth.login.LoginException;
import Thor.API.tcResultSet;
import Thor.API.Exceptions.tcAPIException;
import Thor.API.Operations.tcUserOperationsIntf;
import oracle.iam.identity.exception.NoSuchUserException;
import oracle.iam.identity.exception.UserLookupException;
import oracle.iam.platform.OIMClient;
import oracle.iam.platform.authz.exception.AccessDeniedException;
import oracle.iam.provisioning.api.ProvisioningService;
import oracle.iam.provisioning.vo.Account;
public class ProfileAttributeValue {
public static OIMClient oimClient;
public void OIMConnection(){
System.out.println("Trying to established oim client");
System.out.println("inside OIM Connection");
String oimInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";
// set up the environment for making the OIM API invocation
java.util.Hashtable<String, String> env = new java.util.Hashtable<String, String>();
env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_FACTORY_INITIAL,oimInitialContextFactory);
env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_PROVIDER_URL, "t3://localhost:14000");
//provide the authwl.conf file path from your local system. Copy the authwl.conf from designconsole\config to your local system
System.setProperty("java.security.auth.login.config", "C:\\Software\\designconsole\\designconsole\\config\\authwl.conf"); //Update path of authwl.conf file according to your environment
System.out.println("inside OIM Connection22");
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
oimClient = new OIMClient(env);
System.out.println("inside OIM Connection44");
try {
//Update password of Admin with your environment password
oimClient.login("xelsysadm","Password".toCharArray());
} catch (LoginException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print("Successfully Connected to OIM ");
}
public void searchUser(String Userid){
ProvisioningService ps = oimClient.getService(ProvisioningService.class);
tcUserOperationsIntf userintf = oimClient.getService(tcUserOperationsIntf.class);
System.out.println("inside getUserDetails method");
System.out.println("User id --->"+Userid);
HashMap userMap = new HashMap();
try {
//Fetching the User Profile attribute details
userMap.put("Users.User ID", Userid);
tcResultSet moResultSet = userintf.findUsers(userMap);
String[] CName=moResultSet.getColumnNames();
for(String cname :CName){
System.out.println(cname+"--->"+moResultSet.getStringValue(cname));
// System.out.println("Manager login is --->"+moResultSet.getStringValue("USERS.MANAGER LOGIN"));
}
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws NoSuchUserException, UserLookupException, AccessDeniedException {
// TODO Auto-generated method stub
ProfileAttributeValue findusr=new ProfileAttributeValue();
findusr.OIMConnection();
//Provide the User Login
findusr.searchUser("userLogin");
}
}
No comments:
Post a Comment