org.keycloak.userprofile.config

## Class DeclarativeUserProfileProvider

- java.lang.Object
- - org.keycloak.userprofile.legacy.AbstractUserProfileProvider<DeclarativeUserProfileProvider>
  - - org.keycloak.userprofile.config.DeclarativeUserProfileProvider

- All Implemented Interfaces:
    AmphibianProviderFactory<DeclarativeUserProfileProvider>, ComponentFactory<DeclarativeUserProfileProvider,DeclarativeUserProfileProvider>, ConfiguredProvider, EnvironmentDependentProviderFactory, Provider, ProviderFactory<DeclarativeUserProfileProvider>, UserProfileProvider, UserProfileProviderFactory<DeclarativeUserProfileProvider>

      public class DeclarativeUserProfileProvider
      extends AbstractUserProfileProvider<DeclarativeUserProfileProvider>
      implements AmphibianProviderFactory<DeclarativeUserProfileProvider>, EnvironmentDependentProviderFactory

  `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 and Description
    --- | ---
    `static String` | `ID`
    `static String` | `SYSTEM_DEFAULT_CONFIG_RESOURCE`
    `static String` | `UP_PIECES_COUNT_COMPONENT_CONFIG_KEY`

    - ### Fields inherited from class org.keycloak.userprofile.legacy.AbstractUserProfileProvider

      `contextualMetadataRegistry, session`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DeclarativeUserProfileProvider()`
    `DeclarativeUserProfileProvider(KeycloakSession session, Map<UserProfileContext,UserProfileMetadata> metadataRegistry, String defaultRawConfig)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected UserProfileMetadata` | `configureUserProfile(UserProfileMetadata metadata, KeycloakSession session)` Sub-types can override this method to customize how contextual profile metadata is configured at runtime.
    `protected DeclarativeUserProfileProvider` | `create(KeycloakSession session, Map<UserProfileContext,UserProfileMetadata> metadataRegistry)` Subclasses can override this method to create their instances of `UserProfileProvider`.
    `protected Attributes` | `createAttributes(UserProfileContext context, Map<String,?> attributes, UserModel user, UserProfileMetadata metadata)`
    `protected AttributeValidatorMetadata` | `createConfiguredValidator(String validator, Map<String,Object> validatorConfig)` Create validator for validation configured in the user profile config.
    `protected UserProfileMetadata` | `decorateUserProfileForCache(UserProfileMetadata metadata, ComponentModel model)` Decorate basic metadata provided from `AbstractUserProfileProvider` based on 'per realm' configuration.
    `ComponentModel` | `getComponentModel()`
    `List<ProviderConfigProperty>` | `getConfigProperties()`
    `String` | `getConfiguration()` Get current UserProfile configuration.
    `String` | `getHelpText()`
    `String` | `getId()`
    `protected UPConfig` | `getParsedConfig(ComponentModel model)` Get parsed config file configured in model.
    `boolean` | `isSupported()`
    `void` | `postInit(KeycloakSessionFactory factory)` Called after all provider factories have been initialized
    `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.legacy.AbstractUserProfileProvider

      `close, configureUserProfile, create, create, create, create, getRegexPatternString, init`

    - ### 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.ProviderFactory

      `init, order`

- - ### Field Detail

    - #### SYSTEM_DEFAULT_CONFIG_RESOURCE

          public static final String SYSTEM_DEFAULT_CONFIG_RESOURCE

      See Also:
        Constant Field Values

    - #### ID

          public static final String ID

      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

  - ### Constructor Detail

    - #### DeclarativeUserProfileProvider

          public DeclarativeUserProfileProvider()

    - #### DeclarativeUserProfileProvider

          public DeclarativeUserProfileProvider(KeycloakSession session,
                                                Map<UserProfileContext,UserProfileMetadata> metadataRegistry,
                                                String defaultRawConfig)

  - ### Method Detail

    - #### getId

          public String getId()

      Specified by:
        `getId` in interface `ProviderFactory<DeclarativeUserProfileProvider>`

    - #### create

          protected DeclarativeUserProfileProvider create(KeycloakSession session,
                                                          Map<UserProfileContext,UserProfileMetadata> metadataRegistry)

      Description copied from class: `AbstractUserProfileProvider`
      Subclasses can override this method to create their instances of `UserProfileProvider`.
      Specified by:
        `create` in class `AbstractUserProfileProvider<DeclarativeUserProfileProvider>`
      Parameters:
        `session` - the session
        `metadataRegistry` - the profile metadata
      Returns:
        the profile provider instance

    - #### createAttributes

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

      Overrides:
        `createAttributes` in class `AbstractUserProfileProvider<DeclarativeUserProfileProvider>`

    - #### 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 class `AbstractUserProfileProvider<DeclarativeUserProfileProvider>`
      Parameters:
        `metadata` - the profile metadata
      Returns:
        the metadata

    - #### getHelpText

          public String getHelpText()

      Specified by:
        `getHelpText` in interface `ConfiguredProvider`

    - #### 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 interface `ComponentFactory<DeclarativeUserProfileProvider,DeclarativeUserProfileProvider>`
      Throws:
        `ComponentValidationException`

    - #### getConfiguration

          public String getConfiguration()

      Description copied from interface: `UserProfileProvider`
      Get current UserProfile configuration. JSON formatted file is expected, but depends on the implementation.
      Specified by:
        `getConfiguration` in interface `UserProfileProvider`
      Overrides:
        `getConfiguration` in class `AbstractUserProfileProvider<DeclarativeUserProfileProvider>`
      Returns:
        current UserProfile configuration
      See Also:
        `UserProfileProvider.setConfiguration(String)`

    - #### setConfiguration

          public void setConfiguration(String configuration)

      Description copied from interface: `UserProfileProvider`
      Set new UserProfile configuration. It is persisted inside of the provider.
      Specified by:
        `setConfiguration` in interface `UserProfileProvider`
      Overrides:
        `setConfiguration` in class `AbstractUserProfileProvider<DeclarativeUserProfileProvider>`
      Parameters:
        `configuration` - to be set
      See Also:
        `UserProfileProvider.getConfiguration()`

    - #### postInit

          public void postInit(KeycloakSessionFactory factory)

      Description copied from interface: `ProviderFactory`
      Called after all provider factories have been initialized
      Specified by:
        `postInit` in interface `ProviderFactory<DeclarativeUserProfileProvider>`
      Overrides:
        `postInit` in class `AbstractUserProfileProvider<DeclarativeUserProfileProvider>`

    - #### getConfigProperties

          public List<ProviderConfigProperty> getConfigProperties()

      Specified by:
        `getConfigProperties` in interface `AmphibianProviderFactory<DeclarativeUserProfileProvider>`
      Specified by:
        `getConfigProperties` in interface `ConfiguredProvider`

    - #### getComponentModel

          public ComponentModel getComponentModel()

    - #### decorateUserProfileForCache

          protected UserProfileMetadata decorateUserProfileForCache(UserProfileMetadata metadata,
                                                                    ComponentModel model)

      Decorate basic metadata provided from `AbstractUserProfileProvider` 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.
      Parameters:
        `metadata` - base to be decorated based on configuration loaded from component model
        `model` - component model to get "per realm" configuration from
      Returns:
        decorated metadata

    - #### getParsedConfig

          protected UPConfig getParsedConfig(ComponentModel model)

      Get parsed config file configured in model. Default one used if not configured.
      Parameters:
        `model` - to take config from
      Returns:
        parsed configuration

    - #### 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

    - #### isSupported

          public boolean isSupported()

      Specified by:
        `isSupported` in interface `EnvironmentDependentProviderFactory`
      Returns:
        `true` if the provider is supported and should be available, `false` otherwise

Copyright © 2021 JBoss by Red Hat. All rights reserved.