Class AbstractUserProfileProvider<U extends UserProfileProvider>
- java.lang.Object
- 
- org.keycloak.userprofile.AbstractUserProfileProvider<U>
 
- 
- All Implemented Interfaces:
- Provider,- ProviderFactory<U>,- UserProfileProvider,- UserProfileProviderFactory<U>
 - Direct Known Subclasses:
- DeclarativeUserProfileProvider
 
 public abstract class AbstractUserProfileProvider<U extends UserProfileProvider> extends Object implements UserProfileProvider, UserProfileProviderFactory<U> A base class for UserProfileProviderimplementations providing the main hooks for customizations.- Author:
- Markus Till
 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringCONFIG_ADMIN_READ_ONLY_ATTRIBUTESstatic StringCONFIG_READ_ONLY_ATTRIBUTESprotected Map<UserProfileContext,UserProfileMetadata>contextualMetadataRegistryprotected KeycloakSessionsession
 - 
Constructor SummaryConstructors Constructor Description AbstractUserProfileProvider()AbstractUserProfileProvider(KeycloakSession session, Map<UserProfileContext,UserProfileMetadata> contextualMetadataRegistry)
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()This is called when the server shuts down.protected UserProfileMetadataconfigureUserProfile(UserProfileMetadata metadata)Sub-types can override this method to customize how contextual profile metadata is configured at init time.protected UserProfileMetadataconfigureUserProfile(UserProfileMetadata metadata, KeycloakSession session)Sub-types can override this method to customize how contextual profile metadata is configured at runtime.Ucreate(KeycloakSession session)protected abstract Ucreate(KeycloakSession session, Map<UserProfileContext,UserProfileMetadata> metadataRegistry)Subclasses can override this method to create their instances ofUserProfileProvider.UserProfilecreate(UserProfileContext context, Map<String,?> attributes)UserProfilecreate(UserProfileContext context, Map<String,?> attributes, UserModel user)UserProfilecreate(UserProfileContext context, UserModel user)Creates a newUserProfileinstance only for validation purposes to check whether its attributes are in conformance with the givencontextand profile configuration.protected AttributescreateAttributes(UserProfileContext context, Map<String,?> attributes, UserModel user, UserProfileMetadata metadata)List<ProviderConfigProperty>getConfigMetadata()Returns the metadata for each configuration property supported by this factory.StringgetConfiguration()Get current UserProfile configuration.static PatterngetRegexPatternString(String[] builtinReadOnlyAttributes)voidinit(Config.Scope config)Only called once when the factory is first created.voidpostInit(KeycloakSessionFactory factory)Called after all provider factories have been initializedvoidsetConfiguration(String configuration)Set new UserProfile configuration.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.provider.ProviderFactorygetId, order
 
- 
 
- 
- 
- 
Field Detail- 
CONFIG_ADMIN_READ_ONLY_ATTRIBUTESpublic static final String CONFIG_ADMIN_READ_ONLY_ATTRIBUTES - See Also:
- Constant Field Values
 
 - 
CONFIG_READ_ONLY_ATTRIBUTESpublic static final String CONFIG_READ_ONLY_ATTRIBUTES - See Also:
- Constant Field Values
 
 - 
contextualMetadataRegistryprotected final Map<UserProfileContext,UserProfileMetadata> contextualMetadataRegistry 
 - 
sessionprotected final KeycloakSession session 
 
- 
 - 
Constructor Detail- 
AbstractUserProfileProviderpublic AbstractUserProfileProvider() 
 - 
AbstractUserProfileProviderpublic AbstractUserProfileProvider(KeycloakSession session, Map<UserProfileContext,UserProfileMetadata> contextualMetadataRegistry) 
 
- 
 - 
Method Detail- 
getRegexPatternStringpublic static Pattern getRegexPatternString(String[] builtinReadOnlyAttributes) 
 - 
createpublic UserProfile create(UserProfileContext context, UserModel user) Description copied from interface:UserProfileProviderCreates a new UserProfileinstance only for validation purposes to check whether its attributes are in conformance with the givencontextand profile configuration.- Specified by:
- createin interface- UserProfileProvider
- Parameters:
- context- the context
- user- an existing user
- Returns:
- the user profile instance
 
 - 
