To execute below code you have to add following jars in classpath:
- commons-logging.jar
- eclipselink.jar
- jrf-api.jar
- oimclient.jar
- spring.jar
- wlfullclient.jar
Stand Alone Code:
import java.util.Hashtable;
import java.util.List;
import javax.security.auth.login.LoginException;
import oracle.iam.platform.OIMClient;
import oracle.iam.platform.entitymgr.vo.SearchCriteria;
import oracle.iam.provisioning.api.ApplicationInstanceService;
import oracle.iam.provisioning.exception.ApplicationInstanceNotFoundException;
import oracle.iam.provisioning.exception.GenericAppInstanceServiceException;
import oracle.iam.provisioning.vo.ApplicationInstance;
public class ApplicationInstanceOperation {
static OIMClient oimClient = null;
//identity self service details
String username = "xelsysadm";
String password = "<password>"; //xelsysadm password
String t3url = "t3://<hostname>:<port>"; //OIM HostName and Port
String authwl_location = "<location of authwl.conf file in your local machine>"; //eg. D:\\authwl.conf
public void getOIMConnection() {
System.out.println("getOIMConnection() : Start");
//set system properties
System.setProperty("java.security.auth.login.config", authwl_location);
System.setProperty("OIM.AppServerType", "wls");
System.setProperty("APPSERVER_TYPE", "wls");
Hashtable oimenv = new Hashtable();
oimenv.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
oimenv.put(OIMClient.JAVA_NAMING_PROVIDER_URL,t3url);
oimClient = new OIMClient(oimenv);
try {
oimClient.login(username, password.toCharArray());
System.out.println("Connected");
} catch (LoginException e) {
e.printStackTrace();
}
System.out.println("getOIMConnection() : End");
}
public static void getAppNameByITResKey(long itResourceKey){
ApplicationInstanceService appApplicationInstanceService = oimClient.getService(ApplicationInstanceService.class);
SearchCriteria sc =
new SearchCriteria(ApplicationInstance.ITRES_KEY, itResourceKey, SearchCriteria.Operator.EQUAL);
try {
List applns = appApplicationInstanceService.findApplicationInstance(sc, null);
String [] applnsDetails= applns.get(0).toString().split(":");
ApplicationInstance appDetails= appApplicationInstanceService.findApplicationInstanceByName(applnsDetails[0]);
if(appDetails != null){
System.out.println(appDetails.getDisplayName());
}
} catch (GenericAppInstanceServiceException e) {
e.printStackTrace();
} catch (ApplicationInstanceNotFoundException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
ApplicationInstanceOperation applicationInstanceOperation = new ApplicationInstanceOperation();
applicationInstanceOperation.getOIMConnection();
//IT Resource Key
long itResourceKey = 10;
getAppNameByITResKey(itResourceKey);
}
}
bosdk copy kyu nhi ho rha code
ReplyDelete