Search This Blog

Monday 18 January 2016

Installation of OIM Customization Installer Extension in JDeveloper

Before using OIM Customization Installer,

• JDeveloper 11.1.1.7.0 (studio version) should be installed on the system, which has been done already on the VM
• For any customization that has to be deployed using this framework, below folder structure should be followed to package its source as it should show up in the JDeveloper IDE. The package of all the customization artifacts that will be used in this training course, already follow this recommended structure. 

Folder Structure            Description
PROJECT-CONTEXT]/config All .xml files
[PROJECT-CONTEXT]/resources All the required resources files
[PROJECT-CONTEXT]/lib         All the required jar files
[PROJECT-CONTEXT]/src         All java source files

Please note that the above folder structure is mandatory. A directory can be left empty, but should not be missed out from the folder structure.

Set Environment Variable
Set APPSERVER_TYPE=wls in both windows and Linux Environment where JDeveloper is running.

Note: Please keep wls as small characters.

Sample screen in Windows machine will look like this:


Create Log Directory
Create log directory under {JDEVELOPER-HOME}/jdev/bin

Note: Please keep log as small characters.
Install OIM Customization Installer Extension on JDeveloper
• Select menu  “Help” -> “Check for Updates”


• Select “Install from Local File” from the wizard.
• Browse and select the oim-customization-installer.zip package and click Next


• Click on “Finish”.


• Restart JDeveloper

Wednesday 13 January 2016

Sending Notification with UserID to User on successful user creation in OIM

In this post I will discuss the scenario where we want to send notification to user with User ID on successful account creation in OIM.

We have an out-of-box notification as well for the same, where a mail is sent to user with User ID and password.

Now in this post we will achieve the same, but only User ID will be sent to the user in the notification. But we will discuss on how we can send other desired attributes as well using OIM APIs i.e the same code can be used to send other details as well which we will discuss side-by-side.

To start with, we first need to create a Notification Template that will be used to send notification to end-user. For that click on Notification on Administrator Control present under System configurations tab as shown below:


Click on Notifications and a popup window will appear. Click on Create New Notification's Icon to create New Notification Template as below:



Enter the required details like 

Template Name: Notify User(You can choose any name and the same needs to be referred in code)

Description Text: Notify User when User is Created in OIM

Available Event: Create User(WE will update this once we create a New Event)

Encoding: UTF-8

Message Subject: Congratulations! Your Account has been successfully Created

Type: HTML

Short Message: Create User Successful(Change it as per your Notification requirement)

Long Message:
<html><head></head>  <body>    
                    <p> 
Congratulations!! Your account has been successfully created!!
      Your user login is - $userLoginId
    </p>

                     </body></html>

Click Save after providing the details, template will look as below:



Now, we will create the event so that the same can be selected in the Notification Template. For that first we need to export the metadata. In that open the file metadata->iam-features-identity->IdentityNotificationEvent.xml. Add the below lines in the file:

<EventType name="Notify User">
<StaticData>
<Attribute DataType="X2-Entity" EntityName="User" Name="Granted User"/>
</StaticData>
<Resolver class="oracle.iam.identity.notification.EndDateNotificationEventResolver">
<Param DataType="X2-Entity" EntityName="User" Name="usr_key"/>
</Resolver>

</EventType>

Screenshot is attached for reference below:



Now save the file and import the metadata. Once the import is completed, now we can see the "Notify User" event in the template, select it and save the template as below:



Now, we need to write the code which uses the above template to send Notification to user once the user is created in OIM. For that we have 2 broadly classified scenarios:

1. User Created Using Identity Console
2. User Created Using Flat File

In our code we will write the code to take care of both the cases, you can choose both or one as per the requirement. Read the comments above method to understand the role of each method. We need to 2 jar files for this code namely oimclient.jar and ojdl.jar. Below is the code:

package com.handler.iam;

import java.io.Serializable;

import java.util.ArrayList;
import java.util.HashMap;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import oracle.core.ojdl.logging.ODLLogger;

import static oracle.iam.identity.usermgmt.api.UserManagerConstants.AttributeName.MANAGER_KEY;
import static oracle.iam.identity.usermgmt.api.UserManagerConstants.AttributeName.USER_LOGIN;

import oracle.iam.identity.exception.AccessDeniedException;
import oracle.iam.identity.exception.NoSuchUserException;
import oracle.iam.identity.exception.UserLookupException;
import oracle.iam.identity.usermgmt.api.UserManager;
import oracle.iam.identity.usermgmt.vo.User;
import oracle.iam.notification.api.NotificationService;

