OIM API to Provision Account To User


  1. package com.oimacademy.provision;
  2. import static oracle.iam.identity.utils.Constants.FIRSTNAME;
  3. import static oracle.iam.identity.utils.Constants.SEARCH_SORTEDBY;
  4. import static oracle.iam.identity.utils.Constants.SEARCH_SORTORDER;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Map;
  8. import oracle.iam.platform.entitymgr.spi.entity.Searchable.SortOrder;
  9. import oracle.iam.platform.entitymgr.vo.SearchCriteria;
  10. import oracle.iam.provisioning.api.ApplicationInstanceService;
  11. import oracle.iam.provisioning.api.EntitlementService;
  12. import oracle.iam.provisioning.api.ProvisioningService;
  13. import oracle.iam.provisioning.vo.Account;
  14. import oracle.iam.provisioning.vo.AccountData;
  15. import oracle.iam.provisioning.vo.ApplicationInstance;
  16. import oracle.iam.provisioning.vo.Entitlement;
  17. import oracle.iam.provisioning.vo.EntitlementInstance;
  18. import oracle.iam.provisioning.vo.FormInfo;
  19. import com.oimacademy.connection.Platform;
  20. public class provisionAccount {
  21.  private static ProvisioningService service=Platform.getService(ProvisioningService.class);
  22.  private static ApplicationInstanceService applicationInstanceService=Platform.getService(ApplicationInstanceService.class);
  23. public static void main(String [] args){
  24.   try {
  25.      ApplicationInstance applicationInstance=applicationInstanceService.findApplicationInstanceByName("DisconnectedApp"); 
  26.         FormInfo formInfo = applicationInstance.getAccountForm();
  27.         System.out.println("Object Type  ->"+applicationInstance.getObjectName());
  28.         System.out.println("ApplicationInstanceName   ->"+applicationInstance.getApplicationInstanceName());
  29.         System.out.println("ResourceName   ->"+applicationInstance.getItResourceName());
  30.         System.out.println("ResourceName   ->"+applicationInstance.getItResourceKey());
  31.         Map parentData = new HashMap();
  32.         parentData.put("UD_DIS7601", applicationInstance.getApplicationInstanceName().toString());
  33.         String formKey = String.valueOf(formInfo.getFormKey());        
  34.         AccountData accountData = new AccountData(formKey, null, parentData);
  35.         Account account = new Account(applicationInstance, accountData);
  36.         account.setAccountType(Account.ACCOUNT_TYPE.Primary);
  37.         long oiuKey =0;
  38.       for(int i=5;i<9;i++) {
  39.        oiuKey= service.provision(""+i, account);
  40.           System.out.println("Provisioned Account for User   ->"+i);
  41.       }
  42.    }catch (Exception e){
  43.     System.out.println("In exception block");
  44.     e.printStackTrace();
  45.    }
  46.  }
  47. }

No comments:

Post a Comment