Class AbstractUserProfileProvider<U extends UserProfileProvider>
- All Implemented Interfaces:
Provider
,ProviderFactory<U>
,UserProfileProvider
,UserProfileProviderFactory<U>
- Direct Known Subclasses:
DeclarativeUserProfileProvider
A base class for UserProfileProvider
implementations providing the main hooks for customizations.
- Author:
- Markus Till
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
protected final Map<UserProfileContext,
UserProfileMetadata> static final String
protected final KeycloakSession
-
Constructor Summary
ConstructorDescriptionAbstractUserProfileProvider
(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> contextualMetadataRegistry) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
This is called when the server shuts down.protected UserProfileMetadata
configureUserProfile
(UserProfileMetadata metadata) Sub-types can override this method to customize how contextual profile metadata is configured at init time.protected UserProfileMetadata
configureUserProfile
(UserProfileMetadata metadata, KeycloakSession session) Sub-types can override this method to customize how contextual profile metadata is configured at runtime.create
(KeycloakSession session) protected abstract U
create
(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> metadataRegistry) Subclasses can override this method to create their instances ofUserProfileProvider
.create
(UserProfileContext context, Map<String, ?> attributes) create
(UserProfileContext context, Map<String, ?> attributes, UserModel user) create
(UserProfileContext context, UserModel user) Creates a newUserProfile
instance only for validation purposes to check whether its attributes are in conformance with the givencontext
and profile configuration.protected Attributes
createAttributes
(UserProfileContext context, Map<String, ?> attributes, UserModel user, UserProfileMetadata metadata) Returns the metadata for each configuration property supported by this factory.Get current UserProfile configuration.static Pattern
getRegexPatternString
(String[] builtinReadOnlyAttributes) void
init
(Config.Scope config) Only called once when the factory is first created.void
postInit
(KeycloakSessionFactory factory) Called after all provider factories have been initializedvoid
setConfiguration
(String configuration) Set new UserProfile configuration.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.ProviderFactory
getId, order
Methods inherited from interface org.keycloak.userprofile.UserProfileProvider
isEnabled
-
Field Details
-
CONFIG_ADMIN_READ_ONLY_ATTRIBUTES
- See Also:
-
CONFIG_READ_ONLY_ATTRIBUTES
- See Also:
-
MAX_EMAIL_LOCAL_PART_LENGTH
- See Also:
-
contextualMetadataRegistry
-
session
-
-
Constructor Details
-
AbstractUserProfileProvider
public AbstractUserProfileProvider() -
AbstractUserProfileProvider
public AbstractUserProfileProvider(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> contextualMetadataRegistry)
-
-
Method Details
-
getRegexPatternString
-
create
Description copied from interface:UserProfileProvider
Creates a new
UserProfile
instance only for validation purposes to check whether its attributes are in conformance with the givencontext
and profile configuration.- Specified by:
create
in interfaceUserProfileProvider
- Parameters:
context
- the contextuser
- an existing user- Returns:
- the user profile instance
-
create
Description copied from interface:UserProfileProvider
Creates a new
UserProfile
instance for a givencontext
andattributes
for 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:
create
in interfaceUserProfileProvider
- Parameters:
context
- the contextattributes
- the attributes to associate with the instance returned from this methoduser
- the user to eventually update with the givenattributes
- Returns:
- the user profile instance
-
create
Description copied from interface:UserProfileProvider
Creates a new
UserProfile
instance for a givencontext
andattributes
for 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:
create
in interfaceUserProfileProvider
- Parameters:
context
- the contextattributes
- the attributes to associate with the instance returned from this method- Returns:
- the user profile instance
-
create
- Specified by:
create
in interfaceProviderFactory<U extends UserProfileProvider>
-
init
Description copied from interface:ProviderFactory
Only called once when the factory is first created. This config is pulled from keycloak_server.json- Specified by:
init
in interfaceProviderFactory<U extends UserProfileProvider>
-
postInit
Description copied from interface:ProviderFactory
Called after all provider factories have been initialized- Specified by:
postInit
in interfaceProviderFactory<U extends UserProfileProvider>
-
close
public void close()Description copied from interface:ProviderFactory
This is called when the server shuts down.- Specified by:
close
in interfaceProvider
- Specified by:
close
in interfaceProviderFactory<U extends UserProfileProvider>
-
getConfiguration
Description copied from interface:UserProfileProvider
Get current UserProfile configuration. JSON formatted file is expected, but depends on the implementation.- Specified by:
getConfiguration
in interfaceUserProfileProvider
- Returns:
- current UserProfile configuration
- See Also:
-
setConfiguration
Description copied from interface:UserProfileProvider
Set new UserProfile configuration. It is persisted inside of the provider.- Specified by:
setConfiguration
in interfaceUserProfileProvider
- Parameters:
configuration
- to be set- See Also:
-
create
protected abstract U create(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> metadataRegistry) Subclasses can override this method to create their instances ofUserProfileProvider
.- Parameters:
session
- the sessionmetadataRegistry
- the profile metadata- Returns:
- the profile provider instance
-
configureUserProfile
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
-
configureUserProfile
protected 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 metadatasession
- the current session- Returns:
- the metadata
-
createAttributes
protected Attributes createAttributes(UserProfileContext context, Map<String, ?> attributes, UserModel user, UserProfileMetadata metadata) -
getConfigMetadata
Description copied from interface:ProviderFactory
Returns the metadata for each configuration property supported by this factory.- Specified by:
getConfigMetadata
in interfaceProviderFactory<U extends UserProfileProvider>
- Returns:
- a list with the metadata for each configuration property supported by this factory
-