Search in sources :

Example 21 with ClientRegistration

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

the class EndSession method validateRedirect.

private void validateRedirect(OAuth2Request request, String idToken, String redirectUri) throws InvalidClientException, RedirectUriMismatchException, RelativeRedirectUriException, NotFoundException {
    SignedJwt jwt = new JwtReconstruction().reconstructJwt(idToken, SignedJwt.class);
    JwtClaimsSet claims = jwt.getClaimsSet();
    String clientId = (String) claims.getClaim(OAuth2Constants.JWTTokenParams.AZP);
    ClientRegistration client = clientRegistrationStore.get(clientId, request);
    URI requestedUri = URI.create(redirectUri);
    if (!requestedUri.isAbsolute()) {
        throw new RelativeRedirectUriException();
    }
    if (!client.getPostLogoutRedirectUris().contains(requestedUri)) {
        throw new RedirectUriMismatchException();
    }
}
Also used : RelativeRedirectUriException(org.forgerock.oauth2.core.exceptions.RelativeRedirectUriException) JwtClaimsSet(org.forgerock.json.jose.jwt.JwtClaimsSet) JwtReconstruction(org.forgerock.json.jose.common.JwtReconstruction) ClientRegistration(org.forgerock.oauth2.core.ClientRegistration) RedirectUriMismatchException(org.forgerock.oauth2.core.exceptions.RedirectUriMismatchException) SignedJwt(org.forgerock.json.jose.jws.SignedJwt) URI(java.net.URI)

Aggregations

ClientRegistration (org.forgerock.oauth2.core.ClientRegistration)11 OAuth2ProviderSettings (org.forgerock.oauth2.core.OAuth2ProviderSettings)9 ServerException (org.forgerock.oauth2.core.exceptions.ServerException)6 OpenIdConnectClientRegistration (org.forgerock.openidconnect.OpenIdConnectClientRegistration)6 JsonValue (org.forgerock.json.JsonValue)4 Locale (java.util.Locale)3 SignedJwt (org.forgerock.json.jose.jws.SignedJwt)3 InvalidClientException (org.forgerock.oauth2.core.exceptions.InvalidClientException)3 NotFoundException (org.forgerock.oauth2.core.exceptions.NotFoundException)3 UnauthorizedClientException (org.forgerock.oauth2.core.exceptions.UnauthorizedClientException)3 CoreTokenException (org.forgerock.openam.cts.exceptions.CoreTokenException)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 SSOToken (com.iplanet.sso.SSOToken)2 HashMap (java.util.HashMap)2 AccessToken (org.forgerock.oauth2.core.AccessToken)2 ClientRegistrationStore (org.forgerock.oauth2.core.ClientRegistrationStore)2 ClientAuthenticationFailureFactory (org.forgerock.oauth2.core.exceptions.ClientAuthenticationFailureFactory)2 InvalidRequestException (org.forgerock.oauth2.core.exceptions.InvalidRequestException)2 AMHashMap (com.iplanet.am.sdk.AMHashMap)1 SSOException (com.iplanet.sso.SSOException)1