Pages

Tuesday, April 29, 2014

Removing the Target Resource from the OIM Resource View

Removing the Target Resource from the OIM Resource View.

The following sql queries needs to be executed to remove the User from OIM Resource view. They are

1. Finding the ORC Child Tables.

select  p.owner parent_table_owner,
        p.table_name parent_table_name,
        c.owner child_table_owner,
        c.table_name child_table_name
  from  dba_constraints p,
        dba_constraints c
  where p.owner = 'DEV_OIM'
    and p.table_name = 'ORC'
    and p.constraint_type = 'P'
    and c.r_owner = p.owner
    and c.r_constraint_name = p.constraint_name


2 Delete from OSH Table

delete from OSH where SCH_KEY in (Select SCH_KEY from OSI where orc_key='3014702');

3 Delete from OIU table

delete from OIU where orc_key='3014702';

4. Select the SCH Keys from the OSI Table

Select SCH_KEY from OSI where orc_key='3014702'


5.  Substitute the SCH Keys from the OSI Table SCH_KEY to remove the SCH table

delete  from SCH where SCH_KEY in ('SCH_KEY1','SCH_KEy2','SCH_KEY3');

6. Delete the OSI table

 delete from OSI where orc_key='3014702';


7. Execute the Step 5 to delete the SCH data

8 Delete the Target Resource User Table. In my case UD_ADUSER is my target table

delete from ud_ADUSER where orc_key='3014702';

9. Delete the OTI Table

delete from OTI where orc_key='3014702';

10. Delete the ORC Table

delete from orc where orc_key='3014702';


tcProvisioningOperationsIntf API addTask example

The tcProvisioningOperationsIntf  inteface API being used to add the task to process form instance programmatically.

Pre-Requisite:

Initial Setup.

Please follow the link and setup the OIM client environment to use to create the OIM Objects.


Client Code Setup

tcProvisioningOperationsIntf  API Usage:

1. Retrieving the Process Instance key
2. Retrieving the All the Tasks available for the Process Instance.
3. Add  the Process Task Instance to Process Form

Tasks Needs to be Performed:

1.    Create the OIMClient Handle


OIMClient client= new OIMClient();
client.login(username,password.toCharArray());

2.    Get tcProvisioningOperationsIntf service object


tcProvisioningOperationsIntf provisioningServiceIntf = client.getService(tcProvisioningOperationsIntf.class);
TaskDefinitionOperationsIntf taskdefinition = client.getService(TaskDefinitionOperationsIntf.class);
tcUserOperationsIntf userOperationsIntf=client.getService(tcUserOperationsIntf.class);


3.  Retrieving the Process Instance Key Based on the User Key.

long userKey=123456789;
Map<String,Long> resources= new HashMap<String,Long>();

                tcResultSet trs= userOperationsIntf.getObjects(userKey);
                if(trs != null)
                {
                    int count=trs.getRowCount();
                    for(int i=0;i<count;i++)
                    {
                        trs.goToRow(i);
                        String objectName=trs.getStringValue("Objects.Name");
                        String status=trs.getStringValue("Objects.Object Status.Status");

                        if(status.equalsIgnoreCase("Provisioned") || status.equalsIgnoreCase("Enabled"))
                        {
                            resources.put(objectName,trs.getLongValue("Process Instance.Key"));
                        }
                    }
                }



4. Retrieving the All the Tasks available for the Process Instance

// Resource Name. My Example Resource Name is AD User
String resourceName="AD User";
long  processInstance =  resources.containsKey(resourceName) ? resources.get(resourceName) : -1;

