Saturday 16 September 2017

OIM API - How to Update Process Form Data using tcFormInstanceOperationsIntf API?


To execute below code you have to add following jars in classpath:


  • commons-logging.jar
  • eclipselink.jar
  • jrf-api.jar
  • oimclient.jar
  • spring.jar
  • wlfullclient.jar

Stand Alone Code:


public class ProcessFormDataOps{
       static OIMClient oimClient = null;
        
        //identity self service details
        String username = "xelsysadm";
        String password = "<password>"; //xelsysadm password
        String t3url = "t3://<hostname>:<port>"; //OIM HostName and Port
        String authwl_location = "<location of authwl.conf file in your local machine>"; //eg. D:\\authwl.conf
        
        public void getOIMConnection() {
            System.out.println("getOIMConnection() : Start");
            //set system properties
            System.setProperty("java.security.auth.login.config", authwl_location);
            System.setProperty("OIM.AppServerType", "wls");
            System.setProperty("APPSERVER_TYPE", "wls");
    
            Hashtable oimenv = new Hashtable();
            oimenv.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
            oimenv.put(OIMClient.JAVA_NAMING_PROVIDER_URL,t3url); 
            oimClient = new OIMClient(oimenv);
            try {
                oimClient.login(username, password.toCharArray());
                System.out.println("Connected");
            } catch (LoginException e) {
                e.printStackTrace();
            }
            System.out.println("getOIMConnection() : End");
        }

      public void updateProcessFormData(long pkey, Map updateProFrmDataMap){
          tcFormInstanceOperationsIntf formInstanceIntf = oimClient.getService(tcFormInstanceOperationsIntf.class);
          try {
        System.out.println("Update Process From Data Map :: " + updateProFrmDataMap);
            formInstanceIntf.setProcessFormData(pkey, updateProFrmDataMap);
            System.out.println("Process form data updated successfully");
          } catch(Exception e){
        e.printStackTrace();
          }
       }
    
    public static void main(String[] args) {
        ProcessFormDataOps processFormDataOps = new ProcessFormDataOps();
        processFormDataOps.connect();
        
        //Process Instance Key
        long proInsKey = 140683; 
        
        //Add all attributes which need to be updated
        Map updateProFrmDataMap = new HashMap();

        //updateProFrmDataMap.put("<Column_Name>", "<Attribute_Value>");
        updateProFrmDataMap.put("UD_ADUSER_FIRSTNAME", "Anand");
        updateProFrmDataMap.put("UD_ADUSER_LASTNAME", "Badal");
        processFormDataOps.updateProcessFormData(proInsKey, updateProFrmDataMap);
    }
}


Happy Learning!!!

OIM API - Stand Alone Code to Read Process Form Data.

  To execute below code you have to add following jars in classpath:

  • commons-logging.jar
  • eclipselink.jar
  • jrf-api.jar
  • oimclient.jar
  • spring.jar
  • wlfullclient.jar

 

Stand Alone Code:


public class ProcessFormDataOps{
       static OIMClient oimClient = null;
        
        //identity self service details
        String username = "xelsysadm";
        String password = "<password>"; //xelsysadm password
        String t3url = "t3://<hostname>:<port>"; //OIM HostName and Port
        String authwl_location = "<location of authwl.conf file in your local machine>"; //eg. D:\\authwl.conf
        
