Search in sources :

Example 1 with ClientAuthenticationFailureFactory

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

the class OpenAMClientRegistrationTest method setup.

@BeforeMethod
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    ClientAuthenticationFailureFactory failureFactory = mock(ClientAuthenticationFailureFactory.class);
    clientRegistration = new OpenAMClientRegistration(amIdentity, new PEMDecoder(), resolver, providerSettings, failureFactory);
}
Also used : PEMDecoder(org.forgerock.oauth2.core.PEMDecoder) ClientAuthenticationFailureFactory(org.forgerock.oauth2.core.exceptions.ClientAuthenticationFailureFactory) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with ClientAuthenticationFailureFactory

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

the class OpenAMTokenStoreTest method setUp.

@BeforeMethod
public void setUp() {
    tokenStore = mock(OAuthTokenStore.class);
    providerSettingsFactory = mock(OAuth2ProviderSettingsFactory.class);
    oAuth2UrisFactory = mock(OAuth2UrisFactory.class);
    clientRegistrationStore = mock(OpenIdConnectClientRegistrationStore.class);
    realmNormaliser = mock(RealmNormaliser.class);
    ssoTokenManager = mock(SSOTokenManager.class);
    request = mock(Request.class);
    cookieExtractor = mock(CookieExtractor.class);
    auditLogger = mock(OAuth2AuditLogger.class);
    debug = mock(Debug.class);
    failureFactory = mock(ClientAuthenticationFailureFactory.class);
    oAuth2RequestFactory = new RestletOAuth2RequestFactory(new JacksonRepresentationFactory(new ObjectMapper()));
    ClientAuthenticationFailureFactory failureFactory = mock(ClientAuthenticationFailureFactory.class);
    InvalidClientException expectedResult = mock(InvalidClientException.class);
    when(expectedResult.getError()).thenReturn(new String("invalid_client"));
    when(failureFactory.getException()).thenReturn(expectedResult);
    when(failureFactory.getException(anyString())).thenReturn(expectedResult);
    when(failureFactory.getException(any(OAuth2Request.class), anyString())).thenReturn(expectedResult);
    openAMtokenStore = new OpenAMTokenStore(tokenStore, providerSettingsFactory, oAuth2UrisFactory, clientRegistrationStore, realmNormaliser, ssoTokenManager, cookieExtractor, auditLogger, debug, new SecureRandom(), failureFactory);
}
Also used : OAuth2UrisFactory(org.forgerock.oauth2.core.OAuth2UrisFactory) SSOTokenManager(com.iplanet.sso.SSOTokenManager) JacksonRepresentationFactory(org.forgerock.openam.rest.representations.JacksonRepresentationFactory) RestletOAuth2Request(org.forgerock.oauth2.restlet.RestletOAuth2Request) Request(org.restlet.Request) OAuth2Request(org.forgerock.oauth2.core.OAuth2Request) SecureRandom(java.security.SecureRandom) BDDMockito.anyString(org.mockito.BDDMockito.anyString) OpenIdConnectClientRegistrationStore(org.forgerock.openidconnect.OpenIdConnectClientRegistrationStore) ClientAuthenticationFailureFactory(org.forgerock.oauth2.core.exceptions.ClientAuthenticationFailureFactory) RealmNormaliser(org.forgerock.openam.utils.RealmNormaliser) RestletOAuth2Request(org.forgerock.oauth2.restlet.RestletOAuth2Request) OAuth2Request(org.forgerock.oauth2.core.OAuth2Request) OAuth2ProviderSettingsFactory(org.forgerock.oauth2.core.OAuth2ProviderSettingsFactory) InvalidClientException(org.forgerock.oauth2.core.exceptions.InvalidClientException) RestletOAuth2RequestFactory(org.forgerock.oauth2.restlet.RestletOAuth2RequestFactory) Debug(com.sun.identity.shared.debug.Debug) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with ClientAuthenticationFailureFactory

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

the class SubjectTypeValidatorTest method setUp.

@BeforeTest
public void setUp() {
    ClientAuthenticationFailureFactory failureFactory = mock(ClientAuthenticationFailureFactory.class);
    when(failureFactory.getException()).thenReturn(mock(InvalidClientException.class));
    when(failureFactory.getException(anyString())).thenReturn(mock(InvalidClientException.class));
    when(failureFactory.getException(any(OAuth2Request.class), anyString())).thenReturn(mock(InvalidClientException.class));
    this.mockProviderSettingsFactory = mock(OAuth2ProviderSettingsFactory.class);
    this.mockClientRegistrationStore = mock(OpenIdConnectClientRegistrationStore.class);
    this.subjectTypeValidator = new SubjectTypeValidator(mockProviderSettingsFactory, mockClientRegistrationStore, failureFactory);
}
Also used : OAuth2Request(org.forgerock.oauth2.core.OAuth2Request) OAuth2ProviderSettingsFactory(org.forgerock.oauth2.core.OAuth2ProviderSettingsFactory) InvalidClientException(org.forgerock.oauth2.core.exceptions.InvalidClientException) ClientAuthenticationFailureFactory(org.forgerock.oauth2.core.exceptions.ClientAuthenticationFailureFactory) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with ClientAuthenticationFailureFactory

