Search in sources :

Example 1 with ResourceOwnerSessionValidator

use of org.forgerock.oauth2.core.ResourceOwnerSessionValidator in project OpenAM by OpenRock.

the class AuthorizationServiceImplTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    requestValidator = mock(AuthorizeRequestValidator.class);
    List<AuthorizeRequestValidator> requestValidators = new ArrayList<AuthorizeRequestValidator>();
    requestValidators.add(requestValidator);
    resourceOwnerSessionValidator = mock(ResourceOwnerSessionValidator.class);
    OAuth2ProviderSettingsFactory providerSettingsFactory = mock(OAuth2ProviderSettingsFactory.class);
    resourceOwnerConsentVerifier = mock(ResourceOwnerConsentVerifier.class);
    clientRegistrationStore = mock(ClientRegistrationStore.class);
    tokenIssuer = mock(AuthorizationTokenIssuer.class);
    ClientAuthenticationFailureFactory failureFactory = mock(ClientAuthenticationFailureFactory.class);
    authorizationService = new AuthorizationServiceImpl(requestValidators, resourceOwnerSessionValidator, providerSettingsFactory, resourceOwnerConsentVerifier, clientRegistrationStore, tokenIssuer, failureFactory);
    providerSettings = mock(OAuth2ProviderSettings.class);
    given(providerSettingsFactory.get(Matchers.<OAuth2Request>anyObject())).willReturn(providerSettings);
}
Also used : ArrayList(java.util.ArrayList) ClientAuthenticationFailureFactory(org.forgerock.oauth2.core.exceptions.ClientAuthenticationFailureFactory) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with ResourceOwnerSessionValidator

use of org.forgerock.oauth2.core.ResourceOwnerSessionValidator in project OpenAM by OpenRock.

the class OpenAMResourceOwnerSessionValidatorTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    mockSSOTokenManager = mock(SSOTokenManager.class);
    mockProviderSettingsFactory = mock(OAuth2ProviderSettingsFactory.class);
    providerSettings = mock(OAuth2ProviderSettings.class);
    mockOAuth2Request = mock(OAuth2Request.class);
    restletRequest = new Request();
    mockHttpServletRequest = mock(HttpServletRequest.class);
    CoreGuiceModule.DNWrapper dnWrapper = mock(CoreGuiceModule.DNWrapper.class);
    OpenAMClientDAO mockClientDAO = mock(OpenAMClientDAO.class);
    ClientCredentialsReader mockClientCredentialsReader = mock(ClientCredentialsReader.class);
    given(mockOAuth2Request.getRequest()).willReturn(restletRequest);
    given(mockHttpServletRequest.getRequestURI()).willReturn("/openam/oauth2/authorize");
    given(mockHttpServletRequest.getScheme()).willReturn("http");
    given(mockHttpServletRequest.getServerName()).willReturn("openam.example.com");
    given(mockHttpServletRequest.getServerPort()).willReturn(8080);
    given(ACTIVE_SESSION_TOKEN.getProperty("Organization")).willReturn("/");
    given(mockProviderSettingsFactory.get(any(OAuth2Request.class))).willReturn(providerSettings);
    resourceOwnerSessionValidator = new OpenAMResourceOwnerSessionValidator(dnWrapper, mockSSOTokenManager, mockProviderSettingsFactory, mockClientDAO, mockClientCredentialsReader) {

        @Override
        HttpServletRequest getHttpServletRequest(Request req) {
            return mockHttpServletRequest;
        }
    };
    when(dnWrapper.orgNameToDN("/")).thenReturn("/");
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) HttpServletRequest(javax.servlet.http.HttpServletRequest) OAuth2Request(org.forgerock.oauth2.core.OAuth2Request) OAuth2ProviderSettingsFactory(org.forgerock.oauth2.core.OAuth2ProviderSettingsFactory) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.restlet.Request) OAuth2Request(org.forgerock.oauth2.core.OAuth2Request) CoreGuiceModule(org.forgerock.openam.core.guice.CoreGuiceModule) OAuth2ProviderSettings(org.forgerock.oauth2.core.OAuth2ProviderSettings) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

BeforeMethod (org.testng.annotations.BeforeMethod)2 SSOTokenManager (com.iplanet.sso.SSOTokenManager)1 ArrayList (java.util.ArrayList)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 OAuth2ProviderSettings (org.forgerock.oauth2.core.OAuth2ProviderSettings)1 OAuth2ProviderSettingsFactory (org.forgerock.oauth2.core.OAuth2ProviderSettingsFactory)1 OAuth2Request (org.forgerock.oauth2.core.OAuth2Request)1 ClientAuthenticationFailureFactory (org.forgerock.oauth2.core.exceptions.ClientAuthenticationFailureFactory)1 CoreGuiceModule (org.forgerock.openam.core.guice.CoreGuiceModule)1 Request (org.restlet.Request)1