Source:
Set<AccountGroup.Id> queryForGroups(final DirContext ctx, final String username, LdapQuery.Result account) throws NamingException, AccountException { final LdapSchema schema = getSchema(ctx); final Set<String> groupDNs = new HashSet<String>(); if (!schema.groupMemberQueryList.isEmpty()) { final HashMap<String, String> params = new HashMap<String, String>(); if (schema.groupNeedsAccount) { if (account == null) { account = findAccount(schema, ctx, username); } for (String name : schema.groupMemberQueryList.get(0).getParameters()) { params.put(name, account.get(name)); } } params.put(LdapRealm.USERNAME, username); for (LdapQuery groupMemberQuery : schema.groupMemberQueryList) { for (LdapQuery.Result r : groupMemberQuery.query(ctx, params)) { recursivelyExpandGroups(groupDNs, schema, ctx, r.getDN()); } } } if (schema.accountMemberField != null) { if (account == null) { account = findAccount(schema, ctx, username); } final Attribute groupAtt = account.getAll(schema.accountMemberField); if (groupAtt != null) { final NamingEnumeration<?> groups = groupAtt.getAll(); try { while (groups.hasMore()) { final String nextDN = (String) groups.next(); recursivelyExpandGroups(groupDNs, schema, ctx, nextDN); } } catch (PartialResultException e) } } final Set<AccountGroup.Id> actual = new HashSet<AccountGroup.Id>(); for (String dn : groupDNs) { for (AccountGroup group : groupCache .get(new AccountGroup.ExternalNameKey(dn))) { if (group.getType() == AccountGroup.Type.LDAP) { actual.add(group.getId()); } } } if (actual.isEmpty()) { return Collections.emptySet(); } else { return Collections.unmodifiableSet(actual); } }

Target:
Set<AccountGroup.UUID> queryForGroups(final DirContext ctx, final String username, LdapQuery.Result account) throws NamingException, AccountException { final LdapSchema schema = getSchema(ctx); final Set<String> groupDNs = new HashSet<String>(); if (!schema.groupMemberQueryList.isEmpty()) { final HashMap<String, String> params = new HashMap<String, String>(); if (schema.groupNeedsAccount) { if (account == null) { account = findAccount(schema, ctx, username); } for (String name : schema.groupMemberQueryList.get(0).getParameters()) { params.put(name, account.get(name)); } } params.put(LdapRealm.USERNAME, username); for (LdapQuery groupMemberQuery : schema.groupMemberQueryList) { for (LdapQuery.Result r : groupMemberQuery.query(ctx, params)) { recursivelyExpandGroups(groupDNs, schema, ctx, r.getDN()); } } } if (schema.accountMemberField != null) { if (account == null) { account = findAccount(schema, ctx, username); } final Attribute groupAtt = account.getAll(schema.accountMemberField); if (groupAtt != null) { final NamingEnumeration<?> groups = groupAtt.getAll(); try { while (groups.hasMore()) { final String nextDN = (String) groups.next(); recursivelyExpandGroups(groupDNs, schema, ctx, nextDN); } } catch (PartialResultException e) { } } } final Set<AccountGroup.UUID> actual = new HashSet<AccountGroup.UUID>(); for (String dn : groupDNs) { for (AccountGroup group : groupCache .get(new AccountGroup.ExternalNameKey(dn))) { if (group.getType() == AccountGroup.Type.LDAP) { actual.add(group.getGroupUUID()); } } } if (actual.isEmpty()) { return Collections.emptySet(); } else { return Collections.unmodifiableSet(actual); } }