Package org.keycloak.models
Interface GroupProvider
- All Superinterfaces:
GroupLookupProvider
,Provider
- All Known Subinterfaces:
CacheRealmProvider
- All Known Implementing Classes:
GroupStorageManager
,JpaRealmProvider
,RealmCacheSession
Provider of group records
- Author:
- mhajas
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTopLevelGroup
(RealmModel realm, GroupModel subGroup) Removes parent group for the given group in the given realm.default GroupModel
createGroup
(RealmModel realm, String name) Creates a new group with the given name in the given realm.default GroupModel
createGroup
(RealmModel realm, String id, String name) Creates a new group with the given id and name in the given realm.createGroup
(RealmModel realm, String id, String name, GroupModel toParent) Creates a new group with the given name, id, name and parent to the given realm.default GroupModel
createGroup
(RealmModel realm, String name, GroupModel toParent) Creates a new group with the given name and parent to the given realm.getGroupsByRoleStream
(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults) Returns groups with the given role in the given realm.getGroupsCount
(RealmModel realm, Boolean onlyTopGroups) Returns a number of groups/top level groups (i.e.default Long
getGroupsCount
(RealmModel realm, Stream<String> ids, String search) Returns a number of groups that contains the search string in the namegetGroupsCountByNameContaining
(RealmModel realm, String search) Returns the number of top level groups containing groups with the given string in name for the given realm.getGroupsStream
(RealmModel realm) Returns groups for the given realm.default Stream<GroupModel>
getGroupsStream
(RealmModel realm, Stream<String> ids) Returns a stream of groups with given ids.default Stream<GroupModel>
getGroupsStream
(RealmModel realm, Stream<String> ids, Integer first, Integer max) Returns a paginated stream of groups with given ids.getGroupsStream
(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max) Returns a paginated stream of groups with given ids and given search value in group names.default Stream<GroupModel>
Returns all top level groups (i.e.default Stream<GroupModel>
getTopLevelGroupsStream
(RealmModel realm, Integer firstResult, Integer maxResults) Returns top level groups (i.e.getTopLevelGroupsStream
(RealmModel realm, String search, Boolean exact, Integer firstResult, Integer maxResults) Returns top level groups (i.e.void
moveGroup
(RealmModel realm, GroupModel group, GroupModel toParent) This method is used for moving groups in group structure, for example: making an existing child group child group of some other group, setting a top level group (i.e.boolean
removeGroup
(RealmModel realm, GroupModel group) Removes the given group for the given realm.Methods inherited from interface org.keycloak.storage.group.GroupLookupProvider
getGroupById, getGroupByName, searchForGroupByNameStream, searchForGroupByNameStream, searchGroupsByAttributes
-
Field Details
-
DEFAULT_ESCAPE_SLASHES
static final boolean DEFAULT_ESCAPE_SLASHES- See Also:
-
-
Method Details
-
getGroupsStream
Returns groups for the given realm.- Parameters:
realm
- Realm.- Returns:
- Stream of groups in the Realm.
-
getGroupsStream
Returns a stream of groups with given ids. Effectively the same asgetGroupsStream(realm, ids, null, null, null)
.- Parameters:
realm
- Realm.ids
- Stream of ids.- Returns:
- Stream of GroupModels with the specified ids
-
getGroupsStream
Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max) Returns a paginated stream of groups with given ids and given search value in group names.- Parameters:
realm
- Realm.ids
- Stream of ids.search
- Case insensitive string which will be searched for. Ignored if null.first
- Index of the first result to return. Ignored if negative ornull
.max
- Maximum number of results to return. Ignored if negative ornull
.- Returns:
- Stream of desired groups. Never returns
null
.
-
getGroupsStream
default Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids, Integer first, Integer max) Returns a paginated stream of groups with given ids. Effectively the same asgetGroupsStream(realm, ids, null, first, max)
.- Parameters:
realm
- Realm.ids
- Stream of ids.first
- Index of the first result to return. Ignored if negative ornull
.max
- Maximum number of results to return. Ignored if negative ornull
.- Returns:
- Stream of GroupModels with the specified ids
-
getGroupsCount
Returns a number of groups that contains the search string in the name- Parameters:
realm
- Realm.ids
- List of ids.search
- Case insensitive string which will be searched for. Ignored if null.- Returns:
- Number of groups.
-
getGroupsCount
Returns a number of groups/top level groups (i.e. groups without parent group) for the given realm.- Parameters:
realm
- Realm.onlyTopGroups
- When true the function returns a count of top level groups only.- Returns:
- Number of groups/top level groups.
-
getGroupsCountByNameContaining
Returns the number of top level groups containing groups with the given string in name for the given realm.- Parameters:
realm
- Realm.search
- Case insensitive string which will be searched for.- Returns:
- Number of groups with the given string in its name.
-
getGroupsByRoleStream
Stream<GroupModel> getGroupsByRoleStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults) Returns groups with the given role in the given realm.- Parameters:
realm
- Realm.role
- Role.firstResult
- First result to return. Ignored if negative ornull
.maxResults
- Maximum number of results to return. Ignored if negative ornull
.- Returns:
- Stream of groups with the given role. Never returns
null
.
-
getTopLevelGroupsStream
Returns all top level groups (i.e. groups without parent group) for the given realm.- Parameters:
realm
- Realm.- Returns:
- Stream of all top level groups in the realm. Never returns
null
.
-
getTopLevelGroupsStream
default Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm, Integer firstResult, Integer maxResults) Returns top level groups (i.e. groups without parent group) for the given realm.- Parameters:
realm
- Realm.firstResult
- First result to return. Ignored if negative ornull
.maxResults
- Maximum number of results to return. Ignored if negative ornull
.- Returns:
- Stream of top level groups in the realm. Never returns
null
.
-
getTopLevelGroupsStream
Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm, String search, Boolean exact, Integer firstResult, Integer maxResults) Returns top level groups (i.e. groups without parent group) for the given realm.- Parameters:
realm
- Realm.firstResult
- First result to return. Ignored if negative ornull
.maxResults
- Maximum number of results to return. Ignored if negative ornull
.search
- The name that should be matched- Returns:
- Stream of top level groups in the realm. Never returns
null
.
-
createGroup
Creates a new group with the given name in the given realm. Effectively the same ascreateGroup(realm, null, name, null)
.- Parameters:
realm
- Realm.name
- Name.- Returns:
- Model of the created group.
- Throws:
ModelDuplicateException
- If there is already a top-level group with the given name
-
createGroup
Creates a new group with the given id and name in the given realm. Effectively the same ascreateGroup(realm, id, name, null)
- Parameters:
realm
- Realm.id
- Id.name
- Name.- Returns:
- Model of the created group
- Throws:
ModelDuplicateException
- If a group with given id already exists or there is a top-level group with the given name
-
createGroup
Creates a new group with the given name and parent to the given realm. Effectively the same ascreateGroup(realm, null, name, toParent)
.- Parameters:
realm
- Realm.name
- Name.toParent
- Parent group.- Returns:
- Model of the created group.
- Throws:
ModelDuplicateException
- If the toParent group already has a subgroup with the given name
-
createGroup
Creates a new group with the given name, id, name and parent to the given realm.- Parameters:
realm
- Realm.id
- Id, will be generated ifnull
.name
- Name.toParent
- Parent group, ornull
if the group is top level group- Returns:
- Model of the created group
- Throws:
ModelDuplicateException
- If a group with the given id already exists or the toParent group has a subgroup with the given name
-
removeGroup
Removes the given group for the given realm.- Parameters:
realm
- Realm.group
- Group.- Returns:
- true if the group was removed, false if group doesn't exist or doesn't belong to the given realm
-
moveGroup
This method is used for moving groups in group structure, for example:- making an existing child group child group of some other group,
- setting a top level group (i.e. group without parent group) child of some group,
- making a child group top level group (i.e. removing its parent group).
- Parameters:
realm
- Realm owning this group.group
- Group to update.toParent
- New parent group, ornull
if we are moving the group to top level group.- Throws:
ModelDuplicateException
- If there is already a group with group.name under the toParent group (or top-level if toParent is null)
-
addTopLevelGroup
Removes parent group for the given group in the given realm.- Parameters:
realm
- Realm.subGroup
- Group.- Throws:
ModelDuplicateException
- If there is already a top level group name with the same name
-