Search in sources :

Example 6 with Privilege

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

the class JsonPolicyParserTest method shouldPrintLastModifiedDateInIsoFormat.

@Test
public void shouldPrintLastModifiedDateInIsoFormat() throws Exception {
    // Given
    Privilege policy = new StubPrivilege();
    Date lastModified = new Date(123456789l);
    policy.setLastModifiedDate(lastModified.getTime());
    // When
    JsonValue result = parser.printPolicy(policy);
    // Then
    assertThat(result.get("lastModifiedDate").asString()).isEqualTo(DateUtils.toUTCDateFormatWithMilliseconds(lastModified));
}
Also used : JsonValue(org.forgerock.json.JsonValue) OpenSSOPrivilege(com.sun.identity.entitlement.opensso.OpenSSOPrivilege) Privilege(com.sun.identity.entitlement.Privilege) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 7 with Privilege

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

the class PolicyResourceTest method shouldAcceptPolicyNameFromUrl.

@Test
public void shouldAcceptPolicyNameFromUrl() throws Exception {
    // Given
    String policyName = "policyName";
    JsonValue json = new JsonValue("");
    CreateRequest request = mockCreateRequest(policyName, json);
    Privilege policy = mockPrivilege(policyName, 123l);
    given(mockParser.parsePolicy(policyName, json)).willReturn(policy);
    // When
    policyResource.createInstance(mockServerContext, request);
    // Then
    verify(mockParser).parsePolicy(policyName, json);
}
Also used : CreateRequest(org.forgerock.json.resource.CreateRequest) JsonValue(org.forgerock.json.JsonValue) Privilege(com.sun.identity.entitlement.Privilege) Test(org.testng.annotations.Test)

Example 8 with Privilege

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

the class PrivilegePolicyStoreTest method shouldDelegateUpdatesToPrivilegeManager.

@Test
public void shouldDelegateUpdatesToPrivilegeManager() throws Exception {
    // Given
    String name = "test";
    Privilege policy = new StubPrivilege();
    // When
    Privilege response = testStore.update(name, policy);
    // Then
    verify(mockManager).modify(name, policy);
    assertThat(response).isSameAs(policy);
}
Also used : Privilege(com.sun.identity.entitlement.Privilege) Test(org.testng.annotations.Test)

Example 9 with Privilege

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

the class JsonPolicyParserTest method shouldParseSimpleSubjects.

@Test
public void shouldParseSimpleSubjects() throws Exception {
    // Given
    JsonValue content = buildJson(field("subject", object(field("type", "AuthenticatedUsers"))));
    // When
    Privilege result = parser.parsePolicy(POLICY_NAME, content);
    // Then
    assertThat(result.getSubject()).isInstanceOf(AuthenticatedUsers.class);
}
Also used : JsonValue(org.forgerock.json.JsonValue) OpenSSOPrivilege(com.sun.identity.entitlement.opensso.OpenSSOPrivilege) Privilege(com.sun.identity.entitlement.Privilege) Test(org.testng.annotations.Test)

Example 10 with Privilege

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

the class JsonPolicyParserTest method shouldCorrectlyParseConditionTypes.

@Test
public void shouldCorrectlyParseConditionTypes() throws Exception {
    // Given
    String scope = "givenName";
    JsonValue content = buildJson(field("condition", object(field("type", "OAuth2Scope"), field("requiredScopes", array(scope)))));
    // When
    Privilege result = parser.parsePolicy(POLICY_NAME, content);
    // Then
    assertThat(result.getCondition()).isInstanceOf(OAuth2ScopeCondition.class);
    assertThat(((OAuth2ScopeCondition) result.getCondition()).getRequiredScopes()).isEqualTo(Collections.singleton(scope));
}
Also used : OAuth2ScopeCondition(org.forgerock.openam.entitlement.conditions.environment.OAuth2ScopeCondition) JsonValue(org.forgerock.json.JsonValue) OpenSSOPrivilege(com.sun.identity.entitlement.opensso.OpenSSOPrivilege) Privilege(com.sun.identity.entitlement.Privilege) Test(org.testng.annotations.Test)

Aggregations

Privilege (com.sun.identity.entitlement.Privilege)122 Test (org.testng.annotations.Test)76 JsonValue (org.forgerock.json.JsonValue)46 OpenSSOPrivilege (com.sun.identity.entitlement.opensso.OpenSSOPrivilege)39 HashSet (java.util.HashSet)30 ReferralPrivilege (com.sun.identity.entitlement.ReferralPrivilege)26 EntitlementException (com.sun.identity.entitlement.EntitlementException)23 IPrivilege (com.sun.identity.entitlement.IPrivilege)23 Entitlement (com.sun.identity.entitlement.Entitlement)19 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)18 PrivilegeManager (com.sun.identity.entitlement.PrivilegeManager)17 HashMap (java.util.HashMap)15 EntitlementCondition (com.sun.identity.entitlement.EntitlementCondition)13 ApplicationPrivilege (com.sun.identity.entitlement.ApplicationPrivilege)11 PolicyCondition (com.sun.identity.entitlement.opensso.PolicyCondition)10 Set (java.util.Set)9 SSOToken (com.iplanet.sso.SSOToken)8 PolicySubject (com.sun.identity.entitlement.opensso.PolicySubject)8 Subject (javax.security.auth.Subject)8 ResourceResponse (org.forgerock.json.resource.ResourceResponse)8