Oracle Identity Manager Basics: Creating a Custom Adapter in OIM 11g

Oracle Identity Manager Basics: Creating a Custom Adapter in OIM 11g

The purpose of this entry is to explain how to create a custom adapter in OIM.  The adapter will write to an external file.  This functionality could easily be changed to modify a database or some other process.  We will use a jar to do the actual heavy lifting so almost anything you can do with java you can do through the adapter.  These steps continue where the Custom Resource Object guide finished off using the resource object created there.


    1. Create a java class that has one method which accepts 4 arguments (username, firstname, lastname, favColor) and appends that info to a text file as a CSV.  The file path should be passed as an argument to the constructor.
    2. Copy the jar to the required OIM location
    3. Create the adapter
    4. Add new Process Task
    5. Add as follow-on to Provisioning task

The Steps:

1.Create java class

We want to create a java class that has one method which has 4 arguments and write that to a file.  The constructor will have the filename passed as well as the value true to set the writer to append instead of overwrite.

public doWork(String filename, boolean appendVal){
// Constructor enables overwriting if appendVal = false, otherwise appends
path = filename;
appendVar = appendVal;

public void writeCSV(String arg1, String arg2, String arg3, String arg4) throws IOException{
FileWriter writer = new FileWriter (path, appendVar);
PrintWriter add_line = new PrintWriter(writer);

// CSV requires commas, other formats may require changing delineation method

doWork is a constructor that requires a filename and true

writeCSV(string userName, string firstName, string lastName, string favColor) does the work and writes the strings to the file

Compile the code and make sure it works by running the jar.

2. Copy the jar to the required OIM location

You need to manually copy the jar over to the location where OIM can see it.  In this case, that location will be D:OracleOracle_IDM1serverJavaTasks

3. Create the adapter

Go to the adapter factory, create a new adapter (Name: WriteToFile, Type: Process Task, Desc: anything)

In the Variable List tab, create 5 variables, one for the filename and the other 4 for the 4 variables, all of which will be Strings that Resolve at runtime.

Add an Adapter Task (Name: Write It)

Select the jar file from the API Source menu. (JavaTaskJar.RichProg.jar)

Select the class that has the method we want to use (doWork)

Constructor (0 public doWork(java.lang.String)

Methods (0 public void doWork.writeCSV(java.lang.String,java.lang.String,java.lang.String,java.lang.String) throws

Save. Then go down to the bottom portion.  Under Constructor, if you look at the code in, the constructor requires a filename.  So select Input (Map to: Adapter Variables, Name: filename).

Since the output of the function is void, we don’t need to map anything there but we could output status messages so that other tasks are performed depending on the success of the method.  Map the method Input variables to their respective Adapter Variables.

Save and Build

4.  Add new Process Task

In Process Management, Process Definition, we are going to add a task to the previously created Rubber Ball resource.  Add Task (Name: WriteFile, Conditional, Required for Completion, Allow Cancellation while Pending, Allow Multiple Instances)

In the Integration tab, select the WriteToFile adapter (adpWRITETOFILE).  You need to map the 4 variables to their respective process definitions.  The filename variable needs to be mapped to a literal with D:Oracletest.csv as its value.  For production, you would want to map this to an IT resource so that multiple tasks could use the same location and if it changed, you would only change the location in one place instead of needing to edit each task.

5.  Add as a follow-on to the Provisioning task

We need to assign the newly created task to activate whenever the resource is provisioned.  As a result, we are going to add the WriteFile task to be triggered by Provision It.

In Provision It, under the Responses tab, select the OK Response which signifies that the provision operation completed properly.  Now, hit Assign at the bottom and select WriteFile.  This indicates that when the OK Response is triggered, then WriteFile will be triggered as well.  This area is how you can create multiple tasks dependent on the response of the previous task.  Say we wanted to run a different method if it failed, we could assign that other method as a task to generate for the UNKNOWN response.  Save Provision It.

Now, if you already have the resource provisioned to a user, you can go into resource history and run the task.  The file should be created wherever you listed it (the literal in our case was D:Oracletest.csv).  If you do not have the resource provisioned to a user yet, provision it and the file should be created.  Your custom adapter should be properly working now.  If you run the task multiple times or with different users, it should create a new line everytime the task is run.

The java code can easily be modified to run SQL queries, add a user to a database, etc. which is where the versatility of this process comes in handy.