Package org.keycloak.utils
Class GroupUtils
java.lang.Object
org.keycloak.utils.GroupUtils
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Set<GroupUtils.GroupMembership>getAllMemberships(KeycloakSession session, Collection<GroupModel> groups) static Set<GroupUtils.GroupMembership>getAllMemberships(KeycloakSession session, Collection<GroupModel> groups, boolean direct) static Stream<GroupRepresentation>populateGroupHierarchyFromSubGroups(KeycloakSession session, RealmModel realm, Stream<GroupModel> groups, boolean full, boolean subGroupsCount, String stopAtParentId) Simplified version ofpopulateGroupHierarchyFromSubGroups(KeycloakSession, RealmModel, Stream, boolean, GroupPermissionEvaluator, boolean)that does not perform permission checks.static Stream<GroupRepresentation>populateGroupHierarchyFromSubGroups(KeycloakSession session, RealmModel realm, Stream<GroupModel> groups, boolean full, GroupPermissionEvaluator groupEvaluator, boolean subGroupsCount) This method takes the provided groups and attempts to load their parents all the way to the root group while maintaining the hierarchy data for each GroupRepresentation object.static GroupRepresentationpopulateSubGroupCount(GroupModel group, GroupRepresentation representation) This method's purpose is to look up the subgroup count of a Group and populate it on the representation.static GroupRepresentationtoRepresentation(GroupPermissionEvaluator groupsEvaluator, GroupModel groupTree, boolean full)
-
Constructor Details
-
GroupUtils
public GroupUtils()
-
-
Method Details
-
populateGroupHierarchyFromSubGroups
public static Stream<GroupRepresentation> populateGroupHierarchyFromSubGroups(KeycloakSession session, RealmModel realm, Stream<GroupModel> groups, boolean full, GroupPermissionEvaluator groupEvaluator, boolean subGroupsCount) This method takes the provided groups and attempts to load their parents all the way to the root group while maintaining the hierarchy data for each GroupRepresentation object. Each resultant GroupRepresentation object in the stream should contain relevant subgroups to the originally provided groups- Parameters:
session- The active keycloak sessionrealm- The realm to operate ongroups- The groups that we want to populate the hierarchy for- Returns:
- A stream of groups that contain all relevant groups from the root down with no extra siblings
-
populateGroupHierarchyFromSubGroups
public static Stream<GroupRepresentation> populateGroupHierarchyFromSubGroups(KeycloakSession session, RealmModel realm, Stream<GroupModel> groups, boolean full, boolean subGroupsCount, String stopAtParentId) Simplified version ofpopulateGroupHierarchyFromSubGroups(KeycloakSession, RealmModel, Stream, boolean, GroupPermissionEvaluator, boolean)that does not perform permission checks. Suitable for organization groups where access control is handled at the organization level.- Parameters:
stopAtParentId- If non-null, the hierarchy walk stops when a group's parentId matches this value, preventing the parent from being included. This is used to exclude the internal organization root group from the hierarchy.
-
populateSubGroupCount
public static GroupRepresentation populateSubGroupCount(GroupModel group, GroupRepresentation representation) This method's purpose is to look up the subgroup count of a Group and populate it on the representation. This has been kept separate fromtoRepresentation(org.keycloak.services.resources.admin.fgap.GroupPermissionEvaluator, org.keycloak.models.GroupModel, boolean)in order to keep database lookups separate from a function that aims to only convert objects A way of cohesively ensuring that a GroupRepresentation always has a group count should be considered- Parameters:
group- modelrepresentation- group representation- Returns:
-
toRepresentation
public static GroupRepresentation toRepresentation(GroupPermissionEvaluator groupsEvaluator, GroupModel groupTree, boolean full) -
getAllMemberships
public static Set<GroupUtils.GroupMembership> getAllMemberships(KeycloakSession session, Collection<GroupModel> groups) -
getAllMemberships
public static Set<GroupUtils.GroupMembership> getAllMemberships(KeycloakSession session, Collection<GroupModel> groups, boolean direct)
-