22 Using Oracle Identity Manager APIs from SOA Composites

If the business process requires additional data that is be used in the SOA composite, then you can use a Java embedding step to obtain more information about the requester, the beneficiary, or what is being requested.

This chapter describes how to load Oracle Identity Manager APIs from SOA composites in the following topics:

22.1 Software Prerequisites

Before you configure SOA Server to load Oracle Identity Manager APIs from SOA composites, perform the following:

  1. Install the version of JDeveloper that is compatible with the Oracle Identity Manager deployment. In addition, install any patches for JDeveloper so that JDeveloper works correctly with the SOA composites.

  2. Ensure that OIM_HOME points to the directory on which Oracle Identity Manager is installed. For example: /scratch/shiphome/beahome/Oracle_IDM1/server/ must point to OIM_HOME.

  3. Ensure that DOMAIN_HOME points to the home directory of the domain on which Oracle Identity Manager is installed. For example: /scratch/shiphome/beahome/user_projects/domains/base_domain must point to DOMAIN_HOME.

In this document:

  • OIM_ORACLE_HOME refers to the directory in which Oracle Identity Manager is deployed. For example, /scratch/shiphome/beahome/Oracle_IDM1/ must point to OIM_ORACLE_HOME.

  • DOMAIN_HOME refers to the directory in which the Oracle WebLogic Server domain is installed with the Oracle Identity Manager deployment.

22.2 Configuring the SOA Composite By Using JDeveloper

This section describes the configuration required in JDeveloper as well as in the SOA composite so that the required Java code can be introduced in the composite and deployed to the SOA server. As an example, the "Default Request Approval" composite is used. This composite is in the OIM_HOME/workflows/composites/ directory.

This section contains the following topics:

22.2.1 Setting an Application Server Connection in JDeveloper

Ensure that a new application server connection, which represents the application server on which Oracle Identity Manager is installed, is first setup in JDeveloper . Make sure that the WebLogic Administrative Server and the SOA server are running before performing these steps.

To set up the new application server connection:

  1. From the File menu, select New. The New Gallery dialog box is displayed.

  2. From the left menu, select All Items. On the right pane, select Application Server Connection, and then click OK. The Create Application Server Connection wizard is displayed.

  3. In the Name and Type window, enter a name that will identify the application server in JDeveloper. Select Weblogic 10.3 as the connection type, and then click Next.

  4. In the Authentication window, provide the username and password of the WebLogic user. Click Next.

  5. In the Configuration window, enter the host name, port number, and the WebLogic domain name in which the SOA managed server is running. The port must be the WebLogic Administrative Server port (usually 7001). Click Next.

  6. In the Test window, click Test Connection to make sure all the information entered is correct. The test passes with success status. Click Next.

  7. Click Finish to exit the wizard. This creates the connection to the application server. This connection is required to deploy the composite to the server after making all changes.

22.2.2 Setting Up the SOA Composite in JDeveloper

To set up the SOA composite in JDeveloper for editing:

  1. Copy the DefaultRequestApproval.zip file from the OIM_HOME/workflows/composites/ directory to your JDeveloper working directory. Unzip it in the same directory to create the DefaultRequestApproval directory.

  2. Start JDeveloper in the Default Role.

  3. From the File menu, select Open. The file-open dialog box is displayed. Select the DefaultRequestApproval.jpr file in the DefaultRequestApproval directory. This opens the composite in JDeveloper. Click OK or Yes while the project file is created.

  4. To successfully compile the Java code that you want to write in the composite, the oimclient.jar file must be in the JDeveloper copy of the composite. Copy the oimclient.jar file from the OIM_ORACLE_HOME/server/client/ directory to the JDEVELOPER_WORKING_DIRECTORY/DefaultRequestApproval/SCA-INF/lib/ directory. This directory is the lib/ directory of the composite that you are editing.

See Also:

"Deploying a Single SOA Composite in Oracle JDeveloper" in the Oracle Fusion Middleware Developer's Guide for Oracle SOA Suite for more information about setting up the SOA composite in JDeveloper

22.2.3 Updating the SOA Composite

