Search in sources :

Example 1 with AuthUtilsWrapper

use of org.forgerock.openam.authentication.service.AuthUtilsWrapper in project OpenAM by OpenRock.

the class RestRouterIT method setupMocks.

@BeforeMethod
public void setupMocks() {
    MockitoAnnotations.initMocks(this);
    configResource = mock(SingletonResourceProvider.class);
    usersResource = mock(CollectionResourceProvider.class);
    internalResource = mock(CollectionResourceProvider.class);
    dashboardResource = spy(new DashboardResource());
    authenticateResource = spy(new AuthenticateResource());
    httpAccessAuditFilter = spy(new AbstractHttpAccessAuditFilter(AUTHENTICATION, mock(AuditEventPublisher.class), mock(AuditEventFactory.class)) {

        @Override
        protected String getRealm(Context context) {
            return null;
        }
    });
    auditEventPublisher = mock(AuditEventPublisher.class);
    auditServiceProvider = mock(AuditServiceProvider.class);
    versionBehaviourManager = mock(ResourceApiVersionBehaviourManager.class);
    ssoTokenManager = mock(SSOTokenManager.class);
    authUtilsWrapper = mock(AuthUtilsWrapper.class);
    coreWrapper = mock(CoreWrapper.class);
    SSOToken adminToken = mock(SSOToken.class);
    given(coreWrapper.getAdminToken()).willReturn(adminToken);
    given(coreWrapper.isValidFQDN(anyString())).willReturn(true);
    realmValidator = mock(RestRealmValidator.class);
}
Also used : RootContext(org.forgerock.services.context.RootContext) RequestAuditContext(org.forgerock.services.context.RequestAuditContext) HttpContext(org.forgerock.json.resource.http.HttpContext) SessionContext(org.forgerock.http.session.SessionContext) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) AttributesContext(org.forgerock.services.context.AttributesContext) SecurityContext(org.forgerock.services.context.SecurityContext) Context(org.forgerock.services.context.Context) SSOTokenManager(com.iplanet.sso.SSOTokenManager) CoreWrapper(org.forgerock.openam.core.CoreWrapper) AuditServiceProvider(org.forgerock.openam.audit.AuditServiceProvider) SSOToken(com.iplanet.sso.SSOToken) SingletonResourceProvider(org.forgerock.json.resource.SingletonResourceProvider) AuditEventPublisher(org.forgerock.openam.audit.AuditEventPublisher) CollectionResourceProvider(org.forgerock.json.resource.CollectionResourceProvider) AuthUtilsWrapper(org.forgerock.openam.authentication.service.AuthUtilsWrapper) AuditEventFactory(org.forgerock.openam.audit.AuditEventFactory) ResourceApiVersionBehaviourManager(org.forgerock.http.routing.ResourceApiVersionBehaviourManager) RestRealmValidator(org.forgerock.openam.rest.router.RestRealmValidator) AbstractHttpAccessAuditFilter(org.forgerock.openam.audit.AbstractHttpAccessAuditFilter) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with AuthUtilsWrapper

use of org.forgerock.openam.authentication.service.AuthUtilsWrapper in project OpenAM by OpenRock.

the class SessionResourceTest method setUp.

@BeforeMethod
public void setUp() throws IdRepoException, SSOException {
    SessionQueryManager sessionQueryManager = mock(SessionQueryManager.class);
    ssoTokenManager = mock(SSOTokenManager.class);
    authUtilsWrapper = mock(AuthUtilsWrapper.class);
    propertyWhitelist = mock(SessionPropertyWhitelist.class);
    headerResponse = null;
    urlResponse = null;
    cookieResponse = null;
    given(mockContext.getCallerSSOToken()).willReturn(ssoToken);
    realmContext = new RealmContext(mockContext);
    amIdentity = new AMIdentity(DN.valueOf("id=demo,dc=example,dc=com"), null);
    configureWhitelist();
    sessionResource = new SessionResource(sessionQueryManager, ssoTokenManager, authUtilsWrapper, propertyWhitelist) {

        @Override
        AMIdentity getIdentity(SSOToken ssoToken) throws IdRepoException, SSOException {
            return amIdentity;
        }

        @Override
        String convertDNToRealm(String dn) {
            return "/";
        }

        @Override
        protected String getTokenIdFromHeader(Context context, String cookieName) {
            return headerResponse;
        }

        @Override
        protected String getTokenIdFromUrlParam(ActionRequest request) {
            return urlResponse;
        }

        @Override
        protected String getTokenIdFromCookie(Context context, String cookieName) {
            return cookieResponse;
        }
    };
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) RootContext(org.forgerock.services.context.RootContext) ClientContext(org.forgerock.services.context.ClientContext) RealmContext(org.forgerock.openam.rest.RealmContext) SessionContext(org.forgerock.http.session.SessionContext) SSOTokenContext(org.forgerock.openam.rest.resource.SSOTokenContext) AttributesContext(org.forgerock.services.context.AttributesContext) SecurityContext(org.forgerock.services.context.SecurityContext) Context(org.forgerock.services.context.Context) SSOToken(com.iplanet.sso.SSOToken) RealmContext(org.forgerock.openam.rest.RealmContext) SessionResource(org.forgerock.openam.core.rest.session.SessionResource) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) SessionQueryManager(org.forgerock.openam.core.rest.session.query.SessionQueryManager) AuthUtilsWrapper(org.forgerock.openam.authentication.service.AuthUtilsWrapper) AMIdentity(com.sun.identity.idm.AMIdentity) SessionPropertyWhitelist(org.forgerock.openam.session.SessionPropertyWhitelist) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

SSOToken (com.iplanet.sso.SSOToken)2 SSOTokenManager (com.iplanet.sso.SSOTokenManager)2 SessionContext (org.forgerock.http.session.SessionContext)2 AuthUtilsWrapper (org.forgerock.openam.authentication.service.AuthUtilsWrapper)2 SSOTokenContext (org.forgerock.openam.rest.resource.SSOTokenContext)2 AttributesContext (org.forgerock.services.context.AttributesContext)2 Context (org.forgerock.services.context.Context)2 RootContext (org.forgerock.services.context.RootContext)2 SecurityContext (org.forgerock.services.context.SecurityContext)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 SSOException (com.iplanet.sso.SSOException)1 AMIdentity (com.sun.identity.idm.AMIdentity)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 ResourceApiVersionBehaviourManager (org.forgerock.http.routing.ResourceApiVersionBehaviourManager)1 CollectionResourceProvider (org.forgerock.json.resource.CollectionResourceProvider)1 SingletonResourceProvider (org.forgerock.json.resource.SingletonResourceProvider)1 HttpContext (org.forgerock.json.resource.http.HttpContext)1 AbstractHttpAccessAuditFilter (org.forgerock.openam.audit.AbstractHttpAccessAuditFilter)1 AuditEventFactory (org.forgerock.openam.audit.AuditEventFactory)1 AuditEventPublisher (org.forgerock.openam.audit.AuditEventPublisher)1