import oracle.iam.notification.vo.NotificationEvent;
import oracle.iam.platform.Platform;
import oracle.iam.platform.kernel.spi.PostProcessHandler;
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;
import oracle.iam.upgrade.metadata.Params;

public class userCreationNotification implements PostProcessHandler{
    
    private ODLLogger logger = ODLLogger.getODLLogger("com.scb.oim.generateEmailID");
    
    /**
     * This method is used to send Notification to user when User is created using Identity Screen of OIM
     * @param processId
     * @param eventId
     * @param orchestration
     * @return
     */
    public EventResult execute(long processId, long eventId, Orchestration orchestration) {
        
        logger.entering("Notification", "EventResult execute");
        try {
                logger.info("Entering  EventResult of NotifyUserIdToUser");
                logger.info("Process ID ->" + processId);
                logger.info("Event ID ->" + eventId);
                String oprType = orchestration.getOperation();
                logger.info("oprType ->" + oprType);
                HashMap<String, Serializable> Params = orchestration.getParameters();
                //logger.info("Param ->" + Params);
                Set<String> KeySet = Params.keySet();
                //logger.info("KeySet ->" + KeySet);
                String usrLogin = null;
                String usrKey = null;
                for (String key : KeySet) {
                    logger.info("key ->" + key);
                    Serializable serializable = Params.get(key);
                    logger.info("serializable ->" + serializable);
                    if (key.equalsIgnoreCase("User Login")) {
                            usrLogin = serializable.toString();
                            logger.info("usrLogin ->" + usrLogin);
                            UserManager usrMgr = Platform
                                            .getService(UserManager.class);

                            User user = usrMgr.getDetails(usrLogin, null, true);
                            usrKey = user.getEntityId(); // getAttribute("usr_key").toString();
                            String uid = user.getId();
                            logger.info("uid--->" + uid);
                            logger.info("usrKey ->" + usrKey);
                            String templateName = "Notify User";
                            NotificationService notService = Platform
                                            .getService(NotificationService.class);
                            NotificationEvent eventToSend = this
                                            .createNotificationEvent(templateName, usrKey);
                            notService.notify(eventToSend);

                    }
                }
                
        } catch (Exception e) {
                logger.info("exception e in ExecuteEvent ->"
                                + e.getMessage());
                e.printStackTrace();
        }
        logger.exiting("Notification", "ExecuteEvent");
        return new EventResult();
    }
    
    /**
     * This method is used to create the Notification Event using the Template Name and User Key
     * @param poTemplateName
     * @param userKey
     * @return
     */
    private NotificationEvent createNotificationEvent(String poTemplateName, String userKey) {
        logger.entering("Notification", "createNotificationEvent()");
        NotificationEvent event = null;
        try {
                event = new NotificationEvent();
                String[] receiverUserIds = getRecipientUserIds(userKey);
                event.setUserIds(receiverUserIds);
                event.setTemplateName(poTemplateName);
                event.setSender(null);
                logger.info("User ID: "+receiverUserIds.toString());
                logger.info("Template Name: "+poTemplateName);
                HashMap<String, Object> templateParams = new HashMap<String, Object>();
                templateParams.put("usr_key", userKey);
                event.setParams(templateParams);
                logger.exiting("Notification", "createNotificationEvent()");
        } catch (Exception e) {
                e.printStackTrace();
                logger.severe("Exception in createNotificationEvent()"+e.getMessage());
        }
        return event;
    }

