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