Search in sources :

Example 16 with SSOToken

use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.

the class ApplicationDelegationTest method negativeTest.

@Test
public void negativeTest() throws Exception {
    SSOToken ssoToken = authenticate(USER1, USER1);
    testUserSubject = SubjectUtils.createSubject(ssoToken);
    Application appl = ApplicationManager.getApplication(testUserSubject, "/", APPL_NAME);
    try {
        ApplicationManager.saveApplication(testUserSubject, "/", appl);
    } catch (EntitlementException e) {
        if (e.getErrorCode() != 326) {
            throw e;
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Test(org.testng.annotations.Test)

Example 17 with SSOToken

use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.

the class ApplicationFilterTest method test.

@Test
public void test() throws Exception {
    SSOToken userToken = AuthUtils.authenticate("/", USER1, USER1);
    Subject userSubject = SubjectUtils.createSubject(userToken);
    Set<SearchFilter> filters = new HashSet<SearchFilter>();
    filters.add(new SearchFilter(Application.NAME_SEARCH_ATTRIBUTE, "ApplicationFilterTes*"));
    Set<String> names = ApplicationManager.search(userSubject, "/", filters);
    if (names.isEmpty()) {
        throw new Exception("ApplicationFilterTest.test: expect to return one entry");
    }
    filters.clear();
    filters.add(new SearchFilter(Application.NAME_SEARCH_ATTRIBUTE, "4rwrwr*"));
    names = ApplicationManager.search(userSubject, "/", filters);
    if (!names.isEmpty()) {
        throw new Exception("ApplicationFilterTest.test: expect to return no entries");
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SearchFilter(com.sun.identity.entitlement.util.SearchFilter) Subject(javax.security.auth.Subject) OpenSSOUserSubject(com.sun.identity.entitlement.opensso.OpenSSOUserSubject) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 18 with SSOToken

use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.

the class AdminOnlyAuthzModuleTest method shouldAuthorizeValidContext.

@Test
public void shouldAuthorizeValidContext() throws Exception {
    //given
    SSOTokenContext mockSSOTokenContext = mock(SSOTokenContext.class);
    SSOToken mockSSOToken = mock(SSOToken.class);
    given(mockSSOTokenContext.getCallerSSOToken()).willReturn(mockSSOToken);
    given(mockSSOToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("test");
    given(mockService.isSuperUser("test")).willReturn(true);
    //when
    Promise<AuthorizationResult, ResourceException> result = testModule.authorize(mockSSOTokenContext);
    //then
    assertTrue(result.get().isAuthorized());
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) ResourceException(org.forgerock.json.resource.ResourceException) AuthorizationResult(org.forgerock.authz.filter.api.AuthorizationResult) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 19 with SSOToken

use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.

the class AdminOnlyAuthzModuleTest method shouldFailNonSuperUser.

@Test
public void shouldFailNonSuperUser() throws Exception {
    //given
    SSOTokenContext mockSSOTokenContext = mock(SSOTokenContext.class);
    SSOToken mockSSOToken = mock(SSOToken.class);
    given(mockSSOTokenContext.getCallerSSOToken()).willReturn(mockSSOToken);
    given(mockSSOToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("test");
    given(mockService.isSuperUser("test")).willReturn(false);
    //when
    Promise<AuthorizationResult, ResourceException> result = testModule.authorize(mockSSOTokenContext);
    //then
    assertFalse(result.get().isAuthorized());
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) ResourceException(org.forgerock.json.resource.ResourceException) AuthorizationResult(org.forgerock.authz.filter.api.AuthorizationResult) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 20 with SSOToken

use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.

the class SpecialOrAdminOrAgentAuthzModuleTest method shouldAuthorizeAdmin.

@Test
public void shouldAuthorizeAdmin() throws Exception {
    //given
    SSOTokenContext mockSSOTokenContext = mock(SSOTokenContext.class);
    SSOToken mockSSOToken = mock(SSOToken.class);
    Principal principal = mock(Principal.class);
    given(mockSSOToken.getPrincipal()).willReturn(principal);
    given(mockSSOTokenContext.getCallerSSOToken()).willReturn(mockSSOToken);
    given(mockSSOToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("test");
    given(mockAgentIdentity.isAgent(mockSSOToken)).willReturn(false);
    given(mockSpecialUserIdentity.isSpecialUser(mockSSOToken)).willReturn(false);
    given(mockService.isSuperUser("test")).willReturn(true);
    //when
    Promise<AuthorizationResult, ResourceException> result = testModule.authorize(mockSSOTokenContext);
    //then
    assertTrue(result.get().isAuthorized());
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) ResourceException(org.forgerock.json.resource.ResourceException) AuthorizationResult(org.forgerock.authz.filter.api.AuthorizationResult) Principal(java.security.Principal) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

SSOToken (com.iplanet.sso.SSOToken)776 SSOException (com.iplanet.sso.SSOException)390 Set (java.util.Set)226 SMSException (com.sun.identity.sm.SMSException)218 HashSet (java.util.HashSet)179 IdRepoException (com.sun.identity.idm.IdRepoException)144 HashMap (java.util.HashMap)130 Test (org.testng.annotations.Test)130 CLIException (com.sun.identity.cli.CLIException)117 Iterator (java.util.Iterator)115 AMIdentity (com.sun.identity.idm.AMIdentity)113 Map (java.util.Map)113 IOutput (com.sun.identity.cli.IOutput)99 IOException (java.io.IOException)68 List (java.util.List)57 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)56 IdType (com.sun.identity.idm.IdType)54 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)53 EntitlementException (com.sun.identity.entitlement.EntitlementException)52 ServiceConfig (com.sun.identity.sm.ServiceConfig)52