Search in sources :

Example 11 with Policy

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

the class XACMLPrivilegeUtils method addPolicyToPolicySet.

public static PolicySet addPolicyToPolicySet(Policy policy, PolicySet policySet) throws JAXBException {
    if (policySet == null || policy == null) {
        return policySet;
    }
    JAXBContext jaxbContext = JAXBContext.newInstance(XACMLConstants.XACML3_CORE_PKG);
    List<JAXBElement<?>> pList = policySet.getPolicySetOrPolicyOrPolicySetIdReference();
    JAXBElement<Policy> policyElement = objectFactory.createPolicy(policy);
    pList.add(policyElement);
    return policySet;
}
Also used : Policy(com.sun.identity.entitlement.xacml3.core.Policy) JAXBContext(javax.xml.bind.JAXBContext) JAXBElement(javax.xml.bind.JAXBElement)

Example 12 with Policy

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

the class XACMLPrivilegeUtilsTest method shouldReturnNullWhenGivenNullAsReferralPrivilege.

@Test
public void shouldReturnNullWhenGivenNullAsReferralPrivilege() throws JSONException {
    //Given
    ReferralPrivilege referralPrivilege = null;
    //When
    Policy policy = XACMLPrivilegeUtils.referralToPolicy(referralPrivilege);
    //Then
    assertNull(policy, "Expected Policy to be null.");
}
Also used : Policy(com.sun.identity.entitlement.xacml3.core.Policy) ReferralPrivilege(com.sun.identity.entitlement.ReferralPrivilege) Test(org.testng.annotations.Test)

Example 13 with Policy

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

the class XACMLPrivilegeUtilsTest method shouldIndicateNotAReferralPolicyWhenGivenPolicy.

@Test
public void shouldIndicateNotAReferralPolicyWhenGivenPolicy() throws EntitlementException {
    //Given
    Policy policy = getArbitraryPrivilegeAsPolicy(now);
    //When
    boolean answer = XACMLPrivilegeUtils.isReferralPolicy(policy);
    //Then
    assertFalse(answer, "Expected Policy to be reported as not a ReferralPolicy");
}
Also used : Policy(com.sun.identity.entitlement.xacml3.core.Policy) Test(org.testng.annotations.Test)

Example 14 with Policy

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

the class XACMLPrivilegeUtilsTest method shouldAddPolicyToPolicySet.

@Test
public void shouldAddPolicyToPolicySet() throws JAXBException {
    //Given
    Policy policy = new Policy();
    PolicySet policySet = new PolicySet();
    //When
    XACMLPrivilegeUtils.addPolicyToPolicySet(policy, policySet);
    //Then
    assertPolicySetContainsSameSinglePolicy(policySet, policy);
}
Also used : Policy(com.sun.identity.entitlement.xacml3.core.Policy) PolicySet(com.sun.identity.entitlement.xacml3.core.PolicySet) Test(org.testng.annotations.Test)

Example 15 with Policy

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

the class XACMLPrivilegeUtilsTest method shouldIndicateReferralPolicyWhenGivenReferralPrivilege.

@Test
public void shouldIndicateReferralPolicyWhenGivenReferralPrivilege() throws EntitlementException, JSONException {
    //Given
    Policy policy = getArbitraryReferralPrivilegeAsPolicy(now);
    //When
    boolean answer = XACMLPrivilegeUtils.isReferralPolicy(policy);
    //Then
    assertTrue(answer, "Expected Policy to be reported as a ReferralPolicy");
}
Also used : Policy(com.sun.identity.entitlement.xacml3.core.Policy) Test(org.testng.annotations.Test)

Aggregations

Policy (com.sun.identity.entitlement.xacml3.core.Policy)20 PolicySet (com.sun.identity.entitlement.xacml3.core.PolicySet)12 ReferralPrivilege (com.sun.identity.entitlement.ReferralPrivilege)11 Test (org.testng.annotations.Test)8 JAXBContext (javax.xml.bind.JAXBContext)7 JAXBElement (javax.xml.bind.JAXBElement)7 JSONObject (org.json.JSONObject)7 Privilege (com.sun.identity.entitlement.Privilege)6 AttributeValue (com.sun.identity.entitlement.xacml3.core.AttributeValue)6 Rule (com.sun.identity.entitlement.xacml3.core.Rule)6 EntitlementException (com.sun.identity.entitlement.EntitlementException)5 HashSet (java.util.HashSet)5 EntitlementCondition (com.sun.identity.entitlement.EntitlementCondition)4 Target (com.sun.identity.entitlement.xacml3.core.Target)4 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)3 XACMLOpenSSOPrivilege (com.sun.identity.entitlement.opensso.XACMLOpenSSOPrivilege)3 Condition (com.sun.identity.entitlement.xacml3.core.Condition)3 Match (com.sun.identity.entitlement.xacml3.core.Match)3 VariableDefinition (com.sun.identity.entitlement.xacml3.core.VariableDefinition)3 Version (com.sun.identity.entitlement.xacml3.core.Version)3