Package org.keycloak.userprofile
Class DeclarativeUserProfileProvider
- java.lang.Object
-
- org.keycloak.userprofile.AbstractUserProfileProvider<org.keycloak.userprofile.UserProfileProvider>
-
- org.keycloak.userprofile.DeclarativeUserProfileProvider
-
- All Implemented Interfaces:
org.keycloak.component.AmphibianProviderFactory<org.keycloak.userprofile.UserProfileProvider>
,org.keycloak.component.ComponentFactory<org.keycloak.userprofile.UserProfileProvider,org.keycloak.userprofile.UserProfileProvider>
,org.keycloak.provider.ConfiguredProvider
,org.keycloak.provider.Provider
,org.keycloak.provider.ProviderFactory<org.keycloak.userprofile.UserProfileProvider>
,org.keycloak.userprofile.UserProfileProvider
,org.keycloak.userprofile.UserProfileProviderFactory<org.keycloak.userprofile.UserProfileProvider>
public class DeclarativeUserProfileProvider extends AbstractUserProfileProvider<org.keycloak.userprofile.UserProfileProvider> implements org.keycloak.component.AmphibianProviderFactory<org.keycloak.userprofile.UserProfileProvider>
UserProfileProvider
loading configuration from the changeable JSON file stored in component config. Parsed configuration is cached.- Author:
- Pedro Igor, Vlastimil Elias
-
-
Field Summary
Fields Modifier and Type Field Description static String
ID
static int
PROVIDER_PRIORITY
static String
REALM_USER_PROFILE_ENABLED
static String
UP_PIECES_COUNT_COMPONENT_CONFIG_KEY
-
Fields inherited from class org.keycloak.userprofile.AbstractUserProfileProvider
contextualMetadataRegistry, session
-
-
Constructor Summary
Constructors Constructor Description DeclarativeUserProfileProvider()
DeclarativeUserProfileProvider(org.keycloak.models.KeycloakSession session, Map<org.keycloak.userprofile.UserProfileContext,org.keycloak.userprofile.UserProfileMetadata> metadataRegistry, String defaultRawConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.keycloak.userprofile.UserProfileMetadata
configureUserProfile(org.keycloak.userprofile.UserProfileMetadata metadata, org.keycloak.models.KeycloakSession session)
Sub-types can override this method to customize how contextual profile metadata is configured at runtime.protected org.keycloak.userprofile.UserProfileProvider
create(org.keycloak.models.KeycloakSession session, Map<org.keycloak.userprofile.UserProfileContext,org.keycloak.userprofile.UserProfileMetadata> metadataRegistry)
Subclasses can override this method to create their instances ofUserProfileProvider
.protected org.keycloak.userprofile.Attributes
createAttributes(org.keycloak.userprofile.UserProfileContext context, Map<String,?> attributes, org.keycloak.models.UserModel user, org.keycloak.userprofile.UserProfileMetadata metadata)
protected org.keycloak.component.ComponentModel
createComponentModel()
Create the component model to store configurationprotected org.keycloak.userprofile.AttributeValidatorMetadata
createConfiguredValidator(String validator, Map<String,Object> validatorConfig)
Create validator for validation configured in the user profile config.protected org.keycloak.userprofile.UserProfileMetadata
decorateUserProfileForCache(org.keycloak.userprofile.UserProfileMetadata decoratedMetadata, org.keycloak.component.ComponentModel model)
Decorate basic metadata provided fromAbstractUserProfileProvider
based on 'per realm' configuration.org.keycloak.component.ComponentModel
getComponentModel()
List<org.keycloak.provider.ProviderConfigProperty>
getConfigProperties()
String
getConfiguration()
String
getHelpText()
String
getId()
protected UPConfig
getParsedConfig(org.keycloak.component.ComponentModel model)
Get parsed config file configured in model.void
init(org.keycloak.Config.Scope config)
int
order()
void
setConfiguration(String configuration)
void
validateConfiguration(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.component.ComponentModel model)
-
Methods inherited from class org.keycloak.userprofile.AbstractUserProfileProvider
close, configureUserProfile, create, create, create, create, 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
-
-
-
-
Field Detail
-
ID
public static final String ID
- See Also:
- Constant Field Values
-
PROVIDER_PRIORITY
public static final int PROVIDER_PRIORITY
- See Also:
- Constant Field Values
-
UP_PIECES_COUNT_COMPONENT_CONFIG_KEY
public static final String UP_PIECES_COUNT_COMPONENT_CONFIG_KEY
- See Also:
- Constant Field Values
-
REALM_USER_PROFILE_ENABLED
public static final String REALM_USER_PROFILE_ENABLED
- See Also:
- Constant Field Values
-
-
Method Detail
-
getId
public String getId()
- Specified by:
getId
in interfaceorg.keycloak.provider.ProviderFactory<org.keycloak.userprofile.UserProfileProvider>
-
create
protected org.keycloak.userprofile.UserProfileProvider create(org.keycloak.models.KeycloakSession session, Map<org.keycloak.userprofile.UserProfileContext,org.keycloak.userprofile.UserProfileMetadata> metadataRegistry)
Description copied from class:AbstractUserProfileProvider
Subclasses can override this method to create their instances ofUserProfileProvider
.- Specified by:
create
in classAbstractUserProfileProvider<org.keycloak.userprofile.UserProfileProvider>
- Parameters:
session
- the sessionmetadataRegistry
- the profile metadata- Returns:
- the profile provider instance
-
createAttributes
protected org.keycloak.userprofile.Attributes createAttributes(org.keycloak.userprofile.UserProfileContext context, Map<String,?> attributes, org.keycloak.models.UserModel user, org.keycloak.userprofile.UserProfileMetadata metadata)
- Overrides:
createAttributes
in classAbstractUserProfileProvider<org.keycloak.userprofile.UserProfileProvider>
-
configureUserProfile
protected org.keycloak.userprofile.UserProfileMetadata configureUserProfile(org.keycloak.userprofile.UserProfileMetadata metadata, org.keycloak.models.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<org.keycloak.userprofile.UserProfileProvider>
- Parameters:
metadata
- the profile metadatasession
- the current session- Returns:
- the metadata
-
getHelpText
public String getHelpText()
- Specified by:
getHelpText
in interfaceorg.keycloak.provider.ConfiguredProvider
-
validateConfiguration
public void validateConfiguration(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.component.ComponentModel model) throws org.keycloak.component.ComponentValidationException
- Specified by:
validateConfiguration
in interfaceorg.keycloak.component.ComponentFactory<org.keycloak.userprofile.UserProfileProvider,org.keycloak.userprofile.UserProfileProvider>
- Throws:
org.keycloak.component.ComponentValidationException
-
getConfiguration
public String getConfiguration()
- Specified by:
getConfiguration
in interfaceorg.keycloak.userprofile.UserProfileProvider
- Overrides:
getConfiguration
in classAbstractUserProfileProvider<org.keycloak.userprofile.UserProfileProvider>
-
setConfiguration
public void setConfiguration(String configuration)
- Specified by:
setConfiguration
in interfaceorg.keycloak.userprofile.UserProfileProvider
- Overrides:
setConfiguration
in classAbstractUserProfileProvider<org.keycloak.userprofile.UserProfileProvider>
-
getConfigProperties
public List<org.keycloak.provider.ProviderConfigProperty> getConfigProperties()
- Specified by:
getConfigProperties
in interfaceorg.keycloak.component.AmphibianProviderFactory<org.keycloak.userprofile.UserProfileProvider>
- Specified by:
getConfigProperties
in interfaceorg.keycloak.provider.ConfiguredProvider
-
init
public void init(org.keycloak.Config.Scope config)
- Specified by:
init
in interfaceorg.keycloak.provider.ProviderFactory<org.keycloak.userprofile.UserProfileProvider>
- Overrides:
init
in classAbstractUserProfileProvider<org.keycloak.userprofile.UserProfileProvider>
-
order
public int order()
- Specified by:
order
in interfaceorg.keycloak.provider.ProviderFactory<org.keycloak.userprofile.UserProfileProvider>
-
getComponentModel
public org.keycloak.component.ComponentModel getComponentModel()
-
decorateUserProfileForCache
protected org.keycloak.userprofile.UserProfileMetadata decorateUserProfileForCache(org.keycloak.userprofile.UserProfileMetadata decoratedMetadata, org.keycloak.component.ComponentModel model)
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.- Parameters:
decoratedMetadata
- base to be decorated based on configuration loaded from component modelmodel
- component model to get "per realm" configuration from- Returns:
- decorated metadata
-
getParsedConfig
protected UPConfig getParsedConfig(org.keycloak.component.ComponentModel model)
Get parsed config file configured in model. Default one used if not configured.- Parameters:
model
- to take config from- Returns:
- parsed configuration
-
createComponentModel
protected org.keycloak.component.ComponentModel createComponentModel()
Create the component model to store configuration- Returns:
- component model
-
createConfiguredValidator
protected org.keycloak.userprofile.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
-
-