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 SummaryFieldsModifier and TypeFieldDescriptionprotected Stringstatic final Stringprotected UPConfigstatic final intstatic final Stringstatic final StringFields inherited from class org.keycloak.userprofile.AbstractUserProfileProviderCONFIG_ADMIN_READ_ONLY_ATTRIBUTES, CONFIG_READ_ONLY_ATTRIBUTES, contextualMetadataRegistry, MAX_EMAIL_LOCAL_PART_LENGTH, session
- 
Constructor SummaryConstructorsConstructorDescriptionDeclarativeUserProfileProvider(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> metadataRegistry, String defaultRawConfig, UPConfig parsedDefaultRawConfig) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected 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.protected UserProfileProvidercreate(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> metadataRegistry) Subclasses can override this method to create their instances ofUserProfileProvider.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 provided fromAbstractUserProfileProviderbased on 'per realm' configuration.Get current UserProfile configuration.getId()protected UPConfiggetParsedConfig(String rawConfig) Get parsed config file configured in model.voidinit(Config.Scope config) Only called once when the factory is first created.booleanisEnabled(RealmModel realm) Returns whether the declarative provider is enabled to a realmintorder()voidsetConfiguration(String configuration) Set new UserProfile configuration.voidvalidateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel model) Called before a component is created or updated.Methods inherited from class org.keycloak.userprofile.AbstractUserProfileProviderclose, create, create, create, create, getConfigMetadata, getRegexPatternString, postInitMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.component.AmphibianProviderFactoryclose, create, create, onUpdate, preRemoveMethods inherited from interface org.keycloak.component.ComponentFactorygetCommonProviderConfigProperties, getTypeMetadata, onCreateMethods inherited from interface org.keycloak.provider.ConfiguredProvidergetConfigMethods inherited from interface org.keycloak.provider.ProviderFactorygetConfigMetadata, postInit
- 
Field Details- 
ID- See Also:
 
- 
PROVIDER_PRIORITYpublic 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- 
DeclarativeUserProfileProviderpublic DeclarativeUserProfileProvider()
- 
DeclarativeUserProfileProviderpublic DeclarativeUserProfileProvider(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> metadataRegistry, String defaultRawConfig, UPConfig parsedDefaultRawConfig) 
 
- 
- 
Method Details- 
getId- Specified by:
- getIdin interface- ProviderFactory<UserProfileProvider>
 
- 
createprotected UserProfileProvider create(KeycloakSession session, Map<UserProfileContext, UserProfileMetadata> metadataRegistry) Description copied from class:AbstractUserProfileProviderSubclasses can override this method to create their instances ofUserProfileProvider.- Specified by:
- createin class- AbstractUserProfileProvider<UserProfileProvider>
- Parameters:
- session- the session
- metadataRegistry- the profile metadata
- Returns:
- the profile provider instance
 
- 
createAttributesprotected Attributes createAttributes(UserProfileContext context, Map<String, ?> attributes, UserModel user, UserProfileMetadata metadata) - Overrides:
- createAttributesin class- AbstractUserProfileProvider<UserProfileProvider>
 
- 
configureUserProfileDescription copied from class:AbstractUserProfileProviderSub-types can override this method to customize how contextual profile metadata is configured at init time.- Overrides:
- configureUserProfilein class- AbstractUserProfileProvider<UserProfileProvider>
- Parameters:
- metadata- the profile metadata
- Returns:
- the metadata
 
- 
configureUserProfileprotected UserProfileMetadata configureUserProfile(UserProfileMetadata metadata, KeycloakSession session) Description copied from class:AbstractUserProfileProviderSub-types can override this method to customize how contextual profile metadata is configured at runtime.- Overrides:
- configureUserProfilein class- AbstractUserProfileProvider<UserProfileProvider>
- Parameters:
- metadata- the profile metadata
- session- the current session
- Returns:
- the metadata
 
- 
getHelpText- Specified by:
- getHelpTextin interface- ConfiguredProvider
 
- 
validateConfigurationpublic void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel model) throws ComponentValidationException Description copied from interface:ComponentFactoryCalled before a component is created or updated. Allows you to validate the configuration- Specified by:
- validateConfigurationin interface- ComponentFactory<UserProfileProvider,- UserProfileProvider> 
- Throws:
- ComponentValidationException
 
- 
getConfigurationDescription copied from interface:UserProfileProviderGet current UserProfile configuration. JSON formatted file is expected, but depends on the implementation.- Specified by:
- getConfigurationin interface- UserProfileProvider
- Overrides:
- getConfigurationin class- AbstractUserProfileProvider<UserProfileProvider>
- Returns:
- current UserProfile configuration
- See Also:
 
- 
setConfigurationDescription copied from interface:UserProfileProviderSet new UserProfile configuration. It is persisted inside of the provider.- Specified by:
- setConfigurationin interface- UserProfileProvider
- Overrides:
- setConfigurationin class- AbstractUserProfileProvider<UserProfileProvider>
- Parameters:
- configuration- to be set
- See Also:
 
- 
getConfigProperties- Specified by:
- getConfigPropertiesin interface- AmphibianProviderFactory<UserProfileProvider>
- Specified by:
- getConfigPropertiesin interface- ConfiguredProvider
 
- 
initDescription 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<UserProfileProvider>
- Overrides:
- initin class- AbstractUserProfileProvider<UserProfileProvider>
 
- 
orderpublic int order()- Specified by:
- orderin interface- ProviderFactory<UserProfileProvider>
 
- 
decorateUserProfileForCacheprotected UserProfileMetadata decorateUserProfileForCache(UserProfileMetadata decoratedMetadata, UPConfig parsedConfig) Decorate basic metadata provided fromAbstractUserProfileProviderbased 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.
- 
getParsedConfigGet parsed config file configured in model. Default one used if not configured.
- 
createComponentModelCreate the component model to store configuration- Returns:
- component model
 
- 
createConfiguredValidatorprotected AttributeValidatorMetadata createConfiguredValidator(String validator, Map<String, Object> validatorConfig) Create validator for validation configured in the user profile config.- Parameters:
- validator- id to create validator for
- validatorConfig- of the validator
- Returns:
- validator metadata to run given validation
 
- 
isEnabledDescription copied from interface:UserProfileProviderReturns whether the declarative provider is enabled to a realm- Specified by:
- isEnabledin interface- UserProfileProvider
- Returns:
- trueif the declarative provider is enabled. Otherwise,- false.
 
 
-