Oracle® Fusion Middleware Developer's Guide for Oracle Identity Manager 11g Release 1 (11.1.1) E14309-04 |
|
![]() Previous |
![]() Next |
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:
Before you configure SOA Server to load Oracle Identity Manager APIs from SOA composites, perform the following:
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.
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.
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.
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:
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:
From the File menu, select New. The New Gallery dialog box is displayed.
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.
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.
In the Authentication window, provide the username and password of the WebLogic user. Click Next.
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.
In the Test window, click Test Connection to make sure all the information entered is correct. The test passes with success status. Click Next.
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.
To set up the SOA composite in JDeveloper for editing:
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.
Start JDeveloper in the Default Role.
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.
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 |
To edit the SOA composite in JDeveloper:
In the left pane, click the Projects tab.
Select the ApprovalProcess.bpel file under the DefaultRequestApproval project and open it. This displays the approval workflow.
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.
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());
After updating the composite, you must deploy the composite to SOA. To do so:
In the Projects section, right-click the composite name, and select Deploy.
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 |
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:
Login to Oracle Identity Manager Administrative and User Console.
Click Advanced to go to Advanced Administration.
In the Welcome page, under Administration, click Requests. Alternatively, click the Administration tab, and then click Requests.
From the Actions menu, select Create Request. Alternatively, click the Create Request icon on the toolbar. The Request Creation wizard is displayed.
Note:
|
From the Type of Request list, select Create User. Then, click Next.
In the Enter Details page, enter sample values in the fields to create the user. Then, click Next.
In the Confirm page, click Finish.
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.