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;
}
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.");
}
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");
}
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);
}
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");
}
Aggregations