commit | author | age
|
7f7e0c
|
1 |
package org.keycloak.protocol.cas.mappers; |
MP |
2 |
|
|
3 |
import org.keycloak.Config; |
|
4 |
import org.keycloak.models.KeycloakSession; |
|
5 |
import org.keycloak.models.KeycloakSessionFactory; |
0ad1a9
|
6 |
import org.keycloak.models.ProtocolMapperModel; |
7f7e0c
|
7 |
import org.keycloak.protocol.ProtocolMapper; |
MP |
8 |
import org.keycloak.protocol.cas.CASLoginProtocol; |
0ad1a9
|
9 |
import org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper; |
MP |
10 |
|
|
11 |
import java.util.Map; |
7f7e0c
|
12 |
|
513246
|
13 |
public abstract class AbstractCASProtocolMapper implements ProtocolMapper, CASAttributeMapper { |
7f7e0c
|
14 |
public static final String TOKEN_MAPPER_CATEGORY = "Token mapper"; |
MP |
15 |
|
|
16 |
@Override |
|
17 |
public String getProtocol() { |
|
18 |
return CASLoginProtocol.LOGIN_PROTOCOL; |
|
19 |
} |
|
20 |
|
|
21 |
@Override |
|
22 |
public void close() { |
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
public final ProtocolMapper create(KeycloakSession session) { |
|
27 |
throw new RuntimeException("UNSUPPORTED METHOD"); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public void init(Config.Scope config) { |
|
32 |
} |
|
33 |
|
|
34 |
@Override |
|
35 |
public void postInit(KeycloakSessionFactory factory) { |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public String getDisplayCategory() { |
|
40 |
return TOKEN_MAPPER_CATEGORY; |
|
41 |
} |
0ad1a9
|
42 |
|
MP |
43 |
protected void setMappedAttribute(Map<String, Object> attributes, ProtocolMapperModel mappingModel, Object attributeValue) { |
|
44 |
setPlainAttribute(attributes, mappingModel, OIDCAttributeMapperHelper.mapAttributeValue(mappingModel, attributeValue)); |
|
45 |
} |
|
46 |
|
|
47 |
protected void setPlainAttribute(Map<String, Object> attributes, ProtocolMapperModel mappingModel, Object attributeValue) { |
|
48 |
String protocolClaim = mappingModel.getConfig().get(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME); |
|
49 |
if (protocolClaim == null || attributeValue == null) { |
|
50 |
return; |
|
51 |
} |
|
52 |
attributes.put(protocolClaim, attributeValue); |
|
53 |
} |
7f7e0c
|
54 |
} |