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
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
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
// TODO Auto-generated method stub
}
/**
* Getting the Value from the Request Parameters
*/
private String getParamaterValue(HashMap
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="
</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