From 97fc5ea8d44b25210560c6251a2786e96a9a4e0c Mon Sep 17 00:00:00 2001
From: matthiasp <matthias.piepkorn@proxora.com>
Date: Mon, 18 Sep 2017 12:50:54 +0000
Subject: [PATCH] add Keycloak 3.3.0.CR2 test environment

---
 src/main/java/org/keycloak/protocol/cas/mappers/AbstractCASProtocolMapper.java |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/src/main/java/org/keycloak/protocol/cas/mappers/AbstractCASProtocolMapper.java b/src/main/java/org/keycloak/protocol/cas/mappers/AbstractCASProtocolMapper.java
index 8c61a4e..6838f6d 100644
--- a/src/main/java/org/keycloak/protocol/cas/mappers/AbstractCASProtocolMapper.java
+++ b/src/main/java/org/keycloak/protocol/cas/mappers/AbstractCASProtocolMapper.java
@@ -3,10 +3,14 @@
 import org.keycloak.Config;
 import org.keycloak.models.KeycloakSession;
 import org.keycloak.models.KeycloakSessionFactory;
+import org.keycloak.models.ProtocolMapperModel;
 import org.keycloak.protocol.ProtocolMapper;
 import org.keycloak.protocol.cas.CASLoginProtocol;
+import org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper;
 
-public abstract class AbstractCASProtocolMapper implements ProtocolMapper {
+import java.util.Map;
+
+public abstract class AbstractCASProtocolMapper implements ProtocolMapper, CASAttributeMapper {
     public static final String TOKEN_MAPPER_CATEGORY = "Token mapper";
 
     @Override
@@ -35,4 +39,16 @@
     public String getDisplayCategory() {
         return TOKEN_MAPPER_CATEGORY;
     }
+
+    protected void setMappedAttribute(Map<String, Object> attributes, ProtocolMapperModel mappingModel, Object attributeValue) {
+        setPlainAttribute(attributes, mappingModel, OIDCAttributeMapperHelper.mapAttributeValue(mappingModel, attributeValue));
+    }
+
+    protected void setPlainAttribute(Map<String, Object> attributes, ProtocolMapperModel mappingModel, Object attributeValue) {
+        String protocolClaim = mappingModel.getConfig().get(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME);
+        if (protocolClaim == null || attributeValue == null) {
+            return;
+        }
+        attributes.put(protocolClaim, attributeValue);
+    }
 }

--
Gitblit v1.9.1