if(processInstance ==-1)
{
    return;
}

        Map<String, Long> listTasks= new HashMap<String,Long>();
        try
        {
            Map<String, String> filter=new HashMap<String,String>();
            tcResultSet trs= taskdefinition.getTaskDetail(processInstance, filter);
            if(trs != null && !trs.isEmpty())
            {
                int count=trs.getRowCount();
                for(int i=0;i<count;i++)
                {
                    trs.goToRow(i);
                    //displayData(trs);
                    listTasks.put(trs.getStringValue("Process Definition.Tasks.Task Name"), trs.getLongValue("Process Definition.Tasks.Key"));
                }
            }
           
        } catch (tcAPIException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (tcColumnNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

5.   Add  the Process Task Instance to Process Form


String taskName= "Last Name Updated";
if(listTasks.containsKey(taskName))
{
    long taskKey= listTasks.get(taskName);
            try
        {
            //tcProvisioningOperationsIntf.getT
            tcProvisioningOperationsIntf.addProcessTaskInstance(taskKey, processInstance );

        } catch (tcAPIException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (tcTaskNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}


Monday, April 28, 2014

ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase INVOKE_APPLICATION 5[[ java.lang.InstantiationError: java.lang.VirtualMachineError


The following exception will be thrown when clicking the Schedule Job in Oracle Identity Manager. They are

 Error:



ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase INVOKE_APPLICATION 5[[
java.lang.InstantiationError: java.lang.VirtualMachineError
    at sun.reflect.GeneratedSerializationConstructorAccessor271.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.io.ObjectStreamClass.newInstance(ObjectStreamClass.java:924)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1736)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
    at oracle.iam.scheduler.vo.JobHistory.getExceptionObject(JobHistory.java:79)
    at oracle.iam.features.scheduler.agentry.operations.LookupActor.prepare(LookupActor.java:1251)
    at oracle.iam.consoles.faces.utils.CanonicUtils.prepareOperation(CanonicUtils.java:169)
    at oracle.iam.consoles.faces.utils.CanonicUtils.prepareOperation(CanonicUtils.java:179)
    at oracle.iam.consoles.faces.render.canonic.UICursor$TableActionListener.processAction(UICursor.java:855)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcast(UIXComponentBase.java:675)
    at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:179)
    at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:148)
    at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:271)
    at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:145)
    at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:402)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:902)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:313)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:186)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.help.web.rich.OHWFilter.doFilter(Unknown Source)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.iam.platform.auth.web.PwdMgmtNavigationFilter.doFilter(PwdMgmtNavigationFilter.java:121)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.iam.platform.auth.web.OIMAuthContextFilter.doFilter(OIMAuthContextFilter.java:108)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

]]
[2014-04-28T15:08:27.681-07:00] [oim_server1] [ERROR] [] [oracle.adfinternal.view.faces.config.rich.RegistrationConfigurator] [tid: [ACTIVE].ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 1a1674e1d085fc44:-220db967:145aa4b21f3:-8000-00000000000000dd,0] [APP: oim#11.1.1.3.0] ADF_FACES-60096:Server Exception during PPR, #7[[
javax.servlet.ServletException: java.lang.InstantiationError: java.lang.VirtualMachineError
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.help.web.rich.OHWFilter.doFilter(Unknown Source)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.iam.platform.auth.web.PwdMgmtNavigationFilter.doFilter(PwdMgmtNavigationFilter.java:121)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.iam.platform.auth.web.OIMAuthContextFilter.doFilter(OIMAuthContextFilter.java:108)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: java.lang.InstantiationError: java.lang.VirtualMachineError
    at sun.reflect.GeneratedSerializationConstructorAccessor271.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.io.ObjectStreamClass.newInstance(ObjectStreamClass.java:924)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1736)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
    at oracle.iam.scheduler.vo.JobHistory.getExceptionObject(JobHistory.java:79)
    at oracle.iam.features.scheduler.agentry.operations.LookupActor.prepare(LookupActor.java:1251)
    at oracle.iam.consoles.faces.utils.CanonicUtils.prepareOperation(CanonicUtils.java:169)
    at oracle.iam.consoles.faces.utils.CanonicUtils.prepareOperation(CanonicUtils.java:179)
    at oracle.iam.consoles.faces.render.canonic.UICursor$TableActionListener.processAction(UICursor.java:855)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcast(UIXComponentBase.java:675)
    at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:179)
    at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:148)
    at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:271)
    at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:145)
    at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:402)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:902)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:313)
    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:186)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    ... 41 more

]]




Cause:

The schedule job was failed due to de-serializing the error object in OIM.

Solution:

Backup the JOB_HISTORY Table



Setup the Environment Variables


source /usr/local/bin/oraenv. Enter the Oracle SID or Service Name.

Export the JOB_HISTORY Table


exp DEV_OIM/<DEV_OIM User Password>@DataBase tables=JOB_HISTORY file=job_history.dmp

  The above command will export the data into the local file system.

Delete the JOB_HISTORY table based on Job Name



 Login to the Oracle Data Base as a OIM user. For example my user is DEV_OIM.
 Delete the failed job as follows
     delete from job_history where job_name like '<Schedule Job Name>';

