Calling getTopLevelGroups is slow inside GroupLDAPStorageMapper#getLDAPGroupMappingsConverted (#8430)

Closes #14820 
---------
Co-authored-by: Michal Hajas <mhajas@redhat.com>
This commit is contained in:
Bernd Bohmann
2023-09-20 17:20:43 +02:00
committed by GitHub
parent f8a9e0134a
commit bb2f59df87
20 changed files with 471 additions and 42 deletions
@@ -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.
*