From 2e3b4dea824af204c49ee3310896faf6d107a8c8 Mon Sep 17 00:00:00 2001 From: Matthias Piepkorn <mpiepk@gmail.com> Date: Fri, 27 Jan 2017 22:53:54 +0000 Subject: [PATCH] Fix .gitignore, add .gitattributes --- src/main/java/org/keycloak/protocol/cas/mappers/UserAttributeMapper.java | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/src/main/java/org/keycloak/protocol/cas/mappers/UserAttributeMapper.java b/src/main/java/org/keycloak/protocol/cas/mappers/UserAttributeMapper.java index 5206126..3637069 100644 --- a/src/main/java/org/keycloak/protocol/cas/mappers/UserAttributeMapper.java +++ b/src/main/java/org/keycloak/protocol/cas/mappers/UserAttributeMapper.java @@ -1,6 +1,9 @@ package org.keycloak.protocol.cas.mappers; import org.keycloak.models.ProtocolMapperModel; +import org.keycloak.models.UserModel; +import org.keycloak.models.UserSessionModel; +import org.keycloak.models.utils.KeycloakModelUtils; import org.keycloak.protocol.ProtocolMapperUtils; import org.keycloak.protocol.cas.CASLoginProtocol; import org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper; @@ -60,6 +63,19 @@ return "Map a custom user attribute to a token claim."; } + @Override + public void setAttribute(Map<String, Object> attributes, ProtocolMapperModel mappingModel, UserSessionModel userSession) { + UserModel user = userSession.getUser(); + String protocolClaim = mappingModel.getConfig().get(TOKEN_CLAIM_NAME); + if (protocolClaim == null) { + return; + } + String attributeName = mappingModel.getConfig().get(ProtocolMapperUtils.USER_ATTRIBUTE); + List<String> attributeValue = KeycloakModelUtils.resolveAttribute(user, attributeName); + if (attributeValue == null) return; + attributes.put(protocolClaim, OIDCAttributeMapperHelper.mapAttributeValue(mappingModel, attributeValue)); + } + public static ProtocolMapperModel create(String name, String userAttribute, String tokenClaimName, String claimType, boolean consentRequired, String consentText, boolean multivalued) { -- Gitblit v1.9.1