    /**
     * This method is used to send Notification to user when User is created using BulkUpload or Flat File
     * @param l
     * @param l1
     * @param bulkOrchestration
     * @return
     */
    public BulkEventResult execute(long l, long l1,
                                   BulkOrchestration bulkOrchestration) {
        logger.entering("Notification", "Bulk User Creation");
        try {
                logger.info("Entering  BulkEventResult of NotifyUserIdToUser");
                logger.info("l ->" + l);
                logger.info("l1 ->" + l1);
                String oprType = bulkOrchestration.getOperation();
                logger.info("oprType ->" + oprType);
                HashMap<String, Serializable>[] bulkParams = bulkOrchestration.getBulkParameters();
                for (HashMap<String, Serializable> bulkParam : bulkParams) {
                        logger.info("bulkParam ->" + bulkParam);
                        Set<String> bulkKeySet = bulkParam.keySet();
                        logger.info("bulkKeySet ->" + bulkKeySet);
                        String usrLogin = null;
                        String usrKey = null;
                        for (String key : bulkKeySet) {
                                logger.info("key ->" + key);
                                Serializable serializable = bulkParam.get(key);
                                logger.info("serializable ->" + serializable);
                                if (key.equalsIgnoreCase("User Login")) {
                                        usrLogin = serializable.toString();
                                        logger.info("usrLogin ->" + usrLogin);
                                        UserManager usrMgr = Platform
                                                        .getService(UserManager.class);

                                        User user = usrMgr.getDetails(usrLogin, null, true);
                                        usrKey = user.getEntityId(); // getAttribute("usr_key").toString();
                                        String uid = user.getId();
                                        logger.info("uid--->" + uid);
                                        logger.info("usrKey ->" + usrKey);
                                        String templateName = "Notify User";
                                        NotificationService notService = Platform
                                                        .getService(NotificationService.class);
                                        NotificationEvent eventToSend = this
                                                        .createNotificationEvent(templateName, usrKey);
                                        notService.notify(eventToSend);

                                }
                        }
                }
        } catch (Exception e) {
                logger.info("exception e in BulkExecuteEvent ->"
                                + e.getMessage());
                e.printStackTrace();
        }
        logger.exiting("Notification", "Bulk User Creation");
        return new BulkEventResult();
    }
    
    /**
     * This method is used to fetch the UserID of the reciepient to whom the Notification needs to be sent
     * @param userKey
     * @return
     * @throws NoSuchUserException
     * @throws UserLookupException
     * @throws AccessDeniedException
     */
    private String[] getRecipientUserIds(String userKey) throws NoSuchUserException, UserLookupException, AccessDeniedException {
        UserManager usrMgr = Platform.getService(UserManager.class);
        User user = null;
        String userId = null;
        Set<String> userRetAttrs = new HashSet<String>();
        userRetAttrs.add(MANAGER_KEY.getId());
        userRetAttrs.add(USER_LOGIN.getId());
        User manager = null;
        String managerId = null;
        String managerKey = null;
        Set<String> managerRetAttrs = new HashSet<String>();
        managerRetAttrs.add(USER_LOGIN.getId());
        user = usrMgr.getDetails(userKey, userRetAttrs, false);
        userId = user.getAttribute(USER_LOGIN.getId()).toString();
        List<String> userIds = new ArrayList<String>();
        userIds.add(userId);
        if (user.getAttribute(MANAGER_KEY.getId()) != null) {
                managerKey = user.getAttribute(MANAGER_KEY.getId()).toString();
                manager = usrMgr.getDetails(managerKey, managerRetAttrs, false);
                managerId = manager.getAttribute(USER_LOGIN.getId()).toString();
                userIds.add(managerId);
        }
        String[] recipientIDs = userIds.toArray(new String[0]);
        return recipientIDs;
    }

    public boolean cancel(long l, long l1,
                          AbstractGenericOrchestration abstractGenericOrchestration) {
        return false;
    }

    public void initialize(HashMap<String, String> hashMap) {
    }

    public void compensate(long l, long l1,
                           AbstractGenericOrchestration abstractGenericOrchestration) {
    }

}

Since this is a post-process Event Handler, which we need to attach to Create User Process, we will do the same by creating a EventHandler.xml file will below lines:


<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="com.handler.iam.userCreationNotification" entity-type="User" operation="CREATE" name="NotifyUser" stage="postprocess" order="FIRST" sync="TRUE"/>
</eventhandlers>

Now create a plugin.xml file with below lines:

<?xml version="1.0" encoding="UTF-8"?>
<oimplugins>
  <plugins pluginpoint="oracle.iam.platform.kernel.spi.EventHandler">
    <plugin pluginclass=
        "com.handler.iam.userCreationNotification"
         version="1.0"
         name="userCreationNotification">
    </plugin>
  </plugins>
</oimplugins>

Now, deploy the EventHandler using ant plugin utility and the you will see that the Notification is being sent to user with User ID every time a new user is created in OIM. We can also send other attributes as per our requirement. For that we just need to add the Variables to Notification template using $ sign as we did for $userLoginId post that we have to select the variable from the list of variables already been fetched in the code and map it to that data to send it in Notification. If you still face issues you can contact me.

Monday 4 January 2016

Difference between Oracle Directory Services: OID: OUD: ODSEE: OVD: DIP

If you have just started exploring Identity Management and came across different similar sounding three letter words such as OID, OVD, OUD, blah, blah – and wondering what the heck is the difference between them when they all almost sound similar and all have something to do with directory services – you are not the only one.

