org.keycloak.userprofile

## Class AbstractUserProfileProvider<U extends UserProfileProvider>

- java.lang.Object
- - org.keycloak.userprofile.AbstractUserProfileProvider<U>

- All Implemented Interfaces:
    Provider, ProviderFactory<U>, UserProfileProvider, UserProfileProviderFactory<U>
  Direct Known Subclasses:
    DeclarativeUserProfileProvider

      public abstract class AbstractUserProfileProvider<U extends UserProfileProvider>
      extends Object
      implements UserProfileProvider, UserProfileProviderFactory<U>

  A base class for `UserProfileProvider` implementations providing the main hooks for customizations.

  Author:
    Markus Till

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<UserProfileContext,UserProfileMetadata>` | `contextualMetadataRegistry`
    `protected KeycloakSession` | `session`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractUserProfileProvider()`
    `AbstractUserProfileProvider(KeycloakSession session, Map<UserProfileContext,UserProfileMetadata> contextualMetadataRegistry)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` This is called when the server shuts down.
    `protected 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.
    `U` | `create(KeycloakSession session)`
    `protected abstract U` | `create(KeycloakSession session, Map<UserProfileContext,UserProfileMetadata> metadataRegistry)` Subclasses can override this method to create their instances of `UserProfileProvider`.
    `UserProfile` | `create(UserProfileContext context, Map<String,?> attributes)` Creates a new `UserProfile` instance for a given `context` and `attributes` for validation purposes.
    `UserProfile` | `create(UserProfileContext context, Map<String,?> attributes, UserModel user)` Creates a new `UserProfile` instance for a given `context` and `attributes` for update purposes.
    `UserProfile` | `create(UserProfileContext context, UserModel user)` Creates a new `UserProfile` instance only for validation purposes to check whether its attributes are in conformance with the given `context` and profile configuration.
    `protected Attributes` | `createAttributes(UserProfileContext context, Map<String,?> attributes, UserModel user, UserProfileMetadata metadata)`
    `String` | `getConfiguration()` Get current UserProfile configuration.
    `static Pattern` | `getRegexPatternString(String[] builtinReadOnlyAttributes)`
    `void` | `init(Config.Scope config)` Only called once when the factory is first created.
    `void` | `postInit(KeycloakSessionFactory factory)` Called after all provider factories have been initialized
    `void` | `setConfiguration(String configuration)` Set new UserProfile configuration.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.keycloak.provider.ProviderFactory

      `getId, order`

- - ### Field Detail

    - #### contextualMetadataRegistry

          protected final Map<UserProfileContext,UserProfileMetadata> contextualMetadataRegistry

    - #### session

          protected final KeycloakSession session

  - ### Constructor Detail

    - #### AbstractUserProfileProvider

          public AbstractUserProfileProvider()

    - #### AbstractUserProfileProvider

          public AbstractUserProfileProvider(KeycloakSession session,
                                             Map<UserProfileContext,UserProfileMetadata> contextualMetadataRegistry)

  - ### Method Detail

    - #### getRegexPatternString

          public static Pattern getRegexPatternString(String[] builtinReadOnlyAttributes)

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

    - #### create

          public U create(KeycloakSession session)

      Specified by:
        `create` in interface `ProviderFactory<U extends UserProfileProvider>`

    - #### init

          public void init(Config.Scope config)

      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 interface `ProviderFactory<U extends UserProfileProvider>`

    - #### 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<U extends UserProfileProvider>`

    - #### close

          public void close()

      Description copied from interface: `ProviderFactory`
      This is called when the server shuts down.
      Specified by:
        `close` in interface `Provider`
      Specified by:
        `close` in interface `ProviderFactory<U extends UserProfileProvider>`

    - #### 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`
      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`
      Parameters:
        `configuration` - to be set
      See Also:
        `UserProfileProvider.getConfiguration()`

    - #### create

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

      Subclasses can override this method to create their instances of `UserProfileProvider`.
      Parameters:
        `session` - the session
        `metadataRegistry` - the profile metadata
      Returns:
        the profile provider instance

    - #### configureUserProfile

          protected UserProfileMetadata configureUserProfile(UserProfileMetadata metadata)

      Sub-types can override this method to customize how contextual profile metadata is configured at init time.
      Parameters:
        `metadata` - the profile metadata
      Returns:
        the metadata

    - #### configureUserProfile

          protected UserProfileMetadata configureUserProfile(UserProfileMetadata metadata,
                                                             KeycloakSession session)

      Sub-types can override this method to customize how contextual profile metadata is configured at runtime.
      Parameters:
        `metadata` - the profile metadata
        `session` - the current session
      Returns:
        the metadata

    - #### createAttributes

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

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