To edit the SOA composite in JDeveloper:

  1. In the left pane, click the Projects tab.

  2. Select the ApprovalProcess.bpel file under the DefaultRequestApproval project and open it. This displays the approval workflow.

  3. In the right pane, in the Component Palette, select the Java Embedding task, and drag and drop it after the receiveInput task in the workflow, before the ApprovalTask_1 human task. This creates a new task called Java_Embedding_1. Optionally, you can rename it to Invoke_OIM_API.

  4. Double-click the Invoke_OIM_API Java task. This opens an editor in which you can add the required Java code. Add the Java code as shown in Example 22-1:

    Example 22-1 Embedded Java Source Code

    try {
        System.out.println("Prototype for invoking an OIM API from a SOA Composite");
     
        String oimUserName = "xelsysadm";
        String oimPassword = "Welcome1";
     
        String oimURL = "t3://<hostname>:<port>";
        // set the initial context factory
        String oimInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";
     
        // set up the environment for making the OIM API invocation
        java.util.Hashtable env = new java.util.Hashtable();
        env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_FACTORY_INITIAL, oimInitialContextFactory);
        env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_PROVIDER_URL, oimURL);
     
        // get reference to OIMClient and perform login
        oracle.iam.platform.OIMClient client = new oracle.iam.platform.OIMClient(env);
        client.login(oimUserName, oimPassword);
     
        System.out.println("Login Successful");
     
        // get the RequestService to get details of the request
        oracle.iam.request.api.RequestService reqSvc =
                      (oracle.iam.request.api.RequestService)client.getService(
    oracle.iam.request.api.RequestService.class);
     
        // get the Request ID from the composite
        Object obj = getVariableData("inputVariable",              
                                     "payload",               
                                     "/client:process/ns1:RequestID");
        String reqId = ((oracle.xml.parser.v2.XMLElement)obj).getText();  
        System.out.println("request ID: "+reqId);
        
        // invoke the getBasicRequestData() method on the RequestService API
        oracle.iam.request.vo.Request req = reqSvc.getBasicRequestData(reqId);
        
        // print the results
        System.out.println(req.getRequestStatus());
        System.out.println(req.getRequestTemplateName());
        System.out.println(req.getRequestModelName());
        System.out.println(req.getCreationDate());
     
    } catch (Exception e) {
        e.printStackTrace();
    }
    

    In Example 22-1:

    • Oracle Identity Manager username and password are hard coded for the purpose of this example, as shown:

      System.out.println("Prototype for invoking an OIM API from a SOA Composite");
      
      String oimUserName = "xelsysadm";
      String oimPassword = "Welcome1";
      

      The Oracle Identity Manager username and password can be seeded and retrieved from the CSF. See SOA documentation for more information about how to get credentials from CSF inside a SOA composite.

    • The following code snippet sets up the environment for loading an Oracle Identity Manager API method:

      String oimURL = "t3://HOST_NAME:PORT";
      // set the initial context factory
      String oimInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";
      
      // set up the environment for making the Oracle Identity Manager API invocation
      java.util.Hashtable env = new java.util.Hashtable();
      env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_FACTORY_INITIAL, oimInitialContextFactory);
      env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_PROVIDER_URL, oimURL);
      

      The Initial Context Factory as well as the Oracle Identity Manager URL is set. In this example, the URL has a sample value. This URL has to be updated accordingly.

    • The following code snippet creates an instance of the OIMClient class and uses it to login to Oracle Identity Manager:

      // get reference to OIMClient and perform login
      oracle.iam.platform.OIMClient client = new oracle.iam.platform.OIMClient(env);
      client.login(oimUserName, oimPassword);
      
      System.out.println("Login Successful");
      
    • The following code snippet gets access to the RequestService API which is used to call the getBasicRequestData() method:

      // get the RequestService to get details of the request
      oracle.iam.request.api.RequestService reqSvc=(oracle.iam.request.api.RequestService)client.getService(oracle.iam.request.api.RequestService.class);
      
    • The following code snippet gets the request ID present in the composite data:

      // get the Request ID from the composite
      Object obj = getVariableData("inputVariable","payload","/client:process/ns1:RequestID");
      String reqId = ((oracle.xml.parser.v2.XMLElement)obj).getText();
      System.out.println("request ID: "+reqId);
      
    • The following code snippet invokes the getBasicRequestData() method on the RequestService and prints some of the information obtained from that method:

      // invoke the getBasicRequestData() method on the RequestService API
      oracle.iam.request.vo.Request req = reqSvc.getBasicRequestData(reqId);
      
      // print the results
      System.out.println(req.getRequestStatus());
      System.out.println(req.getRequestTemplateName());
      System.out.println(req.getRequestModelName());
      System.out.println(req.getCreationDate());
      

22.2.4 Deploying the SOA Composite

After updating the composite, you must deploy the composite to SOA. To do so:

  1. In the Projects section, right-click the composite name, and select Deploy.

  2. Select the DefaultRequestApproval ... option. A wizard is displayed that prompts you to select the application server on which the composite is to be deployed. Make sure you select the application server connection created earlier. In addition, select the Override any existing composites with the same revision ID option if you want to override the composite that is already deployed.

After deploying the composite, either re-register the composite or disable and enable the composite from the Oracle Identity Manager side. This is to ensure that Oracle Identity Manager is able to invoke the composite correctly.

See Also:

"Deploying a Single SOA Composite in Oracle JDeveloper" in the Oracle Fusion Middleware Developer's Guide for Oracle SOA Suite for more information about deploying the SOA composite

22.2.5 Testing the Setup

After the SOA composite is updated, you can test the changes to the composites to make sure that the Oracle Identity Manager API is being loaded. The Java code runs as soon as the Request Approval is started in SOA because the code is added to the Default Request Approval composite and before the human task in the workflow.

To create a request and test the Java code:

  1. Login to Oracle Identity Manager Administrative and User Console.

  2. Click Advanced to go to Advanced Administration.

  3. In the Welcome page, under Administration, click Requests. Alternatively, click the Administration tab, and then click Requests.

  4. From the Actions menu, select Create Request. Alternatively, click the Create Request icon on the toolbar. The Request Creation wizard is displayed.

    Note:

    • This must be performed in the test environment.

    • Make sure that no approval polices are associated with the Create User request type.

  5. From the Type of Request list, select Create User. Then, click Next.

  6. In the Enter Details page, enter sample values in the fields to create the user. Then, click Next.

  7. In the Confirm page, click Finish.

  8. Monitor the SOA server console for output from the Java code that you have embedded. Clicking Finish runs the Default Request Approval composite. The following text is displayed in the SOA server console:

    Prototype for invoking an Oracle Identity Manager API from a SOA Composite
    Login Successful
    <Request ID and other request data>
    

This output is displayed if the code is successfully run.