public class UserAdapter extends Object implements CachedUserModel.Streams
CachedUserModel.Streams
UserModel.RequiredAction, UserModel.SearchableFields, UserModel.UserRemovedEvent
Modifier and Type | Field and Description |
---|---|
protected CachedUser |
cached |
protected KeycloakSession |
keycloakSession |
protected RealmModel |
realm |
protected UserModel |
updated |
protected UserCacheSession |
userProviderCache |
COMPARE_BY_USERNAME, DISABLED_REASON, EMAIL, EMAIL_VERIFIED, ENABLED, EXACT, FIRST_NAME, GROUPS, IDP_ALIAS, IDP_USER_ID, INCLUDE_SERVICE_ACCOUNT, LAST_NAME, LOCALE, SEARCH, USERNAME
Constructor and Description |
---|
UserAdapter(CachedUser cached,
UserCacheSession userProvider,
KeycloakSession keycloakSession,
RealmModel realm) |
Modifier and Type | Method and Description |
---|---|
void |
addRequiredAction(String action) |
void |
addRequiredAction(UserModel.RequiredAction action) |
void |
deleteRoleMapping(RoleModel role)
Removes the given role mapping from this object.
|
boolean |
equals(Object o) |
Map<String,List<String>> |
getAttributes() |
Stream<String> |
getAttributeStream(String name)
Obtains all values associated with the specified attribute name.
|
ConcurrentHashMap |
getCachedWith()
Returns a map that contains custom things that are cached along with this model.
|
long |
getCacheTimestamp()
When was the model was loaded from database.
|
Stream<RoleModel> |
getClientRoleMappingsStream(ClientModel app)
Returns stream of client roles that are directly set to this object for the given client.
|
Long |
getCreatedTimestamp()
Get timestamp of user creation.
|
UserModel |
getDelegateForUpdate()
Invalidates the cache for this user and returns a delegate that represents the actual data provider
|
String |
getEmail() |
String |
getFederationLink() |
String |
getFirstAttribute(String name) |
String |
getFirstName() |
long |
getGroupsCountByNameContaining(String search) |
Stream<GroupModel> |
getGroupsStream()
Obtains the groups associated with the user.
|
String |
getId() |
String |
getLastName() |
Stream<RoleModel> |
getRealmRoleMappingsStream()
Returns stream of realm roles that are directly set to this object.
|
Stream<String> |
getRequiredActionsStream()
Obtains the names of required actions associated with the user.
|
Stream<RoleModel> |
getRoleMappingsStream()
Returns stream of all role (both realm all client) that are directly set to this object.
|
String |
getServiceAccountClientLink() |
String |
getUsername() |
void |
grantRole(RoleModel role)
Grants the given role to this object.
|
int |
hashCode() |
boolean |
hasRole(RoleModel role)
Returns
true if this object is directly or indirectly assigned the given role, false otherwise. |
void |
invalidate()
Invalidate the cache for this model
|
boolean |
isEmailVerified() |
boolean |
isEnabled() |
boolean |
isMarkedForEviction() |
boolean |
isMemberOf(GroupModel group) |
void |
joinGroup(GroupModel group) |
void |
leaveGroup(GroupModel group) |
void |
removeAttribute(String name) |
void |
removeRequiredAction(String action) |
void |
removeRequiredAction(UserModel.RequiredAction action) |
void |
setAttribute(String name,
List<String> values) |
void |
setCreatedTimestamp(Long timestamp) |
void |
setEmail(String email)
Sets email for this user.
|
void |
setEmailVerified(boolean verified) |
void |
setEnabled(boolean enabled) |
void |
setFederationLink(String link) |
void |
setFirstName(String firstName) |
void |
setLastName(String lastName) |
void |
setServiceAccountClientLink(String clientInternalId) |
void |
setSingleAttribute(String name,
String value)
Set single value of specified attribute.
|
void |
setUsername(String username)
Sets username for this user.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getAttribute, getGroups, getRequiredActions
getGroups, getGroups, getGroupsCount, getGroupsStream
getClientRoleMappings, getRealmRoleMappings, getRoleMappings
protected final CachedUser cached
protected final UserCacheSession userProviderCache
protected final KeycloakSession keycloakSession
protected final RealmModel realm
protected volatile UserModel updated
public UserAdapter(CachedUser cached, UserCacheSession userProvider, KeycloakSession keycloakSession, RealmModel realm)
public String getFirstName()
getFirstName
in interface UserModel
public void setFirstName(String firstName)
setFirstName
in interface UserModel
public String getLastName()
getLastName
in interface UserModel
public void setLastName(String lastName)
setLastName
in interface UserModel
public void setEmail(String email)
UserModel
public UserModel getDelegateForUpdate()
CachedUserModel
getDelegateForUpdate
in interface CachedUserModel
public boolean isMarkedForEviction()
isMarkedForEviction
in interface CachedUserModel
public void invalidate()
CachedUserModel
invalidate
in interface CachedUserModel
public long getCacheTimestamp()
CachedUserModel
getCacheTimestamp
in interface CachedUserModel
public ConcurrentHashMap getCachedWith()
CachedUserModel
getCachedWith
in interface CachedUserModel
public String getUsername()
getUsername
in interface UserModel
public void setUsername(String username)
UserModel
setUsername
in interface UserModel
username
- username stringpublic Long getCreatedTimestamp()
UserModel
getCreatedTimestamp
in interface UserModel
public void setCreatedTimestamp(Long timestamp)
setCreatedTimestamp
in interface UserModel
public void setEnabled(boolean enabled)
setEnabled
in interface UserModel
public void setSingleAttribute(String name, String value)
UserModel
setSingleAttribute
in interface UserModel
public void setAttribute(String name, List<String> values)
setAttribute
in interface UserModel
public void removeAttribute(String name)
removeAttribute
in interface UserModel
public String getFirstAttribute(String name)
getFirstAttribute
in interface UserModel
public Stream<String> getAttributeStream(String name)
UserModel
getAttributeStream
in interface UserModel
getAttributeStream
in interface UserModel.Streams
name
- the name of the attribute.Stream
of attribute values.public Map<String,List<String>> getAttributes()
getAttributes
in interface UserModel
public Stream<String> getRequiredActionsStream()
UserModel
getRequiredActionsStream
in interface UserModel
getRequiredActionsStream
in interface UserModel.Streams
Stream
of required action names.public void addRequiredAction(UserModel.RequiredAction action)
addRequiredAction
in interface UserModel
public void removeRequiredAction(UserModel.RequiredAction action)
removeRequiredAction
in interface UserModel
public void addRequiredAction(String action)
addRequiredAction
in interface UserModel
public void removeRequiredAction(String action)
removeRequiredAction
in interface UserModel
public boolean isEmailVerified()
isEmailVerified
in interface UserModel
public void setEmailVerified(boolean verified)
setEmailVerified
in interface UserModel
public String getFederationLink()
getFederationLink
in interface UserModel
public void setFederationLink(String link)
setFederationLink
in interface UserModel
public String getServiceAccountClientLink()
getServiceAccountClientLink
in interface UserModel
public void setServiceAccountClientLink(String clientInternalId)
setServiceAccountClientLink
in interface UserModel
public Stream<RoleModel> getRealmRoleMappingsStream()
RoleMapperModel
getRealmRoleMappingsStream
in interface RoleMapperModel
getRealmRoleMappingsStream
in interface RoleMapperModel.Streams
RoleModel
. Never returns null
.public Stream<RoleModel> getClientRoleMappingsStream(ClientModel app)
RoleMapperModel
getClientRoleMappingsStream
in interface RoleMapperModel
getClientRoleMappingsStream
in interface RoleMapperModel.Streams
app
- ClientModel
Client to get the roles for.RoleModel
. Never returns null
.public boolean hasRole(RoleModel role)
RoleMapperModel
true
if this object is directly or indirectly assigned the given role, false
otherwise.
For example, true
is returned for hasRole(R) if:
hasRole
in interface RoleMapperModel
public void grantRole(RoleModel role)
RoleMapperModel
grantRole
in interface RoleMapperModel
public Stream<RoleModel> getRoleMappingsStream()
RoleMapperModel
getRoleMappingsStream
in interface RoleMapperModel
getRoleMappingsStream
in interface RoleMapperModel.Streams
RoleModel
. Never returns null
.public void deleteRoleMapping(RoleModel role)
RoleMapperModel
deleteRoleMapping
in interface RoleMapperModel
role
- Role to removepublic Stream<GroupModel> getGroupsStream()
UserModel
getGroupsStream
in interface UserModel
getGroupsStream
in interface UserModel.Streams
Stream
of groups.public long getGroupsCountByNameContaining(String search)
getGroupsCountByNameContaining
in interface UserModel
public void joinGroup(GroupModel group)
public void leaveGroup(GroupModel group)
leaveGroup
in interface UserModel
public boolean isMemberOf(GroupModel group)
isMemberOf
in interface UserModel
Copyright © 2021 JBoss by Red Hat. All rights reserved.