use of org.forgerock.oauth2.core.ClientRegistrationStore in project OpenAM by OpenRock.
the class OpenAMTokenStoreTest method realmAgnosticTokenStoreShouldIgnoreRealmMismatch.
@Test
public void realmAgnosticTokenStoreShouldIgnoreRealmMismatch() throws Exception {
//Given
OpenAMTokenStore realmAgnosticTokenStore = new OAuth2GuiceModule.RealmAgnosticTokenStore(tokenStore, providerSettingsFactory, oAuth2UrisFactory, clientRegistrationStore, realmNormaliser, ssoTokenManager, cookieExtractor, auditLogger, debug, new SecureRandom(), failureFactory);
JsonValue token = json(object(field("tokenName", Collections.singleton("access_token")), field("realm", Collections.singleton("/otherrealm"))));
given(tokenStore.read("TOKEN_ID")).willReturn(token);
ConcurrentHashMap<String, Object> attributes = new ConcurrentHashMap<String, Object>();
given(request.getAttributes()).willReturn(attributes);
attributes.put("realm", "/testrealm");
OAuth2Request request = oAuth2RequestFactory.create(this.request);
//When
AccessToken accessToken = realmAgnosticTokenStore.readAccessToken(request, "TOKEN_ID");
//Then
assertThat(accessToken).isNotNull();
assertThat(request.getToken(AccessToken.class)).isSameAs(accessToken);
}
use of org.forgerock.oauth2.core.ClientRegistrationStore in project OpenAM by OpenRock.
the class OpenIdConnectAuthorizeRequestValidatorTest method setUp.
@BeforeMethod
public void setUp() throws InvalidClientException, NotFoundException {
ClientRegistrationStore clientRegistrationStore = mock(ClientRegistrationStore.class);
clientRegistration = mock(ClientRegistration.class);
given(clientRegistrationStore.get(anyString(), Matchers.<OAuth2Request>anyObject())).willReturn(clientRegistration);
requestValidator = new OpenIdConnectAuthorizeRequestValidator(clientRegistrationStore);
}
use of org.forgerock.oauth2.core.ClientRegistrationStore in project OpenAM by OpenRock.
the class OpenAMScopeValidatorTest method setup.
@BeforeMethod
public void setup() throws Exception {
client = mock(ClientRegistration.class);
request = mock(OAuth2Request.class);
providerSettings = mock(OAuth2ProviderSettings.class);
clientRegistrationStore = mock(OpenIdConnectClientRegistrationStore.class);
OAuth2ProviderSettingsFactory factory = mock(OAuth2ProviderSettingsFactory.class);
when(factory.get(request)).thenReturn(providerSettings);
ScriptEvaluator scriptEvaluator = mock(ScriptEvaluator.class);
IdentityManager identityManager = mock(IdentityManager.class);
identity = mock(AMIdentity.class);
when(identityManager.getResourceOwnerIdentity(anyString(), anyString())).thenReturn(identity);
validator = new OpenAMScopeValidator(identityManager, null, factory, null, scriptEvaluator, clientRegistrationStore, null);
}
use of org.forgerock.oauth2.core.ClientRegistrationStore 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);
}
use of org.forgerock.oauth2.core.ClientRegistrationStore in project OpenAM by OpenRock.
the class IdTokenClaimGathererTest method mockClientRegistrationStore.
private ClientRegistrationStore mockClientRegistrationStore() throws InvalidClientException, NotFoundException {
ClientRegistrationStore clientRegistrationStore = mock(ClientRegistrationStore.class);
given(clientRegistrationStore.get("CLIENT_ID", oAuth2Request)).willReturn(clientRegistration);
given(clientRegistration.getClientSecret()).willReturn("CLIENT_SECRET");
return clientRegistrationStore;
}
Aggregations