Pages

Friday, July 29, 2011

Developing and Deploying OIM 11G Custom Event Handlers Task

Hi

In my example I am setting the middle Name if the user doesn't provide any middle Name in the OIM Form in the CREATE Operation. Please follow steps to build the Custom Pre-Process Event Handlers in OIM 11g.

Environment Setup

The following jar files are required to compile the Custom Scheduler Task Java file. They are
1) wlfullclient.jar
2) wlclient.jar

Generating wlfullclient.jar
Go to the WL_Home/server/lib directory and Run the following command

java -jar wljarbuilder.jar

It will generate the wlfullclient.jar file and set the class path for the wlfullclient.jar and wlclient.jar file.


Develop the Java Class

package test.eventhandlers;

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

import com.thortech.util.logging.Logger;
import oracle.iam.platform.context.ContextAware;
import oracle.iam.platform.kernel.spi.PreProcessHandler;
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 NamePreProcessEventHandlers implements PreProcessHandler{

private Logger logger=Logger.getLogger("logger Handel Name");

private String methodName="";
public NamePreProcessEventHandlers()
{
debug("Invoking NamePreProcessEventHandlers");
}
@Override
public boolean cancel(long arg0, long arg1,
AbstractGenericOrchestration arg2) {
// TODO Auto-generated method stub
return false;
}

@Override
public void compensate(long arg0, long arg1,
AbstractGenericOrchestration arg2) {
// TODO Auto-generated method stub

}

// Write Your implementation.
public EventResult execute(long processId, long eventId, Orchestration orchestration) {
// TODO Auto-generated method stub


this.methodName="execute";
// this method getting the Request parameters from the OIM form
HashMap parameters=orchestration.getParameters();

debug("Parameters "+parameters);
String operation=orchestration.getOperation();
debug("Pre Process Operation "+operation);

if(operation != null && operation.equalsIgnoreCase("create"))
{
String firstName= getParamaterValue(parameters,"First Name")
if(firstName != null && !firstName.trim().isEmpty())
{
if(!parameters.containsKey("Middle Name"))
{
orchestration.addParameter("Middle Name", firstName.substring(0,1));
}
}

}
return new EventResult();
}

@Override
public BulkEventResult execute(long arg0, long arg1, BulkOrchestration arg2) {
// TODO Auto-generated method stub
return null;
}

@Override
public void initialize(HashMap arg0) {
// TODO Auto-generated method stub

}

/**
* Getting the Value from the Request Parameters
*/
private String getParamaterValue(HashMap parameters,
String key) {
String value = (parameters.get(key) instanceof ContextAware)
? (String) ((ContextAware) parameters.get(key)).getObjectValue()
: (String) parameters.get(key);
return value;
}

private void debug(String message)
{
logger.debug(this.getClass().getName()+" : "+methodName+" : "+message);
}
}
Make Jar File

Jar cvf NamePreProcessEventHandlers.jar *


Develop the Custom Event Handler Config File

<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">
<action-handler class="test.eventhandlers.NamePreProcessEventHandlers" entity-type="User" operation="CREATE" name="NamePreProcessEventHandlers" stage="preprocess" order="FIRST" sync="TRUE"/>
</eventhandlers>


Save this file as EventHandlers.xml and the directory structure of the file is /oracle/home/eventhandlers/metadata/EventHandlers.xml.

XML Name space is very important when you deploying custom event handler in MDS Schema. If you give wrong name space in eventhandler tag and it will deploy in the OIMMetadata MDS Schema But OIM won't recognised as a Event Handler. If you give the correct Name space and it will loaded into the OIM and evaluated the preprocess in the create operation.


Develop the plugin.xml file

<oimplugins>
<plugins pluginpoint="oracle.iam.platform.kernel.spi.EventHandler">
<plugin pluginclass="test.eventhandlers.NamePreProcessEventHandlers" version="1.0" name="
NamePreProcessEventHandlers"/>
</plugins>
</oimplugins>

Making the EventHandler.zip File

plugin.xml file
lib/NamePreProcessEventHandlers.jar

