Friday, 5 May 2017

OIM 11gR2 PS3 Provisioning Request using API

Provisioning request in OIM 11gR2 PS3 can be made for following:

1. Application Instance
2. Entitlements
3. Roles

Below are the API usage of all the request operations. You can use this sample methods and modify accordingly for bulk operations.

Application Instance Provisioning Request


/**
* Requesting Application Instance. This method
* can be further modified to use for bulk action.
* @param args
*/
private String createApplicationRequest() throws Exception{
RequestBeneficiaryEntity requestEntity = new RequestBeneficiaryEntity();
requestEntity.setRequestEntityType(oracle.iam.platform.utils.vo.OIMType.ApplicationInstance); //Type of the Request
requestEntity.setEntitySubType("APP_INSTANCE_NAME"); //Name of the Application Instance
requestEntity.setEntityKey("APP_INSTANCE_KEY"); //Application instance key
requestEntity.setOperation(RequestConstants.MODEL_PROVISION_APPLICATION_INSTANCE_OPERATION); //Request operation type.
/**
* here in each RequestBeneficiaryEntityAttribute object we will
* be setting the request data
* FIELD_1,FIELD_2,FIELD_3 are the request data set filed label name and the "value" is the corresponding value.
*/
List<RequestBeneficiaryEntityAttribute> attrs = new ArrayList<RequestBeneficiaryEntityAttribute>();
RequestBeneficiaryEntityAttribute attr;
attr = new RequestBeneficiaryEntityAttribute("FIELD_1", "value", RequestBeneficiaryEntityAttribute.TYPE.String);
attrs.add(attr);
attr = new RequestBeneficiaryEntityAttribute("FIELD_2", "value", RequestBeneficiaryEntityAttribute.TYPE.String);
attrs.add(attr);
attr = new RequestBeneficiaryEntityAttribute("FIELD_3", "value", RequestBeneficiaryEntityAttribute.TYPE.String);
attrs.add(attr);
//Continue setting RequestBeneficiaryEntity
requestEntity.setEntityData(attrs);
//Adding RequestBeneficiaryEntity to List
List<RequestBeneficiaryEntity> entities = new ArrayList<RequestBeneficiaryEntity>();
entities.add(requestEntity);
//creating new Beneficiary
Beneficiary beneficiary = new Beneficiary();
beneficiary.setBeneficiaryKey("USR_KEY"); //set BeneficiaryKey as User key
beneficiary.setBeneficiaryType(Beneficiary.USER_BENEFICIARY); //set the type as user
beneficiary.setTargetEntities(entities); //set target entities as list of RequestBeneficiaryEntity
//Adding Beneficiary to List
List<Beneficiary> beneficiaries = new ArrayList<Beneficiary>();
beneficiaries.add(beneficiary);
//Creating new RequestData and set the Beneficiaries with List of Beneficiaries
RequestData requestData = new RequestData();
requestData.setBeneficiaries(beneficiaries);
/**
* getRequesterConnection() is a seperate method to create OIM connection.
*/
OIMClient oimClientObjReq = getRequesterConnection("REQUESTER_LOGIN_ID"); //create an OIM connection with requester's login
RequestService requestAPI = (RequestService)oimClientObjReq.getService(RequestService.class);
String requestId = requestAPI.submitRequest(requestData);
System.out.println("requestId: "+requestId);
return requestId;
}

Entitlement Provisioning Request


private String createEntitlementRequest() throws Exception{
/**
* Creating a new RequestBeneficiaryEntity object which
* will hold all the requested entitlement related data.
*/
RequestBeneficiaryEntity requestEntity = new RequestBeneficiaryEntity();
requestEntity.setRequestEntityType(oracle.iam.platform.utils.vo.OIMType.Entitlement); //Type of the Request
requestEntity.setEntitySubType("ENT_CODE"); //Name of the Entitlement
requestEntity.setEntityKey("ENT_LIST_KEY"); //Entitlement key
requestEntity.setOperation(RequestConstants.MODEL_PROVISION_ENTITLEMENT_OPERATION); //Request operation type.
//Adding RequestBeneficiaryEntity to List
List<RequestBeneficiaryEntity> entities = new ArrayList<RequestBeneficiaryEntity>();
entities.add(requestEntity);
//creating new Beneficiary
Beneficiary beneficiary = new Beneficiary();
beneficiary.setBeneficiaryKey("USR_KEY"); //set BeneficiaryKey as User key
beneficiary.setBeneficiaryType(Beneficiary.USER_BENEFICIARY); //set the type as user
beneficiary.setTargetEntities(entities); //set target entities as list of RequestBeneficiaryEntity
//Adding Beneficiary to List
List<Beneficiary> beneficiaries = new ArrayList<Beneficiary>();
beneficiaries.add(beneficiary);
//Creating new RequestData and set the Beneficiaries with List of Beneficiaries
RequestData requestData = new RequestData();
requestData.setBeneficiaries(beneficiaries);
/**
* getRequesterConnection() is a seperate method to create OIM connection.
*/
OIMClient oimClientObjReq = getRequesterConnection("REQUESTER_LOGIN_ID"); //create an OIM connection with requester's login
RequestService requestAPI = (RequestService)oimClientObjReq.getService(RequestService.class);
String requestId = requestAPI.submitRequest(requestData); //Return request ID
System.out.println("requestId: "+requestId);
return requestId;
}


