From bcfe985c24821a4ba878c87fbdedada4abc45ddf Mon Sep 17 00:00:00 2001 From: vramik Date: Fri, 4 Dec 2020 10:45:09 +0100 Subject: [PATCH] KEYCLOAK-16543 fix compilation failure on keycloak-services --- .../org/keycloak/protocol/oidc/TokenManager.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/services/src/main/java/org/keycloak/protocol/oidc/TokenManager.java b/services/src/main/java/org/keycloak/protocol/oidc/TokenManager.java index 95e7116a0692..27dbcdcaa101 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/TokenManager.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/TokenManager.java @@ -634,15 +634,13 @@ public AccessToken transformAccessToken(KeycloakSession session, AccessToken tok public AccessTokenResponse transformAccessTokenResponse(KeycloakSession session, AccessTokenResponse accessTokenResponse, UserSessionModel userSession, ClientSessionContext clientSessionCtx) { - for (Map.Entry entry : ProtocolMapperUtils.getSortedProtocolMappers(session, clientSessionCtx)) { - ProtocolMapperModel mapping = entry.getKey(); - ProtocolMapper mapper = entry.getValue(); - if (mapper instanceof OIDCAccessTokenResponseMapper) { - accessTokenResponse = ((OIDCAccessTokenResponseMapper) mapper).transformAccessTokenResponse(accessTokenResponse, mapping, session, userSession, clientSessionCtx); - } - } + AtomicReference finalResponseToken = new AtomicReference<>(accessTokenResponse); + ProtocolMapperUtils.getSortedProtocolMappers(session, clientSessionCtx) + .filter(mapper -> mapper.getValue() instanceof OIDCAccessTokenResponseMapper) + .forEach(mapper -> finalResponseToken.set(((OIDCAccessTokenResponseMapper) mapper.getValue()) + .transformAccessTokenResponse(finalResponseToken.get(), mapper.getKey(), session, userSession, clientSessionCtx))); - return accessTokenResponse; + return finalResponseToken.get(); } public AccessToken transformUserInfoAccessToken(KeycloakSession session, AccessToken token,