Why do we have different similar components offered by same company? Well, each has something different to offer, some brownie features. 

In this article, I will try to highlight main points of all the different products for directory management in 11g of the Fusion Middleware stack offered by Oracle and difference between them.

What is a Directory Service? A directory service is something that provides information about people and resources to a client requesting information. For eg: Phone Book. The information may be a name, a telephone number, an email address, application preferences, group memberships, and so on. The client may be a person and/or application.

As of today, Oracle has 3 different LDAP directories.

a) Oracle Internet Directory (OID)

b) Oracle Directory Server Enterprise Edition (ODSEE)

c) Oracle Unified Directory (OUD).

There’s two other products which are related to directory services:-

d) Directory Integration Platform(DIP)

e) Oracle Virtual Directory (OVD)

Now,  lets see the main points of each component.


Oracle Internet Directory (OID)


a) OID was totally developed by Oracle. 
b) OID is written in Java and C language
c) OID requires an Oracle Enterprise Edition database to be used as physical storage media.
d) Oracle will be releasing security patches and will be enhancing the product as well purely because there are some Oracle products that still require the OID architecture.


Oracle Directory Server Enterprise Edition (ODSEE)


a) ODSEE is SUNs implementation of LDAP. It is a BEST known directory server with proven large deployments in carrier and enterprise environments.
b) ODSEE has got its own embedded database to physically store the LDAP information.
c) It has a directory server and a replication server associated with ODSEE. So we can replicate data from one ODSEE directory to another ODSEE directory as well.
d) ODSEE is now in Maintenance mode from here on. So basically it is still supported but no new features are going to be introduced in this.


Oracle Unified Directory (OUD)


a) OUD is the latest of three LDAP directories. Its is based on the OpenDS standard which was originally developed by SUN.
b) OUD is purely based on Java. A pure Java solution simplifies multiplatform support, deployment, and ongoing maintenance.
c) OUD has an embedded database(Berkeley database) associated with it. It's a small & lightweight but still, it is very fast and robust database to physically hold the LDAP information.
d) OUD can also act as Replication or Proxy servers. Proxy servers can either be used for load balancing or data distribution. 
e) OUD is the preferred (if possible) Directory services, recommended by Oracle for all new development and new deployments.


Directory Integration Platform (DIP)


a) Directory Integration Platform is a product associated with the directory services which is a general-purpose synchronization solution that supports numerous data sources, including OUD 11g.
b) DIP provides the following services for synchronizing identity data from authoritative sources such as LDAP directories and databases:
1) Keeping data and groups synchronized between LDAP directories including OUD 11g, OID, DSEE and Microsoft Active Directory.
2) Keep passwords synchronized between LDAP directories and OUD 11g
3) Synchronizing data between OUD 11g and relational databases
4) Translating attributes and data between OUD 11g and other authoritative sources
c) In 10g, DIP was part of OID architecture. In 11g this has been stripped out and runs as a standalone product that is deployed on a WebLogic server. 
d) There are only five different types of LDAP directories we can synchronize data with using DIP; SUN directories, Active Directory, Novell eDirectory, OpenLDAP, and IBM Tivoli. 
e) Using DIP, we can import information in OID from an Oracle database but can't write it back to database. And it needs to be an Oracle database, not any other database.
f) Most of the things achieved by DIP, can also be done via OIM which is slightly more flexible.


Oracle Virtual Directory (OVD)


a) OVD does not have any available storage media.
b) OVD server is a Java server process that runs outside of WebLogic Domain.
c) OVD is basically a virtual representation of an LDAP directory. Beneath it, we can have AD, OID or OUD or ODSEE or a database. Using adaptors in OVD, we can decide what to connect to.

Sunday 3 January 2016

Creating Post-Process Event Handler to Create Email-ID in OIM for Users created through Flat File

A Post-Process Event handler are consequent operations related to the current operation taking place. Eg: In our case we want E-Mail ID to be created for the user in OIM as soon as the user is successfully created.

Now to create the post-process event handler we need to implement PostProcessHandler interface.

Below are the 2 ways in which a user can be created in OIM:
1. Using Create option from OIM Identity Console
2. Using Bulk Upload like Flat-File

Now to handle these 2 cases, we use below 2 methods as described by PostProcessHandler interface:

1. public EventResult execute(long l, long l1, Orchestration orchestration)
2. public BulkEventResult execute(long l, long l1,                 BulkOrchestration bulkOrchestration)

