Wednesday, August 7, 2024

how to fetch IT roles based on entitlements in SailPoint IIQ?

import java.util.ArrayList;
import java.util.List;
import sailpoint.api.SailPointContext;
import sailpoint.object.Bundle;
import sailpoint.object.Filter;
import sailpoint.object.Profile;
import sailpoint.object.QueryOptions; 

String appName="Mighty";
String entitlementName = "DPA";
QueryOptions profileQo = new QueryOptions();
profileQo.addFilter(Filter.eq("application.name", appName));


  List bundles = new ArrayList();
  List profiles = context.getObjects(Profile.class, profileQo);

  if (profiles != null) {
    for (Object profileObj : profiles) {
      Profile p = (Profile) profileObj;
      List constraints = p.getConstraints();
      List filterList = null;
  
      if (constraints != null) {
        for (Object filter : constraints) {

          filterList = new ArrayList();
          if (filter instanceof sailpoint.object.Filter.LeafFilter) {
            sailpoint.object.Filter.LeafFilter f = (sailpoint.object.Filter.LeafFilter) filter;

            //Filter can have multiple values 
            Object value = f.getValue();

            if (value instanceof ArrayList) {

              ArrayList entitlements = new ArrayList();
              entitlements = (ArrayList) value;

              for (Object obj : entitlements) {
                if (obj.toString().equals(entitlementName)) {

                  Bundle bun = p.getBundle();
                  bundles.add(bun.getName());
                }

              }

            }

          }

        }

      }

    }

  }

  return bundles;

No comments:

Post a Comment

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...