Package org.keycloak.userprofile
Class DeclarativeUserProfileProvider
java.lang.Object
org.keycloak.userprofile.AbstractUserProfileProvider<UserProfileProvider>
org.keycloak.userprofile.DeclarativeUserProfileProvider
- All Implemented Interfaces:
AmphibianProviderFactory<UserProfileProvider>
,ComponentFactory<UserProfileProvider,
,UserProfileProvider> ConfiguredProvider
,Provider
,ProviderFactory<UserProfileProvider>
,UserProfileProvider
,UserProfileProviderFactory<UserProfileProvider>
public class DeclarativeUserProfileProvider
extends AbstractUserProfileProvider<UserProfileProvider>
implements AmphibianProviderFactory<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
Modifier and TypeFieldDescriptionprotected String
static final String
protected UPConfig
static final int
static final String
static final String
Fields inherited from class org.keycloak.userprofile.AbstractUserProfileProvider
CONFIG_ADMIN_READ_ONLY_ATTRIBUTES, CONFIG_READ_ONLY_ATTRIBUTES, contextualMetadataRegistry, MAX_EMAIL_LOCAL_PART_LENGTH, session
-
Constructor Summary
ConstructorDescriptionDeclarativeUserProfileProvider
(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> metadataRegistry, String defaultRawConfig, UPConfig parsedDefaultRawConfig) -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.protected UserProfileProvider
create
(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> metadataRegistry) Subclasses can override this method to create their instances ofUserProfileProvider
.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 provided fromAbstractUserProfileProvider
based on 'per realm' configuration.Get current UserProfile configuration.getId()
protected UPConfig
getParsedConfig
(String rawConfig) Get parsed config file configured in model.void
init
(Config.Scope config) Only called once when the factory is first created.boolean
isEnabled
(RealmModel realm) Returns whether the declarative provider is enabled to a realmint
order()
void
setConfiguration
(String configuration) Set new UserProfile configuration.void
validateConfiguration
(KeycloakSession session, RealmModel realm, ComponentModel model) Called before a component is created or updated.Methods inherited from class org.keycloak.userprofile.AbstractUserProfileProvider
close, create, create, create, create, getConfigMetadata, getRegexPatternString, 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.component.AmphibianProviderFactory
close, create, create, onUpdate, preRemove
Methods inherited from interface org.keycloak.component.ComponentFactory
getCommonProviderConfigProperties, getTypeMetadata, onCreate
Methods inherited from interface org.keycloak.provider.ConfiguredProvider
getConfig
Methods inherited from interface org.keycloak.provider.ProviderFactory
getConfigMetadata, postInit
-
Field Details
-
ID
- See Also:
-
PROVIDER_PRIORITY
public static final int PROVIDER_PRIORITY- See Also:
-
UP_PIECES_COUNT_COMPONENT_CONFIG_KEY
- See Also:
-
REALM_USER_PROFILE_ENABLED
- See Also:
-
defaultRawConfig
-
parsedDefaultRawConfig
-
-
Constructor Details
-
DeclarativeUserProfileProvider
public DeclarativeUserProfileProvider() -
DeclarativeUserProfileProvider
public DeclarativeUserProfileProvider(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> metadataRegistry, String defaultRawConfig, UPConfig parsedDefaultRawConfig)
-
-
Method Details
-
getId
- Specified by:
getId
in interfaceProviderFactory<UserProfileProvider>
-
create
protected UserProfileProvider create(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> metadataRegistry) Description copied from class:AbstractUserProfileProvider
Subclasses can override this method to create their instances ofUserProfileProvider
.- Specified by:
create
in classAbstractUserProfileProvider<UserProfileProvider>
- Parameters:
session
- the sessionmetadataRegistry
- the profile metadata- Returns:
- the profile provider instance
-
createAttributes
protected Attributes createAttributes(UserProfileContext context, Map<String, ?> attributes, UserModel user, UserProfileMetadata metadata) - Overrides:
createAttributes
in classAbstractUserProfileProvider<UserProfileProvider>
-
configureUserProfile
Description copied from class:AbstractUserProfileProvider
Sub-types can override this method to customize how contextual profile metadata is configured at init time.- Overrides:
configureUserProfile
in classAbstractUserProfileProvider<UserProfileProvider>
- Parameters:
metadata
- the profile metadata- Returns:
- the metadata
-
configureUserProfile
protected UserProfileMetadata configureUserProfile(UserProfileMetadata metadata, KeycloakSession session) Description copied from class:AbstractUserProfileProvider
Sub-types can override this method to customize how contextual profile metadata is configured at runtime.- Overrides:
configureUserProfile
in classAbstractUserProfileProvider<UserProfileProvider>
- Parameters:
metadata
- the profile metadatasession
- the current session- Returns:
- the metadata
-
getHelpText
- Specified by:
getHelpText
in interfaceConfiguredProvider
-
validateConfiguration
public void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel model) throws ComponentValidationException Description copied from interface:ComponentFactory
Called before a component is created or updated. Allows you to validate the configuration- Specified by:
validateConfiguration
in interfaceComponentFactory<UserProfileProvider,
UserProfileProvider> - Throws:
ComponentValidationException
-
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
- Overrides:
getConfiguration
in classAbstractUserProfileProvider<UserProfileProvider>
- 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
- Overrides:
setConfiguration
in classAbstractUserProfileProvider<UserProfileProvider>
- Parameters:
configuration
- to be set- See Also:
-
getConfigProperties
- Specified by:
getConfigProperties
in interfaceAmphibianProviderFactory<UserProfileProvider>
- Specified by:
getConfigProperties
in interfaceConfiguredProvider
-
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<UserProfileProvider>
- Overrides:
init
in classAbstractUserProfileProvider<UserProfileProvider>
-
order
public int order()- Specified by:
order
in interfaceProviderFactory<UserProfileProvider>
-
decorateUserProfileForCache
protected UserProfileMetadata decorateUserProfileForCache(UserProfileMetadata decoratedMetadata, UPConfig parsedConfig) Decorate basic metadata provided fromAbstractUserProfileProvider
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. -
getParsedConfig
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
-
isEnabled
Description copied from interface:UserProfileProvider
Returns whether the declarative provider is enabled to a realm- Specified by:
isEnabled
in interfaceUserProfileProvider
- Returns:
true
if the declarative provider is enabled. Otherwise,false
.
-