public class UserStorageManager extends AbstractStorageManager<UserStorageProvider,UserStorageProviderModel> implements UserProvider.Streams, OnUserCache, OnCreateComponent, OnUpdateComponent
UserProvider.Streams
session
Constructor and Description |
---|
UserStorageManager(KeycloakSession session) |
Modifier and Type | Method and Description |
---|---|
void |
addConsent(RealmModel realm,
String userId,
UserConsentModel consent) |
void |
addFederatedIdentity(RealmModel realm,
UserModel user,
FederatedIdentityModel socialLink) |
UserModel |
addUser(RealmModel realm,
String username)
UserRegistrationProvider methods implementations start here |
UserModel |
addUser(RealmModel realm,
String id,
String username,
boolean addDefaultRoles,
boolean addDefaultRequiredActions)
UserStorageProvider methods implementation end here
UserProvider methods implementations start here -> no StorageProviders involved |
void |
close()
UserProvider methods implementations end here |
protected void |
deleteInvalidUser(RealmModel realm,
UserModel user) |
UserConsentModel |
getConsentByClient(RealmModel realm,
String userId,
String clientInternalId) |
Stream<UserConsentModel> |
getConsentsStream(RealmModel realm,
String userId)
Obtains the consents associated with the user identified by the specified
userId . |
Stream<FederatedIdentityModel> |
getFederatedIdentitiesStream(UserModel user,
RealmModel realm)
Obtains the federated identities of the specified user.
|
FederatedIdentityModel |
getFederatedIdentity(UserModel user,
String socialProvider,
RealmModel realm) |
Stream<UserModel> |
getGroupMembersStream(RealmModel realm,
GroupModel group)
UserLookupProvider methods implementations end here
UserQueryProvider methods implementation start here |
Stream<UserModel> |
getGroupMembersStream(RealmModel realm,
GroupModel group,
Integer firstResult,
Integer maxResults)
Obtains users that belong to a specific group.
|
int |
getNotBeforeOfUser(RealmModel realm,
UserModel user) |
Stream<UserModel> |
getRoleMembersStream(RealmModel realm,
RoleModel role)
Obtains users that have the specified role.
|
Stream<UserModel> |
getRoleMembersStream(RealmModel realm,
RoleModel role,
Integer firstResult,
Integer maxResults)
Searches for users that have the specified role.
|
UserModel |
getServiceAccount(ClientModel client) |
UserModel |
getUserByEmail(String email,
RealmModel realm) |
UserModel |
getUserByFederatedIdentity(FederatedIdentityModel socialLink,
RealmModel realm) |
UserModel |
getUserById(String id,
RealmModel realm)
UserRegistrationProvider methods implementations end here
UserLookupProvider methods implementations start here |
UserModel |
getUserByUsername(String username,
RealmModel realm) |
int |
getUsersCount(Map<String,String> params,
RealmModel realm)
Returns the number of users that match the given filter parameters.
|
int |
getUsersCount(Map<String,String> params,
RealmModel realm,
Set<String> groupIds)
Returns the number of users that match the given filter parameters and is in
at least one of the given groups.
|
int |
getUsersCount(RealmModel realm)
Returns the number of users, without consider any service account.
|
int |
getUsersCount(RealmModel realm,
boolean includeServiceAccount)
Returns the number of users.
|
int |
getUsersCount(RealmModel realm,
Set<String> groupIds)
Returns the number of users that are in at least one of the groups
given.
|
int |
getUsersCount(String search,
RealmModel realm)
Returns the number of users that match the given criteria.
|
int |
getUsersCount(String search,
RealmModel realm,
Set<String> groupIds)
Returns the number of users that match the given criteria and are in
at least one of the groups given.
|
Stream<UserModel> |
getUsersStream(RealmModel realm)
Searches all users in the realm.
|
Stream<UserModel> |
getUsersStream(RealmModel realm,
boolean includeServiceAccounts)
Obtains the users associated with the specified realm.
|
Stream<UserModel> |
getUsersStream(RealmModel realm,
Integer firstResult,
Integer maxResults,
boolean includeServiceAccounts)
Obtains the users associated with the specified realm.
|
Stream<UserModel> |
getUsersStream(RealmModel realm,
int firstResult,
int maxResults)
Searches all users in the realm, starting from the
firstResult and containing at most maxResults . |
void |
grantToAllUsers(RealmModel realm,
RoleModel role)
UserQueryProvider methods implementation end here
UserBulkUpdateProvider methods implementation start here |
protected Stream<UserModel> |
importValidation(RealmModel realm,
Stream<UserModel> users) |
protected UserModel |
importValidation(RealmModel realm,
UserModel user)
Allows a UserStorageProvider to proxy and/or synchronize an imported user.
|
protected UserProvider |
localStorage() |
void |
onCache(RealmModel realm,
CachedUserModel user,
UserModel delegate) |
void |
onCreate(KeycloakSession session,
RealmModel realm,
ComponentModel model) |
void |
onUpdate(KeycloakSession session,
RealmModel realm,
ComponentModel oldModel,
ComponentModel newModel) |
void |
preRemove(ClientScopeModel clientScope) |
void |
preRemove(ProtocolMapperModel protocolMapper) |
void |
preRemove(RealmModel realm)
UserBulkUpdateProvider methods implementation end here
UserStorageProvider methods implementations start here -> no StorageProviders involved |
void |
preRemove(RealmModel realm,
ClientModel client) |
void |
preRemove(RealmModel realm,
ComponentModel component) |
void |
preRemove(RealmModel realm,
GroupModel group) |
void |
preRemove(RealmModel realm,
IdentityProviderModel provider) |
void |
preRemove(RealmModel realm,
RoleModel role) |
protected Stream<UserModel> |
query(org.keycloak.storage.UserStorageManager.PaginatedQuery pagedQuery,
RealmModel realm,
int firstResult,
int maxResults) |
boolean |
removeFederatedIdentity(RealmModel realm,
UserModel user,
String socialProvider) |
void |
removeImportedUsers(RealmModel realm,
String storageProviderId)
Removes any imported users from a specific User Storage Provider.
|
boolean |
removeUser(RealmModel realm,
UserModel user)
Called if user originated from this provider.
|
boolean |
revokeConsentForClient(RealmModel realm,
String userId,
String clientInternalId) |
Stream<UserModel> |
searchForUserByUserAttributeStream(String attrName,
String attrValue,
RealmModel realm)
Searches for users that have a specific attribute with a specific value.
|
Stream<UserModel> |
searchForUserStream(Map<String,String> attributes,
RealmModel realm)
Searches for user by parameter.
|
Stream<UserModel> |
searchForUserStream(Map<String,String> attributes,
RealmModel realm,
Integer firstResult,
Integer maxResults)
Searches for user by parameter.
|
Stream<UserModel> |
searchForUserStream(String search,
RealmModel realm)
Searches for users with username, email or first + last name that is like search string.
|
Stream<UserModel> |
searchForUserStream(String search,
RealmModel realm,
Integer firstResult,
Integer maxResults)
Searches for users with username, email or first + last name that is like search string.
|
void |
setNotBeforeForUser(RealmModel realm,
UserModel user,
int notBefore) |
void |
unlinkUsers(RealmModel realm,
String storageProviderId)
Set federation link to null to imported users of a specific User Storage Provider
|
void |
updateConsent(RealmModel realm,
String userId,
UserConsentModel consent) |
void |
updateFederatedIdentity(RealmModel realm,
UserModel federatedUser,
FederatedIdentityModel federatedIdentityModel) |
consumeEnabledStorageProvidersWithTimeout, flatMapEnabledStorageProvidersWithTimeout, getEnabledStorageProviders, getStorageProviderFactory, getStorageProviderInstance, getStorageProviderInstance, getStorageProviderInstance, getStorageProviderInstance, getStorageProviderModel, getStorageProviderModels, getStorageProviderTimeout, mapEnabledStorageProvidersWithTimeout
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConsents, getFederatedIdentities, getUsers, getUsers
getGroupMembers, getGroupMembers, getUsers, getUsers, searchForUser, searchForUser, searchForUser, searchForUser, searchForUserByUserAttribute
countUsersInGroups, getRoleMembers, getRoleMembers
public UserStorageManager(KeycloakSession session)
protected UserProvider localStorage()
protected UserModel importValidation(RealmModel realm, UserModel user)
realm
- user
- protected void deleteInvalidUser(RealmModel realm, UserModel user)
protected Stream<UserModel> importValidation(RealmModel realm, Stream<UserModel> users)
protected Stream<UserModel> query(org.keycloak.storage.UserStorageManager.PaginatedQuery pagedQuery, RealmModel realm, int firstResult, int maxResults)
public UserModel addUser(RealmModel realm, String username)
UserRegistrationProvider
methods implementations start hereaddUser
in interface UserRegistrationProvider
public boolean removeUser(RealmModel realm, UserModel user)
UserRegistrationProvider
removeUser
in interface UserRegistrationProvider
public UserModel getUserById(String id, RealmModel realm)
UserRegistrationProvider
methods implementations end here
UserLookupProvider
methods implementations start heregetUserById
in interface UserLookupProvider
public UserModel getUserByUsername(String username, RealmModel realm)
getUserByUsername
in interface UserLookupProvider
public UserModel getUserByEmail(String email, RealmModel realm)
getUserByEmail
in interface UserLookupProvider
public Stream<UserModel> getGroupMembersStream(RealmModel realm, GroupModel group)
UserLookupProvider
methods implementations end here
UserQueryProvider
methods implementation start heregetGroupMembersStream
in interface UserQueryProvider
getGroupMembersStream
in interface UserQueryProvider.Streams
realm
- a reference to the realm.group
- a reference to the group.Stream
of users that belong to the group.UserFederatedStorageProvider
public Stream<UserModel> getGroupMembersStream(RealmModel realm, GroupModel group, Integer firstResult, Integer maxResults)
UserQueryProvider
UserFederatedStorageProvider
as this is done automatically.getGroupMembersStream
in interface UserQueryProvider
getGroupMembersStream
in interface UserQueryProvider.Streams
realm
- a reference to the realm.group
- a reference to the group.firstResult
- first result to return. Ignored if negative.maxResults
- maximum number of results to return. Ignored if negative.Stream
of users that belong to the group.UserFederatedStorageProvider
public Stream<UserModel> getRoleMembersStream(RealmModel realm, RoleModel role)
UserQueryProvider
getRoleMembersStream
in interface UserQueryProvider
realm
- a reference to the realm.role
- a reference to the role.Stream
of users that have the specified role.public Stream<UserModel> getRoleMembersStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults)
UserQueryProvider
getRoleMembersStream
in interface UserQueryProvider
realm
- a reference to the realm.role
- a reference to the role.firstResult
- first result to return. Ignored if negative.maxResults
- maximum number of results to return. Ignored if negative.Stream
of users that have the specified role.public Stream<UserModel> getUsersStream(RealmModel realm)
UserQueryProvider
getUsersStream
in interface UserQueryProvider
getUsersStream
in interface UserQueryProvider.Streams
realm
- a reference to the realm.Stream
of users.public Stream<UserModel> getUsersStream(RealmModel realm, int firstResult, int maxResults)
UserQueryProvider
firstResult
and containing at most maxResults
.getUsersStream
in interface UserQueryProvider
getUsersStream
in interface UserQueryProvider.Streams
realm
- a reference to the realm.firstResult
- first result to return. Ignored if negative.maxResults
- maximum number of results to return. Ignored if negative.Stream
of users.public Stream<UserModel> getUsersStream(RealmModel realm, boolean includeServiceAccounts)
UserProvider
getUsersStream
in interface UserProvider
getUsersStream
in interface UserProvider.Streams
realm
- a reference to the realm being used for the search.includeServiceAccounts
- true
if service accounts should be included in the result; false
otherwise.Stream
of users associated withe the realm.public Stream<UserModel> getUsersStream(RealmModel realm, Integer firstResult, Integer maxResults, boolean includeServiceAccounts)
UserProvider
getUsersStream
in interface UserProvider
getUsersStream
in interface UserProvider.Streams
realm
- a reference to the realm being used for the search.firstResult
- first result to return. Ignored if negative.maxResults
- maximum number of results to return. Ignored if negative.includeServiceAccounts
- true
if service accounts should be included in the result; false
otherwise.Stream
of users associated withe the realm.public int getUsersCount(RealmModel realm, boolean includeServiceAccount)
UserQueryProvider
getUsersCount
in interface UserQueryProvider
realm
- the realmincludeServiceAccount
- if true, the number of users will also include service accounts. Otherwise, only the number of users.public int getUsersCount(RealmModel realm)
UserQueryProvider
getUsersCount
in interface UserQueryProvider
realm
- the realmpublic int getUsersCount(RealmModel realm, Set<String> groupIds)
UserQueryProvider
getUsersCount
in interface UserQueryProvider
realm
- the realmgroupIds
- set of groups id to check forpublic int getUsersCount(String search, RealmModel realm)
UserQueryProvider
getUsersCount
in interface UserQueryProvider
search
- search criteriarealm
- the realmpublic int getUsersCount(String search, RealmModel realm, Set<String> groupIds)
UserQueryProvider
getUsersCount
in interface UserQueryProvider
search
- search criteriarealm
- the realmgroupIds
- set of groups to check forpublic int getUsersCount(Map<String,String> params, RealmModel realm)
UserQueryProvider
getUsersCount
in interface UserQueryProvider
params
- filter parametersrealm
- the realmpublic int getUsersCount(Map<String,String> params, RealmModel realm, Set<String> groupIds)
UserQueryProvider
getUsersCount
in interface UserQueryProvider
params
- filter parametersrealm
- the realmgroupIds
- set if groups to check forpublic Stream<UserModel> searchForUserStream(String search, RealmModel realm)
UserQueryProvider
searchForUserStream
in interface UserQueryProvider
searchForUserStream
in interface UserQueryProvider.Streams
search
- case sensitive search string.realm
- a reference to the realm.Stream
of users that match the search string.public Stream<UserModel> searchForUserStream(String search, RealmModel realm, Integer firstResult, Integer maxResults)
UserQueryProvider
searchForUserStream
in interface UserQueryProvider
searchForUserStream
in interface UserQueryProvider.Streams
search
- case sensitive search string.realm
- a reference to the realm.firstResult
- first result to return. Ignored if negative.maxResults
- maximum number of results to return. Ignored if negative.Stream
of users that match the search criteria.public Stream<UserModel> searchForUserStream(Map<String,String> attributes, RealmModel realm)
UserQueryProvider
searchForUserStream
in interface UserQueryProvider
searchForUserStream
in interface UserQueryProvider.Streams
attributes
- a map containing the search parameters.realm
- a reference to the realm.Stream
of users that match the search parameters.public Stream<UserModel> searchForUserStream(Map<String,String> attributes, RealmModel realm, Integer firstResult, Integer maxResults)
UserQueryProvider
searchForUserStream
in interface UserQueryProvider
searchForUserStream
in interface UserQueryProvider.Streams
attributes
- a map containing the search parameters.realm
- a reference to the realm.firstResult
- first result to return. Ignored if negative.maxResults
- maximum number of results to return. Ignored if negative.Stream
of users that match the search criteria.public Stream<UserModel> searchForUserByUserAttributeStream(String attrName, String attrValue, RealmModel realm)
UserQueryProvider
UserFederatedStorageProvider
as this is done automatically.searchForUserByUserAttributeStream
in interface UserQueryProvider
searchForUserByUserAttributeStream
in interface UserQueryProvider.Streams
attrName
- the attribute name.attrValue
- the attribute value.realm
- a reference to the realm.Stream
of users that match the search criteria.UserFederatedStorageProvider
public void grantToAllUsers(RealmModel realm, RoleModel role)
UserQueryProvider
methods implementation end here
UserBulkUpdateProvider
methods implementation start heregrantToAllUsers
in interface UserBulkUpdateProvider
realm
- Realmrole
- Role to be grantedpublic void preRemove(RealmModel realm)
UserBulkUpdateProvider
methods implementation end here
UserStorageProvider
methods implementations start here -> no StorageProviders involvedpreRemove
in interface UserProvider
public void preRemove(RealmModel realm, GroupModel group)
preRemove
in interface UserProvider
public void preRemove(RealmModel realm, RoleModel role)
preRemove
in interface UserProvider
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions)
UserStorageProvider
methods implementation end here
UserProvider
methods implementations start here -> no StorageProviders involvedaddUser
in interface UserProvider
public void addFederatedIdentity(RealmModel realm, UserModel user, FederatedIdentityModel socialLink)
addFederatedIdentity
in interface UserProvider
public void updateFederatedIdentity(RealmModel realm, UserModel federatedUser, FederatedIdentityModel federatedIdentityModel)
updateFederatedIdentity
in interface UserProvider
public boolean removeFederatedIdentity(RealmModel realm, UserModel user, String socialProvider)
removeFederatedIdentity
in interface UserProvider
public void preRemove(RealmModel realm, IdentityProviderModel provider)
preRemove
in interface UserProvider
public void addConsent(RealmModel realm, String userId, UserConsentModel consent)
addConsent
in interface UserProvider
public UserConsentModel getConsentByClient(RealmModel realm, String userId, String clientInternalId)
getConsentByClient
in interface UserProvider
public Stream<UserConsentModel> getConsentsStream(RealmModel realm, String userId)
UserProvider
userId
.getConsentsStream
in interface UserProvider
getConsentsStream
in interface UserProvider.Streams
realm
- a reference to the realm.userId
- the user identifier.Stream
of consents associated with the user.public void updateConsent(RealmModel realm, String userId, UserConsentModel consent)
updateConsent
in interface UserProvider
public boolean revokeConsentForClient(RealmModel realm, String userId, String clientInternalId)
revokeConsentForClient
in interface UserProvider
public void setNotBeforeForUser(RealmModel realm, UserModel user, int notBefore)
setNotBeforeForUser
in interface UserProvider
public int getNotBeforeOfUser(RealmModel realm, UserModel user)
getNotBeforeOfUser
in interface UserProvider
public UserModel getUserByFederatedIdentity(FederatedIdentityModel socialLink, RealmModel realm)
getUserByFederatedIdentity
in interface UserProvider
public UserModel getServiceAccount(ClientModel client)
getServiceAccount
in interface UserProvider
public Stream<FederatedIdentityModel> getFederatedIdentitiesStream(UserModel user, RealmModel realm)
UserProvider
getFederatedIdentitiesStream
in interface UserProvider
getFederatedIdentitiesStream
in interface UserProvider.Streams
user
- a reference to the user.realm
- a reference to the realm.Stream
of federated identities associated with the user.public FederatedIdentityModel getFederatedIdentity(UserModel user, String socialProvider, RealmModel realm)
getFederatedIdentity
in interface UserProvider
public void preRemove(RealmModel realm, ClientModel client)
preRemove
in interface UserProvider
public void preRemove(ProtocolMapperModel protocolMapper)
preRemove
in interface UserProvider
public void preRemove(ClientScopeModel clientScope)
preRemove
in interface UserProvider
public void preRemove(RealmModel realm, ComponentModel component)
preRemove
in interface UserProvider
public void removeImportedUsers(RealmModel realm, String storageProviderId)
UserProvider
removeImportedUsers
in interface UserProvider
public void unlinkUsers(RealmModel realm, String storageProviderId)
UserProvider
unlinkUsers
in interface UserProvider
public void close()
UserProvider
methods implementations end hereclose
in interface UserProvider
close
in interface Provider
public void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model)
onCreate
in interface OnCreateComponent
public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel)
onUpdate
in interface OnUpdateComponent
public void onCache(RealmModel realm, CachedUserModel user, UserModel delegate)
onCache
in interface OnUserCache
Copyright © 2020 JBoss by Red Hat. All rights reserved.