Search in sources :

Example 1 with JacksonRepresentationFactory

use of org.forgerock.openam.rest.representations.JacksonRepresentationFactory in project OpenAM by OpenRock.

the class ResourceSetRegistrationExceptionFilterTest method setup.

@BeforeMethod
public void setup() {
    Restlet next = mock(Restlet.class);
    JacksonRepresentationFactory jacksonRepresentationFactory = new JacksonRepresentationFactory(new ObjectMapper());
    exceptionFilter = new ResourceSetRegistrationExceptionFilter(next, jacksonRepresentationFactory);
}
Also used : Restlet(org.restlet.Restlet) JacksonRepresentationFactory(org.forgerock.openam.rest.representations.JacksonRepresentationFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with JacksonRepresentationFactory

use of org.forgerock.openam.rest.representations.JacksonRepresentationFactory 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 JacksonRepresentationFactory

use of org.forgerock.openam.rest.representations.JacksonRepresentationFactory in project OpenAM by OpenRock.

the class RestletOAuth2RequestTest method theSetUp.

@BeforeMethod
private void theSetUp() {
    //you need this
    request = new Request();
    Reference reference = new Reference("http://127.0.0.1:8080/test");
    request.setResourceRef(reference);
    request.setMethod(Method.POST);
    JacksonRepresentationFactory jacksonRepresentationFactory = new JacksonRepresentationFactory(new ObjectMapper());
    requestUnderTest = new RestletOAuth2Request(jacksonRepresentationFactory, request);
}
Also used : Reference(org.restlet.data.Reference) JacksonRepresentationFactory(org.forgerock.openam.rest.representations.JacksonRepresentationFactory) Request(org.restlet.Request) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with JacksonRepresentationFactory

use of org.forgerock.openam.rest.representations.JacksonRepresentationFactory in project OpenAM by OpenRock.

the class TokenEndpointResourceTest method setUp.

@BeforeClass
@SuppressWarnings("unchecked")
public void setUp() {
    JacksonRepresentationFactory jacksonRepresentationFactory = new JacksonRepresentationFactory(new ObjectMapper());
    requestFactory = mock(OAuth2RequestFactory.class);
    accessTokenService = mock(AccessTokenService.class);
    OAuth2Representation representation = new OAuth2Representation(null);
    exceptionHandler = new ExceptionHandler(representation, null, null, jacksonRepresentationFactory);
    hook = mock(TokenRequestHook.class);
    tokenEndpointResource = new TokenEndpointResource(requestFactory, accessTokenService, exceptionHandler, CollectionUtils.asSet(hook), jacksonRepresentationFactory);
}
Also used : OAuth2RequestFactory(org.forgerock.oauth2.core.OAuth2RequestFactory) AccessTokenService(org.forgerock.oauth2.core.AccessTokenService) JacksonRepresentationFactory(org.forgerock.openam.rest.representations.JacksonRepresentationFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

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