Package org.keycloak.broker.oidc.mappers
Class AbstractJsonUserAttributeMapper
java.lang.Object
org.keycloak.broker.provider.AbstractIdentityProviderMapper
org.keycloak.broker.oidc.mappers.AbstractJsonUserAttributeMapper
- All Implemented Interfaces:
IdentityProviderMapper
,ConfiguredProvider
,Provider
,ProviderFactory<IdentityProviderMapper>
- Direct Known Subclasses:
FacebookUserAttributeMapper
,GitHubUserAttributeMapper
,GoogleUserAttributeMapper
,InstagramUserAttributeMapper
,LinkedInUserAttributeMapper
,MicrosoftUserAttributeMapper
,OpenshiftV4AttributeMapper
,PayPalUserAttributeMapper
,StackoverflowUserAttributeMapper
Abstract class for Social Provider mappers which allow mapping of JSON user profile field into Keycloak user
attribute. Concrete mapper classes with own ID and provider mapping must be implemented for each social provider who
uses
JsonNode
user profile.- Author:
- Vlastimil Elias (velias at redhat dot com)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Config param where name of mapping source JSON User Profile field is stored.static final String
Config param where name of mapping target USer attribute is stored.static final String
Key inBrokeredIdentityContext.getContextData()
whereJsonNode
with user profile is stored.protected static final org.jboss.logging.Logger
protected static final org.jboss.logging.Logger
Fields inherited from interface org.keycloak.broker.provider.IdentityProviderMapper
ANY_PROVIDER, DEFAULT_IDENTITY_PROVIDER_MAPPER_SYNC_MODES
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
getJsonValue
(com.fasterxml.jackson.databind.JsonNode baseNode, String fieldPath) protected static Object
getJsonValue
(IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context) void
preprocessFederatedIdentity
(KeycloakSession session, RealmModel realm, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context) Called to determine what keycloak username and email to use to process the login request from the external IDP.static void
storeUserProfileForMapper
(BrokeredIdentityContext user, com.fasterxml.jackson.databind.JsonNode profile, String provider) Store used profile JsonNode into user context for later use by this mapper.boolean
supportsSyncMode
(IdentityProviderSyncMode syncMode) void
updateBrokeredUser
(KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context) Called when this user has logged in before and has already been imported.void
updateBrokeredUserLegacy
(KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context) Called when this user has logged in before and has already been imported.Methods inherited from class org.keycloak.broker.provider.AbstractIdentityProviderMapper
close, create, importNewUser, init, postInit
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.keycloak.provider.ConfiguredProvider
getConfig
Methods inherited from interface org.keycloak.broker.provider.IdentityProviderMapper
getCompatibleProviders
Methods inherited from interface org.keycloak.provider.ProviderFactory
getConfigMetadata, getId, order
-
Field Details
-
logger
protected static final org.jboss.logging.Logger logger -
LOGGER_DUMP_USER_PROFILE
protected static final org.jboss.logging.Logger LOGGER_DUMP_USER_PROFILE -
CONF_JSON_FIELD
Config param where name of mapping source JSON User Profile field is stored.- See Also:
-
CONF_USER_ATTRIBUTE
Config param where name of mapping target USer attribute is stored.- See Also:
-
CONTEXT_JSON_NODE
Key inBrokeredIdentityContext.getContextData()
whereJsonNode
with user profile is stored.- See Also:
-
-
Constructor Details
-
AbstractJsonUserAttributeMapper
public AbstractJsonUserAttributeMapper()
-
-
Method Details
-
storeUserProfileForMapper
public static void storeUserProfileForMapper(BrokeredIdentityContext user, com.fasterxml.jackson.databind.JsonNode profile, String provider) Store used profile JsonNode into user context for later use by this mapper. Profile data are dumped into special logger if enabled also to allow investigation of the structure.- Parameters:
user
- context to store profile data intoprofile
- to store into contextprovider
- identification of social provider to be used in log dump- See Also:
-
supportsSyncMode
-
getConfigProperties
-
getDisplayCategory
-
getDisplayType
-
getHelpText
-
preprocessFederatedIdentity
public void preprocessFederatedIdentity(KeycloakSession session, RealmModel realm, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context) Description copied from interface:IdentityProviderMapper
Called to determine what keycloak username and email to use to process the login request from the external IDP. It's called before "FirstBrokerLogin" flow, so can be used to map attributes to BrokeredIdentityContext ( BrokeredIdentityContext.setUserAttribute ), which will be available on "Review Profile" page and in authenticators during FirstBrokerLogin flow- Specified by:
preprocessFederatedIdentity
in interfaceIdentityProviderMapper
- Overrides:
preprocessFederatedIdentity
in classAbstractIdentityProviderMapper
-
updateBrokeredUserLegacy
public void updateBrokeredUserLegacy(KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context) Description copied from interface:IdentityProviderMapper
Called when this user has logged in before and has already been imported. Legacy behaviour. When updating the mapper to correctly update brokered users in all sync modes, move the old behavior into this method.- Specified by:
updateBrokeredUserLegacy
in interfaceIdentityProviderMapper
- Overrides:
updateBrokeredUserLegacy
in classAbstractIdentityProviderMapper
-
updateBrokeredUser
public void updateBrokeredUser(KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context) Description copied from interface:IdentityProviderMapper
Called when this user has logged in before and has already been imported.- Specified by:
updateBrokeredUser
in interfaceIdentityProviderMapper
- Overrides:
updateBrokeredUser
in classAbstractIdentityProviderMapper
-
getJsonValue
protected static Object getJsonValue(IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context) -
getJsonValue
-