mirror of
https://github.com/keycloak/keycloak.git
synced 2026-05-01 20:52:51 -05:00
Calling getTopLevelGroups is slow inside GroupLDAPStorageMapper#getLDAPGroupMappingsConverted (#8430)
Closes #14820 --------- Co-authored-by: Michal Hajas <mhajas@redhat.com>
This commit is contained in:
@@ -19,9 +19,7 @@ package org.keycloak.storage.group;
|
||||
import org.keycloak.models.GroupModel;
|
||||
import org.keycloak.models.RealmModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface GroupLookupProvider {
|
||||
@@ -35,6 +33,19 @@ public interface GroupLookupProvider {
|
||||
*/
|
||||
GroupModel getGroupById(RealmModel realm, String id);
|
||||
|
||||
/**
|
||||
* Returns a group from the given realm with the corresponding name and parent
|
||||
*
|
||||
* @param realm Realm.
|
||||
* @param parent parent Group. If {@code null} top level groups are searched
|
||||
* @param name name.
|
||||
* @return GroupModel with the corresponding name.
|
||||
*/
|
||||
default GroupModel getGroupByName(RealmModel realm, GroupModel parent, String name) {
|
||||
return (parent == null ? realm.getTopLevelGroupsStream() : parent.getSubGroupsStream())
|
||||
.filter(groupModel -> groupModel.getName().equals(name)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the group hierarchy with the given string in name for the given realm.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user