Search in sources :

Example 1 with IDRepoResponseProvider

use of com.sun.identity.policy.plugins.IDRepoResponseProvider in project OpenAM by OpenRock.

the class PrivilegeUtils method nrpsToResourceAttributes.

private static Set<ResourceAttribute> nrpsToResourceAttributes(Set nrps) throws EntitlementException {
    Set<ResourceAttribute> resourceAttributesSet = new HashSet<ResourceAttribute>();
    if (nrps != null && !nrps.isEmpty()) {
        for (Object nrpObj : nrps) {
            Object[] nrpa = (Object[]) nrpObj;
            String nrpName = (String) nrpa[0];
            ResponseProvider rp = (ResponseProvider) nrpa[1];
            if (rp instanceof IDRepoResponseProvider) {
                resourceAttributesSet.addAll(nrpsToResourceAttributes((IDRepoResponseProvider) rp, nrpName));
            } else if (rp instanceof ResponseProvider) {
                resourceAttributesSet.addAll(mapGenericResponseProvider(nrpName, rp));
            }
        }
    }
    return resourceAttributesSet;
}
Also used : IDRepoResponseProvider(com.sun.identity.policy.plugins.IDRepoResponseProvider) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) ResourceAttribute(com.sun.identity.entitlement.ResourceAttribute) IDRepoResponseProvider(com.sun.identity.policy.plugins.IDRepoResponseProvider) HashSet(java.util.HashSet)

Example 2 with IDRepoResponseProvider

use of com.sun.identity.policy.plugins.IDRepoResponseProvider in project OpenAM by OpenRock.

the class PrivilegeUtils method resourceAttributesToResponseProviders.

private static Map<String, ResponseProvider> resourceAttributesToResponseProviders(Set<ResourceAttribute> resourceAttributes) throws PolicyException, EntitlementException {
    Map<String, ResponseProvider> results = new HashMap<String, ResponseProvider>();
    if (resourceAttributes != null) {
        Map<String, Map<String, Set<String>>> map = new HashMap<String, Map<String, Set<String>>>();
        for (ResourceAttribute ra : resourceAttributes) {
            if (ra instanceof StaticAttributes) {
                resourceAttributesToResponseProviders((StaticAttributes) ra, map);
            } else if (ra instanceof UserAttributes) {
                resourceAttributesToResponseProviders((UserAttributes) ra, map);
            }
        }
        for (String n : map.keySet()) {
            ResponseProvider rp = new IDRepoResponseProvider();
            Map<String, Set<String>> values = map.get(n);
            Set<String> dynValues = values.get(IDRepoResponseProvider.DYNAMIC_ATTRIBUTE);
            if ((dynValues != null) && !dynValues.isEmpty()) {
                Map<String, Set<String>> configParams = new HashMap<String, Set<String>>();
                configParams.put(PolicyConfig.SELECTED_DYNAMIC_ATTRIBUTES, dynValues);
                rp.initialize(configParams);
            }
            rp.setProperties(values);
            results.put(n, rp);
        }
        // Copy any legacy response providers over directly
        for (ResourceAttribute ra : resourceAttributes) {
            if (ra instanceof PolicyResponseProvider) {
                PolicyResponseProvider prp = (PolicyResponseProvider) ra;
                results.put(prp.getPResponseProviderName(), prp.getResponseProvider());
            }
        }
    }
    return results;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) StaticAttributes(com.sun.identity.entitlement.StaticAttributes) IDRepoResponseProvider(com.sun.identity.policy.plugins.IDRepoResponseProvider) UserAttributes(com.sun.identity.entitlement.UserAttributes) IDRepoResponseProvider(com.sun.identity.policy.plugins.IDRepoResponseProvider) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) ResourceAttribute(com.sun.identity.entitlement.ResourceAttribute) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ResourceAttribute (com.sun.identity.entitlement.ResourceAttribute)2 ResponseProvider (com.sun.identity.policy.interfaces.ResponseProvider)2 IDRepoResponseProvider (com.sun.identity.policy.plugins.IDRepoResponseProvider)2 HashSet (java.util.HashSet)2 StaticAttributes (com.sun.identity.entitlement.StaticAttributes)1 UserAttributes (com.sun.identity.entitlement.UserAttributes)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1