Tuesday, 26 January 2016

Implementing Custom Reconciliation Operations using OIM ReconOperationsService API


This post illustrates custom code that create's a trusted reconciliation event.

You would need OIM's ReconOperationsService API, this provides you with different set of methods that you can utilize while performing reconciliation events in your implementation based on requirement.

The following sample code can be wrapped in a scheduler or a custom connector.

More Read:  ReconOperationsService


package com.oim.recon.operations;
import java.util.Date;
import java.util.HashMap;

import oracle.core.ojdl.logging.ODLLogger;

import oracle.iam.platform.OIMClient;
import oracle.iam.reconciliation.api.EventAttributes;
import oracle.iam.reconciliation.api.ReconOperationsService;
import Thor.API.Exceptions.tcAPIException;
import oracle.iam.reconciliation.api.ChangeType;

import com.oim.oimconnection.*;

public class TrustedReconOps {
                private ODLLogger logger = ODLLogger.getODLLogger
                             (TrustedReconOps.class.getName());
                private ReconOperationsService reconOps;             
                private String resourceObjName="eBusiness Person" //Trusted source IT Resource Name

                /**
                 * Constructor
                 * @param oimClient - OIM Client Instance
                 */
                public ReconciliationEvents(OIMClient oimClient){
                     this.reconOps = oimClient.getService(ReconOperationsService.class);
                }
                /**
                 *This method sets even attributes that are required for reconc. operations
                 *@return evtAttrs - EventAttributes
                 */
                public EventAttributes getEventAttributes(){
                    EventAttributes evtAttrs= new EventAttributes();
                    evtAttrs.setEventFinished(true);
                    evtAttrs.setActionDate(new Date()); // Use current date
                    evtAttrs.setActionDate(null); // Processing will be done instantly; no deferring date
                    evtAttrs.setChangeType(ChangeType.REGULAR); // For create and modify operations
                    return evtAttrs;
                }

                /**
                 *This method creates a recon. event and processes the event
                 *@param userAttrs -Hash Map
                 *@throws tcAPIException
                 */
                public void createReconciliationEvent(HashMap userAttrs) throws tcAPIException{
                    //get EventAttributes
                    EventAttributes ea=this.getEventAttributes(); 
                    //create event
                    long reconEventID= this.reconOps.createReconciliationEvent( 
this.resourceObjName,userAttrs,ea);  
                    logger.info("The Reconciliation Event id is " +reconEventID);
                    try {
                         reconOps.processReconciliationEvent(reconEventID);  //process event
                    }catch (tcAPIException e) {
                         e.printStackTrace();
                    }catch (Exception e) {
                         e.printStackTrace();
                    }
                }


Give all minimum required fields while create event,the same method "createReconciliationEvent" can be used for update as there is no specific ReconOperationsService method for update.Make sure you pass the "Full Name" in map while update operation else following exception would occur:

The Recon. id is13144

Thor.API.Exceptions.tcAPIException: An exception occurred: oracle.iam.platform.kernel.ValidationFailedException: IAM-3050146:The base value for Display Name should not be null for modify operation.:Display Name
 at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:237)
 at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
 at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
 at oracle.iam.reconciliation.api.ReconOperationsService_emc07d_ReconOperationsServiceRemoteImpl_1036_WLStub.processReconciliationEventx(Unknown Source)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
 at com.sun.proxy.$Proxy2.processReconciliationEventx(Unknown Source)
 at oracle.iam.reconciliation.api.ReconOperationsServiceDelegate.processReconciliationEvent(Unknown Source)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at Thor.API.Base.SecurityInvocationHandler$1.run(SecurityInvocationHandler.java:68)
 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
 at weblogic.security.Security.runAs(Security.java:41)
 at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(weblogicLoginSession.java:52)
 at Thor.API.Base.SecurityInvocationHandler.invoke(SecurityInvocationHandler.java:79)
 at com.sun.proxy.$Proxy3.processReconciliationEvent(Unknown Source)
 at com.oim.recon.operations.TrustedReconOps.createReconciliationEvent(TrustedReconOps.java:53)
 at com.oim.recon.operations.TrustedReconOps.main(TrustedReconOps.java:82)

Caused by: Thor.API.Exceptions.tcAPIException: An exception occurred: oracle.iam.platform.kernel.ValidationFailedException: IAM-3050146:The base value for Display Name should not be null for modify operation.:Display Name



Once done, you can verify the event generated for a user in "Reconciliation Event Manager" and user created in OIM.



References:

http://docs.tpu.ru/docs/oracle/en/fmw/11.1.1.6.0/doc.1111/e14309/reconsched.htm
http://docs.oracle.com/cd/E51625_01/apirefs.1111/e17334/oracle/iam/reconciliation/api/ReconOperationsService.html


No comments:

Post a Comment