Hi Team,
I am getting error while creating an advanced policy for one role at a time for one of our app. Please help here to get it resolved.
below is the error screenshot.
Below is the piece of code written.
import sailpoint.object.Policy;
import sailpoint.object.PolicyViolation;
import sailpoint.object.Identity;
import sailpoint.object.Entitlement;
import sailpoint.object.Filter;
import sailpoint.object.Apllication;
import sailpoint.object.QueryOptions;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.Locale;
import sailpoint.object.Link;
public List getIdentityEntitlements(Identity identity,String appName) {
List applicationLinks = identity.getLinks();
List entitlementList = new ArrayList();
if(applicationLinks != null && applicationLinks.size() >0 ) {
for (Link link:applicationLinks) {
if(appName.equals(link.getApplicationName())) {
entitlementList = link.getEntitlements(Locale.getDefault(),"");
}
}
}
return entitlementList;
}
public boolean isLinkPresent(String identityName, String appName) {
boolean isLinkPresent = false;
QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq(“identity.name”, identityName));
qo.addFilter(Filter.eq(“application.name”, appName));
Iterator itr = context.search(Link.class, qo);
if (itr.hasNext()) {
isLinkPresent = true;
}
return isLinkPresent;
}
PolicyViolation policyViolation = null;
Identity expectedIdentity = identity;
Identity oldIdentity = context.getObjectByName(Identity.class, identity.getName());
String appName= “Asia Group Insurance System SLOCPI”;
List expectedEnt = getIdentityEntitlements(expectedIdentity, appName);
List existingEnt = getIdentityEntitlements(oldIdentity, appName);
boolean isViolation = false;
boolean isLinkPresent = isLinkPresent(identity.getName(), appName);
if (expectedEnt != null && expectedEnt.size() >1) {
isViolation = true;
}
//if identity have the more than required entitlements then flag violation
if (isViolation) {
policyViolation = new PolicyViolation();
policyViolation.setActive(true);
policyViolation.setIdentity(identity);
policyViolation.setPolicy(policy);
policyViolation.setStatus(sailpoint.object.PolicyViolation.Status.Open);
}
return policyViolation;