/** {@inheritDoc} */ public void updateAuthorizationCode(AuthorizationCode authorizationCode) { deleteAuthorizationCode(authorizationCode.getTokenId()); // Store in CTS try { tokenStore.create(authorizationCode); if (auditLogger.isAuditLogEnabled()) { String[] obs = {"UPDATED_AUTHORIZATION_CODE", authorizationCode.toString()}; auditLogger.logAccessMessage("CREATED_AUTHORIZATION_CODE", obs, null); } } catch (CoreTokenException e) { if (auditLogger.isAuditLogEnabled()) { String[] obs = {"FAILED_UPDATE_AUTHORIZATION_CODE", authorizationCode.toString()}; auditLogger.logErrorMessage("FAILED_UPDATE_AUTHORIZATION_CODE", obs, null); } logger.error( "DefaultOAuthTokenStoreImpl::Unable to create authorization code " + authorizationCode.getTokenInfo(), e); throw new OAuthProblemException( Status.SERVER_ERROR_INTERNAL.getCode(), "Internal error", "Could not create token in CTS", null); } }
/** For c_hash, used when code and id_token exist in scope. */ private String generateCHash( String algorithm, OAuth2Request request, OAuth2ProviderSettings providerSettings) throws ServerException { final AuthorizationCode authorizationCode = request.getToken(AuthorizationCode.class); if (authorizationCode == null) { logger.message("c_hash generation requires an existing code."); return null; } final String codeValue = authorizationCode.getTokenId(); return generateHash(algorithm, codeValue, providerSettings); }