Search in sources :

Example 1 with BaseURLProvider

use of org.forgerock.openam.services.baseurl.BaseURLProvider in project OpenAM by OpenRock.

the class OpenAMOAuth2UrisFactory method get.

/**
     * Gets a OAuth2Uris instance.
     *
     * @param context TODO
     * @param realmInfo The realm information.
     * @return A UmaProviderSettings instance.
     */
@Override
public OAuth2Uris get(Context context, RealmInfo realmInfo) throws NotFoundException, ServerException {
    String absoluteRealm = realmInfo.getAbsoluteRealm();
    BaseURLProvider baseURLProvider = baseURLProviderFactory.get(absoluteRealm);
    String baseUrl;
    try {
        baseUrl = baseURLProvider.getRealmURL(context.asContext(HttpContext.class), "/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 2 with BaseURLProvider

use of org.forgerock.openam.services.baseurl.BaseURLProvider 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 3 with BaseURLProvider

use of org.forgerock.openam.services.baseurl.BaseURLProvider in project OpenAM by OpenRock.

the class DeviceCodeResourceTest method mockBaseUrlProvider.

private void mockBaseUrlProvider() {
    BaseURLProvider urlProvider = mock(BaseURLProvider.class);
    given(baseURLProviderFactory.get("REALM")).willReturn(urlProvider);
    given(urlProvider.getRootURL(any(HttpServletRequest.class))).willReturn("BASE_URL");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) BaseURLProvider(org.forgerock.openam.services.baseurl.BaseURLProvider)

Aggregations

BaseURLProvider (org.forgerock.openam.services.baseurl.BaseURLProvider)3 ServerException (org.forgerock.oauth2.core.exceptions.ServerException)2 InvalidBaseUrlException (org.forgerock.openam.services.baseurl.InvalidBaseUrlException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1