Search in sources :

Example 6 with Version

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

the class XACMLPrivilegeUtilsTest method assertPolicySetContentsMatchPrivilegesContent.

private void assertPolicySetContentsMatchPrivilegesContent(PolicySet policySet, Set<Privilege> privileges) {
    if (privileges != null && !privileges.isEmpty()) {
        assertTrue(policySet != null, "Expected PolicySet to not be null.");
    }
    List<Policy> policies = getPoliciesFromPolicySet(policySet);
    assertEquals(policies.size(), privileges.size(), "Mismatch between number of Policy elements in PolicySet, " + "and number of original Privileges.");
    List<String> policyIdList = new ArrayList<String>();
    for (Policy policy : policies) {
        policyIdList.add(policy.getPolicyId());
    }
    List<String> privilegeIdList = new ArrayList<String>();
    for (Privilege privilege : privileges) {
        privilegeIdList.add(privilege.getName());
    }
    assertTrue(policyIdList.containsAll(privilegeIdList), "Not all Privilege names were included in the " + "PolicySet.");
    assertTrue(privilegeIdList.containsAll(policyIdList), "Extra names were added to the PolicySet which were " + "not in the list of Privilege names.");
    List<String> descriptionList = new ArrayList<String>();
    for (Policy policy : policies) {
        descriptionList.add(policy.getDescription());
    }
    for (Privilege privilege : privileges) {
        String description = privilege.getDescription();
        assertTrue(descriptionList.contains(description), "Privilege with description '" + description + "' not " + "found in PolicySet.");
    }
    String privilegesVersion = formatMillisecondsAsTimestamp(now);
    for (Policy policy : policies) {
        assertEquals(policy.getVersion().getValue(), privilegesVersion, "Policy found with version not matching " + "Privilege creation date.");
    }
}
Also used : Policy(com.sun.identity.entitlement.xacml3.core.Policy) ArrayList(java.util.ArrayList) ReferralPrivilege(com.sun.identity.entitlement.ReferralPrivilege) Privilege(com.sun.identity.entitlement.Privilege)

Aggregations

Policy (com.sun.identity.entitlement.xacml3.core.Policy)4 PolicySet (com.sun.identity.entitlement.xacml3.core.PolicySet)4 Target (com.sun.identity.entitlement.xacml3.core.Target)4 Version (com.sun.identity.entitlement.xacml3.core.Version)4 SimpleDateFormat (java.text.SimpleDateFormat)4 JAXBContext (javax.xml.bind.JAXBContext)3 AnyOf (com.sun.identity.entitlement.xacml3.core.AnyOf)2 AttributeValue (com.sun.identity.entitlement.xacml3.core.AttributeValue)2 Rule (com.sun.identity.entitlement.xacml3.core.Rule)2 VariableDefinition (com.sun.identity.entitlement.xacml3.core.VariableDefinition)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 JSONObject (org.json.JSONObject)2 Entitlement (com.sun.identity.entitlement.Entitlement)1 EntitlementCondition (com.sun.identity.entitlement.EntitlementCondition)1 EntitlementException (com.sun.identity.entitlement.EntitlementException)1 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)1 Privilege (com.sun.identity.entitlement.Privilege)1 ReferralPrivilege (com.sun.identity.entitlement.ReferralPrivilege)1 ResourceAttribute (com.sun.identity.entitlement.ResourceAttribute)1