Search in sources :

Example 11 with OAuth2Uris

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

the class OpenAMOAuth2UrisFactory method get.

@Override
public OAuth2Uris get(HttpServletRequest request, RealmInfo realmInfo) throws NotFoundException, ServerException {
    String absoluteRealm = realmInfo.getAbsoluteRealm();
    BaseURLProvider baseURLProvider = baseURLProviderFactory.get(absoluteRealm);
    String baseUrl;
    try {
        baseUrl = baseURLProvider.getRealmURL(request, "/oauth2", absoluteRealm);
    } catch (InvalidBaseUrlException e) {
        throw new ServerException("Configuration error");
    }
    return get(absoluteRealm, baseUrl);
}
Also used : ServerException(org.forgerock.oauth2.core.exceptions.ServerException) InvalidBaseUrlException(org.forgerock.openam.services.baseurl.InvalidBaseUrlException) BaseURLProvider(org.forgerock.openam.services.baseurl.BaseURLProvider)

Example 12 with OAuth2Uris

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

the class OpenAMResourceSetStoreTest method setup.

@BeforeMethod
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    dataStore = mock(TokenDataStore.class);
    OAuth2ProviderSettingsFactory providerSettingsFactory = mock(OAuth2ProviderSettingsFactory.class);
    OAuth2UrisFactory<RealmInfo> oAuth2UrisFactory = mock(OAuth2UrisFactory.class);
    OAuth2Uris oAuth2Uris = mock(OAuth2Uris.class);
    TokenIdGenerator idGenerator = mock(TokenIdGenerator.class);
    store = new OpenAMResourceSetStore("REALM", providerSettingsFactory, oAuth2UrisFactory, idGenerator, dataStore);
    given(oAuth2UrisFactory.get(Matchers.<OAuth2Request>anyObject())).willReturn(oAuth2Uris);
    given(oAuth2Uris.getResourceSetRegistrationPolicyEndpoint(anyString())).willReturn("POLICY_URI");
}
Also used : TokenDataStore(org.forgerock.openam.sm.datalayer.store.TokenDataStore) RealmInfo(org.forgerock.openam.core.RealmInfo) TokenIdGenerator(org.forgerock.openam.cts.api.tokens.TokenIdGenerator) OAuth2ProviderSettingsFactory(org.forgerock.oauth2.core.OAuth2ProviderSettingsFactory) OAuth2Uris(org.forgerock.oauth2.core.OAuth2Uris) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

OAuth2Uris (org.forgerock.oauth2.core.OAuth2Uris)9 OAuth2ProviderSettings (org.forgerock.oauth2.core.OAuth2ProviderSettings)6 ServerException (org.forgerock.oauth2.core.exceptions.ServerException)6 InvalidBaseUrlException (org.forgerock.openam.services.baseurl.InvalidBaseUrlException)4 BeforeMethod (org.testng.annotations.BeforeMethod)3 KeyPair (java.security.KeyPair)2 HashMap (java.util.HashMap)2 JsonValue (org.forgerock.json.JsonValue)2 OAuth2ProviderSettingsFactory (org.forgerock.oauth2.core.OAuth2ProviderSettingsFactory)2 OAuth2Request (org.forgerock.oauth2.core.OAuth2Request)2 InvalidClientException (org.forgerock.oauth2.core.exceptions.InvalidClientException)2 NotFoundException (org.forgerock.oauth2.core.exceptions.NotFoundException)2 RealmInfo (org.forgerock.openam.core.RealmInfo)2 BaseURLProvider (org.forgerock.openam.services.baseurl.BaseURLProvider)2 UmaPendingRequest (org.forgerock.openam.sm.datalayer.impl.uma.UmaPendingRequest)2 Request (org.restlet.Request)2 Evaluator (com.sun.identity.entitlement.Evaluator)1 AMIdentity (com.sun.identity.idm.AMIdentity)1 Subject (javax.security.auth.Subject)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1