Package org.keycloak.userprofile
Class UserProfileUtil
java.lang.Object
org.keycloak.userprofile.UserProfileUtil
- Author:
- Marek Posolda
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AttributeMetadatacreateAttributeMetadata(String attrName, UserProfileMetadata metadata, int guiOrder, String storageProviderName) static AttributeMetadatacreateAttributeMetadata(String attrName, UserProfileMetadata metadata, AttributeGroupMetadata metadataGroup, int guiOrder, String storageProviderName) Adds metadata attribute to the user-profile for users from specified userStorageProviderstatic UserProfileMetadatacreateUserProfileMetadata(KeycloakSession session, UserProfile profile) static booleanisRootAttribute(String name) Returns whether the attribute with the givennameis a root attribute.static AttributeGroupMetadatalookupUserMetadataGroup(KeycloakSession session) Find the metadata group "user-metadata"static voidsetDefaultValuesForReadOnlyAttributes(UserModel user, Attributes attributes) Sets the configured default value of each attribute that is read-only in the context of the givenattributesand has no value on theuser.
-
Field Details
-
USER_METADATA_GROUP
- See Also:
-
ONLY_ADMIN_CONDITION
-
-
Constructor Details
-
UserProfileUtil
public UserProfileUtil()
-
-
Method Details
-
lookupUserMetadataGroup
Find the metadata group "user-metadata"- Parameters:
session-- Returns:
- metadata group if exists, otherwise null
-
createAttributeMetadata
public static AttributeMetadata createAttributeMetadata(String attrName, UserProfileMetadata metadata, AttributeGroupMetadata metadataGroup, int guiOrder, String storageProviderName) Adds metadata attribute to the user-profile for users from specified userStorageProvider- Parameters:
attrName- attribute namemetadata- user-profile metadata where attribute would be addedmetadataGroup- metadata group in user-profileguiOrder- guiOrder to where to put the attributestorageProviderName- storageProviderName (just for logging purposes)- Returns:
- the attribute metadata if attribute was created. False otherwise
-
createAttributeMetadata
public static AttributeMetadata createAttributeMetadata(String attrName, UserProfileMetadata metadata, int guiOrder, String storageProviderName) -
isRootAttribute
Returns whether the attribute with the givennameis a root attribute.- Parameters:
name- the attribute name- Returns:
-
setDefaultValuesForReadOnlyAttributes
Sets the configured default value of each attribute that is read-only in the context of the givenattributesand has no value on theuser. Read-only attributes are not persisted from the attributes provided in a context, so this is needed when creating users to make sure their default values are stored. The value always comes from the configuration, never from the attributes provided in the context.- Parameters:
user- the newly created userattributes- the attributes of the profile used to create the user
-
createUserProfileMetadata
public static UserProfileMetadata createUserProfileMetadata(KeycloakSession session, UserProfile profile)
-