Search in sources :

Example 11 with PolicyCondition

use of com.sun.identity.entitlement.opensso.PolicyCondition in project OpenAM by OpenRock.

the class JsonPolicyParserTest method shouldAllowLegacyPolicyConditions.

@Test
public void shouldAllowLegacyPolicyConditions() throws Exception {
    // Given
    List<String> realm = Arrays.asList("REALM");
    JsonValue content = buildJson(field("condition", object(field("type", "Policy"), field("className", AuthenticateToRealmCondition.class.getName()), field("properties", object(field("AuthenticateToRealm", realm))))));
    // When
    Privilege result = parser.parsePolicy(POLICY_NAME, content);
    // Then
    assertThat(result.getCondition()).isInstanceOf(PolicyCondition.class);
    PolicyCondition condition = (PolicyCondition) result.getCondition();
    assertThat(condition.getClassName()).isEqualTo(AuthenticateToRealmCondition.class.getName());
    assertThat(condition.getProperties()).isEqualTo(Collections.singletonMap("AuthenticateToRealm", new HashSet<String>(realm)));
}
Also used : JsonValue(org.forgerock.json.JsonValue) AuthenticateToRealmCondition(com.sun.identity.policy.plugins.AuthenticateToRealmCondition) PolicyCondition(com.sun.identity.entitlement.opensso.PolicyCondition) OpenSSOPrivilege(com.sun.identity.entitlement.opensso.OpenSSOPrivilege) Privilege(com.sun.identity.entitlement.Privilege) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Test(org.testng.annotations.Test)

Aggregations

PolicyCondition (com.sun.identity.entitlement.opensso.PolicyCondition)11 EntitlementCondition (com.sun.identity.entitlement.EntitlementCondition)10 Privilege (com.sun.identity.entitlement.Privilege)10 Test (org.testng.annotations.Test)10 HashSet (java.util.HashSet)9 Set (java.util.Set)4 AndCondition (com.sun.identity.entitlement.AndCondition)3 NotCondition (com.sun.identity.entitlement.NotCondition)3 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)2 OrCondition (com.sun.identity.entitlement.OrCondition)2 OpenSSOPrivilege (com.sun.identity.entitlement.opensso.OpenSSOPrivilege)2 PolicySubject (com.sun.identity.entitlement.opensso.PolicySubject)2 AuthenticateToRealmCondition (com.sun.identity.policy.plugins.AuthenticateToRealmCondition)2 LinkedHashSet (java.util.LinkedHashSet)2 JsonValue (org.forgerock.json.JsonValue)2 LogicalCondition (com.sun.identity.entitlement.LogicalCondition)1 HashMap (java.util.HashMap)1 JsonPointer (org.forgerock.json.JsonPointer)1 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)1