Search in sources :

Example 6 with AllOf

use of com.sun.identity.entitlement.xacml3.core.AllOf 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 7 with AllOf

use of com.sun.identity.entitlement.xacml3.core.AllOf 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 8 with AllOf

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

the class XACMLPrivilegeUtils method entitlementSubjectToAnyOfList.

// TODO: not used now, use, test, fix and verify
public static List<AnyOf> entitlementSubjectToAnyOfList(EntitlementSubject es) {
    if (es == null) {
        return null;
    }
    List<AnyOf> anyOfList = new ArrayList<AnyOf>();
    AnyOf anyOf = new AnyOf();
    anyOfList.add(anyOf);
    List<AllOf> allOfList = anyOf.getAllOf();
    AllOf allOf = new AllOf();
    allOfList.add(allOf);
    List<Match> matchList = allOf.getMatch();
    if (es instanceof UserSubject) {
        UserSubject us = (UserSubject) es;
        String userId = us.getID();
        Match match = new Match();
        matchList.add(match);
        match.setMatchId("user-subject-match");
        AttributeValue attributeValue = new AttributeValue();
        String dataType = "datatype";
        attributeValue.setDataType(dataType);
        attributeValue.getContent().add(userId);
        AttributeDesignator attributeDesignator = new AttributeDesignator();
        String category = "subject-category";
        attributeDesignator.setCategory(category);
        String attributeId = "user-subject:user-id";
        attributeDesignator.setAttributeId(attributeId);
        String dt = "xs;string";
        attributeDesignator.setDataType(dt);
        String issuer = "subject:issuer";
        // attributeDesignator.setIssuer(issuer); TODO: verify and fix
        boolean mustBePresent = true;
        attributeDesignator.setMustBePresent(mustBePresent);
        match.setAttributeValue(attributeValue);
        match.setAttributeDesignator(attributeDesignator);
    }
    return anyOfList;
}
Also used : AttributeValue(com.sun.identity.entitlement.xacml3.core.AttributeValue) AttributeDesignator(com.sun.identity.entitlement.xacml3.core.AttributeDesignator) AnyOf(com.sun.identity.entitlement.xacml3.core.AnyOf) UserSubject(com.sun.identity.entitlement.UserSubject) ArrayList(java.util.ArrayList) AllOf(com.sun.identity.entitlement.xacml3.core.AllOf) Match(com.sun.identity.entitlement.xacml3.core.Match)

Example 9 with AllOf

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

the class XACMLPrivilegeUtils method entitlementSubjectToAnyOf.

public static AnyOf entitlementSubjectToAnyOf(EntitlementSubject es) throws JAXBException {
    if (es == null) {
        return null;
    }
    AnyOf anyOf = new AnyOf();
    List<AllOf> allOfList = anyOf.getAllOf();
    AllOf allOf = new AllOf();
    allOfList.add(allOf);
    List<Match> matchList = allOf.getMatch();
    Match match = new Match();
    matchList.add(match);
    match.setMatchId(XACMLConstants.JSON_SUBJECT_MATCH);
    AttributeValue attributeValue = new AttributeValue();
    String dataType = XACMLConstants.JSON_SUBJECT_DATATYPE + ":" + es.getClass().getName();
    attributeValue.setDataType(dataType);
    String esString = es.getState();
    attributeValue.getContent().add(esString);
    AttributeDesignator attributeDesignator = new AttributeDesignator();
    String category = XACMLConstants.XACML_ACCESS_SUBJECT_CATEGORY;
    attributeDesignator.setCategory(category);
    String attributeId = XACMLConstants.JSON_SUBJECT_ID;
    attributeDesignator.setAttributeId(attributeId);
    String dt = XACMLConstants.JSON_SUBJECT_DATATYPE + ":" + es.getClass().getName();
    attributeDesignator.setDataType(dt);
    // TODO: not a constant?
    String issuer = XACMLConstants.SUBJECT_ISSUER;
    //attributeDesignator.setIssuer(issuer); //TODO: verify and fix
    boolean mustBePresent = true;
    attributeDesignator.setMustBePresent(mustBePresent);
    match.setAttributeValue(attributeValue);
    match.setAttributeDesignator(attributeDesignator);
    return anyOf;
}
Also used : AttributeValue(com.sun.identity.entitlement.xacml3.core.AttributeValue) AttributeDesignator(com.sun.identity.entitlement.xacml3.core.AttributeDesignator) AnyOf(com.sun.identity.entitlement.xacml3.core.AnyOf) AllOf(com.sun.identity.entitlement.xacml3.core.AllOf) Match(com.sun.identity.entitlement.xacml3.core.Match)

Aggregations

AnyOf (com.sun.identity.entitlement.xacml3.core.AnyOf)9 AllOf (com.sun.identity.entitlement.xacml3.core.AllOf)7 Match (com.sun.identity.entitlement.xacml3.core.Match)7 AttributeValue (com.sun.identity.entitlement.xacml3.core.AttributeValue)5 ArrayList (java.util.ArrayList)4 AttributeDesignator (com.sun.identity.entitlement.xacml3.core.AttributeDesignator)3 JSONObject (org.json.JSONObject)3 Policy (com.sun.identity.entitlement.xacml3.core.Policy)2 Rule (com.sun.identity.entitlement.xacml3.core.Rule)2 Target (com.sun.identity.entitlement.xacml3.core.Target)2 VariableDefinition (com.sun.identity.entitlement.xacml3.core.VariableDefinition)2 Version (com.sun.identity.entitlement.xacml3.core.Version)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashSet (java.util.HashSet)2 JAXBContext (javax.xml.bind.JAXBContext)2 Entitlement (com.sun.identity.entitlement.Entitlement)1 EntitlementCondition (com.sun.identity.entitlement.EntitlementCondition)1 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)1 ResourceAttribute (com.sun.identity.entitlement.ResourceAttribute)1 UserSubject (com.sun.identity.entitlement.UserSubject)1