Package org.keycloak.userprofile
Class DefaultUserProfile
java.lang.Object
org.keycloak.userprofile.DefaultUserProfile
- All Implemented Interfaces:
UserProfile
The default implementation for UserProfile. Should be reused as much as possible by the different implementations
of UserProfileProvider.
This implementation is not specific to any user profile implementation.
- Author:
- Pedro Igor
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultUserProfile(UserProfileMetadata metadata, Attributes attributes, Function<Attributes, UserModel> userCreator, UserModel user, KeycloakSession session) -
Method Summary
Modifier and TypeMethodDescriptioncreate()Creates a newUserModelbased on the attributes associated with this instance.Returns the attributes associated with this instance.<R extends AbstractUserRepresentation>
Rvoidupdate(boolean removeAttributes, AttributeChangeListener... changeListener) Updates theUserModelassociated with this instance.voidvalidate()Validates the attributes associated with this instance.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.userprofile.UserProfile
update
-
Constructor Details
-
DefaultUserProfile
public DefaultUserProfile(UserProfileMetadata metadata, Attributes attributes, Function<Attributes, UserModel> userCreator, UserModel user, KeycloakSession session)
-
-
Method Details
-
validate
public void validate()Description copied from interface:UserProfileValidates the attributes associated with this instance.- Specified by:
validatein interfaceUserProfile
-
create
Description copied from interface:UserProfileCreates a newUserModelbased on the attributes associated with this instance.- Specified by:
createin interfaceUserProfile- Returns:
- the
UserModelinstance created from this profile - Throws:
ValidationException- in case validation fails
-
update
Description copied from interface:UserProfileUpdates the
UserModelassociated with this instance. If noUserModelis associated with this instance, this operation has no effect.Before updating the
UserModel, this method first checks whether theUserProfile.validate()method was previously invoked. If not, the validation step is performed prior to updating the model.- Specified by:
updatein interfaceUserProfile- Parameters:
removeAttributes- if attributes should be removed from theUserModelif they are not among the attributes associated with this instance.changeListener- a set of one or more listeners to listen for attribute changes
-
getAttributes
Description copied from interface:UserProfileReturns the attributes associated with this instance. Note that the attributes returned by this method are not necessarily the same from theUserModelas they are based on the configurations set in theUPConfigand the context this instance is based on.- Specified by:
getAttributesin interfaceUserProfile- Returns:
- the attributes associated with this instance.
-
toRepresentation
- Specified by:
toRepresentationin interfaceUserProfile
-