Package org.keycloak.storage.user
Interface UserQueryProvider
-
- All Known Subinterfaces:
UserCache
,UserCache.Streams
,UserProvider
,UserProvider.Streams
,UserQueryProvider.Streams
- All Known Implementing Classes:
JpaUserProvider
,LDAPStorageProvider
,MapUserProvider
,UserCacheSession
,UserStorageManager
public interface UserQueryProvider
This is an optional capability interface that is intended to be implemented by anyUserStorageProvider
that supports complex user querying. You must implement this interface if you want to view and manage users from the administration console. Note that all methods in this interface should limit search only to data available within the storage that is represented by this provider. They should not lookup other storage providers for additional information.- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
UserQueryProvider.Streams
Deprecated.This interface is no longer necessary, collection-based methods were removed from the parent interface and therefore the parent interface can be used directly
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description static int
countUsersInGroups(Stream<UserModel> users, Set<String> groupIds)
Returns the number of users from the given list of users that are in at least one of the groups given in the groups set.default Stream<UserModel>
getGroupMembersStream(RealmModel realm, GroupModel group)
Obtains users that belong to a specific group.Stream<UserModel>
getGroupMembersStream(RealmModel realm, GroupModel group, Integer firstResult, Integer maxResults)
Obtains users that belong to a specific group.default Stream<UserModel>
getRoleMembersStream(RealmModel realm, RoleModel role)
Obtains users that have the specified role.default Stream<UserModel>
getRoleMembersStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults)
Searches for users that have the specified role.default int
getUsersCount(RealmModel realm)
Returns the number of users, without consider any service account.default int
getUsersCount(RealmModel realm, boolean includeServiceAccount)
Returns the number of users.default int
getUsersCount(RealmModel realm, String search)
Returns the number of users that would be returned by a call tosearchForUserStream
default int
getUsersCount(RealmModel realm, String search, Set<String> groupIds)
Returns the number of users that would be returned by a call tosearchForUserStream
and are members of at least one of the groups given by thegroupIds
set.default int
getUsersCount(RealmModel realm, Map<String,String> params)
Returns the number of users that match the given filter parameters.default int
getUsersCount(RealmModel realm, Map<String,String> params, Set<String> groupIds)
Returns the number of users that match the given filter parameters and is in at least one of the given groups.default int
getUsersCount(RealmModel realm, Set<String> groupIds)
Returns the number of users that are in at least one of the groups given.default Stream<UserModel>
getUsersStream(RealmModel realm)
Deprecated.UsesearchForUserStream(RealmModel, Map)
with an empty params map instead.default Stream<UserModel>
getUsersStream(RealmModel realm, Integer firstResult, Integer maxResults)
Deprecated.UsesearchForUserStream(RealmModel, Map, Integer, Integer)
with an empty params map instead.Stream<UserModel>
searchForUserByUserAttributeStream(RealmModel realm, String attrName, String attrValue)
Searches for users that have a specific attribute with a specific value.default Stream<UserModel>
searchForUserStream(RealmModel realm, String search)
Searches for users whose username, email, first name or last name contain any of the strings insearch
separated by whitespace.Stream<UserModel>
searchForUserStream(RealmModel realm, String search, Integer firstResult, Integer maxResults)
Searches for users whose username, email, first name or last name contain any of the strings insearch
separated by whitespace.default Stream<UserModel>
searchForUserStream(RealmModel realm, Map<String,String> params)
Searches for user by parameter.Stream<UserModel>
searchForUserStream(RealmModel realm, Map<String,String> params, Integer firstResult, Integer maxResults)
Searches for user by parameter.
-
-
-
Method Detail
-
getUsersCount
default int getUsersCount(RealmModel realm)
Returns the number of users, without consider any service account.- Parameters:
realm
- the realm- Returns:
- the number of users
-
getUsersCount
default int getUsersCount(RealmModel realm, Set<String> groupIds)
Returns the number of users that are in at least one of the groups given.- Parameters:
realm
- the realmgroupIds
- set of groups IDs, the returned user needs to belong to at least one of them- Returns:
- the number of users that are in at least one of the groups
-
getUsersCount
default int getUsersCount(RealmModel realm, String search)
Returns the number of users that would be returned by a call tosearchForUserStream
- Parameters:
realm
- the realmsearch
- case insensitive list of strings separated by whitespaces.- Returns:
- number of users that match the search
-
getUsersCount
default int getUsersCount(RealmModel realm, String search, Set<String> groupIds)
Returns the number of users that would be returned by a call tosearchForUserStream
and are members of at least one of the groups given by thegroupIds
set.- Parameters:
realm
- the realmsearch
- case insensitive list of strings separated by whitespaces.groupIds
- set of groups IDs, the returned user needs to belong to at least one of them- Returns:
- number of users that match the search and given groups
-
getUsersCount
default int getUsersCount(RealmModel realm, Map<String,String> params)
Returns the number of users that match the given filter parameters.- Parameters:
realm
- the realmparams
- filter parameters- Returns:
- number of users that match the given filters
-
getUsersCount
default int getUsersCount(RealmModel realm, Map<String,String> params, Set<String> groupIds)
Returns the number of users that match the given filter parameters and is in at least one of the given groups.- Parameters:
params
- filter parametersrealm
- the realmgroupIds
- set if groups to check for- Returns:
- number of users that match the given filters and groups
-
countUsersInGroups
static int countUsersInGroups(Stream<UserModel> users, Set<String> groupIds)
Returns the number of users from the given list of users that are in at least one of the groups given in the groups set.- Parameters:
users
- list of users to checkgroupIds
- id of groups that should be checked for- Returns:
- number of users that are in at least one of the groups
-
getUsersCount
default int getUsersCount(RealmModel realm, boolean includeServiceAccount)
Returns the number of users.- Parameters:
realm
- the realmincludeServiceAccount
- if true, the number of users will also include service accounts. Otherwise, only the number of users.- Returns:
- the number of users
-
getUsersStream
@Deprecated default Stream<UserModel> getUsersStream(RealmModel realm)
Deprecated.UsesearchForUserStream(RealmModel, Map)
with an empty params map instead.Searches all users in the realm.- Parameters:
realm
- a reference to the realm.- Returns:
- a non-null
Stream
of users.
-
getUsersStream
@Deprecated default Stream<UserModel> getUsersStream(RealmModel realm, Integer firstResult, Integer maxResults)
Deprecated.UsesearchForUserStream(RealmModel, Map, Integer, Integer)
with an empty params map instead.Searches all users in the realm, starting from thefirstResult
and containing at mostmaxResults
.- Parameters:
realm
- a reference to the realm.firstResult
- first result to return. Ignored if negative ornull
.maxResults
- maximum number of results to return. Ignored if negative ornull
.- Returns:
- a non-null
Stream
of users.
-
searchForUserStream
default Stream<UserModel> searchForUserStream(RealmModel realm, String search)
Searches for users whose username, email, first name or last name contain any of the strings insearch
separated by whitespace. If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE). This method is used by the admin console search box- Parameters:
realm
- a reference to the realm.search
- case insensitive list of string separated by whitespaces.- Returns:
- a non-null
Stream
of users that match the search string.
-
searchForUserStream
Stream<UserModel> searchForUserStream(RealmModel realm, String search, Integer firstResult, Integer maxResults)
Searches for users whose username, email, first name or last name contain any of the strings insearch
separated by whitespace. If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE). This method is used by the admin console search box- Parameters:
realm
- a reference to the realm.search
- case insensitive list of string separated by whitespaces.firstResult
- first result to return. Ignored if negative, zero, ornull
.maxResults
- maximum number of results to return. Ignored if negative ornull
.- Returns:
- a non-null
Stream
of users that match the search criteria.
-
searchForUserStream
default Stream<UserModel> searchForUserStream(RealmModel realm, Map<String,String> params)
Searches for user by parameter. If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE). Valid parameters are:UserModel.FIRST_NAME
- first name (case insensitive string)UserModel.LAST_NAME
- last name (case insensitive string)UserModel.EMAIL
- email (case insensitive string)UserModel.USERNAME
- username (case insensitive string)UserModel.EMAIL_VERIFIED
- search only for users with verified/non-verified email (true/false)UserModel.ENABLED
- search only for enabled/disabled users (true/false)UserModel.IDP_ALIAS
- search only for users that have a federated identity from idp with the given alias configured (case sensitive string)UserModel.IDP_USER_ID
- search for users with federated identity with the given userId (case sensitive string)
- Parameters:
realm
- a reference to the realm.params
- a map containing the search parameters.- Returns:
- a non-null
Stream
of users that match the search parameters.
-
searchForUserStream
Stream<UserModel> searchForUserStream(RealmModel realm, Map<String,String> params, Integer firstResult, Integer maxResults)
Searches for user by parameter. If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE). Valid parameters are:UserModel.FIRST_NAME
- first name (case insensitive string)UserModel.LAST_NAME
- last name (case insensitive string)UserModel.EMAIL
- email (case insensitive string)UserModel.USERNAME
- username (case insensitive string)UserModel.EMAIL_VERIFIED
- search only for users with verified/non-verified email (true/false)UserModel.ENABLED
- search only for enabled/disabled users (true/false)UserModel.IDP_ALIAS
- search only for users that have a federated identity from idp with the given alias configured (case sensitive string)UserModel.IDP_USER_ID
- search for users with federated identity with the given userId (case sensitive string)
- Parameters:
realm
- a reference to the realm.params
- a map containing the search parameters.firstResult
- first result to return. Ignored if negative, zero, ornull
.maxResults
- maximum number of results to return. Ignored if negative ornull
.- Returns:
- a non-null
Stream
of users that match the search criteria.
-
getGroupMembersStream
default Stream<UserModel> getGroupMembersStream(RealmModel realm, GroupModel group)
Obtains users that belong to a specific group.- Parameters:
realm
- a reference to the realm.group
- a reference to the group.- Returns:
- a non-null
Stream
of users that belong to the group.
-
getGroupMembersStream
Stream<UserModel> getGroupMembersStream(RealmModel realm, GroupModel group, Integer firstResult, Integer maxResults)
Obtains users that belong to a specific group.- Parameters:
realm
- a reference to the realm.group
- a reference to the group.firstResult
- first result to return. Ignored if negative, zero, ornull
.maxResults
- maximum number of results to return. Ignored if negative ornull
.- Returns:
- a non-null
Stream
of users that belong to the group.
-
getRoleMembersStream
default Stream<UserModel> getRoleMembersStream(RealmModel realm, RoleModel role)
Obtains users that have the specified role.- Parameters:
realm
- a reference to the realm.role
- a reference to the role.- Returns:
- a non-null
Stream
of users that have the specified role.
-
getRoleMembersStream
default Stream<UserModel> getRoleMembersStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults)
Searches for users that have the specified role.- Parameters:
realm
- a reference to the realm.role
- a reference to the role.firstResult
- first result to return. Ignored if negative ornull
.maxResults
- maximum number of results to return. Ignored if negative ornull
.- Returns:
- a non-null
Stream
of users that have the specified role.
-
searchForUserByUserAttributeStream
Stream<UserModel> searchForUserByUserAttributeStream(RealmModel realm, String attrName, String attrValue)
Searches for users that have a specific attribute with a specific value.- Parameters:
realm
- a reference to the realm.attrName
- the attribute name.attrValue
- the attribute value.- Returns:
- a non-null
Stream
of users that match the search criteria.
-
-