commit | author | age
|
7f7e0c
|
1 |
package org.keycloak.protocol.cas.mappers; |
MP |
2 |
|
89e3d7
|
3 |
import org.keycloak.models.ClientSessionContext; |
MP |
4 |
import org.keycloak.models.KeycloakSession; |
513246
|
5 |
import org.keycloak.models.ProtocolMapperModel; |
MP |
6 |
import org.keycloak.models.UserSessionModel; |
7f7e0c
|
7 |
import org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper; |
MP |
8 |
import org.keycloak.provider.ProviderConfigProperty; |
|
9 |
|
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.List; |
513246
|
12 |
import java.util.Map; |
MP |
13 |
|
|
14 |
import static org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME; |
7f7e0c
|
15 |
|
MP |
16 |
public class HardcodedClaim extends AbstractCASProtocolMapper { |
|
17 |
private static final List<ProviderConfigProperty> configProperties = new ArrayList<ProviderConfigProperty>(); |
|
18 |
|
|
19 |
public static final String CLAIM_VALUE = "claim.value"; |
|
20 |
|
|
21 |
static { |
|
22 |
OIDCAttributeMapperHelper.addTokenClaimNameConfig(configProperties); |
|
23 |
|
|
24 |
ProviderConfigProperty property = new ProviderConfigProperty(); |
|
25 |
property.setName(CLAIM_VALUE); |
|
26 |
property.setLabel("Claim value"); |
|
27 |
property.setType(ProviderConfigProperty.STRING_TYPE); |
|
28 |
property.setHelpText("Value of the claim you want to hard code. 'true' and 'false can be used for boolean values."); |
|
29 |
configProperties.add(property); |
|
30 |
|
|
31 |
OIDCAttributeMapperHelper.addJsonTypeConfig(configProperties); |
|
32 |
} |
|
33 |
|
|
34 |
public static final String PROVIDER_ID = "cas-hardcoded-claim-mapper"; |
|
35 |
|
|
36 |
|
|
37 |
@Override |
|
38 |
public List<ProviderConfigProperty> getConfigProperties() { |
|
39 |
return configProperties; |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public String getId() { |
|
44 |
return PROVIDER_ID; |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public String getDisplayType() { |
|
49 |
return "Hardcoded claim"; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public String getHelpText() { |
|
54 |
return "Hardcode a claim into the token."; |
|
55 |
} |
|
56 |
|
513246
|
57 |
@Override |
89e3d7
|
58 |
public void setAttribute(Map<String, Object> attributes, ProtocolMapperModel mappingModel, UserSessionModel userSession, |
MP |
59 |
KeycloakSession session, ClientSessionContext clientSessionCt) { |
0ad1a9
|
60 |
setMappedAttribute(attributes, mappingModel, mappingModel.getConfig().get(CLAIM_VALUE)); |
513246
|
61 |
} |
MP |
62 |
|
7f7e0c
|
63 |
} |