OIM API to Create IDA Rule


  1. package com.oimacademy.NeedEvaluate;
  2. import java.util.List;

  3. import jxxload_help.PackageManager;

  4. import com.oimacademy.connection.Platform;

  5. import oracle.iam.platform.entitymgr.NoSuchEntityException;
  6. import oracle.iam.platform.entitymgr.exception.AccessDeniedException;
  7. import oracle.iam.platform.entitymgr.exception.EntityAlreadyExistsException;
  8. import oracle.iam.platform.entitymgr.exception.EntityCreateException;
  9. import oracle.iam.platform.entitymgr.exception.EntitySearchException;
  10. import oracle.iam.platform.entitymgr.exception.ValidationFailedException;
  11. import oracle.iam.platform.entitymgr.vo.AbstractEntityTypeManagerResult;
  12. import oracle.iam.platform.entitymgr.vo.EntityConstants;
  13. import oracle.iam.platform.entitymgr.vo.SearchCriteria;
  14. import oracle.iam.policyengine.api.PolicyTypeManager;
  15. import oracle.iam.policyengine.api.RuleManager;
  16. import oracle.iam.policyengine.vo.Condition;
  17. import oracle.iam.policyengine.vo.PolicyType;
  18. import oracle.iam.policyengine.vo.Rule;
  19. public class CreateIDARule {
  20.  protected RuleManager ruleManager;
  21.  public static void main(String[] args) throws ValidationFailedException, EntityAlreadyExistsException, EntityCreateException, AccessDeniedException, EntitySearchException, NoSuchEntityException {
  22.  //API to retrieve policy Type Manager
  23.   PackageManager ptm = Platform.getService(PolicyTypeManager.class);
  24.   SearchCriteria sc1 = new SearchCriteria(EntityConstants.NAME, "Identity Audit", SearchCriteria.Operator.EQUAL);
  25.   List<PolicyType> ptList = ptm.search(sc1, null, null);
  26.   PolicyType pt = ptList.get(0);
  27.   RuleManager ruleManager = Platform.getService(RuleManager.class);
  28.   String ruleName = "TestRule_3";
  29.   String lhs ="appType[ABC].appInstance[ABC].account[*]";
  30.   String rhs ="CN=ABC,DC=abc,DC=com";
  31.   Rule ruleCreate = new Rule();
  32.   Condition trivialCondition = new Condition(lhs, rhs, Condition.Operator.ENDS_WITH);
  33.   ruleCreate.setAttribute(Rule.Attribute.NAME.attributeName,ruleName);
  34.   ruleCreate.setAttribute(Rule.Attribute.DESCRIPTION.attributeName," API Rule Creation "+ruleName);
  35.   ruleCreate.setAttribute(Rule.Attribute.TYPE_ID.attributeName,(String)pt.getEntityId());
  36.   ruleCreate.setAttribute(Rule.Attribute.CONDITION.attributeName,trivialCondition);
  37.   AbstractEntityTypeManagerResult result = ruleManager.create(ruleCreate);
  38.   System.out.println("  ID -> "+result.getEntityId());
  39.  }
  40. }


No comments:

Post a Comment