use of org.forgerock.oauth2.core.exceptions.ClientAuthenticationFailureFactory 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 5 with ClientAuthenticationFailureFactory

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

the class DeviceCodeGrantTypeHandlerTest method setup.

@BeforeMethod
public void setup() throws Exception {
    initMocks(this);
    OAuth2ProviderSettingsFactory providerSettingsFactory = mock(OAuth2ProviderSettingsFactory.class);
    when(providerSettingsFactory.get(request)).thenReturn(providerSettings);
    when(providerSettings.getDeviceCodePollInterval()).thenReturn(5);
    when(providerSettings.validateRequestedClaims(anyString())).thenAnswer(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            return (String) invocation.getArguments()[0];
        }
    });
    OAuth2UrisFactory oAuth2UrisFactory = mock(OAuth2UrisFactory.class);
    when(oAuth2UrisFactory.get(request)).thenReturn(oAuth2Uris);
    ClientAuthenticator clientAuthenticator = mock(ClientAuthenticator.class);
    ClientRegistration clientRegistration = mock(ClientRegistration.class);
    when(clientAuthenticator.authenticate(eq(request), anyString())).thenReturn(clientRegistration);
    accessTokenGenerator = new GrantTypeAccessTokenGenerator(tokenStore);
    when(tokenStore.createAccessToken(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anySetOf(String.class), any(RefreshToken.class), anyString(), anyString(), any(OAuth2Request.class))).thenReturn(accessToken);
    when(tokenStore.createRefreshToken(anyString(), anyString(), anyString(), anyString(), anySetOf(String.class), any(OAuth2Request.class), anyString())).thenReturn(refreshToken);
    ClientAuthenticationFailureFactory failureFactory = mock(ClientAuthenticationFailureFactory.class);
    InvalidClientException expectedResult = mock(InvalidClientException.class);
    when(expectedResult.getError()).thenReturn("invalid_client");
    when(failureFactory.getException()).thenReturn(expectedResult);
    when(failureFactory.getException(anyString())).thenReturn(expectedResult);
    when(failureFactory.getException(any(OAuth2Request.class), anyString())).thenReturn(expectedResult);
    grantTypeHandler = new DeviceCodeGrantTypeHandler(providerSettingsFactory, clientAuthenticator, tokenStore, clientRegistrationStore, failureFactory, oAuth2UrisFactory, accessTokenGenerator);
}
Also used : ClientAuthenticationFailureFactory(org.forgerock.oauth2.core.exceptions.ClientAuthenticationFailureFactory) InvocationOnMock(org.mockito.invocation.InvocationOnMock) InvalidClientException(org.forgerock.oauth2.core.exceptions.InvalidClientException) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

ClientAuthenticationFailureFactory (org.forgerock.oauth2.core.exceptions.ClientAuthenticationFailureFactory)5 BeforeMethod (org.testng.annotations.BeforeMethod)4 InvalidClientException (org.forgerock.oauth2.core.exceptions.InvalidClientException)3 OAuth2ProviderSettingsFactory (org.forgerock.oauth2.core.OAuth2ProviderSettingsFactory)2 OAuth2Request (org.forgerock.oauth2.core.OAuth2Request)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SSOTokenManager (com.iplanet.sso.SSOTokenManager)1 Debug (com.sun.identity.shared.debug.Debug)1 SecureRandom (java.security.SecureRandom)1 ArrayList (java.util.ArrayList)1 OAuth2UrisFactory (org.forgerock.oauth2.core.OAuth2UrisFactory)1 PEMDecoder (org.forgerock.oauth2.core.PEMDecoder)1 RestletOAuth2Request (org.forgerock.oauth2.restlet.RestletOAuth2Request)1 RestletOAuth2RequestFactory (org.forgerock.oauth2.restlet.RestletOAuth2RequestFactory)1 JacksonRepresentationFactory (org.forgerock.openam.rest.representations.JacksonRepresentationFactory)1 RealmNormaliser (org.forgerock.openam.utils.RealmNormaliser)1 OpenIdConnectClientRegistrationStore (org.forgerock.openidconnect.OpenIdConnectClientRegistrationStore)1 BDDMockito.anyString (org.mockito.BDDMockito.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Request (org.restlet.Request)1