Class DeclarativeUserProfileProvider

java.lang.Object
org.keycloak.userprofile.DeclarativeUserProfileProvider
All Implemented Interfaces:
Provider, UserProfileProvider

public class DeclarativeUserProfileProvider extends Object implements 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 Details

  • Constructor Details

  • Method Details

    • createAttributes

      protected Attributes createAttributes(UserProfileContext context, Map<String,?> attributes, UserModel user, UserProfileMetadata metadata)
    • create

      public UserProfile create(UserProfileContext context, UserModel user)
      Description copied from interface: UserProfileProvider

      Creates a new UserProfile instance only for validation purposes to check whether its attributes are in conformance with the given context and profile configuration.

      Specified by:
      create in interface UserProfileProvider
      Parameters:
      context - the context
      user - an existing user
      Returns:
      the user profile instance
    • create

      public UserProfile create(UserProfileContext context, Map<String,?> attributes, UserModel user)
      Description copied from interface: UserProfileProvider

      Creates a new UserProfile instance for a given context and attributes 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 interface UserProfileProvider
      Parameters:
      context - the context
      attributes - the attributes to associate with the instance returned from this method
      user - the user to eventually update with the given attributes
      Returns:
      the user profile instance
    • create

      public UserProfile create(UserProfileContext context, Map<String,?> attributes)
      Description copied from interface: UserProfileProvider

      Creates a new UserProfile instance for a given context and attributes 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 interface UserProfileProvider
      Parameters:
      context - the context
      attributes - 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

      public UPConfig getConfiguration()
      Description copied from interface: UserProfileProvider
      Get current UserProfile configuration.
      Specified by:
      getConfiguration in interface UserProfileProvider
      Returns:
      current UserProfile configuration
      See Also:
    • setConfiguration

      public void setConfiguration(UPConfig configuration)
      Description copied from interface: UserProfileProvider
      Set new UserProfile configuration. It is persisted inside of the provider.
      Specified by:
      setConfiguration in interface UserProfileProvider
      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 each UserProfileContext in each realm, and metadata are cached then and this method is called again only if configuration changes.
    • parseConfigOrDefault

      protected UPConfig parseConfigOrDefault(ComponentModel component)
      Get parsed config file configured in model. Default one used if not configured.
    • createComponentModel

      protected ComponentModel 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 for
      validatorConfig - of the validator
      Returns:
      validator metadata to run given validation
    • close

      public void close()
      Specified by:
      close in interface Provider