public List<String> getUserGroups(String username) throws RemoteException {
        username = JID.unescapeNode(username);
        LOG.debug("fetch all crowd groups for user:" + username);
        
        int maxResults = 100;
        int startIndex = 0;
        List<String> results = new ArrayList<>();
        StringBuilder request = new StringBuilder("user/group/nested?username=").append(urlEncode(username))
            .append("&max-results=").append(maxResults)
            .append("&start-index=");
        
        try {
            while (true) {
                final HttpUriRequest getRequest = RequestBuilder.get(crowdServer.resolve(request.toString() + startIndex))
                    .setConfig(requestConfig)
                    .addHeader(HEADER_ACCEPT_APPLICATION_XML)
                    .addHeader(HEADER_ACCEPT_CHARSET_UTF8)
                    .build();

                try (final CloseableHttpResponse response = client.execute(getRequest, clientContext)) {
                    if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
                        handleHTTPError(response);
                    }
                    final Groups groups = JAXB.unmarshal(response.getEntity().getContent(), Groups.class);

                    if (groups != null && groups.group != null) {
                        for (final Group group : groups.group) {
                            results.add(group.name);
                        }

                        if (groups.group.size() != maxResults) {
                            break;
                        } else {
                            startIndex += maxResults;
                        }
                    } else {
                        break;
                    }
                }
            }
            
        } catch (IOException ioe) {
            handleError(ioe);
        }
        
        return results;
    }
Get all the groups of a given username
@param username the user
@return a List of groups name
@throws RemoteException if an exception occurred communicating with the crowd server
xmppserver/src/main/java/org/jivesoftware/openfire/crowd/CrowdManager.java