Regsiter the Plugin File into the OIM Server

ant -f pluginregistration.xml register

It will ask the following details after running the above command


1) OIM Admin User Name : xelsysadm
2) OIM Admin Password : xelsysadm password
3) OIM URL : t3://localhost:14000
4) Plugin Zip File absolute path.

It will deploy the OIM Plugin without any issue. Some Times It will throw error if the class file is not found in the jar file.

Importing the Custom Event into MDS Schema

Go to the OIM_HOME/bin directory and modify the following properties in the weblogic.properties file

wls_servername=oim_server1
application_name=OIMMetadata
metadata_from_loc=/home/oracle/eventhandlers

Event Handler Config file location as /home/oracle/eventhandlers/metadata/EventHandlers.xml

Run the weblogicImportmetada.sh file and will ask the following details


1) Weblogic Admin User Name : weblogic
2) Weblogic Admin Password : weblogic admin password
3) weblogic Admin URL : t3://localhost:7001

After running the above command the custom scheduler task will be imported into the MDS Schema.

Clear the OIM Cache

Run the PurgeCache.sh All file and it will ask the following details.


1) OIM Admin User Name : xelsysadm
2) OIM Admin Password : xelsysadm password
3) OIM URL : t3://localhost:14000


After running the above command and it will clear the OIM cache

Restart the OIM Server

Go to the WL_DOMAIN_HOME/bin direcory and run stopManagedServer.sh oim_server1 command and it will stop the oim managed server.

Run the startManagedServer.sh oim_server1 and it will start the OIM Managed Server.

Testing The Event Handlers

Login to the OIM Admin Console >> Create User >> Enter First Name,Last Name, User Id, Password, Organization Name, User Type and Click Save Button. It will display the Log Message


Trouble Shooting

Problem : Event Handler Not Loaded in the OIM Server
Cause : Event Handler Name space is missing
Solution : Check the Scheduler name space in the scheduer task. The name space always 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"

Problem : The Event Handler implemented class file not found while deploying the plugin.zip file.
Cause : The class file is missing in the zip file.

Solution : Please add the jar file into the lib directory and make the zip file again and regsiter the plugin.


Reference Document : Oracle Identity Manager Developer Guide

Enabling The Logging in OIM 11g

Any Custom Schedule Task and Event Handlers to debug in the OIM 11g Server to enable the logging. The following way to enable the logging in Oracle Identity Manager 11g.

Pre-Requisite


Java Code Configuration


Add the following line into your java code.

Import Statement

import com.thortech.util.logging.Logger;

private Logger logger=Logger.getLogger("Logger-Name");



Configuration Of Logging


Go to the $DOMAIN_HOME/config/fmwconfig/servers/oim_server1 directory and edit the logging.xml file.

Configure The Log Handler

<log_handler name='logger Handel Name' level='FINEST' class='oracle.core.ojdl.logging.ODLHandlerFactory'>
<property name='logreader:' value='off'/>
<property name='path' value='Log File Location'/>
<property name='format' value='ODL-Text'/>
<property name='useThreadName' value='true'/>
<property name='locale' value='en'/>
<property name='maxFileSize' value='5242880'/>
<property name='maxLogSize' value='52428800'/>
<property name='encoding' value='UTF-8'/>

Include The Logger Handler Logger Configuration

<logger name="Logger-Name" level="Log Level" useParentHandlers="false">
<handler name="logger-Handel-Name"/>
<handler name="console-handler"/>
</logger>

Oracle Identity Manager 11G Log Levels


Log Level                                         ODL Message Type:Level

SEVERE.intValue()+100                  INCIDENT_ERROR:1
SEVERE                                           ERROR:1
WARNING                                       WARNING:1
INFO                                                 NOTIFICATION:1
CONFIG                                           NOTIFICATION:16
FINE                                                 TRACE:1
FINER                                               TRACE:16
FINEST                                             TRACE:32

The FINEST log level will give the more debug info. If you want to debug your schedule task or event handlers, please use FINEST Log level.