Below is the complete code to implement the logic:

package com.iam.oim;

import com.scb.db.DBUtil;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.HashMap;

import oracle.core.ojdl.logging.ODLLogger;

import oracle.iam.platform.Platform;
import oracle.iam.platform.kernel.spi.PostProcessHandler;
import oracle.iam.platform.context.ContextAware;
import oracle.iam.platform.entitymgr.EntityManager;
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 generateEmailID implements PostProcessHandler{

    private ODLLogger logger = ODLLogger.getODLLogger(Constant.LOGGER_NAME);
    private static final String CLASS_NAME="com.scb.oim.generateEmailID";
    
    /**
     * This method is used to remove any spaces present in the string
     * @param userName
     * @return
     */
    
    private String removeSpaces(String userName){
        userName=userName.replaceAll("-","");
        userName=userName.replaceAll(" ","");
        userName=userName.replaceAll("","");
        return userName;
    }
    
    /**
     * Thsi method is used to fetch the User Details like FirstName, MiddleName, LastName etc.
     * @param parameters
     * @param key
     * @return
     */
    
    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;
    }
    
    /**
     * This method will generate the E-Mail Address based on the logic, like FirstName.LastName@xyz.com or FirstNameMiddleName.LastName@xyz.com
     * @param FN
     * @param MN
     * @param LN
     * @param counter
     * @return
     */
    
    private String generateEmailID(String FN, String MN, String LN, int counter) {
        
        String methodName= "generateEmailID";
        logger.entering(CLASS_NAME, methodName);
        String address = "@xyz.com";
        String emailID = "";
        String count = "";
        
        if(counter > 0){
            count = Integer.toString(counter);
        }
        
        if(MN.equalsIgnoreCase("Null")){
            emailID = ((FN.concat(".")).concat(LN)).concat(count).concat(address);
            logger.info("Generate Email ID: "+emailID);
        }
        else{
            emailID = (((FN.concat(MN)).concat(".")).concat(LN)).concat(count).concat(address);
            logger.info("Generate Email ID: "+emailID);
        }
        logger.exiting(CLASS_NAME, methodName);
        return emailID;
    }
    
    /**
     * This method will check for the uniqueness of the generated Email ID by validting against OIM DB
     * @param email
     * @param Conn
     * @return
     */

    private String checkEmailID(String email, Connection Conn) {
      
      String methodName = "checkEmailID";
      
      logger.entering(CLASS_NAME, methodName);
      String flag =  "Unique";
      int Count = 0;
      PreparedStatement ps = null;
      ResultSet rs = null;
      
      try{
          ps = Conn.prepareStatement(Constant.SQL_SELECT_EMAIL_ID);
          ps.setString(1, email);
          rs = ps.executeQuery();
          
          while(rs.next()){
              Count = rs.getInt(1);
              logger.info("Count: "+Count);
          }
          if(Count>0){
              flag = "Duplicate";
              logger.info("Generated Email ID already exists: "+email);
          }
          else{
              logger.info("Generate Email ID is Unique: "+email);
          }
          logger.exiting(CLASS_NAME, methodName);
          return flag;
      }
        catch (Exception e){
                logger.severe("Exception inside get checkEmailID"+e.getMessage());
        }finally{
                try{
                    if (ps != null){
                            ps.close();
                    }
                    if(rs!=null){
                            rs.close();
                    }
                }catch(Exception e){
                        logger.severe("Exception while closing the ps and rs"+e.getMessage());
                }
        }
      
      return flag;
    }
    
    /**
     * Main Class that executes the PostProcess Event Handler
     * @param parameterHashMap
     * @param targetType
     * @param targetId
     */
    private void executeEvent(HashMap parameterHashMap, String targetType, String targetId) {
        
        Connection oimConnection=DBUtil.getOIMConnection();
        
        if(targetId!=null){
            try{
                    EntityManager mgr = Platform.getService(EntityManager.class);
                    String flag = "Duplicate";
                    int i = 0;
                    
                    //Fetching FirstName, MiddleName and LastName of User to generate Email ID
                    
                    String FirstName = getParamaterValue(parameterHashMap, "First Name");
                    String MiddleName = getParamaterValue(parameterHashMap, "Middle Name");
                    String LastName = getParamaterValue(parameterHashMap, "Last Name");
                    logger.info("First Name: "+FirstName);
                    logger.info("Middle Name: "+MiddleName);
                    logger.info("Last Name: "+LastName);
                   
                    HashMap<String, Object> modParams = new HashMap<String, Object>(); 
                    
                    if((FirstName == null || (FirstName.length() == 0))&&(LastName == null || (LastName.length() == 0))){
                        logger.info("Invalid First Name or Last Name");
                        System.exit(0);
                    }
                    else{
                        
                        if(MiddleName == null || (MiddleName.length() == 0)){
                            MiddleName= "Null";
                            logger.info("Middle Name is NULL!!!!");
                        }
                        
                        FirstName = removeSpaces(FirstName);
                        MiddleName = removeSpaces(MiddleName);
                        LastName = removeSpaces(LastName);
                        
                        
                        
                        String genEmail = generateEmailID(FirstName, MiddleName, LastName, i);
                        
                        //Check if generated Email ID is unique
                        flag = checkEmailID(genEmail, oimConnection);
                        
                        while (flag.equalsIgnoreCase("Duplicate")){
                            i = i+1;
                            genEmail = generateEmailID(FirstName, MiddleName, LastName, i);
                            flag = checkEmailID(genEmail, oimConnection);
                        }
                        if(flag.equalsIgnoreCase("Unique")){
                            modParams.put("Email", genEmail);
                            mgr.modifyEntity(targetType, targetId, modParams);
                            logger.info("USER Modified SUCCESSFULLY WITH EMAIL ID: "+genEmail);
                        }
                    }
                }catch(Exception e){
                    logger.severe("Exception inside executeEvent()"+e.getMessage());
                }finally{
                try{
                    if(oimConnection!=null){
                        oimConnection.close();
                    }
                }catch(Exception e){
                    logger.severe("Exception occured while closing Connection"+e.getMessage());
                }
        }
        }
    
    }
    
    /**
     * This method is called to when a user is created using Identity Console
     * @param l
     * @param l1
     * @param orchestration
     * @return
     */
    
    public EventResult execute(long l, long l1, Orchestration orchestration) {
        
        String methodName = "EventResult()";
        logger.entering(CLASS_NAME, methodName);
        
        HashMap<String, Serializable> parameters = orchestration.getParameters();
    
        logger.info(String.format("Parameters: ", parameters));
        
        String targetType = orchestration.getTarget().getType();
        String entityID = orchestration.getTarget().getEntityId();
        
        logger.info("Target Type: "+targetType);
        logger.info("Entity ID: "+entityID);
        
        try {  
                    executeEvent(parameters,orchestration.getTarget().getType(), orchestration.getTarget().getEntityId());  
                     
               } catch (Exception e) {  
                   e.printStackTrace();  
               }
        logger.exiting(CLASS_NAME, methodName);
        return new EventResult();
    }

    /**
     * This method is called to when a users are created using Flat File or Bulk Upload Utility
     * @param l
     * @param l1
     * @param bulkOrchestration
     * @return
     */
    
    public BulkEventResult execute(long l, long l1,
                                   BulkOrchestration bulkOrchestration) {
                logger.info("Executing BULK operation");  
                HashMap<String, Serializable>[] bulkParameters = bulkOrchestration.getBulkParameters();  
                  
                String[] entityIds = bulkOrchestration.getTarget().getAllEntityId();  
                  
                for (int i = 0; i < bulkParameters.length; i++) {  
            
                    try {  
                       executeEvent(bulkParameters[i],bulkOrchestration.getTarget().getType(), entityIds[i]);  
                    } catch (Exception e) {  
                        e.printStackTrace();  
                    }  
                }  
          
                return new BulkEventResult();  
    }

    public boolean cancel(long l, long l1,
                          AbstractGenericOrchestration abstractGenericOrchestration) {
        return false;
    }

    public void compensate(long l, long l1,
                           AbstractGenericOrchestration abstractGenericOrchestration) {
    }

    public void initialize(HashMap<String, String> hashMap) {
    }
}

In my case I have 2 more files that need to be used to make this code work. I have defined a separate class to establish OIM DB Connection which is as below and the same has been referred from above code:

package com.iam.db;

import java.sql.Connection;

import oracle.iam.platform.Platform;

public class DBUtil {
    public static Connection getOIMConnection() {
        Connection conn = null;

        try {
            conn = Platform.getOperationalDS().getConnection();
            return conn;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }

}

Last class is just to define the final contants and thus I have named it as Constant.java

package com.iam.oim;

public class Constant {
    public static final String LOGGER_NAME = "com.scb.oim.generateEmailID";
    public static final String SQL_SELECT_EMAIL_ID="select count(*) from usr where usr_email = ?";

}