use of org.forgerock.openam.oauth2.legacy.LegacyAccessTokenAdapter in project OpenAM by OpenRock.
the class TokenResponseType method createToken.
public CoreToken createToken(Token accessToken, Map<String, Object> data) throws NotFoundException {
final String tokenType = (String) data.get(OAuth2Constants.CoreTokenParams.TOKEN_TYPE);
final Set<String> scope = (Set<String>) data.get(OAuth2Constants.CoreTokenParams.SCOPE);
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 redirectUri = (String) data.get(OAuth2Constants.CoreTokenParams.REDIRECT_URI);
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(tokenType, scope, resourceOwner, clientId, redirectUri, null, requestFactory.create(Request.getCurrent()), codeChallenge, codeChallengeMethod);
return new LegacyAccessTokenAdapter((AccessToken) tokenEntry.getValue());
} catch (ServerException e) {
throw OAuthProblemException.OAuthError.SERVER_ERROR.handle(Request.getCurrent(), e.getMessage());
}
}
Aggregations