From 1482f2bf59b0e26b74f1e34631d5366e1abaff96 Mon Sep 17 00:00:00 2001 From: Doccrazy <Doccrazy@users.noreply.github.com> Date: Fri, 27 Jan 2017 23:44:12 +0000 Subject: [PATCH] Update README.md --- src/main/java/org/keycloak/protocol/cas/mappers/UserPropertyMapper.java | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/src/main/java/org/keycloak/protocol/cas/mappers/UserPropertyMapper.java b/src/main/java/org/keycloak/protocol/cas/mappers/UserPropertyMapper.java index 21cdeb6..057636d 100644 --- a/src/main/java/org/keycloak/protocol/cas/mappers/UserPropertyMapper.java +++ b/src/main/java/org/keycloak/protocol/cas/mappers/UserPropertyMapper.java @@ -1,6 +1,8 @@ package org.keycloak.protocol.cas.mappers; import org.keycloak.models.ProtocolMapperModel; +import org.keycloak.models.UserModel; +import org.keycloak.models.UserSessionModel; import org.keycloak.protocol.ProtocolMapperUtils; import org.keycloak.protocol.cas.CASLoginProtocol; import org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper; @@ -52,6 +54,18 @@ return "Map a built in user property (email, firstName, lastName) 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 propertyName = mappingModel.getConfig().get(ProtocolMapperUtils.USER_ATTRIBUTE); + String propertyValue = ProtocolMapperUtils.getUserModelValue(user, propertyName); + attributes.put(protocolClaim, OIDCAttributeMapperHelper.mapAttributeValue(mappingModel, propertyValue)); + } + public static ProtocolMapperModel create(String name, String userAttribute, String tokenClaimName, String claimType, boolean consentRequired, String consentText) { -- Gitblit v1.9.1