Monday, August 31, 2020

Custom Target Reconciliation

import Thor.API.Exceptions.tcAPIException;

import Thor.API.Operations.tcProvisioningOperationsIntf;

import Thor.API.Operations.tcUserOperationsIntf;

import com.bea.security.providers.xacml.entitlement.parser.Roles;

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Date;

import java.util.HashMap;

import java.util.Hashtable;

import java.util.Map;

import javax.security.auth.login.LoginException;

import oracle.iam.platform.OIMClient;

import oracle.iam.reconciliation.api.BatchAttributes;

import oracle.iam.reconciliation.api.EventAttributes;

import oracle.iam.reconciliation.api.InputData;

import oracle.iam.reconciliation.api.ReconOperationsService;

import oracle.iam.reconciliation.api.ReconciliationResult;

import oracle.iam.scheduler.vo.TaskSupport;


public class TestRecon extends TaskSupport {


static OIMClient client = null;

private tcUserOperationsIntf userOperation = null;

private tcProvisioningOperationsIntf provisionOperation = null;

private ReconOperationsService reconOperation;

private String fileName;

private String ItResource;

private String resourceObjName;


public OIMClient oimConnection() {


oracle.iam.platform.OIMClient oimClient = null;

try {

Hashtable<Object, Object> env = new Hashtable<Object, Object>();

env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, weblogic.jndi.WLInitialContextFactory");

env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, "t3://:14000");

System.setProperty("java.security.auth.login.config", "");

System.setProperty("OIM.AppServerType", "wls");

System.setProperty("APPSERVER_TYPE", "wls");

oimClient = new oracle.iam.platform.OIMClient(env);

oimClient.login("xelsysadm", "Welcome123".toCharArray());

} catch (LoginException e) {

e.printStackTrace();

} catch (Exception e) {

e.printStackTrace();

}

System.out.print("Successfully Connected with OIM ");

return oimClient;

}


public static void login() throws LoginException {


System.out.println("inside oim login....");

String ctxFactory = "weblogic.jndi.WLInitialContextFactory";

String serverURL = "t3://localhost:14000/identity";

System.setProperty("java.security.auth.login.config", "C:\\Users\\bprasad\\Desktop\\designconsole\\config\\authwl.conf");

System.setProperty("APPSERVER_TYPE", "wls");

String username = "XELSYSADM";

char[] password = "Welcome123".toCharArray();

Hashtable env = new Hashtable();

env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, ctxFactory);

env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, serverURL);

client = new OIMClient(env);

try {

System.out.println("Logging in");

client.login(username, password);

System.out.println("Login successful..");

} catch (Exception e) {

e.printStackTrace();

System.out.println("Login failed");

}

}

public TestRecon() {

}

public static void main(String[] args) throws LoginException {


// String fileName = "C:\\Users\\Downloads\\OIM\\projects\\workday\\sampleIn.csv";

String itresourceName = "FlatFileTrusted";

String resourceObj = "FlatFileTrusted User";

HashMap<String, String> map = null;

map = new HashMap<String, String>();

map.put("File Name", fileName);

map.put("ITResource Name", itresourceName);

map.put("Resource Object Name", resourceObj);

TestRecon dummyRecon = new TestRecon();

login();

dummyRecon.execute(map);

}


public void execute(HashMap hashMap) {


fileName = hashMap.get("File Name").toString();

ItResource = hashMap.get("ITResource Name").toString();

this.resourceObjName = hashMap.get("Resource Object Name").toString();

initialize();

// getReconData();

triggerRecon();

}

private void initialize() {


this.userOperation = ((tcUserOperationsIntf) client.getService(tcUserOperationsIntf.class));

this.provisionOperation = ((tcProvisioningOperationsIntf) client

.getService(tcProvisioningOperationsIntf.class));

reconOperation = ((ReconOperationsService) client.getService(ReconOperationsService.class));

}

public HashMap getAttributes() {

return null;

}

public void setAttributes() {

}

private void getReconData() {

String file = this.fileName;

BufferedReader reader = null;

try {

reader = new BufferedReader(new FileReader(file));

int headerFieldCount = 0;

String line = "";

while ((line = reader.readLine()) != null) {

this.data.add(line.split("\\,"));

}

} catch (Exception e) {

e.printStackTrace();

try {

reader.close();

} catch (IOException ioe) {

ioe.printStackTrace();

} catch (Exception e1) {

e1.printStackTrace();

}

} finally {

try {

reader.close();

} catch (IOException e) {

e.printStackTrace();

} catch (Exception e) {

e.printStackTrace();

}

}

}

private void triggerRecon() {


EventAttributes ea = new EventAttributes();

Map reconMap = new HashMap();

reconMap.put("User Login", "Magnus6142");

reconMap.put("First Name", "MagnusF");

reconMap.put("Last Name", "MagnusL");

reconMap.put("Organization", "Skillopedia");

reconMap.put("User Type ", "Employee");

reconMap.put("CPI", "112211");

reconMap.put("Employee Number", "2855");

reconMap.put("WorkdayStatus", "Active");

reconMap.put("status", "Active");

reconMap.put("Role", "EMP");

ea.setEventFinished(true);

ea.setActionDate(null);

long eventKey = reconOperation.createReconciliationEvent(this.resourceObjName, reconMap, ea);

try {

reconOperation.processReconciliationEvent(eventKey);

} catch (tcAPIException e) {

e.printStackTrace();

} catch (Exception e) {

e.printStackTrace();

}

}

}

No comments:

Post a Comment

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...