Role Provisioning Request


private String createRoleRequest() throws Exception{

/**
* Creating a new RequestBeneficiaryEntity object which
* will hold all the requested Role related data.
*/

RequestBeneficiaryEntity requestEntity = new RequestBeneficiaryEntity();
requestEntity.setRequestEntityType(oracle.iam.platform.utils.vo.OIMType.Role); //Type of the Request
requestEntity.setEntitySubType("UGP_KEY"); //Name of the Role
requestEntity.setEntityKey("UGP_NAME"); //Role key
requestEntity.setOperation(RequestConstants.MODEL_ASSIGN_ROLES_OPERATION); //Request operation type.

//Adding RequestBeneficiaryEntity to List
List<RequestBeneficiaryEntity> entities = new ArrayList<RequestBeneficiaryEntity>();
entities.add(requestEntity);

//creating new Beneficiary
Beneficiary beneficiary = new Beneficiary();
beneficiary.setBeneficiaryKey("USR_KEY"); //set BeneficiaryKey as User key
beneficiary.setBeneficiaryType(Beneficiary.USER_BENEFICIARY); //set the type as user
beneficiary.setTargetEntities(entities); //set target entities as list of RequestBeneficiaryEntity

//Adding Beneficiary to List
List<Beneficiary> beneficiaries = new ArrayList<Beneficiary>();
beneficiaries.add(beneficiary);

//Creating new RequestData and set the Beneficiaries with List of Beneficiaries
RequestData requestData = new RequestData();
requestData.setBeneficiaries(beneficiaries);

/**
* getRequesterConnection() is a seperate method to create OIM connection.
*/

OIMClient oimClientObjReq = getRequesterConnection("REQUESTER_LOGIN_ID"); //create an OIM connection with requester's login
RequestService requestAPI = (RequestService)oimClientObjReq.getService(RequestService.class);
String requestId = requestAPI.submitRequest(requestData); //Return request ID

System.out.println("requestId: "+requestId);
return requestId;
}


9 comments:

  1. I am getting error below:
    Exception in thread "main" javax.ejb.EJBException: error unmarshalling arguments; nested exception is:
    java.io.InvalidClassException: oracle.iam.request.vo.RequestBeneficiaryEntity; local class incompatible: stream classdesc serialVersionUID = 6834978990138398140, local class serialVersionUID = 5714285250557319894; nested exception is: java.io.InvalidClassException: oracle.iam.request.vo.RequestBeneficiaryEntity; local class incompatible: stream classdesc serialVersionUID = 6834978990138398140, local class serialVersionUID = 5714285250557319894
    java.io.InvalidClassException: oracle.iam.request.vo.RequestBeneficiaryEntity; local class incompatible: stream classdesc serialVersionUID = 6834978990138398140, local class serialVersionUID = 5714285250557319894
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:612)

    ReplyDelete
  2. Hi
    I resolved it.As i was using old JARS.
    Here one questions is how do i raise request for others ?

    ReplyDelete
    Replies
    1. Hi Srikant,

      If u need to raise request for others, then use the Beneficiary key in

      beneficiary.setBeneficiaryKey("USR_KEY"); //set BeneficiaryKey as User key

      U need to create each Beneficiary object for each user.

      Delete
  3. Hi

    If I pass USR_KEY in beneficiary.setBeneficiaryKey("USR_KEY") and creates to create each Beneficiary object for each user, requester and beneficiary are same and its ok.

    Now,Lets say I am going to raise request for other user where requester should be my name and beneficiary would be other for which i am going to create request.So when I will track request id I should see my name as requester.

    So in current scenario, it is self request but same time I need request for others.

    ReplyDelete
  4. Hi Srikant,

    beneficiary.setBeneficiaryKey("USR_KEY") will always have beneficiary user key. oimClientObjReq.getService(RequestService.class) is getting used for calling the request submit API, and here the oimClientObjReq object will be logged in by the requester id and password. If you see the code OIMClient oimClientObjReq = getRequesterConnection("REQUESTER_LOGIN_ID") is creating a session for requester user.

    ReplyDelete
  5. Yea..but in case of request for others..requester name and beneficiary name should be different and that is the goal to achive over here.but in that code requester and beneficiary name remains same.

    ReplyDelete
    Replies
    1. Put the different login ids for beneficiary and Requester in the above code and test the code. I am pretty sure that, this way your understanding will be very clear and u will have no further confusion.

      Delete
  6. Hi Avijit,

    createEntitlementRequest method works fine if user is not having any account provisioned or if there is just one account provisioned to user. If user is having multiple accounts of same application instance, to which entitlement belongs, then OIM will get confused to which account the requested entitlement has to be associated. Is there a way to achieve the same.

    ReplyDelete
  7. I am trying to create request for Entitlement but when executing the code its showing me error below. can you please guide to resolve the issue.
    oracle.iam.request.exception.RequestServiceException: An error occurred in oracle.iam.provisioning.plugins.EntitlementDatasetPlugin and the cause of error is 6~GRPNYK.
    at oracle.iam.provisioning.plugins.EntitlementDatasetPlugin.getRequestDatasetName(EntitlementDatasetPlugin.java:140)

    ReplyDelete

Followers

OIM API for adding process task and retry failed task

 In this blog you can find how to add new process task and retry any failed/rejected tasks using API. Adding new process task: /************...