OIM API To Revoke Accounts From OIU Table


  1. package com.oimacademy.NeedEvaluate;
  2. import Thor.API.Security.XLClientSecurityAssociation;
  3. import com.oimacademy.connection.Platform;
  4. import com.thortech.xl.client.dataobj.tcDataBaseClient;
  5. import com.thortech.xl.dataaccess.tcDataProvider;
  6. import com.thortech.xl.dataaccess.tcDataSet;
  7. import com.thortech.xl.dataaccess.tcDataSetException;
  8. import oracle.iam.platform.OIMClient;
  9. import oracle.iam.platform.authopss.exception.AccessDeniedException;
  10. import oracle.iam.provisioning.api.ProvisioningService;
  11. import oracle.iam.provisioning.exception.AccountNotFoundException;
  12. import oracle.iam.provisioning.exception.GenericProvisioningException;
  13. import java.util.Hashtable;
  14. import java.util.logging.Level;
  15. import java.util.logging.Logger;
  16. import javax.security.auth.login.LoginException;
  17. public class RevokeAccounts {
  18.  public static void main(String[] args) throws AccountNotFoundException, AccessDeniedException, GenericProvisioningException,tcDataSetException {
  19.   OIMClient oimClient = null;
  20.   tcDataProvider dbProvider = null;
  21.   try {
  22.    ProvisioningService provService = Platform.getService(ProvisioningService.class);
  23.    XLClientSecurityAssociation.setClientHandle(oimClient);
  24.    dbProvider = new tcDataBaseClient();
  25.    String query = "SELECT OIU_KEY FROM OIU"; // Query all accounts
  26.    tcDataSet accountsDataSet = new tcDataSet(); // store result set of               // query
  27.    accountsDataSet.setQuery(dbProvider, query);
  28.    accountsDataSet.executeQuery();
  29.    int numRecords = accountsDataSet.getTotalRowCount();
  30.    for (int i = 0; i < numRecords; i++) {
  31.     accountsDataSet.goToRow(i);
  32.     long accountId = accountsDataSet.getLong("OIU_KEY");
  33.     provService.revoke(accountId); // revoke account
  34.    }
  35.   } finally {
  36.    if (oimClient != null)
  37.     oimClient.logout();
  38.   }
  39.  }
  40. }

No comments:

Post a Comment