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.
Modifier and Type | Field and Description |
---|---|
protected Map<UserProfileContext,UserProfileMetadata> |
contextualMetadataRegistry |
protected KeycloakSession |
session |
Constructor and Description |
---|
AbstractUserProfileProvider() |
AbstractUserProfileProvider(KeycloakSession session,
Map<UserProfileContext,UserProfileMetadata> contextualMetadataRegistry) |
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)
|
UserProfile |
create(UserProfileContext context,
Map<String,?> attributes,
UserModel user)
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getId, order
protected final Map<UserProfileContext,UserProfileMetadata> contextualMetadataRegistry
protected final KeycloakSession session
public AbstractUserProfileProvider()
public AbstractUserProfileProvider(KeycloakSession session, Map<UserProfileContext,UserProfileMetadata> contextualMetadataRegistry)
public static Pattern getRegexPatternString(String[] builtinReadOnlyAttributes)
public UserProfile create(UserProfileContext context, UserModel user)
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.
create
in interface UserProfileProvider
context
- the contextuser
- an existing userpublic UserProfile create(UserProfileContext context, Map<String,?> attributes, UserModel user)
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.
create
in interface UserProfileProvider
context
- the contextattributes
- the attributes to associate with the instance returned from this methoduser
- the user to eventually update with the given attributes
public UserProfile create(UserProfileContext context, Map<String,?> attributes)
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
.
create
in interface UserProfileProvider
context
- the contextattributes
- the attributes to associate with the instance returned from this methodpublic U create(KeycloakSession session)
create
in interface ProviderFactory<U extends UserProfileProvider>
public void init(Config.Scope config)
ProviderFactory
init
in interface ProviderFactory<U extends UserProfileProvider>
public void postInit(KeycloakSessionFactory factory)
ProviderFactory
postInit
in interface ProviderFactory<U extends UserProfileProvider>
public void close()
ProviderFactory
close
in interface Provider
close
in interface ProviderFactory<U extends UserProfileProvider>
public String getConfiguration()
UserProfileProvider
getConfiguration
in interface UserProfileProvider
UserProfileProvider.setConfiguration(String)
public void setConfiguration(String configuration)
UserProfileProvider
setConfiguration
in interface UserProfileProvider
configuration
- to be setUserProfileProvider.getConfiguration()
protected abstract U create(KeycloakSession session, Map<UserProfileContext,UserProfileMetadata> metadataRegistry)
UserProfileProvider
.session
- the sessionmetadataRegistry
- the profile metadataprotected UserProfileMetadata configureUserProfile(UserProfileMetadata metadata)
metadata
- the profile metadataprotected UserProfileMetadata configureUserProfile(UserProfileMetadata metadata, KeycloakSession session)
metadata
- the profile metadatasession
- the current sessionprotected Attributes createAttributes(UserProfileContext context, Map<String,?> attributes, UserModel user, UserProfileMetadata metadata)
Copyright © 2021 JBoss by Red Hat. All rights reserved.