Restart the OIM Server

    

     Stop the Web Logic Managed OIM Server


     3.1 Go to the DOMAIN_HOME/bin directory and execute the following command to stop the OIM Server.

./stopManagedWebLogic.sh <web logic managed server name> t3://<Web Logic Admin Host>:<Port> weblogic <weblogic password>


    Start the Web Logic Managed OIM Server

./startManagedWebLogic.sh <web logic managed server name> t3://<Web Logic Admin Host>:<Port>


After restarting the oim server, the issue will be resolved.

Tuesday, April 22, 2014

Revoking OIM Resource


Revoking the OIM Resource pro-grammatically as follows:



Pre-Requisite:

Initial Setup.

Please follow the link and setup the OIM client environment to use to create the OIM Objects.


Client Code Setup

Tasks Needs to be Performed:

1.    Create the OIMClient Handle


OIMClient client= new OIMClient();
client.login(username,password.toCharArray());

2.    Get the service objects

UserManager userManager=client.getService(UserManager.class);
tcUserOperationsIntf tcUserOperationsIntf= client.getService(tcUserOperationsIntf.class);

3.  Retrieving the User Details. 

String userId="testabc";
User user=userManager.getDetails(userId, null, true);



4.  Retrieving the User Key. 

long userKey=-1;
if(user != null)
{
userKey=new Long(user.getEntityId());
}

           

5.  Retrieving the User Provisioned Resources. 

Map<String,Long> resources= new HashMap<String,Long> ();

if(userKey !=-1)
{
   tcResultSet rs= tcUserOperationsIntf.getObjects(usrKey);
 
            if(rs != null)
            {
                int count=rs.getTotalRowCount();
                for(int i=0;i<count;i++)
                {
                        rs.goToRow(i);
                        String resourceName=rs.getStringValue("Objects.Name");
                        String status=rs.getStringValue("Process Instance.Status");
                        long instanceKey=rs.getLongValue("Users-Object Instance For User.Key");
                        long processInstanceKey=rs.getLongValue("Process Instance.Key");
                        String resourceStatus=rs.getStringValue("Objects.Object Status.Status");
                        if( (resourceStatus != null && (resourceStatus.equalsIgnoreCase("provisioned") ||
                                 resourceStatus.equalsIgnoreCase("disabled") ||
                                 resourceStatus.equalsIgnoreCase("enabled") ) )||
                                 (status != null && status.equalsIgnoreCase("c")))
                        {
                             resources.put(resourceName,instanceKey);
                        }
                }
            }
}

6.  Revoke a Resource.

