Search in sources :

Example 1 with LegacyJwtTokenAdapter

use of org.forgerock.openam.oauth2.legacy.LegacyJwtTokenAdapter in project OpenAM by OpenRock.

the class IDTokenResponseType method createToken.

public CoreToken createToken(org.forgerock.oauth2.core.Token accessToken, Map<String, Object> data) throws NotFoundException {
    final OAuth2Request request = requestFactory.create(Request.getCurrent());
    final ResourceOwner resourceOwner = ownerAuthenticator.authenticate(request, true);
    final String clientId = (String) data.get(OAuth2Constants.CoreTokenParams.CLIENT_ID);
    final String nonce = (String) data.get(OAuth2Constants.Custom.NONCE);
    final String codeChallenge = (String) data.get(OAuth2Constants.Custom.CODE_CHALLENGE);
    final String codeChallengeMethod = (String) data.get(OAuth2Constants.Custom.CODE_CHALLENGE_METHOD);
    try {
        final Map.Entry<String, Token> tokenEntry = handler.handle(null, null, resourceOwner, clientId, null, nonce, request, codeChallenge, codeChallengeMethod);
        return new LegacyJwtTokenAdapter((OpenIdConnectToken) tokenEntry.getValue());
    } catch (InvalidClientException e) {
        throw OAuthProblemException.OAuthError.INVALID_CLIENT.handle(Request.getCurrent(), e.getMessage());
    } catch (ServerException e) {
        throw OAuthProblemException.OAuthError.SERVER_ERROR.handle(Request.getCurrent(), e.getMessage());
    }
}
Also used : OAuth2Request(org.forgerock.oauth2.core.OAuth2Request) ServerException(org.forgerock.oauth2.core.exceptions.ServerException) ResourceOwner(org.forgerock.oauth2.core.ResourceOwner) InvalidClientException(org.forgerock.oauth2.core.exceptions.InvalidClientException) Token(org.forgerock.oauth2.core.Token) CoreToken(org.forgerock.openam.oauth2.legacy.CoreToken) OpenIdConnectToken(org.forgerock.openidconnect.OpenIdConnectToken) Map(java.util.Map) LegacyJwtTokenAdapter(org.forgerock.openam.oauth2.legacy.LegacyJwtTokenAdapter)

Aggregations

Map (java.util.Map)1 OAuth2Request (org.forgerock.oauth2.core.OAuth2Request)1 ResourceOwner (org.forgerock.oauth2.core.ResourceOwner)1 Token (org.forgerock.oauth2.core.Token)1 InvalidClientException (org.forgerock.oauth2.core.exceptions.InvalidClientException)1 ServerException (org.forgerock.oauth2.core.exceptions.ServerException)1 CoreToken (org.forgerock.openam.oauth2.legacy.CoreToken)1 LegacyJwtTokenAdapter (org.forgerock.openam.oauth2.legacy.LegacyJwtTokenAdapter)1 OpenIdConnectToken (org.forgerock.openidconnect.OpenIdConnectToken)1