Bulk Provisioning Entitlements Via Reconciliation process for DBUM Connector


  1. package com.oimacademy.reconciliation;
  2. import java.sql.Connection;
  3. import java.sql.ResultSet;
  4. import java.sql.SQLException;
  5. import java.sql.Statement;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. import oracle.iam.reconciliation.api.ChangeType;
  11. import oracle.iam.reconciliation.api.EventAttributes;
  12. import oracle.iam.reconciliation.api.ReconOperationsService;
  13. import com.oimacademy.connection.DataSource;
  14. import com.oimacademy.connection.Platform;
  15. public class BulkProvisioningEntitlementsViaReconciliation {     
  16.     public static void main(String[] args) {
  17.            try {
  18.                List list =getLookupCodes("1629");
  19.                 ReconOperationsService recService = Platform.getService(ReconOperationsService.class);
  20.                 //Add Object Reconciliation Fields for resource Object. No Childern fields.
  21.                     Map<String, Object> mapKeyValue = new HashMap<String,Object>();    
  22.                     //For Dummy Connector
  23.     /*                mapKeyValue.put("USR_LOGIN","USER"+i);
  24.                     mapKeyValue.put("ACCOUNT_NAME","USER Account");
  25.                     mapKeyValue.put("IT Resource","dummyITResName");     */                     
  26.                     //For DBUM Connector  // You can get below details from Design Console -> Connector Resource Object.
  27.                     // Need to add all mandatory attributes as defined in Connector Resource Object
  28.                     mapKeyValue.put("IT Resource Name","Oracle DB"); // IT Resource Name
  29.                     mapKeyValue.put("User Name","TUSER"); // To Which user need to provision entitlements         
  30.                     mapKeyValue.put("Password","Welcome1");
  31.                     mapKeyValue.put("Authentication Type","PASSWORD");
  32.                     mapKeyValue.put("Account Status","OPEN");
  33.                     mapKeyValue.put("Reference ID","TUSER");                   
  34.                     //Create Even Attribute and call createReconciliationEvent
  35.                     EventAttributes eventAttr = new EventAttributes();
  36.                     eventAttr.setEventFinished(false); 
  37.                     eventAttr.setChangeType(ChangeType.CHANGELOG);
  38.                     //long reconEventKey = recService.createReconciliationEvent("dummy", mapKeyValue,eventAttr);
  39.                    long reconEventKey = recService.createReconciliationEvent("Oracle DB User", mapKeyValue,eventAttr);
  40.                     System.out.println("Recon Event ID -> "+reconEventKey);
  41.                     /*********Creating Data set Up for Child Forms *******************************/                
  42.            //Create multi valued AttributeData for Child Forms
  43.                     Map<String,Object> mapChldKeyValue = null;                   
  44.             //DBUM Connector                    
  45.                   recService.providingAllMultiAttributeData(reconEventKey, "Privilege List",true);
  46.                    //Add Child Form multi valued data                  
  47.                    for(int j=0; j<list.size();j++){                   
  48.                     mapChldKeyValue = new HashMap<String,Object>();
  49.                     mapChldKeyValue.put("Privilege Name",list.get(j));
  50.             // mapChldKeyValue.put("Privilege Name","4~CREATE PROFILE");
  51.                     mapChldKeyValue.put("Privilege Admin Option",""); 
  52.                     recService.addMultiAttributeData(reconEventKey,"Privilege List", mapChldKeyValue);
  53.                     System.out.println(" Added into Recon Service with loop value -> "+j);
  54.                    }                   
  55.                     recService.finishReconciliationEvent(reconEventKey);
  56.                     recService.processReconciliationEvent(reconEventKey);                    
  57.                     //processing event
  58.                     System.out.println("Completed Recon Event Operation -> "+reconEventKey);                   
  59.                   }catch(Exception e){
  60.                       e.printStackTrace();             
  61.                   }         
  62.        }
  63.     // Method to get Entitlements From LKV table. Need to pass LKU_KEY
  64.     public static List getLookupCodes(String lkuKey){
  65.         List list = new ArrayList();
  66.         Connection con = DataSource.getConnection();
  67.         try {
  68.             Statement stmt = con.createStatement();
  69.             String query ="select * from LKV where lku_key="+lkuKey;
  70.             ResultSet rs = stmt.executeQuery(query);
  71.             while (rs.next()) {
  72.                 list.add(rs.getString("lkv_encoded"));
  73.             }
  74.         } catch (SQLException e) {
  75.             // TODO Auto-generated catch block
  76.             e.printStackTrace();
  77.         }
  78.         System.out.println("Size"+ list.size());
  79.         return list;
  80.         }
  81.     }

No comments:

Post a Comment