Submit OIM Request using API code

package com.ravikumar.ghr;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import org.apache.log4j.Logger;
import oracle.iam.platform.OIMClient;
import oracle.iam.request.api.RequestService;
import oracle.iam.request.vo.Beneficiary;
import oracle.iam.request.vo.RequestBeneficiaryEntity;
import oracle.iam.request.vo.RequestConstants;
import oracle.iam.request.vo.RequestData;
import ts.idm.common.utils.CustomOIMClient;
import ts.idm.selfservicebulkrolemembershipoperations.model.RoleMembershipBean;

public class CustomRequest {

public static boolean submitCustomRequest(String requesterUserLogin,String beneficiaryUserKey, String roleName, String roleKey) {

Logger logger = Logger.getLogger(CustomRequest.class);
logger.debug("-------- processMembershipOperation started ---------");
logger.debug("requesterUserLogin: " + requesterUserLogin);
logger.info("requesterUserLogin: " + requesterUserLogin);
boolean processedStatus = false;
CustomOIMClient c = new CustomOIMClient();
OIMClient client = null;
try {
client = c.getAdminConnection();// check my another post for establishing connection using local code
logger.debug("Connected to OIM Client");

int count = 0;
RequestService requestAPI = (RequestService) client.getService(RequestService.class);

RequestBeneficiaryEntity reqBenefEntity = new RequestBeneficiaryEntity();
reqBenefEntity.setRequestEntityType(oracle.iam.platform.utils.vo.OIMType.Role);
reqBenefEntity.setEntitySubType(roleName);
reqBenefEntity.setEntityKey(roleKey);

reqBenefEntity.setOperation(RequestConstants.MODEL_ASSIGN_ROLES_OPERATION);
//reqBenefEntity.setOperation(RequestConstants.MODEL_REMOVE_ROLES_OPERATION);
logger.debug("Operation set to " + RequestConstants.MODEL_ASSIGN_ROLES_OPERATION);



List<Beneficiary> beneficiaries = new ArrayList<Beneficiary>();
List<RequestBeneficiaryEntity> entities = new ArrayList<RequestBeneficiaryEntity>();
entities.add(reqBenefEntity);

Beneficiary beneficiary = new Beneficiary();
beneficiary.setBeneficiaryKey(beneficiaryUserKey);
beneficiary.setBeneficiaryType(Beneficiary.USER_BENEFICIARY);
beneficiary.setTargetEntities(entities);
beneficiaries.add(beneficiary);
logger.debug(beneficiaryUserKey + " is added as beneficiary");

RequestData reqData = new RequestData();
reqData.setBeneficiaries(beneficiaries);

logger.debug("Beneficiaries are set to: " + beneficiaries);


reqData.setJustification("Justification");

logger.debug("Initializing request service object");

logger.debug("sbumitting the request");
String requestId = null;
try {

requestId = requestAPI.submitRequest(reqData);
logger.debug("Request Id created: " + requestId);
if (requestId != null) {
logger.info("Request created successfully , Request Id: " + requestId);
}
} catch (Exception e) {
e.printStackTrace();
logger.debug(e.getMessage());
}


} catch (Exception e) {
e.printStackTrace();
logger.debug(e.getMessage());
}

return processedStatus;
}

}

Comments

Popular posts from this blog

Rules in Sailpoint

Sailpoint Installation Steps (IdentityIQ 7.3 Installation in Windows Machine)

How to create provisioning plan in Sailpoint