Class UserRealmRoleMappingMapper
- java.lang.Object
- 
- org.keycloak.protocol.oidc.mappers.AbstractOIDCProtocolMapper
- 
- org.keycloak.protocol.oidc.mappers.UserRealmRoleMappingMapper
 
 
- 
- All Implemented Interfaces:
- OIDCAccessTokenMapper,- OIDCIDTokenMapper,- UserInfoTokenMapper,- ProtocolMapper,- ConfiguredProvider,- Provider,- ProviderFactory<ProtocolMapper>
 
 public class UserRealmRoleMappingMapper extends AbstractOIDCProtocolMapper Allows mapping of user realm role mappings to an ID and Access Token claim.- Author:
- Thomas Darimont
 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringPROVIDER_ID- 
Fields inherited from class org.keycloak.protocol.oidc.mappers.AbstractOIDCProtocolMapperTOKEN_MAPPER_CATEGORY
 
- 
 - 
Constructor SummaryConstructors Constructor Description UserRealmRoleMappingMapper()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ProtocolMapperModelcreate(String realmRolePrefix, String name, String tokenClaimName, boolean accessToken, boolean idToken)static ProtocolMapperModelcreate(String realmRolePrefix, String name, String tokenClaimName, boolean accessToken, boolean idToken, boolean multiValued)List<ProviderConfigProperty>getConfigProperties()StringgetDisplayCategory()StringgetDisplayType()StringgetHelpText()StringgetId()intgetPriority()Priority of this protocolMapper implementation.protected static voidsetClaim(IDToken token, ProtocolMapperModel mappingModel, Set<String> rolesToAdd, String clientId, String prefix)Retrieves all roles of the current user based on direct roles set to the user, its groups and their parent groups.protected voidsetClaim(IDToken token, ProtocolMapperModel mappingModel, UserSessionModel userSession, KeycloakSession session, ClientSessionContext clientSessionCtx)Intended to be overridden inProtocolMapperimplementations to add claims to an token.- 
Methods inherited from class org.keycloak.protocol.oidc.mappers.AbstractOIDCProtocolMapperclose, create, getProtocol, init, postInit, setClaim, setClaim, transformAccessToken, transformAccessTokenResponse, transformIDToken, transformUserInfoToken
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.provider.ConfiguredProvidergetConfig
 - 
Methods inherited from interface org.keycloak.protocol.oidc.mappers.OIDCAccessTokenMappertransformAccessToken
 - 
Methods inherited from interface org.keycloak.protocol.oidc.mappers.OIDCIDTokenMappertransformIDToken
 - 
Methods inherited from interface org.keycloak.protocol.ProtocolMappervalidateConfig
 - 
Methods inherited from interface org.keycloak.provider.ProviderFactorygetConfigMetadata, order
 - 
Methods inherited from interface org.keycloak.protocol.oidc.mappers.UserInfoTokenMappertransformUserInfoToken
 
- 
 
- 
- 
- 
Field Detail- 
PROVIDER_IDpublic static final String PROVIDER_ID - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getConfigPropertiespublic List<ProviderConfigProperty> getConfigProperties() 
 - 
getIdpublic String getId() 
 - 
getDisplayTypepublic String getDisplayType() 
 - 
getDisplayCategorypublic String getDisplayCategory() 
 - 
getHelpTextpublic String getHelpText() 
 - 
setClaimprotected void setClaim(IDToken token, ProtocolMapperModel mappingModel, UserSessionModel userSession, KeycloakSession session, ClientSessionContext clientSessionCtx) Description copied from class:AbstractOIDCProtocolMapperIntended to be overridden inProtocolMapperimplementations to add claims to an token.- Overrides:
- setClaimin class- AbstractOIDCProtocolMapper
 
 - 
createpublic static ProtocolMapperModel create(String realmRolePrefix, String name, String tokenClaimName, boolean accessToken, boolean idToken) 
 - 
createpublic static ProtocolMapperModel create(String realmRolePrefix, String name, String tokenClaimName, boolean accessToken, boolean idToken, boolean multiValued) 
 - 
getPrioritypublic int getPriority() Description copied from interface:ProtocolMapperPriority of this protocolMapper implementation. Lower goes first.- Specified by:
- getPriorityin interface- ProtocolMapper
- Returns:
 
 - 
setClaimprotected static void setClaim(IDToken token, ProtocolMapperModel mappingModel, Set<String> rolesToAdd, String clientId, String prefix) Retrieves all roles of the current user based on direct roles set to the user, its groups and their parent groups. Then it recursively expands all composite roles, and restricts according to the given predicaterestriction. If the current client sessions is restricted (i.e. no client found in active user session has full scope allowed), the final list of roles is also restricted by the client scope. Finally, the list is mapped to the token into a claim.- Parameters:
- token-
- mappingModel-
- rolesToAdd-
- clientId-
- prefix-
 
 
- 
 
-