Best Practices from Oracle Development's A‑Team

Populating request attributes in OIM 11g R2 Part I - Prepopulate Plug-in


This is the first of a two posts series about pre-populating requests in OIM 11 R2. This post is also part of the OIM 11g Academy Series (Need to find this HTTP link).

Main Article

With the introduction of the Catalog, request creation process changed from a wizard to a shopping cart experience style. But request pre-populating is still a common requirement for OIM customers.

There are two different approaches to pre-populate a request:

  •     Pre-populate plug-ins
  •     UI customization

This post is about pre-populate plug-ins, and a second one will be posted for the UI customization.

Pre-populate plug-ins can be used when the same logic needs to be executed for both UI and API request creation, and they can also be used when a UI interaction is not required.

The customization approach is always to have one plug-in for each attribute that must be pre-populated in the request. Another important thing to notice is that the same plug-in can be used across different resources and even different attributes.

The plug-in code must implement the oracle.iam.request.plugins.PrePopulationAdapter interface. Below the example code for this post:


        package com.oracle.demo.iam.prepop.plugin;     import java.io.Serializable;     import java.util.HashSet;     import java.util.List;         import oracle.iam.identity.usermgmt.api.UserManager;         import oracle.iam.identity.usermgmt.api.UserManagerConstants.AttributeName;         import oracle.iam.identity.usermgmt.vo.User;         import oracle.iam.platform.Platform;         import oracle.iam.request.vo.Beneficiary;         import oracle.iam.request.vo.RequestData;     public class UserLoginPrePop implements oracle.iam.request.plugins.PrePopulationAdapter {         public UserLoginPrePop() {             super();         }         public Serializable prepopulate(RequestData requestData) {             String prePopUserId = null;             List<Beneficiary> benList = requestData.getBeneficiaries();             if(benList.size()==1){                 UserManager  usersvc = Platform.getService(UserManager.class);                 for(Beneficiary benf: benList){                     HashSet<string> searchAttrs = new java.util.HashSet<String>();                     searchAttrs.add(AttributeName.USER_LOGIN.getId());                     try {                         User userBenef = usersvc.getDetails(benf.getBeneficiaryKey(),searchAttrs, false);                         if (userBenef!= null) {                             prePopUserId = userBenef.getLogin();                         }                     } catch (Exception e) {                         e.printStackTrace();                     }                 }             }             return prePopUserId;         }     }

A pre-populate plug-in is like any other OIM plug-in: the plug-in class must be compiled and deployed to a Jar file. The Jar file must be added to a ZIP file under the path '/lib'. The ZIP file must contain in the root path a XML file declaring the plug-in. The XML used in this example is shown below:


<?xml version="1.0" encoding="UTF-8" ?> <oimplugins xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  <plugins pluginpoint="oracle.iam.request.plugins.PrePopulationAdapter">  <plugin pluginclass= "com.oracle.demo.iam.prepop.plugin.UserLoginPrePop" version="1.0" name="UserLoginPrePop">   <metadata name="PrePopulationAdapater">    <value>OracleDBUMForm::Username|OIDUserForm::User ID</value>   </metadata>  </plugin> </plugins> </oimplugins>

There are a few import things to pay attention to in the XML above:

  • The 'xmlns' tag attribute must be present in the XML otherwise the plug-in is not invoked by OIM
  • The pluginpoin element must be 'oracle.iam.request.plugins.PrePopulationAdapter'
  • The 'metadata' tag and its child node 'value'. 'value' must contain the pairs of 'FormName::AttributeName'. Each pair indicates a form attribute that will be populated by the pre-populate plug-in. In this case, such attributes are 'Username' in the 'OracleDBUMForm' form and 'User ID' in the 'OIDUserForm' form. The form names are the ones configured when the ApplicationInstances and their forms were created (and not the 'process form' created when the connector is imported into OIM).

The pre-populate plug-in can be deployed to either $OIM_HOME/server/plugins or it can be registered using the plug-in registration script. In production environments, it is always recommended to deploy using the command line as this approach uploads the plug-in Zip file to the database.

This blog post was created based on examples provided by my colleague Manoj Yadav.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha