Tuesday, January 24, 2012

Custom Event Handler in OIM 11G

Step 1:
 //The below code shows an example of implementing the PreProcessHandler. In the same way you can implement the other interfaces:
Pre-Process-- oracle.iam.platform.kernel.spi.PreProcessHandler
Post-Process-- oracle.iam.platform.kernel.spi.PostProcessHandler
Validation-- oracle.iam.platform.kernel.spi.ValidationHandler
Validation handler can be used to validate the data being entered while creating a user,role in OIM.
Writing a custom code to implement the actual logic:
Sample code:

import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

import com.thortech.util.logging.Logger;

import oracle.iam.platform.context.ContextAware;
import oracle.iam.platform.kernel.vo.AbstractGenericOrchestration;
import oracle.iam.platform.kernel.vo.BulkEventResult;
import oracle.iam.platform.kernel.vo.BulkOrchestration;
import oracle.iam.platform.kernel.vo.EventResult;
import oracle.iam.platform.kernel.vo.Orchestration;


public class GenerateUserID implements oracle.iam.platform.kernel.spi.PreProcessHandler{

    public boolean cancel(long l, long l1, AbstractGenericOrchestration abstractgenericorchestration) {
        // TODO Auto-generated method stub
        return false;
    }

    public void compensate(long l, long l1, AbstractGenericOrchestration abstractgenericorchestration) {
        // TODO Auto-generated method stub
       
    }

    public EventResult execute(long processID, long eventID, Orchestration orchestration) {
        // TODO Auto-generated method stub
        Logger logger=Logger.getLogger("CustomEventHandler");
        logger.debug("Entering the EventHandler");
        HashMap<String, Serializable> parameters = orchestration.getParameters();
        Set<String> keyset=parameters.keySet();
        Iterator<String> itr=keyset.iterator();
        while(itr.hasNext()){
            String attrName=itr.next();
            System.out.println("Attr Name is : "+attrName);
            System.out.println(parameters.get(attrName));
        }
        String middleName = getParamaterValue(parameters, "Middle Name");
        if (middleName==null||middleName.isEmpty()) {
            String firstName = getParamaterValue(parameters, "First Name");
            middleName = firstName.substring(1,3);
            orchestration.addParameter("Middle Name", middleName);
            }
        return new EventResult();
    }

    public BulkEventResult execute(long l, long l1, BulkOrchestration bulkorchestration) {
        // TODO Auto-generated method stub
        return null;
    }
   
    private String getParamaterValue(HashMap<String, Serializable> parameters,
            String key) {
            String value = (parameters.get(key) instanceof ContextAware)
            ? (String) ((ContextAware) parameters.get(key)).getObjectValue()
            : (String) parameters.get(key);
            return value;
            }

    public void initialize(HashMap<String, String> arg0) {
        // TODO Auto-generated method stub
       
    }

   

}

Step 2:
Create a plugin.xml file with the following contents:



<?xml version="1.0" encoding="UTF-8"?>
<oimplugins xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oracle.com/schema/oim/plugin plugin.xsd">
<plugins pluginpoint="oracle.iam.platform.kernel.spi.EventHandler">
<plugin pluginclass=
"com.test.ad.GenerateUserID"
version="1.0"
name="SamplePreprocessExtension">
</plugin>
</plugins>
</oimplugins>

Step 3:

Creating a metadata xml.
Note: Make sure that the right namespace is given if you are using the latest version 11.1.1.5. This is not required if you are using older version 11.1.1.3.
EventHandlers.xml
<?xml version="1.0" encoding="UTF-8"?> 
<eventhandlers xmlns="http://www.oracle.com/schema/oim/platform/kernel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oracle.com/schema/oim/platform/kernel orchestration-handlers.xsd">
<!-- Custom preprocess event handlers -->
<action-handler
class="com.test.ad.GenerateUserID"
entity-type="User"
operation="CREATE"
name="SamplePreprocessExtension"
stage="preprocess"
order="1000"
sync="TRUE"/>
</eventhandlers>

Step 4: Packaging
Package the contents in the following manner:

Folder Handler.zip if extracted should look like this:
lib[dir]
plugin.xml[file]

Note: The lib folder should containg the jar file which has the custom eventhandler implementation.

Step 5:
Register the plugin using the OIM_HOME/plugin-utility/pluginregistration.xml.
Run the following command:
ant -f pluginregistration.xml register
Give the complete path of the zip file like /app/Oracle/CustomPlugins/Handler.zip and make sure that the user has enough permissions.
Note: make sure that the ant path is exported to the path.

Step 6:
MDS import:

 Using the weblogicImportMetadata.sh/bat import the EventHandlers.xml.

Now validate the user create functionality as implemented by the eventhandler.






Monday, January 16, 2012

Configuring BI publisher with OIM 11G


Configure BI Publisher URL in OIM 11g
OIM 11g uses BI Publisher for reports.
  Here are the steps to configure BI Publisher with OIM 11g:


Login to Enterprise Manager URL will be

http://IP_or_Domain_Admin_Server:Admin_Server_Port/em
Example :http://oimserverhost:7001/em

Go to Identity and Access ---> "OIM"

Right Click  "OIM" and Select "System MBean Browser"

Go to "Application Defined MBeans" ---> "oracle.iam" ---> "Server: << OIM_Server_Name >> " ---> "Application:oim" ---> "XMLConfig" ---> "config" ---> "XMLConfig.DiscoverConfig" ---> "Discovery"

 At right side, you'll see following attribute "BIPublisherURL"


In Value column, provide the URL of your BI Publisher.

Click Apply.

Restart the Server

Login into OIM 11g.

Go to Advanced Tab ---> Administration ---> Reports ---> BI Publisher

Adding a new Data Source in BI publisher:


Login to Oracle BI publisher -Administrator/Administrator
Goto -->Admin-->Datasources-->JDBC DataSource

Create the data source of type 11G and save it. This should create the report data store automatically and we will be able to view the OOTB OIM reports by going to the Reports-->Shared Folder-->more-->Oracle Identity Manager Reports.