使用KeyClope Java连接器,如何在不使用getGroupByPath的情况下获取自定义组属性?

使用KeyClope Java连接器,如何在不使用getGroupByPath的情况下获取自定义组属性?,java,keycloak,Java,Keycloak,我们使用getGroupByPath函数访问groups属性,如下所示: GroupRepresentation group = realm.getGroupByPath(Constants.SLASH + groupName); List<String> displayNames = group.getAttributes().get(Constants.ATTRIBUT_NAME_DISPLAY_NAME); String displayName = displayNames.g

我们使用getGroupByPath函数访问groups属性,如下所示:

GroupRepresentation group = realm.getGroupByPath(Constants.SLASH + groupName);
List<String> displayNames = group.getAttributes().get(Constants.ATTRIBUT_NAME_DISPLAY_NAME);
String displayName = displayNames.get(0);
GroupRepresentation group=realm.getGroupByPath(Constants.SLASH+groupName);
List displayNames=group.getAttributes().get(常量.attribute\u NAME\u DISPLAY\u NAME);
String displayName=displayNames.get(0);
不幸的是,
getGroupByPath
实现不能处理大量的组(我们有超过20K个组,包括6K个根组)。因此,我们使用
realm.groups().groups(groupName,0,1)
访问GroupRepresentation对象。这可以正常工作,但给定对象不包含组的属性:(


有没有一种方法可以不使用getGroupByPath访问组的属性?

多亏了我的同事Leo HP,我们找到了一个解决方法,如果不是解决方案的话:

List<GroupRepresentation> groupList = realm.groups().groups(groupName, 0, 1);
GroupResource groupResource = realm.groups.group(groupList.get(0).getId());
GroupRepresentation group = groupResource.toRepresentation();

List<String> displayNames = group.getAttributes().get(Constants.ATTRIBUT_NAME_DISPLAY_NAME);
String displayName = displayNames.get(0);
List-groupList=realm.groups().groups(groupName,0,1);
GroupResource-GroupResource=realm.groups.group(groupList.get(0.getId());
GroupRepresentation group=groupResource.toRepresentation();
List displayNames=group.getAttributes().get(常量.attribute\u NAME\u DISPLAY\u NAME);
String displayName=displayNames.get(0);
好极了