Package org.keycloak.storage
Class GroupStorageManager
java.lang.Object
org.keycloak.storage.AbstractStorageManager<GroupStorageProvider,GroupStorageProviderModel>
org.keycloak.storage.GroupStorageManager
- All Implemented Interfaces:
GroupProvider,Provider,GroupLookupProvider
public class GroupStorageManager
extends AbstractStorageManager<GroupStorageProvider,GroupStorageProviderModel>
implements GroupProvider
-
Field Summary
Fields inherited from class org.keycloak.storage.AbstractStorageManager
sessionFields inherited from interface org.keycloak.models.GroupProvider
DEFAULT_ESCAPE_SLASHES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTopLevelGroup(RealmModel realm, GroupModel subGroup) Removes parent group for the given group in the given realm.voidclose()createGroup(RealmModel realm, String id, GroupModel.Type type, String name, GroupModel toParent) Creates a new group with the given name, id, name and parent to the given realm.getGroupById(RealmModel realm, String id) Returns a group from the given realm with the corresponding idgetGroupByName(RealmModel realm, GroupModel parent, String name) Returns a group from the given realm with the corresponding name and parentgetGroupsByRoleStream(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.getGroupsCountByNameContaining(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.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.getTopLevelGroupsStream(RealmModel realm, String search, Boolean exact, Integer firstResult, Integer maxResults) Returns top level groups (i.e.voidmoveGroup(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.voidpreRemove(RealmModel realm) Called when a realm is removed.booleanremoveGroup(RealmModel realm, GroupModel group) Removes the given group for the given realm.searchForGroupByNameStream(RealmModel realm, String search, Boolean exact, Integer firstResult, Integer maxResults) Obtaining groups from an external client storage is time-bounded.searchGroupsByAttributes(RealmModel realm, Map<String, String> attributes, Integer firstResult, Integer maxResults) Returns the groups filtered by attribute names and attribute values for the given realm.Methods inherited from class org.keycloak.storage.AbstractStorageManager
consumeEnabledStorageProvidersWithTimeout, flatMapEnabledStorageProvidersWithTimeout, getEnabledStorageProviders, getStorageProviderFactory, getStorageProviderInstance, getStorageProviderInstance, getStorageProviderInstance, getStorageProviderInstance, getStorageProviderModel, getStorageProviderModels, getStorageProviderTimeout, mapEnabledStorageProvidersWithTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.storage.group.GroupLookupProvider
searchForGroupByNameStreamMethods inherited from interface org.keycloak.models.GroupProvider
createGroup, createGroup, createGroup, createGroup, getGroupsCount, getGroupsStream, getGroupsStream, getTopLevelGroupsStream, getTopLevelGroupsStream
-
Constructor Details
-
GroupStorageManager
-
-
Method Details
-
getGroupById
Description copied from interface:GroupLookupProviderReturns a group from the given realm with the corresponding id- Specified by:
getGroupByIdin interfaceGroupLookupProvider- Parameters:
realm- Realm.id- Id.- Returns:
- GroupModel with the corresponding id.
-
getGroupByName
Description copied from interface:GroupLookupProviderReturns a group from the given realm with the corresponding name and parent- Specified by:
getGroupByNamein interfaceGroupLookupProvider- Parameters:
realm- Realm.parent- parent Group. Ifnulltop level groups are searchedname- name.- Returns:
- GroupModel with the corresponding name.
-
searchGroupsByAttributes
public Stream<GroupModel> searchGroupsByAttributes(RealmModel realm, Map<String, String> attributes, Integer firstResult, Integer maxResults) Description copied from interface:GroupLookupProviderReturns the groups filtered by attribute names and attribute values for the given realm.- Specified by:
searchGroupsByAttributesin interfaceGroupLookupProvider- Parameters:
realm- Realm.attributes- name-value pairs that are compared to group attributes.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 attributes matching all searched attributes. Never returns
null.
-
searchForGroupByNameStream
public Stream<GroupModel> searchForGroupByNameStream(RealmModel realm, String search, Boolean exact, Integer firstResult, Integer maxResults) Obtaining groups from an external client storage is time-bounded. In case the external group storage isn't available at least groups from a local storage are returned. For this purpose theorg.keycloak.services.DefaultKeycloakSessionFactory#getClientStorageProviderTimeout()property is used. Default value is 3000 milliseconds and it's configurable. SeeDefaultKeycloakSessionFactoryfor details.- Specified by:
searchForGroupByNameStreamin interfaceGroupLookupProvider- Parameters:
realm- Realm.search- Case sensitive searched string.exact- Boolean which defines whether search param should be matched exactly.firstResult- First result to return. Ignored if negative ornull.maxResults- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of root groups that have the given string in their name themself or a group in their child-collection has.
The returned hierarchy contains siblings that do not necessarily have a matching name. Never returns
null.
-
getGroupsStream
Description copied from interface:GroupProviderReturns groups for the given realm.- Specified by:
getGroupsStreamin interfaceGroupProvider- Parameters:
realm- Realm.- Returns:
- Stream of groups in the Realm.
-
getGroupsStream
public Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max) Description copied from interface:GroupProviderReturns a paginated stream of groups with given ids and given search value in group names.- Specified by:
getGroupsStreamin interfaceGroupProvider- 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.
-
getGroupsCount
Description copied from interface:GroupProviderReturns a number of groups/top level groups (i.e. groups without parent group) for the given realm.- Specified by:
getGroupsCountin interfaceGroupProvider- Parameters:
realm- Realm.onlyTopGroups- When true the function returns a count of top level groups only.- Returns:
- Number of groups/top level groups.
-
getGroupsCountByNameContaining
Description copied from interface:GroupProviderReturns the number of top level groups containing groups with the given string in name for the given realm.- Specified by:
getGroupsCountByNameContainingin interfaceGroupProvider- Parameters:
realm- Realm.search- Case insensitive string which will be searched for.- Returns:
- Number of groups with the given string in its name.
-
getGroupsByRoleStream
public Stream<GroupModel> getGroupsByRoleStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults) Description copied from interface:GroupProviderReturns groups with the given role in the given realm.- Specified by:
getGroupsByRoleStreamin interfaceGroupProvider- 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
public Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm, String search, Boolean exact, Integer firstResult, Integer maxResults) Description copied from interface:GroupProviderReturns top level groups (i.e. groups without parent group) for the given realm.- Specified by:
getTopLevelGroupsStreamin interfaceGroupProvider- Parameters:
realm- Realm.search- The name that should be matchedfirstResult- 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.
-
createGroup
public GroupModel createGroup(RealmModel realm, String id, GroupModel.Type type, String name, GroupModel toParent) Description copied from interface:GroupProviderCreates a new group with the given name, id, name and parent to the given realm.- Specified by:
createGroupin interfaceGroupProvider- Parameters:
realm- Realm.id- Id, will be generated ifnull.type- the group type. if not set, defaults toGroupModel.Type.REALMname- Name.toParent- Parent group, ornullif the group is top level group- Returns:
- Model of the created group
-
removeGroup
Description copied from interface:GroupProviderRemoves the given group for the given realm.- Specified by:
removeGroupin interfaceGroupProvider- 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
Description copied from interface:GroupProviderThis 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).
- Specified by:
moveGroupin interfaceGroupProvider- Parameters:
realm- Realm owning this group.group- Group to update.toParent- New parent group, ornullif we are moving the group to top level group.
-
addTopLevelGroup
Description copied from interface:GroupProviderRemoves parent group for the given group in the given realm.- Specified by:
addTopLevelGroupin interfaceGroupProvider- Parameters:
realm- Realm.subGroup- Group.
-
preRemove
Description copied from interface:GroupProviderCalled when a realm is removed. Should remove all groups that belong to the realm.- Specified by:
preRemovein interfaceGroupProvider- Parameters:
realm- a reference to the realm
-
close
public void close()
-