Sunday, January 20, 2013

Using the OIM 11g R1 API

Version: Oracle Identity Manager 11g R1
Description: This guide shows how to set up and use the Oracle Identity Manager 11g R1 API in a Java application.

  1. Here are the files needed to use the OIM client:
     oimclient.jar
     commons-logging.jar
     eclipselink.jar
     spring.jar
     authwl.conf
     wlfullclient.jar

  2. The first four files can be found in "oimclient.zip", which is located in "<oim_home>/server/client" directory.  Look in the "lib" and "conf" directories.
     cd /home/oracle/Oracle/Middleware/Oracle_IDM1/server/client
     unzip oimclient.zip

  3. The "wlfullclient.jar" has to be generated.
     cd /home/oracle/Oracle/Middleware/wlserver_10.3/server/lib/
     java -jar /home/oracle/Oracle/Middleware/modules/com.bea.core.jarbuilder_1.6.0.1.jar

  4. "authwl.conf" can be found in "<oim_home>/designconsole/config"
     cd /home/oracle/Oracle/Middleware/Oracle_IDM1/designconsole/config

import oracle.iam.platform.OIMClient;
import java.util.Hashtable;
import javax.security.auth.login.LoginException;
import oracle.iam.identity.usermgmt.api.UserManager;
import oracle.iam.platform.entitymgr.vo.SearchCriteria;

/**
 * This class shows how to use the OIM APIs.
 */
public class OracleIdentityManager 
{
    public static void main(String[] args) throws LoginException 
    {
        String ctxFactory = "weblogic.jndi.WLInitialContextFactory";
        String oimServerURL = "t3://localhost:14000";
        String authwlConfigPath = "/home/oracle/oimClient_lib/conf/authwl.conf"; //The authwl.conf file can be found the designconsole directory which is in MW_HOME/Oracle_IDM1
        String username = "xelsysadm"; //OIM User Login
        String password = "Password1"; //OIM User Password

        System.setProperty("java.security.auth.login.config", authwlConfigPath);
        Hashtable<string,string> env = new Hashtable<string,string>();
        env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, ctxFactory);
        env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, oimServerURL);
        OIMClient oimClient = new OIMClient(env);
        oimClient.login(username, password.toCharArray()); //login to OIM

        //Accessing Oracle Identity Manager Services
        UserManager userManager = oimClient.getService(UserManager.class);
        oimClient.logout(); //Logout User from OIM Client
    }
}

No comments:

Post a Comment