Generating the wlfullclient.jar File

Generating wlfullclient.jar

Setting the CLASSPATH
Go to the OIM DOMAIN/bin directory and run the following command.
./setDomainEnv.sh

The above command will set the classpath

Generating the wlfullclient.jar

Go to the $WL_HOME/server/lib directory and Run the following command

java -jar wljarbuilder.jar

It will generate the wlfullclient.jar file and set the class path for the wlfullclient.jar.

Saturday, July 23, 2011

Developing and Deploying OIM 11G Custom Scheduler Task

Hi

The following steps used to build the Custom Scheduler Task in OIM 11g

Environment Setup

The following jar files are required to compile the Custom Scheduler Task Java file. They are
1) wlfullclient.jar
2) wlclient.jar

Generating wlfullclient.jar
Go to the WL_Home/server/lib directory and Run the following command

java -jar wljarbuilder.jar

It will generate the wlfullclient.jar file and set the class path for the wlfullclient.jar and wlclient.jar file.


Develop the Java Class

package test.scheduler;

import java.util.HashMap;

import oracle.iam.scheduler.vo.TaskSupport;

public class TrustedSourceReconciliation extends TaskSupport {

public TrustedSourceReconciliation() {


System.out.println("TrustedSourceReconciliation() Called");
}

/**
* This method called by quartz scheduler and HashMap contains the config parameters.
*/
public void execute(HashMap arg0) throws Exception {

System.out.println("SfsuTrustedSourceReconciliation Arguments "+arg0);
}

public HashMap getAttributes()
{
return null;
}
public void setAttributes()
{

}

}

Make Jar File

Jar cvf TrustedSourceReconciliation.jar *


Develop the Custom Scheduler Config File


<scheduledtasks xmlns="http://xmlns.oracle.com/oim/scheduler">
<task>
<name>TrustedSourceReconciliation</name>
<class>test.scheduler.TrustedSourceReconciliation</class>
<description>Trusted Reconciliation</description>
<retry>5</retry>
<parameters>
<string-param required="true" encrypted="false" helpText="User Name">DB User Name</string-param>
<string-param required="true" encrypted="false" helpText="DB Password">DB Password</string-param>
<string-param required="true" encrypted="false" helpText="DB URL">DB URL</string-param>
<string-param required="true" encrypted="false" helpText="Select Statement">Select Statement</string-param>
</parameters>
</task>
</scheduledTasks>

Save this file as TrustedSourceReconciliation.xml because Custom Scheduler task name and file name as same as per the oracle custom scheduler scpecification.

XML Name space is very important when you deploying custom scheduler task in MDS Schema. If you give wrong name space in scheduledTasks tag and it will deploy in the OIM MDS Schema But OIM won't recognised as a ScheuledTask.


Develop the plugin.xml file

<?xml version="1.0" encoding="UTF-8"?>
<oimplugins>
<plugins pluginpoint="oracle.iam.scheduler.vo.TaskSupport">
<plugin pluginclass="test.scheduler.TrustedSourceReconciliation" version="1.0" name="TrustedSourceReconciliation"/>
</plugins>
</oimplugins>


Making the Scheduler.zip File

plugin.xml file
lib/TrustedSourceReconciliation.jar

Regsiter the Plugin File into the OIM Server

ant -f pluginregistration.xml register

It will ask the following details after running the above command


1) OIM Admin User Name : xelsysadm
2) OIM Admin Password : xelsysadm password
3) OIM URL : t3://localhost:14000
4) Plugin Zip File absolute path.

It will deploy the OIM Plugin without any issue. Some Times It will throw error if the class file is not found in the jar file.

Importing the Custom Scheduler Task into MDS Schema

Go to the OIM_HOME/bin directory and modify the following properties in the weblogic.properties file

wls_servername=oim_server1
application_name=oim
metadata_from_loc=/home/oracle/schedulers

Schedeler Config file location as /home/oracle/schedulers/db/TrustedSourceReconciliation.xml

Run the weblogicImportmetada.sh file and will ask the following details


