Search in sources :

Example 11 with Match

use of com.sun.identity.entitlement.xacml3.core.Match in project OpenAM by OpenRock.

the class XACMLPrivilegeUtils method getAllMatchesFromTarget.

static List<Match> getAllMatchesFromTarget(Target target) {
    List<Match> matches = new ArrayList<Match>();
    if (target != null) {
        List<AnyOf> anyOfList = target.getAnyOf();
        for (AnyOf anyOf : anyOfList) {
            List<AllOf> allOfList = anyOf.getAllOf();
            for (AllOf allOf : allOfList) {
                List<Match> matchList = allOf.getMatch();
                matches.addAll(matchList);
            }
        }
    }
    return matches;
}
Also used : AnyOf(com.sun.identity.entitlement.xacml3.core.AnyOf) ArrayList(java.util.ArrayList) AllOf(com.sun.identity.entitlement.xacml3.core.AllOf) Match(com.sun.identity.entitlement.xacml3.core.Match)

Example 12 with Match

use of com.sun.identity.entitlement.xacml3.core.Match in project OpenAM by OpenRock.

the class XACMLPrivilegeUtils method actionNamesToAnyOfList.

public static List<AnyOf> actionNamesToAnyOfList(Set<String> actionNames, String applicationName) {
    if (actionNames == null || actionNames.isEmpty()) {
        return null;
    }
    List<AnyOf> anyOfList = new ArrayList<AnyOf>();
    AnyOf anyOf = new AnyOf();
    anyOfList.add(anyOf);
    List<AllOf> allOfList = anyOf.getAllOf();
    for (String actionName : actionNames) {
        AllOf allOf = new AllOf();
        List<Match> matchList = allOf.getMatch();
        matchList.add(actionNameToMatch(actionName, applicationName));
        allOfList.add(allOf);
    }
    return anyOfList;
}
Also used : AnyOf(com.sun.identity.entitlement.xacml3.core.AnyOf) ArrayList(java.util.ArrayList) AllOf(com.sun.identity.entitlement.xacml3.core.AllOf) Match(com.sun.identity.entitlement.xacml3.core.Match)

Example 13 with Match

use of com.sun.identity.entitlement.xacml3.core.Match in project OpenAM by OpenRock.

the class XACMLPrivilegeUtils method getActionNamesFromMatches.

static Set<String> getActionNamesFromMatches(List<Match> matches) {
    if (matches == null) {
        return null;
    }
    Set<String> actionNames = new HashSet<String>();
    for (Match match : matches) {
        String matchId = match.getMatchId();
        if ((matchId != null) && matchId.indexOf(":action-match:") != -1) {
            AttributeValue attributeValue = match.getAttributeValue();
            if (attributeValue != null) {
                List<Object> contentList = attributeValue.getContent();
                if ((contentList != null) && !contentList.isEmpty()) {
                    // FIXME: log a warning if more than one element
                    Object obj = contentList.get(0);
                    actionNames.add(obj.toString());
                }
            }
        }
    }
    return actionNames;
}
Also used : AttributeValue(com.sun.identity.entitlement.xacml3.core.AttributeValue) JSONObject(org.json.JSONObject) HashSet(java.util.HashSet) Match(com.sun.identity.entitlement.xacml3.core.Match)

Example 14 with Match

use of com.sun.identity.entitlement.xacml3.core.Match in project OpenAM by OpenRock.

the class XACMLPrivilegeUtils method applicationNameToAnyOf.

public static AnyOf applicationNameToAnyOf(String applicationName) {
    AnyOf anyOf = new AnyOf();
    List<AllOf> allOfList = anyOf.getAllOf();
    AllOf allOf = new AllOf();
    List<Match> matchList = allOf.getMatch();
    matchList.add(applicationNameToMatch(applicationName));
    allOfList.add(allOf);
    return anyOf;
}
Also used : AnyOf(com.sun.identity.entitlement.xacml3.core.AnyOf) AllOf(com.sun.identity.entitlement.xacml3.core.AllOf) Match(com.sun.identity.entitlement.xacml3.core.Match)

Example 15 with Match

use of com.sun.identity.entitlement.xacml3.core.Match in project OpenAM by OpenRock.

the class XACMLPrivilegeUtils method getResourceNamesFromMatches.

static Set<String> getResourceNamesFromMatches(List<Match> matches) {
    if (matches == null) {
        return null;
    }
    Set<String> resourceNames = new HashSet<String>();
    for (Match match : matches) {
        String matchId = match.getMatchId();
        if ((matchId != null) && matchId.indexOf(":resource-match:") != -1) {
            AttributeValue attributeValue = match.getAttributeValue();
            if (attributeValue != null) {
                List<Object> contentList = attributeValue.getContent();
                if ((contentList != null) && !contentList.isEmpty()) {
                    // FIXME: log a warning if more than one element
                    Object obj = contentList.get(0);
                    resourceNames.add(obj.toString());
                }
            }
        }
    }
    return resourceNames;
}
Also used : AttributeValue(com.sun.identity.entitlement.xacml3.core.AttributeValue) JSONObject(org.json.JSONObject) HashSet(java.util.HashSet) Match(com.sun.identity.entitlement.xacml3.core.Match)

Aggregations

Match (com.sun.identity.entitlement.xacml3.core.Match)17 AttributeValue (com.sun.identity.entitlement.xacml3.core.AttributeValue)12 AnyOf (com.sun.identity.entitlement.xacml3.core.AnyOf)9 AllOf (com.sun.identity.entitlement.xacml3.core.AllOf)7 AttributeDesignator (com.sun.identity.entitlement.xacml3.core.AttributeDesignator)7 JSONObject (org.json.JSONObject)7 HashSet (java.util.HashSet)6 ArrayList (java.util.ArrayList)4 PolicySet (com.sun.identity.entitlement.xacml3.core.PolicySet)3 Rule (com.sun.identity.entitlement.xacml3.core.Rule)3 Target (com.sun.identity.entitlement.xacml3.core.Target)3 Entitlement (com.sun.identity.entitlement.Entitlement)2 EntitlementCondition (com.sun.identity.entitlement.EntitlementCondition)2 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)2 Privilege (com.sun.identity.entitlement.Privilege)2 ReferralPrivilege (com.sun.identity.entitlement.ReferralPrivilege)2 ResourceAttribute (com.sun.identity.entitlement.ResourceAttribute)2 Policy (com.sun.identity.entitlement.xacml3.core.Policy)2 VariableDefinition (com.sun.identity.entitlement.xacml3.core.VariableDefinition)2 Version (com.sun.identity.entitlement.xacml3.core.Version)2