Package org.keycloak.userprofile
Class DeclarativeUserProfileProvider
java.lang.Object
org.keycloak.userprofile.DeclarativeUserProfileProvider
- All Implemented Interfaces:
Provider
,UserProfileProvider
UserProfileProvider
loading configuration from the changeable JSON file stored in component config. Parsed
configuration is cached.- Author:
- Pedro Igor, Vlastimil Elias <velias@redhat.com>
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDeclarativeUserProfileProvider
(KeycloakSession session, DeclarativeUserProfileProviderFactory factory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected UserProfileMetadata
configureUserProfile
(UserProfileMetadata metadata, KeycloakSession session) Specifies how contextual profile metadata is configured at runtime.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) protected ComponentModel
Create the component model to store configurationprotected AttributeValidatorMetadata
createConfiguredValidator
(String validator, Map<String, Object> validatorConfig) Create validator for validation configured in the user profile config.protected UserProfileMetadata
decorateUserProfileForCache
(UserProfileMetadata decoratedMetadata, UPConfig parsedConfig) Decorate basic metadata based on 'per realm' configuration.Get current UserProfile configuration.protected UPConfig
parseConfigOrDefault
(ComponentModel component) Get parsed config file configured in model.void
setConfiguration
(UPConfig configuration) Set new UserProfile configuration.
-
Field Details
-
UP_COMPONENT_CONFIG_KEY
- See Also:
-
PARSED_CONFIG_COMPONENT_KEY
- See Also:
-
PARSED_UP_CONFIG_COMPONENT_KEY
- See Also:
-
parsedDefaultRawConfig
-
-
Constructor Details
-
DeclarativeUserProfileProvider
public DeclarativeUserProfileProvider(KeycloakSession session, DeclarativeUserProfileProviderFactory factory)
-
-
Method Details
-
createAttributes
protected Attributes createAttributes(UserProfileContext context, Map<String, ?> attributes, UserModel user, UserProfileMetadata metadata) -
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
-
configureUserProfile
protected UserProfileMetadata configureUserProfile(UserProfileMetadata metadata, KeycloakSession session) Specifies how contextual profile metadata is configured at runtime.- Parameters:
metadata
- the profile metadata- Returns:
- the metadata
-
getConfiguration
Description copied from interface:UserProfileProvider
Get current UserProfile configuration.- 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. It can be null and in this case, userProfile implementation will switch to use the default configuration- See Also:
-
decorateUserProfileForCache
protected UserProfileMetadata decorateUserProfileForCache(UserProfileMetadata decoratedMetadata, UPConfig parsedConfig) Decorate basic metadata based on 'per realm' configuration. This method is called for eachUserProfileContext
in each realm, and metadata are cached then and this method is called again only if configuration changes. -
parseConfigOrDefault
Get parsed config file configured in model. Default one used if not configured. -
createComponentModel
Create the component model to store configuration- Returns:
- component model
-
createConfiguredValidator
protected AttributeValidatorMetadata createConfiguredValidator(String validator, Map<String, Object> validatorConfig) Create validator for validation configured in the user profile config.- Parameters:
validator
- id to create validator forvalidatorConfig
- of the validator- Returns:
- validator metadata to run given validation
-
close
public void close()
-