Steps Developing Schedule Task with OIM 11g R2
1. Create a java class by implementing oracle.iam.scheduler.vo.TaskSupport interface.
- Include the following JAR files in the class path to compile a custom class:
From OIM_INSTALL_HOME/server/platform
- iam-platform-kernel.jar
- iam-platform-utils.jar
- iam-platform-context.jar
- iam-plaftorm-authz-service.jar
From OIM_INSTALL_HOME/designconsole/lib
- oimclient.jar
- xlAPI.jar
All other JAR files like
xlVO.jar and xlScheduler.jar
- Create a library of JAR files containing the custom classes.
Sample java code
package com.scheduletask;
import java.util.HashMap;
import oracle.iam.identity.usermgmt.api.UserManager;
import oracle.iam.identity.usermgmt.vo.User;
import oracle.iam.platform.Platform;
import oracle.iam.scheduler.vo.TaskSupport;
public class CreateNewUser extends TaskSupport{
@Override
public void execute(HashMap hm) throws Exception {
System.out.println("**************inside CreateNewUser **********");
// Lookup a service
UserManager usermgr = Platform.getService(UserManager.class);
// Build new User
String userKey = null; // USR_KEY
String firstName = (String) hm.get("First Name"); // USR_FIRST_NAME
String lastName = (String) hm.get("Last Name"); // USR_LAST_NAME
String userLogin = (String) hm.get("User Login"); // USR_LOGIN
String organizationKey = "1"; // ACT_KEY [Organization]
String userType = "End-User"; // USR_TYPE
String role = "Full-Time"; // USR_EMP_TYPE [User Type]
User newUser = new User(userKey);
newUser.setLogin(userLogin);
newUser.setFirstName(firstName);
newUser.setLastName(lastName);
newUser.setOrganizationKey(organizationKey);
newUser.setUserType(userType);
newUser.setEmployeeType(role);
// Call a method from a service
usermgr.create(newUser);
}
@Override
public HashMap getAttributes() {
return null;
}
@Override
public void setAttributes() {
}
}
4. createMETA-INF xml file for schedule task like
<?xml version="1.0" encoding="UTF-8"?>
<scheduledTasks xmlns="http://xmlns.oracle.com/oim/scheduler">
<task>
<name>Create New User</name>
<class>com.scheduletask.CreateNewUser</class>
<description>Create a new OIM User</description>
<retry>5</retry>
<parameters>
<string-param required="true" encrypted="false" helpText="First Name">First Name</string-param>
<string-param required="true" encrypted="false" helpText="Last Name">Last Name</string-param>
<string-param required="true" encrypted="false" helpText="User Login">User Login</string-param>
</parameters>
</task>
</scheduledTasks>
- Create plugin.xml file: sample is as below. Note: The name should be plugin.xml only<?xml version="1.0" encoding="UTF-8"?><oimplugins xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><plugins pluginpoint="oracle.iam.scheduler.vo.TaskSupport"><plugin pluginclass= "com.scheduletask.CreateNewUser" version="1.0.1" name="CreateNewUser"></plugin></plugins></oimplugins>
- Put all the files in a structure as below and create zip folder
Plugin_name.zip à lib à jar
- META-INF à Scheduletask xml
- Plugin.xml
- Copy the zip folder at some location in server
- Set ANT_HOME=/home/oracle/Oracle/Middleware/modules/org.apache.ant_1.7.1 and PATH for $ANT_HOME/bin
- Go to directory /home/oracle/Oracle/Middleware/Oracle_IDM1/server/plugin_utility and modify ant.properties file for below settingwls.home=/home/oracle/Oracle/Middleware/wlserver_10.3oim.home=/home/oracle/Oracle/Middleware/Oracle_IDM1/serverlogin.config=${oim.home}/config/authwl.confmw.home=/home/oracle/Oracle/Middleware
- Run ant command ant -f pluginregistration.xml register
This will prompt for the Oracle Identity Manager username and password along with the server information and the location of the plugin zip file. Enter the complete path of the zip file location.
OIM User name: xelsysadm
Password:
url: t3://oimhost:oimport
Comments
Post a Comment