OIM Entitlement Revoke Request


  1. package com.oimacademy.provision;
  2. import java.util.ArrayList;
  3. import java.util.Calendar;
  4. import java.util.List;
  5. import javax.xml.registry.InvalidRequestException;
  6. import com.oimacademy.connection.Platform;
  7. import oracle.iam.platform.utils.vo.OIMType;
  8. import oracle.iam.request.api.RequestService;
  9. import oracle.iam.request.exception.BulkBeneficiariesAddException;
  10. import oracle.iam.request.exception.BulkEntitiesAddException;
  11. import oracle.iam.request.exception.InvalidRequestDataException;
  12. import oracle.iam.request.exception.RequestServiceException;
  13. import oracle.iam.request.vo.Beneficiary;
  14. import oracle.iam.request.vo.RequestBeneficiaryEntity;
  15. import oracle.iam.request.vo.RequestBeneficiaryEntityAttribute;
  16. import oracle.iam.request.vo.RequestConstants;
  17. import oracle.iam.request.vo.RequestData;
  18. public class EntitlementRequest {
  19.  public long createRevokeEntitlementRequest(RequestService reqSvc) throws InvalidRequestException, InvalidRequestDataException, RequestServiceException, BulkBeneficiariesAddException, BulkEntitiesAddException, oracle.iam.request.exception.InvalidRequestException{
  20.      long requestKey=0;
  21.      RequestData reqData = new RequestData();  
  22.   List<Beneficiary> benList = new ArrayList<Beneficiary>();  
  23.   RequestBeneficiaryEntity reqBenEnt = new RequestBeneficiaryEntity();
  24.   reqBenEnt.setRequestEntityType(OIMType.Entitlement);
  25.   reqBenEnt.setEntitySubType("148"); //ENT_LIST_KEY
  26.   reqBenEnt.setOperation(RequestConstants.MODEL_REVOKE_ENTITLEMENT_OPERATION);
  27.   reqBenEnt.setEntityKey("27"); //ENT_ASSIGN_KEY  
  28.   RequestBeneficiaryEntityAttribute reqBenEntAttr = new RequestBeneficiaryEntityAttribute();
  29.   reqBenEntAttr.setName("ParentAccountId");
  30.   reqBenEntAttr.setType(RequestBeneficiaryEntityAttribute.TYPE.String);
  31.   reqBenEntAttr.setValue("167"); //OIU_KEY  
  32.   List<RequestBeneficiaryEntityAttribute> reqBenEntAttrList = new ArrayList();
  33.   reqBenEntAttrList.add(reqBenEntAttr);
  34.   reqBenEnt.setEntityData(reqBenEntAttrList);  
  35.   List<RequestBeneficiaryEntity> reqBenEntList = new ArrayList();
  36.   reqBenEntList.add(reqBenEnt);  
  37.   Beneficiary ben = new Beneficiary("User","107");
  38.   ben.setTargetEntities(reqBenEntList);  
  39.   benList.add(ben);  
  40.   reqData.setBeneficiaries(benList);
  41.   reqData.setJustification("Testing to check the time lag for revoke request");
  42.   System.out.println(Calendar.getInstance().getTime());
  43.   String requestId = reqSvc.submitRequest(reqData);
  44.   System.out.println("Request Id: "+requestId);
  45.   System.out.println(Calendar.getInstance().getTime());
  46.      return requestKey;
  47.     } 
  48.  public static void main(String[] args){
  49.   RequestService reqSvc = Platform.getService(RequestService.class);
  50.   try {
  51.    new EntitlementRequest().createRevokeEntitlementRequest(reqSvc);
  52.    
  53.   } catch (InvalidRequestException | InvalidRequestDataException
  54.     | RequestServiceException | BulkBeneficiariesAddException
  55.     | BulkEntitiesAddException
  56.     | oracle.iam.request.exception.InvalidRequestException e) {
  57.    // TODO Auto-generated catch block
  58.    e.printStackTrace();
  59.   }
  60.  }
  61. }

1 comment:

  1. Hi,
    I have used the same codes to revoke the entitlement in OIM-11gR2ps3 but we are getting issues. Once we run the program, Entitlement is getting revoked and request Id is also getting generated but for Connected Application(like Active Directory), the request status is showing Request Approved Fulfillment failed. Do you have any idea about this issue.
    You response will be much appreciated.

    ReplyDelete