createpublic UserProfile create(UserProfileContext context, Map<String,?> attributes, UserModel user) Description copied from interface:UserProfileProviderCreates a new UserProfileinstance for a givencontextandattributesfor update purposes.Instances created from this method are going to run validations and updates based on the given user. This might be useful when updating an existing user.- Specified by:
- createin interface- UserProfileProvider
- Parameters:
- context- the context
- attributes- the attributes to associate with the instance returned from this method
- user- the user to eventually update with the given- attributes
- Returns:
- the user profile instance
 
 - 
createpublic UserProfile create(UserProfileContext context, Map<String,?> attributes) Description copied from interface:UserProfileProviderCreates a new UserProfileinstance for a givencontextandattributesfor validation purposes.Instances created from this method are usually related to contexts where validation and updates are performed in different steps, or when creating new users based on the given attributes.- Specified by:
- createin interface- UserProfileProvider
- Parameters:
- context- the context
- attributes- the attributes to associate with the instance returned from this method
- Returns:
- the user profile instance
 
 - 
createpublic U create(KeycloakSession session) - Specified by:
- createin interface- ProviderFactory<U extends UserProfileProvider>
 
 - 
initpublic void init(Config.Scope config) Description copied from interface:ProviderFactoryOnly called once when the factory is first created. This config is pulled from keycloak_server.json- Specified by:
- initin interface- ProviderFactory<U extends UserProfileProvider>
 
 - 
postInitpublic void postInit(KeycloakSessionFactory factory) Description copied from interface:ProviderFactoryCalled after all provider factories have been initialized- Specified by:
- postInitin interface- ProviderFactory<U extends UserProfileProvider>
 
 - 
closepublic void close() Description copied from interface:ProviderFactoryThis is called when the server shuts down.- Specified by:
- closein interface- Provider
- Specified by:
- closein interface- ProviderFactory<U extends UserProfileProvider>
 
 - 
getConfigurationpublic String getConfiguration() Description copied from interface:UserProfileProviderGet current UserProfile configuration. JSON formatted file is expected, but depends on the implementation.- Specified by:
- getConfigurationin interface- UserProfileProvider
- Returns:
- current UserProfile configuration
- See Also:
- UserProfileProvider.setConfiguration(String)
 
 - 
setConfigurationpublic void setConfiguration(String configuration) Description copied from interface:UserProfileProviderSet new UserProfile configuration. It is persisted inside of the provider.- Specified by:
- setConfigurationin interface- UserProfileProvider
- Parameters:
- configuration- to be set
- See Also:
- UserProfileProvider.getConfiguration()
 
 - 
createprotected abstract U create(KeycloakSession session, Map<UserProfileContext,UserProfileMetadata> metadataRegistry) Subclasses can override this method to create their instances ofUserProfileProvider.- Parameters:
- session- the session
- metadataRegistry- the profile metadata
- Returns:
- the profile provider instance
 
 - 
configureUserProfileprotected UserProfileMetadata configureUserProfile(UserProfileMetadata metadata) Sub-types can override this method to customize how contextual profile metadata is configured at init time.- Parameters:
- metadata- the profile metadata
- Returns:
- the metadata
 
 - 
configureUserProfileprotected UserProfileMetadata configureUserProfile(UserProfileMetadata metadata, KeycloakSession session) Sub-types can override this method to customize how contextual profile metadata is configured at runtime.- Parameters:
- metadata- the profile metadata
- session- the current session
- Returns:
- the metadata
 
 - 
createAttributesprotected Attributes createAttributes(UserProfileContext context, Map<String,?> attributes, UserModel user, UserProfileMetadata metadata) 
 - 
getConfigMetadatapublic List<ProviderConfigProperty> getConfigMetadata() Description copied from interface:ProviderFactoryReturns the metadata for each configuration property supported by this factory.- Specified by:
- getConfigMetadatain interface- ProviderFactory<U extends UserProfileProvider>
- Returns:
- a list with the metadata for each configuration property supported by this factory
 
 
- 
 
-