import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import sailpoint.api.SailPointContext;
import sailpoint.object.Attributes;
import sailpoint.object.Certifiable;
import sailpoint.object.EntitlementGroup;
import sailpoint.object.Filter;
import sailpoint.object.ManagedAttribute;
import sailpoint.tools.GeneralException;
public class WorkgroupECertExclusionRule {
static SailPointContext context = null;
static Log log = null;
static List items = null;
static List itemsToExclude = null;
static String explanation = null;
static String excludeEntitlement() {
log.debug("Entering into Exclusion Rule");
ManagedAttribute access = null;
// ManagedAttribute access = null;
String accessCert = null;
Attributes attrs = null;
String appName = null;
String entAttrName = null;
String entAttrVal = null;
Filter masterFilter = null;
List entitlementList = new ArrayList();
for (Iterator iterator = items.iterator(); iterator.hasNext();) {
try {
Certifiable certifiable = (Certifiable) iterator.next();
if (certifiable instanceof EntitlementGroup) {
EntitlementGroup entitlementGroup = (EntitlementGroup) certifiable;
appName = entitlementGroup.getApplicationName();
attrs = entitlementGroup.getAttributes();
entAttrName = attrs.getKeys().get(0).toString();
entAttrVal = attrs.getString(entAttrName);
masterFilter = Filter.and(new Filter[] { Filter.eq("value", entAttrVal),
Filter.eq("attribute", entAttrName), Filter.eq("application.name", appName) });
access = context.getUniqueObject(ManagedAttribute.class, masterFilter);
accessCert = access.getAttribute("certifiable").toString();
if (!accessCert.equalsIgnoreCase("True")) {
itemsToExclude.add(certifiable);
iterator.remove();
explanation = "No need to certify these items";
}
}
} catch (GeneralException e) {
log.error("GeneralException in exclusion: " + e.getMessage());
}
}
items.addAll(entitlementList);
log.debug("Exiting from Exclusion Rule");
return explanation;
}
public static void main(String[] args) {
String message = excludeEntitlement();
}
}
No comments:
Post a Comment