commit | author | age
|
7f7e0c
|
1 |
package org.keycloak.protocol.cas.mappers; |
MP |
2 |
|
|
3 |
import org.keycloak.models.ProtocolMapperModel; |
|
4 |
import org.keycloak.protocol.ProtocolMapperUtils; |
|
5 |
import org.keycloak.protocol.cas.CASLoginProtocol; |
|
6 |
import org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper; |
|
7 |
import org.keycloak.provider.ProviderConfigProperty; |
|
8 |
|
|
9 |
import java.util.ArrayList; |
|
10 |
import java.util.HashMap; |
|
11 |
import java.util.List; |
|
12 |
import java.util.Map; |
|
13 |
|
|
14 |
import static org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper.JSON_TYPE; |
|
15 |
import static org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME; |
|
16 |
|
|
17 |
public class FullNameMapper extends AbstractCASProtocolMapper { |
|
18 |
private static final List<ProviderConfigProperty> configProperties = new ArrayList<ProviderConfigProperty>(); |
|
19 |
|
|
20 |
static { |
|
21 |
OIDCAttributeMapperHelper.addTokenClaimNameConfig(configProperties); |
|
22 |
} |
|
23 |
|
|
24 |
public static final String PROVIDER_ID = "cas-full-name-mapper"; |
|
25 |
|
|
26 |
|
|
27 |
@Override |
|
28 |
public List<ProviderConfigProperty> getConfigProperties() { |
|
29 |
return configProperties; |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public String getId() { |
|
34 |
return PROVIDER_ID; |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public String getDisplayType() { |
|
39 |
return "User's full name"; |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public String getHelpText() { |
|
44 |
return "Maps the user's first and last name to the OpenID Connect 'name' claim. Format is <first> + ' ' + <last>"; |
|
45 |
} |
|
46 |
|
|
47 |
public static ProtocolMapperModel create(String name, String tokenClaimName, |
|
48 |
boolean consentRequired, String consentText) { |
|
49 |
ProtocolMapperModel mapper = new ProtocolMapperModel(); |
|
50 |
mapper.setName(name); |
|
51 |
mapper.setProtocolMapper(PROVIDER_ID); |
|
52 |
mapper.setProtocol(CASLoginProtocol.LOGIN_PROTOCOL); |
|
53 |
mapper.setConsentRequired(consentRequired); |
|
54 |
mapper.setConsentText(consentText); |
|
55 |
Map<String, String> config = new HashMap<String, String>(); |
|
56 |
config.put(TOKEN_CLAIM_NAME, tokenClaimName); |
|
57 |
mapper.setConfig(config); |
|
58 |
return mapper; |
|
59 |
} |
|
60 |
} |