String resourceName="AD User";
if(resources.containsKey(resourceName))
{

tcUserOperationsIntf.revokeObject(userKey, resources.get(resourceName));


Wednesday, April 16, 2014

Event Handler Handler deployment in OIM

Event Handler Handler deployment in OIM

Three ways to deploy the Event Handler Handler deployment in OIM. They are

1. OIM Utilities,

2. OIM Deployment Manager,

3. OIM API.



1. OIM Utilities,


2. OIM Deployment Manager

   
    The following tasks needs to be developed to deploy the Event Handler through OIM deployment manager. They are

    2.1 Developing the Event Handler XML file

Sample Event Handler Xml File.


<?xml version = '1.0' encoding = 'UTF-8'?>
<xl-ddm-data version="2.0.1.0" user="XELSYSADM" database="jdbc:oracle:thin:@localhost:1521/oim" exported-date="1397256851696" description="EventHandler.xml">
<eventhandlers repo-type="MDS" name="/metadata/" mds-path="/metadata/" mds-file="EventHandlers.xml">
<completeXml>
<eventhandlers>
<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"/>
    <action-handler class="test.eventhandlers.NamePreProcessEventHandlers" entity-type="User" operation="MODIFY" name="NamePreProcessEventHandlers" stage="preprocess" order="LAST" sync="TRUE"/>
</eventhandlers>
</eventhandlers>
</completeXml>
</eventhandlers>
</xl-ddm-data>

In the above xml  you can replace the following parameters according to your naming convention. They are

1. name="/metadata/". For example you want to store event handler in the metadata/EventHandler.xml  in the MDS repository. You should specify the name="/metadata/".

2. mds-path="/metadata/". For example you want to store event handler in the metadata/EventHandler.xml  in the MDS repository. You should specify the mds-path="/metadata/".

3. class="test.eventhandlers.NamePreProcessEventHandlers". Replace with your class name.
4. name="NamePreProcessEventHandlers". Replace with your name. Class Name and Name should be the same.


    2.2 Deploy the Event Handler in OIM Deployment Manager

    After creating the EventHandler.xml file and you need to deploy the event handler in OIM deployment manager as follows.

  2.2.1 Login to the OIM Server.
  2.2.2 Click Advaned  --> Import Deployment Manager File -->Add File --> choose event handler xml file --> Import

2.3 Deploy the Plugin in OIM Plugin using API


2.4 Restart the OIM Server.

 

3. OIM API

Importing the EventHandler MDS OIM repository.


The tcImportOperationsIntf interface API being used to import the Event Handler in MDS OIM repository.




Pre-Requisite:

Initial Setup.

Please follow the link and setup the OIM client environment to use to create the OIM Objects.


Client Code Setup

tcImportOperationsIntf  API Usage:

1. Import the Event Handler in the OIM Reposiory.

Tasks Needs to be Performed:

1.    Create the OIMClient Handle


OIMClient client= new OIMClient();
client.login(username,password.toCharArray());

2.    Get PlatformService and PlatformUtilsService service object

tcImportOperationsIntf importOperationsIntf = client.getService(tcImportOperationsIntf.class);

3.  Create the  EventHandler.xml file

<?xml version = '1.0' encoding = 'UTF-8'?>
<xl-ddm-data version="2.0.1.0" user="XELSYSADM" database="jdbc:oracle:thin:@localhost:1521/oim" exported-date="1397256851696" description="EventHandler.xml">
<eventhandlers repo-type="MDS" name="/metadata/" mds-path="/metadata/" mds-file="EventHandlers.xml">
<completeXml>
<eventhandlers>
<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"/>
    <action-handler class="test.eventhandlers.NamePreProcessEventHandlers" entity-type="User" operation="MODIFY" name="NamePreProcessEventHandlers" stage="preprocess" order="LAST" sync="TRUE"/>
</eventhandlers>
</eventhandlers>
</completeXml>
</eventhandlers>
</xl-ddm-data>

In the above xml  you can replace the following parameters according to your naming convention. They are

1. name="/metadata/". For example you want to store event handler in the metadata/EventHandler.xml  in the MDS repository. You should specify the name="/metadata/".

2. mds-path="/metadata/". For example you want to store event handler in the metadata/EventHandler.xml  in the MDS repository. You should specify the mds-path="/metadata/".

3. class="test.eventhandlers.NamePreProcessEventHandlers". Replace with your class name.
4. name="NamePreProcessEventHandlers". Replace with your name. Class Name and Name should be the same.
         

4.  Read the EventHander.xml file Content

                String filename="/tmp/EventHandler.xml";
             StringBuffer sb= new StringBuffer();
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
String readLine=null;
while((readLine =br.readLine()) != null)
{
sb.append(readLine+"\n");
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
if(br != null)
{
try {
br.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

4.  Import the EventHander.xml file into MDS repo. 


String operation=" - Import Event Handler - ";
                 String category="eventhandlers";

try
{
importOperationsIntf.acquireLock(true);
if(importOperationsIntf.isLockAcquired())
{
List<RootObject> importObjects= new ArrayList<RootObject>();
System.out.println(operation + "Import File Name - "+filename);
Collection<RootObject> importFiles=importOperationsIntf.addXMLFile(filename, sb.toString());
for (RootObject rootObject : importFiles)
{
if(rootObject.isNewObject())
{
importObjects.add(rootObject);
}
else if(rootObject.isImportable())
{
importObjects.add(rootObject);
}
else if(rootObject.isSharedObject())
{
importObjects.add(rootObject);
}
else
{
System.out.println(operation + category + " - Not Importing Objects  "+rootObject.getName());;
}
}
Collection<RootObject> missingDepndencies= importOperationsIntf.getMissingDependencies(importFiles, category);
if(missingDepndencies != null && !missingDepndencies.isEmpty())
{
System.out.println(operation + category + " - Missing Dependencies  "+missingDepndencies);
throw new RuntimeException("The  "+category + " - "+missingDepndencies + " Dependencies missing.");
}

HashMap messages=importOperationsIntf.getImportMessages(importObjects);
for(Object obj:messages.keySet())
{
System.out.println(operation + "Import Task Messages "+messages.get(obj));
}
if(!importObjects.isEmpty())
{
System.out.println(operation + "Import "+filename + " is going to Start");
importOperationsIntf.performImport(importObjects);
System.out.println(operation + " Import "+filename + " is Successfully completed");
}
}
else
{
System.out.println(operation + "Lock Not Acquired");
throw new OIMDeploymentException("Lock Not Acquired");
}
} catch (tcAPIException e)
{
System.out.println(operation +e);
throw new OIMDeploymentException(e);

} catch (DDMException e) {
System.out.println(operation +e);
throw new OIMDeploymentException(e);
} catch (TransformationException e) {
System.out.println(operation +e);
throw new OIMDeploymentException(e);
}
catch (NamingException e)
{
System.out.println(operation +e);
throw new OIMDeploymentException(e);
} catch (tcBulkException e)
{
System.out.println(operation +e);
throw new OIMDeploymentException(e);
} catch (SQLException e) {
System.out.println(operation +e);
throw new OIMDeploymentException(e);
}

5.  Register the OIM Plugin. 

6.  Restart the OIM Server. 

Register and UnRegister OIM Plugin in OIM Server


The PlatformService interface API being used to register and  un-register the OIM plugin pro-grammatically in OIM repository as follows:



Pre-Requisite:

Initial Setup.

Please follow the link and setup the OIM client environment to use to create the OIM Objects.


Client Code Setup
Developing the EventHandler Class 

PlatformService  API Usage:

1. Registering the Plugin.

2. Unrgister the Plugin.

Tasks Needs to be Performed:

1.    Create the OIMClient Handle


OIMClient client= new OIMClient();
client.login(username,password.toCharArray());

2.    Get PlatformService and PlatformUtilsService service object

PlatformService platformService = client.getService(PlatformService.class);
PlatformUtilsService platformUtilsService = client.getService(PlatformUtilsService.class);

3.  Create 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>

Replace pluginclass with your plugin class name.
           

4.  Create the Plugin Zip File. 

mkdir NamePreProcessEventHandlers
mkdir NamePreProcessEventHandlers/lib

copy plugin.xml file to NamePreProcessEventHandlers directory
copy NamePreProcessEventHandlers.jar file to NamePreProcessEventHandlers/lib directory
Create the NamePreProcessEventHandlers.zip file as follows
zip NamePreProcessEventHandlers.zip NamePreProcessEventHandlers/*

5.  Register the Plugin. 

                String operation=" - RegisterPlugin - ";
                // replace the plugin zip file according to your file path
                 String pluginFile="/tmp/NamePreProcessEventHandlers.zip"
File file= new File(pluginFile);
if(file.exists())
{
int size= (int)file.length();
byte data[]= new byte[size];
InputStream ins=null;
try
{
ins= new FileInputStream(file);
int bytesread= ins.read(data, 0,size);
while(bytesread < size)
{
bytesread += ins.read(data, bytesread, (bytesread-size));
}
platformService.registerPlugin(data);
}
catch(Exception e)
{
System.out.println(operation+e);
throw new RuntimeException(e);
}
finally
{
if(ins != null)
{
try {
ins.close();
} catch (IOException e)
{
System.out.println(operation+e);
throw new RuntimeException(e);
}
}
}


}
else
{
throw new RuntimeException("The Plugin File "+pluginFile + " Not Found");
}


6.  UnRegister Plugin.


operation=" - unRegisterPlugin - ";
                 String pluginClass="test.eventhandlers.NamePreProcessEventHandlers";
                  // replace plugin class with your pluin class name
try
{
platformService.unRegisterPlugin(pluginClass);
} catch (PlatformServiceAccessDeniedException e) {
System.out.println(operation+e);
throw new RuntimeException(e);
} catch (PluginException e) {
System.out.println(operation+e);
throw new RuntimeException(e);
}

7. Purge Cache.

String operation=" - purgeCache - ";
                String category="All";
try
{
platformUtilsService.purgeCache(category);
logger.info(operation+"Purge Cache "+category+" Completed Successfully");
} catch (InvalidCacheCategoryException e)
{
System.out.println(operation+e);
throw new RuntimeException(e);
}

8. Restart the OIM Server