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
public abstract class AbstractJsonUserAttributeMapper extends AbstractIdentityProviderMapper
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 usesJsonNode
user profile.- Author:
- Vlastimil Elias (velias at redhat dot com)
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONF_JSON_FIELD
Config param where name of mapping source JSON User Profile field is stored.static String
CONF_USER_ATTRIBUTE
Config param where name of mapping target USer attribute is stored.static String
CONTEXT_JSON_NODE
Key inBrokeredIdentityContext.getContextData()
whereJsonNode
with user profile is stored.protected static org.jboss.logging.Logger
logger
protected static org.jboss.logging.Logger
LOGGER_DUMP_USER_PROFILE
-
Fields inherited from interface org.keycloak.broker.provider.IdentityProviderMapper
ANY_PROVIDER, DEFAULT_IDENTITY_PROVIDER_MAPPER_SYNC_MODES
-
-
Constructor Summary
Constructors Constructor Description AbstractJsonUserAttributeMapper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ProviderConfigProperty>
getConfigProperties()
String
getDisplayCategory()
String
getDisplayType()
String
getHelpText()
static 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 Detail
-
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
public static final String CONF_JSON_FIELD
Config param where name of mapping source JSON User Profile field is stored.- See Also:
- Constant Field Values
-
CONF_USER_ATTRIBUTE
public static final String CONF_USER_ATTRIBUTE
Config param where name of mapping target USer attribute is stored.- See Also:
- Constant Field Values
-
CONTEXT_JSON_NODE
public static final String CONTEXT_JSON_NODE
Key inBrokeredIdentityContext.getContextData()
whereJsonNode
with user profile is stored.- See Also:
- Constant Field Values
-
-
Method Detail
-
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:
preprocessFederatedIdentity(KeycloakSession, RealmModel, IdentityProviderMapperModel, BrokeredIdentityContext)
,BrokeredIdentityContext.getContextData()
-
supportsSyncMode
public boolean supportsSyncMode(IdentityProviderSyncMode syncMode)
-
getConfigProperties
public List<ProviderConfigProperty> getConfigProperties()
-
getDisplayCategory
public String getDisplayCategory()
-
getDisplayType
public String getDisplayType()
-
getHelpText
public String 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)
-
-