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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDeclarativeUserProfileProvider(KeycloakSession session, DeclarativeUserProfileProviderFactory factory) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected UserProfileMetadataconfigureUserProfile(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 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) protected ComponentModelCreate the component model to store configurationprotected AttributeValidatorMetadatacreateConfiguredValidator(String validator, Map<String, Object> validatorConfig) Create validator for validation configured in the user profile config.protected UserProfileMetadatadecorateUserProfileForCache(UserProfileMetadata decoratedMetadata, UPConfig parsedConfig) Decorate basic metadata based on 'per realm' configuration.Get current UserProfile configuration.protected UPConfigparseConfigOrDefault(ComponentModel component) Get parsed config file configured in model.voidsetConfiguration(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:UserProfileProviderCreates a new
UserProfileinstance only for validation purposes to check whether its attributes are in conformance with the givencontextand profile configuration.- Specified by:
createin interfaceUserProfileProvider- Parameters:
context- the contextuser- an existing user- Returns:
- the user profile instance
-
create
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 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: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 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:UserProfileProviderGet current UserProfile configuration.- Specified by:
getConfigurationin interfaceUserProfileProvider- Returns:
- current UserProfile configuration
- See Also:
-
setConfiguration
Description copied from interface:UserProfileProviderSet new UserProfile configuration. It is persisted inside of the provider.- Specified by:
setConfigurationin 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 eachUserProfileContextin 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()
-