private static List<String> getIdentitiesFrom(IQ packet) {
        List<String> discoIdentities = new ArrayList<>();
        Element query = packet.getChildElement();
        if (query == null) {
            return discoIdentities;
        }
        Iterator<Element> identitiesIterator = query.elementIterator("identity");
        if (identitiesIterator != null) {
            while (identitiesIterator.hasNext()) {
                Element identityElement = identitiesIterator.next();

                StringBuilder discoIdentity = new StringBuilder();

                String cat = identityElement.attributeValue("category");
                String type = identityElement.attributeValue("type");
                String lang = identityElement.attributeValue("xml:lang");
                String name = identityElement.attributeValue("name");

                if (cat != null) {
                    discoIdentity.append(cat);
                }
                discoIdentity.append('/');

                if (type != null) {
                    discoIdentity.append(type);
                }
                discoIdentity.append('/');

                if (lang != null) {
                    discoIdentity.append(lang);
                }
                discoIdentity.append('/');

                if (name != null) {
                    discoIdentity.append(name);
                }

                discoIdentities.add(discoIdentity.toString());
            }
        }
        return discoIdentities;
    }
Extracts a list of identities from an IQ packet.

@param packet the packet
@return a list of identities
xmppserver/src/main/java/org/jivesoftware/openfire/entitycaps/EntityCapabilitiesManager.java