1) Weblogic Admin User Name : weblogic
2) Weblogic Admin Password : weblogic admin password
3) weblogic Admin URL : t3://localhost:7001

After running the above command the custom scheduler task will be imported into the MDS Schema.

Clear the OIM Cache

Run the PurgeCache.sh All file and it will ask the following details.


1) OIM Admin User Name : xelsysadm
2) OIM Admin Password : xelsysadm password
3) OIM URL : t3://localhost:14000


After running the above command and it will clear the OIM cache

Restart the OIM Server

Go to the WL_DOMAIN_HOME/bin direcory and run stopManagedServer.sh oim_server1 command and it will stop the oim managed server.

Run the startManagedServer.sh oim_server1 and it will start the OIM Managed Server.

Testing The Scheduler Task

Login to the OIM Admin Console >> Advanced >> System Management >> Scheduler >>Create >> Search the TrustedSourceReconciliation and select the Scheduler and enter the parameters and click Save and run the Scheduler.


Trouble Shooting

Problem : Scheduler Task is not showing in the Scheduler List
Cause : Scheduler Name space is missing
Solution : Check the Scheduler name space in the scheduer task. The name space always xmlns="http://xmlns.oracle.com/oim/scheduler"

Problem : The Scheduler implemented class file not found while deploying the plugin.zip file.
Cause : The class file is missing in the zip file.

Solution : Please add the jar file into the lib directory and make the zip file again and regsiter the plugin.


Reference Document : Oracle Identity Manager Developer Guide

Tuesday, July 19, 2011

java.lang.UnsupportedOperationException: Remote JDBC disabled Error

Problem: I couldn't able to get the connection from the weblogic data source and I am getting the following exception  while creating the connection using ds.getConnection(). They are

Exception in thread "main" java.lang.UnsupportedOperationException: Remote JDBC disabled
    at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
    at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
    at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
    at weblogic.jdbc.common.internal.RmiDataSource_1035_WLStub.getConnection(Unknown Source)
    at edu.sfsu.oim11g.util.SfsuOimUtil.getConnection(SfsuOimUtil.java:152)
    at edu.sfsu.oim11g.db.dao.SfsuDataDao.getSfsuData(SfsuDataDao.java:23)
    at edu.sfsu.oim11g.db.dao.SfsuDataDao.main(SfsuDataDao.java:79)
Caused by: java.lang.UnsupportedOperationException: Remote JDBC disabled
    at weblogic.jdbc.common.internal.JDBCServerHelperImpl.<clinit>(JDBCServerHelperImpl.java:36)
    at weblogic.jdbc.common.internal.JDBCService.initialize(JDBCService.java:91)
    at weblogic.jdbc.common.internal.JDBCService.start(JDBCService.java:137)
    at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)


Solution:


1) Go to the Weblogic Domain Directory and edit the setDomainEnv.sh file
2) Modify WLS_JDBC_REMOTE_ENABLED value false to true.
WLS_JDBC_REMOTE_ENABLED="-Dweblogic.jdbc.remoteEnabled=true"
3) Restart the WebLogic Servers

Creating the User Attributes in Oracle Identity Manager 11G

Creating The Custom Attributes in OIM.

The Following tasks are invovled to create the custom attributes in OIM. They are

1) OIM Admin Console

Logged into the OIM Console with Admin Credentials and it will display the following screen.




2) Click the Administration link on the right side corner and it will display the following screen.




3) Click Advanced Administration link and it will display the following screen.


4) Click the Configuration Link and It will display the following screen.


5) Click the User Configuration >> User Configuration >> Action >> User Attributes from the Action list and It will display the following screen.


6) Click Create Attribute Link and It will display the following screen.


7) Enter the Attribute Name,Back-end Attribute Name and select Category Name and Display Type and click Next Button and it will display the following screen. In this case my attribute name is Server.


8) Select default options and enter the attribute size and click next and it will display the following screen.


9) After Clicking the Next button and it will display the summary screen and click Save.


10) Finally the attribute is created in the Criteria Tab.