OIM API To Disable User using Request API


  1. package com.oimacademy.request;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import oracle.iam.api.OIMService;
  5. import oracle.iam.exception.OIMServiceException;
  6. import oracle.iam.identity.exception.NoSuchUserException;
  7. import oracle.iam.identity.exception.UserLookupException;
  8. import oracle.iam.platform.utils.vo.OIMType;
  9. import oracle.iam.request.vo.RequestConstants;
  10. import oracle.iam.request.vo.RequestData;
  11. import oracle.iam.request.vo.RequestEntity;
  12. import oracle.iam.vo.OperationResult;
  13. import com.oimacademy.connection.Platform;
  14. public class RequestToDisableUser {
  15.  private final OIMService oimService  =Platform.getService(OIMService.class);;
  16.   public OperationResult disableUser() throws NoSuchUserException, UserLookupException, OIMServiceException
  17.      {
  18.          // usr_key
  19.          String usrKey = "";
  20.          //request entity
  21.          RequestEntity requestEntity = new RequestEntity();
  22.          requestEntity.setRequestEntityType(OIMType.User);
  23.          requestEntity.setEntityKey(usrKey); 
  24.          requestEntity.setOperation(RequestConstants.MODEL_DISABLE_OPERATION);
  25.          List<RequestEntity>  entities = new ArrayList<RequestEntity>();
  26.          entities.add(requestEntity);      
  27.          RequestData requestData = new RequestData();
  28.          requestData.setTargetEntities(entities);          
  29.          // Invoke 
  30.          OperationResult result = oimService.doOperation(requestData, OIMService.Intent.REQUEST);         
  31.          return result;
  32.      }
  33. }

No comments:

Post a Comment