        public void getOIMConnection() {
            System.out.println("getOIMConnection() : Start");
            //set system properties
            System.setProperty("java.security.auth.login.config", authwl_location);
            System.setProperty("OIM.AppServerType", "wls");
            System.setProperty("APPSERVER_TYPE", "wls");
    
            Hashtable oimenv = new Hashtable();
            oimenv.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
            oimenv.put(OIMClient.JAVA_NAMING_PROVIDER_URL,t3url); 
            oimClient = new OIMClient(oimenv);
            try {
                oimClient.login(username, password.toCharArray());
                System.out.println("Connected");
            } catch (LoginException e) {
                e.printStackTrace();
            }
            System.out.println("getOIMConnection() : End");
        }

public void getProcessFormData(long processInstanceKey){
   System.out.println("getProcessFormData() : Start");
tcFormInstanceOperationsIntf formInstanceIntf = oimClient.getService(tcFormInstanceOperationsIntf.class);
try {
tcResultSet trs = formInstanceIntf.getProcessFormData(processInstanceKey);
int count = trs.getRowCount();
for (int i = 0; i < count; i++) {
trs.goToRow(i);
String columnNames[] = trs.getColumnNames();
for (String fieldName : columnNames) {
System.out.println(fieldName + " :: " + trs.getStringValue(fieldName));
}
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("getProcessFormData() : End");
}
public static void main(String[] args) {
ProcessFormDataOps processFormDataOps = new ProcessFormDataOps();
processFormDataOps.connect();
long proInsKey = 140683; //Process Instance Key
processFormDataOps.getProcessFormData(proInsKey);
}
}


Happy Learning!!!

Sunday 10 September 2017

OIM - SQL query to get all proxy assigned for users.

SELECT DISTINCT USR.USR_LOGIN "User_Login", 
PU.USR_LOGIN "Proxy_User_Login",
TO_CHAR(P.PXD_START_DATE,'DD-MON-YYYY') "Proxy_Start_Date",
TO_CHAR(P.PXD_END_DATE,'DD-MON-YYYY') "Proxy_End_Date"
FROM PXD P, USR, USR PU
WHERE P.PXD_ORIG_USR_KEY = USR.USR_KEY
AND P.PXD_PROXY_KEY = PU.USR_KEY
AND P.PXD_END_DATE > SYSDATE;

OIM - How to Migrate User's Proxy from one environment to other environment in OIM?

First export proxy details from source OIM :-


Execute below SQL query to get all proxy assigned for users:


SELECT DISTINCT USR.USR_LOGIN "User_Login", 
PU.USR_LOGIN "Proxy_User_Login",
TO_CHAR(P.PXD_START_DATE,'DD-MON-YYYY') "Proxy_Start_Date",
TO_CHAR(P.PXD_END_DATE,'DD-MON-YYYY') "Proxy_End_Date"
FROM PXD P, USR, USR PU
WHERE P.PXD_ORIG_USR_KEY = USR.USR_KEY
AND P.PXD_PROXY_KEY = PU.USR_KEY
AND P.PXD_END_DATE > SYSDATE;

Export Proxy details in CSV file:





Execute below code to add proxy for users on destination OIM :-


To execute below code you have to add following jars in classpath:

  • commons-logging.jar

  • eclipselink.jar

  • jrf-api.jar

  • oimclient.jar

  • spring.jar

  • wlfullclient.jar

 

Stand Alone Code:


import java.util.Date;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Set;
import javax.security.auth.login.LoginException;
import oracle.iam.platform.OIMClient;
import oracle.iam.platformservice.api.PlatformUtilsService;
import oracle.iam.platformservice.exception.PlatformServiceException;
import oracle.iam.platformservice.vo.JarElement;

public class OIMProxyOperation{
        OIMClient oimClient = null;
        
        //identity self service details
        String username = "xelsysadm";
        String password = "<password>"; //xelsysadm password
        String t3url = "t3://<hostname>:<port>"; //Destination OIM HostName and Port
        String authwl_location = "<location of authwl.conf file in your local machine>"; //eg. D:\\authwl.conf
        
        public void getOIMConnection() {
            System.out.println("getOIMConnection() : Start");
            //set system properties
            System.setProperty("java.security.auth.login.config", authwl_location);
            System.setProperty("OIM.AppServerType", "wls");
            System.setProperty("APPSERVER_TYPE", "wls");
    
            Hashtable oimenv = new Hashtable();
            oimenv.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
            oimenv.put(OIMClient.JAVA_NAMING_PROVIDER_URL,t3url); 
            oimClient = new OIMClient(oimenv);
            try {
                oimClient.login(username, password.toCharArray());
                System.out.println("Connected");
            } catch (LoginException e) {
                e.printStackTrace();
            }
            System.out.println("getOIMConnection() : End");
        }

    public void addProxy(String csvFile) {
        System.out.println("addProxy() : Start");
        UserManager userManager = oimClient.getService(UserManager.class);
        BufferedReader br = null;
        String line = "";
        String cvsSplitBy = ",";
        int i = 0;
        try {     
            //Code for csv reader
            br = new BufferedReader(new FileReader(csvFile));
            br.readLine();
            while ((line = br.readLine()) != null) {
                String[] str = line.split(cvsSplitBy);
                String userLogin = str[0];
                String proxyUserLogin = str[1];
                String startDate = str[2];
                String endDate = str[3];
                
                Date proxyStartDate = new SimpleDateFormat("dd-MMM-yyyy").parse(startDate);
                Date proxyEndDate = new SimpleDateFormat("dd-MMM-yyyy").parse(endDate);
                System.out.println("UserLogin :: " + userLogin + " " + "ProxyUserKey :: " + proxyUserLogin + " " + "Proxy Start Date :: " + proxyStartDate + " " + "Proxy End Date :: " + proxyEndDate);
                userManager.addProxyForUser(userLogin, proxyUserLogin, proxyStartDate, proxyEndDate, true);
                i++;
            }
            System.out.println("User updated count :" + i);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("addProxy() : End");
        }
        
    public static void main(String[] args) {
        try {
            OIMProxyOperation obj = new OIMProxyOperation();
            obj.getOIMConnection();
            String csvFile = "D:\\ProxyDetails.csv"; //location of csv file
            obj.addProxy(csvFile);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}


Happy Learning!!!

OIM API - Stand alone code to Upload/Update/Delete Jar.

To execute below code you have to add following jars in classpath:

  • commons-logging.jar

  • eclipselink.jar

  • jrf-api.jar

  • oimclient.jar

  • spring.jar

  • wlfullclient.jar

 

Stand Alone Code:


import java.util.Date;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Set;
import javax.security.auth.login.LoginException;
import oracle.iam.platform.OIMClient;
import oracle.iam.platformservice.api.PlatformUtilsService;
import oracle.iam.platformservice.exception.PlatformServiceException;
import oracle.iam.platformservice.vo.JarElement;

public class CustomJarUtilities {
       static OIMClient oimClient = null;
        
        //identity self service details
        String username = "xelsysadm";
        String password = "<password>"; //xelsysadm password
        String t3url = "t3://<hostname>:<port>"; //OIM HostName and Port
        String authwl_location = "<location of authwl.conf file in your local machine>"; //eg. D:\\authwl.conf
        
 public void getOIMConnection() {
            System.out.println("getOIMConnection() : Start");
            //set system properties
            System.setProperty("java.security.auth.login.config", authwl_location);
            System.setProperty("OIM.AppServerType", "wls");
            System.setProperty("APPSERVER_TYPE", "wls");
    
            Hashtable oimenv = new Hashtable();
            oimenv.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
            oimenv.put(OIMClient.JAVA_NAMING_PROVIDER_URL,t3url); 
            oimClient = new OIMClient(oimenv);
            try {
                oimClient.login(username, password.toCharArray());
                System.out.println("Connected");
            } catch (LoginException e) {
                e.printStackTrace();
            }
            System.out.println("getOIMConnection() : End");
        }

public void uploadJar(PlatformUtilsService service, String jarType, String jarPath){
            System.out.println("uploadJar() : Start");
            System.out.println("Jar Path : " + jarPath);
            System.out.println("Jar Type : " + jarType);
            Set<JarElement> jarElement = new HashSet<JarElement>();
            JarElement elem = new JarElement();
            elem.type = jarType;
            elem.path = jarPath;
            jarElement.add(elem);
            try {
                    service.uploadJars(jarElement);
            } catch (PlatformServiceException e) {
                    System.out.println("Upload Jar Operation Failed ...");
                    e.printStackTrace();
            }
            System.out.println("Jar Uploaded Successfully ...");
   System.out.println("uploadJar() : End");
}

public void updateJar(PlatformUtilsService service, String jarType, String jarPath){
            System.out.println("updateJar() : Start");
            System.out.println("Jar Path : " + jarPath);
            System.out.println("Jar Type : " + jarType);
            Set<JarElement> jarElement = new HashSet<JarElement>();
            JarElement elem = new JarElement();
            elem.type = jarType;
            elem.path = jarPath;
            jarElement.add(elem);
            try {
                    service.updateJars(jarElement);
            } catch (PlatformServiceException e) {
                    System.out.println("Update Jar Operation Failed ...");
                    e.printStackTrace();
            }
            System.out.println("Jar Updated Successfully ...");
   System.out.println("updateJar() : End");
}

 public void deleteJar(PlatformUtilsService service, String jarType, String jarPath){
            System.out.println("deleteJar() : Start");
            System.out.println("Jar Path : " + jarPath);
            System.out.println("Jar Type : " + jarType);
            Set<JarElement> jarElement = new HashSet<JarElement>();
            JarElement elem = new JarElement();
            elem.type = jarType;
            elem.path = jarPath;
            jarElement.add(elem);
            try {
                    service.deleteJars(jarElement);
            } catch (PlatformServiceException e) {
                    System.out.println("Delete Jar Operation Failed ...");
                    e.printStackTrace();
            }
            System.out.println("Jar Deleted Successfully ..."); 
            System.out.println("deleteJar() : End");
        }
        
public static void main(String[] args) {
             CustomJarUtilities customJarUtility = new CustomJarUtilities();
             customJarUtility.getOIMConnection();
             if(oimClient != null){
                PlatformUtilsService service = (PlatformUtilsService)oimClient.getService(PlatformUtilsService.class);
                
                //Possible Values : "JavaTasks" , "ICFBundle", "ScheduleTask", "ThirdParty";
                String jarType = "JavaTasks";
                
                //The Jars location should be on the OIM installed machine
                String jarPath = "/home/oracle/customJars/test.jar";
                
                /******** Upload Jar ********/
                customJarUtility.uploadJar(service, jarType, jarPath);
                
                /******** Update Jar ********/
                customJarUtility.updateJar(service, jarType, jarPath);
                 
                /******** Delete Jar ********/
                customJarUtility.deleteJar(service, jarType, jarPath);
                 
                oimClient.logout();
             }
             else{
                     System.out.println(new Date() +" oimClient is null");
             } 
}
}

OIM - How to change expiration time of SOA Composite?


Login to SOA Composer(http://<HOST_NAME>:8001/soa/composer).



Go to Open Task.



Select Composite for which you want to change expiration time.



Click on Edit.



Edit expiration time.



Save changes.





Commit changes.





Note: Servers restart not required to reflect these changes.


Happy Learning!!!

Saturday 9 September 2017

OIM - SQL query to get all the entitlements provisioned to the user.


SELECT EL.ENT_CODE "Entitlement Name"
FROM ENT_LIST EL, ENT_ASSIGN EA, USR
WHERE EL.ENT_LIST_KEY = EA.ENT_LIST_KEY
AND EA.USR_KEY = USR.USR_KEY
AND EA.ENT_STATUS = 'Provisioned'
AND UPPER(USR.USR_LOGIN) = UPPER('<Replace_User_Login>');

OIM - SQL query to get all the User's provisioned/enabled accounts.


SELECT OBJ.OBJ_NAME, OST_STATUS
FROM OBJ,OBI,OIU,OST,USR
WHERE OBJ.OBJ_KEY = OBI.OBJ_KEY
AND OBI.OBI_KEY = OIU.OBI_KEY
AND OIU.USR_KEY = USR.USR_KEY
AND OIU.OST_KEY = OST.OST_KEY
AND OST.OBJ_KEY = OBJ.OBJ_KEY
AND OST.OST_STATUS IN ('Enabled','Provisioned')
AND UPPER(USR.USR_LOGIN) = UPPER('<Replace_User_Login>');

OIM - SQL Query to get all the members of specific Role.


SELECT UGP.UGP_NAME,USR.USR_LOGIN
FROM UGP, USG, USR  
WHERE USG.USR_KEY = USR.USR_KEY
AND UGP.UGP_KEY = USG.UGP_KEY
AND UPPER(UGP_NAME) = UPPER('<Replace_Role_Name>');

OIM - SQL Query to get all the members of specific Admin Role.


SELECT USR.USR_LOGIN, AR.ROLE_NAME
FROM ADMIN_ROLE_MEMBERSHIP ARM, ADMIN_ROLE AR, USR
WHERE ARM.USER_ID = USR.USR_KEY
AND ARM.ROLE_ID = AR.ROLE_ID
AND USR.USR_STATUS = 'Active'
AND AR.ROLE_NAME=  '<Replace_Admin_Role_Name>';


OIM - SQL Query to get all the Users having specific entitlement provisioned.


SELECT USR.USR_LOGIN, USR.USR_FIRST_NAME, USR.USR_LAST_NAME
FROM ENT_LIST EL, ENT_ASSIGN EA, USR
WHERE EL.ENT_LIST_KEY = EA.ENT_LIST_KEY
AND EA.USR_KEY = USR.USR_KEY
AND EA.ENT_STATUS = 'Provisioned'
AND EL.ENT_CODE = '<Replace_Entitlement_Name>';