public class DefaultAttributes extends HashMap<String,List<String>> implements Attributes
The default implementation for Attributes. Should be reused as much as possible by the different implementations
of UserProfileProvider.
One of the main aspects of this implementation is to allow normalizing attributes accordingly to the profile configuration and current context. As such, it provides some common normalization to common profile attributes (e.g.: username, email, first and last names, dynamic read-only attributes).
This implementation is not specific to any user profile implementation.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
static String |
READ_ONLY_ATTRIBUTE_KEY
To reference dynamic attributes that can be configured as read-only when setting up the provider.
|
protected UserModel |
user |
EMPTY_VALUE| Constructor and Description |
|---|
DefaultAttributes(UserProfileContext context,
Map<String,?> attributes,
UserModel user,
UserProfileMetadata profileMetadata,
KeycloakSession session) |
| Modifier and Type | Method and Description |
|---|---|
Set<Map.Entry<String,List<String>>> |
attributeSet()
Returns all attributes defined.
|
boolean |
contains(String name)
Checks whether an attribute with the given
name is defined. |
protected AttributeContext |
createAttributeContext(AttributeMetadata metadata) |
AttributeMetadata |
getMetadata(String name)
Returns the metadata associated with the attribute with the given
name. |
Map<String,List<String>> |
getReadable()
Returns only the attributes that have read/write permissions.
|
List<String> |
getValues(String name)
Returns all values for an attribute with the given
name. |
boolean |
isReadOnly(String attributeName)
Checks whether an attribute is read-only.
|
boolean |
isRequired(String name)
Returns whether the attribute with the given
name is required. |
Set<String> |
nameSet()
Returns the names of all defined attributes.
|
Map<String,List<String>> |
toMap() |
boolean |
validate(String name,
Consumer<ValidationError>... listeners)
Validates the attribute with the given
name. |
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesequals, hashCode, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitgetFirstValue, getReadable, isRootAttributepublic static final String READ_ONLY_ATTRIBUTE_KEY
protected final UserModel user
public DefaultAttributes(UserProfileContext context, Map<String,?> attributes, UserModel user, UserProfileMetadata profileMetadata, KeycloakSession session)
public boolean isReadOnly(String attributeName)
AttributesisReadOnly in interface Attributespublic boolean isRequired(String name)
Attributesname is required.isRequired in interface Attributesname - the attribute nametrue if the attribute is required. Otherwise, false.public boolean validate(String name, Consumer<ValidationError>... listeners)
Attributesname.validate in interface Attributesname - the name of the attributelisteners - the listeners for listening for errors. ValidationError.inputHint contains name of the attribute in error.true if validation is successful. Otherwise, false. In case there is no attribute with the given name,
false is also returned but without triggering listenerspublic List<String> getValues(String name)
Attributesname.getValues in interface Attributesname - the name of the attributepublic boolean contains(String name)
Attributesname is defined.contains in interface Attributesname - the name of the attributetrue if the attribute is defined. Otherwise, falsepublic Set<String> nameSet()
AttributesnameSet in interface Attributespublic Set<Map.Entry<String,List<String>>> attributeSet()
AttributesattributeSet in interface Attributespublic AttributeMetadata getMetadata(String name)
AttributesReturns the metadata associated with the attribute with the given name.
The AttributeMetadata is a copy of the original metadata. The original metadata
keeps immutable.
getMetadata in interface Attributesname - the attribute namepublic Map<String,List<String>> getReadable()
AttributesgetReadable in interface Attributesprotected AttributeContext createAttributeContext(AttributeMetadata metadata)
Copyright © 2021 JBoss by Red Hat. All rights reserved.