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
TheUserQueryProvider.Streams
interface makes all collection-based methods inUserQueryProvider
default by providing implementations that delegate to theStream
-based variants instead of the other way around.
-
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.List<UserModel>
getGroupMembers(RealmModel realm, GroupModel group)
Deprecated.UsegetGroupMembersStream
instead.List<UserModel>
getGroupMembers(RealmModel realm, GroupModel group, int firstResult, int maxResults)
Deprecated.UsegetGroupMembersStream
instead.default Stream<UserModel>
getGroupMembersStream(RealmModel realm, GroupModel group)
Obtains users that belong to a specific group.default Stream<UserModel>
getGroupMembersStream(RealmModel realm, GroupModel group, Integer firstResult, Integer maxResults)
Obtains users that belong to a specific group.default List<UserModel>
getRoleMembers(RealmModel realm, RoleModel role)
Deprecated.UsegetRoleMembersStream
instead.default List<UserModel>
getRoleMembers(RealmModel realm, RoleModel role, int firstResult, int maxResults)
Deprecated.UsegetRoleMembersStream
instead.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.List<UserModel>
getUsers(RealmModel realm)
Deprecated.UsegetUsersStream
instead.List<UserModel>
getUsers(RealmModel realm, int firstResult, int maxResults)
Deprecated.UsegetUsersStream
instead.default int
getUsersCount(String search, RealmModel realm)
Deprecated.UsegetUsersCount
default int
getUsersCount(String search, RealmModel realm, Set<String> groupIds)
Deprecated.UsegetUsersCount
instead.default int
getUsersCount(Map<String,String> params, RealmModel realm)
Deprecated.UsegetUsersCount
instead.default int
getUsersCount(Map<String,String> params, RealmModel realm, Set<String> groupIds)
Deprecated.UsegetUsersCount
instead.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)
Searches all users in the realm.default Stream<UserModel>
getUsersStream(RealmModel realm, Integer firstResult, Integer maxResults)
Searches all users in the realm, starting from thefirstResult
and containing at mostmaxResults
.List<UserModel>
searchForUser(String search, RealmModel realm)
Deprecated.UsesearchForUserStream
instead.List<UserModel>
searchForUser(String search, RealmModel realm, int firstResult, int maxResults)
Deprecated.UsesearchForUserStream
instead.List<UserModel>
searchForUser(Map<String,String> params, RealmModel realm)
Deprecated.UsesearchForUserStream
instead.List<UserModel>
searchForUser(Map<String,String> params, RealmModel realm, int firstResult, int maxResults)
Deprecated.UsesearchForUserStream
instead.List<UserModel>
searchForUserByUserAttribute(String attrName, String attrValue, RealmModel realm)
Deprecated.UsesearchForUserByUserAttributeStream
instead.default 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.default 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.default 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
@Deprecated default int getUsersCount(String search, RealmModel realm)
Deprecated.UsegetUsersCount
-
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
@Deprecated default int getUsersCount(String search, RealmModel realm, Set<String> groupIds)
Deprecated.UsegetUsersCount
instead.
-
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
@Deprecated default int getUsersCount(Map<String,String> params, RealmModel realm)
Deprecated.UsegetUsersCount
instead.
-
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
-
getUsersCount
@Deprecated default int getUsersCount(Map<String,String> params, RealmModel realm, Set<String> groupIds)
Deprecated.UsegetUsersCount
instead.
-
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
-
getUsers
@Deprecated List<UserModel> getUsers(RealmModel realm)
Deprecated.UsegetUsersStream
instead.
-
getUsersStream
default Stream<UserModel> getUsersStream(RealmModel realm)
Searches all users in the realm.- Parameters:
realm
- a reference to the realm.- Returns:
- a non-null
Stream
of users.
-
getUsers
@Deprecated List<UserModel> getUsers(RealmModel realm, int firstResult, int maxResults)
Deprecated.UsegetUsersStream
instead.
-
getUsersStream
default Stream<UserModel> getUsersStream(RealmModel realm, Integer firstResult, Integer maxResults)
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.
-
searchForUser
@Deprecated List<UserModel> searchForUser(String search, RealmModel realm)
Deprecated.UsesearchForUserStream
instead.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:
search
- case insensitive list of string separated by whitespaces.realm
- realm to search within- Returns:
- list of users that satisfies the given search condition
-
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.
-
searchForUser
@Deprecated List<UserModel> searchForUser(String search, RealmModel realm, int firstResult, int maxResults)
Deprecated.UsesearchForUserStream
instead.Searches for users whose username, email, first name or last name contain any of the strings insearch
separated by whitespace. The resulting user list should be paginated with respect to parametersfirstResult
andmaxResults
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:
search
- case insensitive list of string separated by whitespaces.realm
- a reference to the realmfirstResult
- first result to return. Ignored if negative or zero.maxResults
- maximum number of results to return. Ignored if negative.- Returns:
- paginated list of users from the realm that satisfies given search
-
searchForUserStream
default 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.
-
searchForUser
@Deprecated List<UserModel> searchForUser(Map<String,String> params, RealmModel realm)
Deprecated.UsesearchForUserStream
instead.Search for user by a map of parameters. 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:
params
- a map containing the search parametersrealm
- a reference to the realm- Returns:
- list of users that satisfies given search conditions
-
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.
-
searchForUser
@Deprecated List<UserModel> searchForUser(Map<String,String> params, RealmModel realm, int firstResult, int maxResults)
Deprecated.UsesearchForUserStream
instead.Search for user by parameter. 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:
params
- 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.- Returns:
- a non-null
Stream
of users that match the search criteria.
-
searchForUserStream
default 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.
-
getGroupMembers
@Deprecated List<UserModel> getGroupMembers(RealmModel realm, GroupModel group)
Deprecated.UsegetGroupMembersStream
instead.Get users that belong to a specific group.- Parameters:
realm
- a reference to the realmgroup
- a reference to the group- Returns:
- a list of all users that are members of the given group
-
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.
-
getGroupMembers
@Deprecated List<UserModel> getGroupMembers(RealmModel realm, GroupModel group, int firstResult, int maxResults)
Deprecated.UsegetGroupMembersStream
instead.Gets paginated list of users that belong to a specific group.- Parameters:
realm
- a reference to the realmgroup
- a reference to the groupfirstResult
- first result to return. Ignored if negative or zero.maxResults
- maximum number of results to return. Ignored if negative.- Returns:
- paginated list of members of the given group
-
getGroupMembersStream
default 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.
-
getRoleMembers
@Deprecated default List<UserModel> getRoleMembers(RealmModel realm, RoleModel role)
Deprecated.UsegetRoleMembersStream
instead.Get users that belong to a specific role.- Parameters:
realm
- a reference to the realmrole
- a reference to the role- Returns:
- a list of users that has the given role assigned
-
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.
-
getRoleMembers
@Deprecated default List<UserModel> getRoleMembers(RealmModel realm, RoleModel role, int firstResult, int maxResults)
Deprecated.UsegetRoleMembersStream
instead.Search for users that have a specific role with a specific roleId.- Parameters:
realm
- a reference to the realmrole
- a reference to the rolefirstResult
- first result to return. Ignored if negative or zero.maxResults
- maximum number of results to return. Ignored if negative.- Returns:
- a paginated list of users that has the given role assigned
-
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.
-
searchForUserByUserAttribute
@Deprecated List<UserModel> searchForUserByUserAttribute(String attrName, String attrValue, RealmModel realm)
Deprecated.UsesearchForUserByUserAttributeStream
instead.Search for users that have a specific attribute with a specific value.- Parameters:
attrName
- a name of the attribute that will be searchedattrValue
- a value of the attribute that will be searchedrealm
- a reference to the realm- Returns:
- list of users with the given attribute name and value
-
searchForUserByUserAttributeStream
default 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.
-
-