@VisibleForTesting
    static String generateS(final IQ packet) {
        // Initialize an empty string S.
        final StringBuilder s = new StringBuilder();

        // Sort the service discovery identities by category and then by type
        // (if it exists), formatted as 'category' '/' 'type' / 'lang' / 'name'
        final List<String> discoIdentities = getIdentitiesFrom(packet);
        Collections.sort(discoIdentities);

        // For each identity, append the 'category/type/lang/name' to S,
        // followed by the '<' character.
        for (String discoIdentity : discoIdentities) {
            s.append(discoIdentity);
            s.append('<');
        }

        // Sort the supported service discovery features.
        final List<String> discoFeatures = getFeaturesFrom(packet);
        Collections.sort(discoFeatures);

        // For each feature, append the feature to S, followed by the '<'
        // character.
        for (String discoFeature : discoFeatures) {
            s.append(discoFeature);
            s.append('<');
        }

        // If the service discovery information response includes XEP-0128
        // data forms, sort the forms by the FORM_TYPE (i.e., by the XML
        // character data of the <value/> element).
        final List<String> extendedDataForms = getExtendedDataForms(packet);
        Collections.sort(extendedDataForms);

        for (String extendedDataForm : extendedDataForms) {
            s.append(extendedDataForm);
            // no need to add '<', this is done in #getExtendedDataForms()
        }
        return s.toString();
    }
Generates a 'ver' hash attribute used in validation to help prevent
poisoning of entity capabilities information.

@see #isValid(IQ)

The value of the 'ver' attribute is generated according to the method
outlined in XEP-0115.

@param packet IQ reply to the entity cap request.
@param algorithm The hashing algorithm to use (e.g. SHA-1)
@return the generated 'ver' hash
xmppserver/src/main/java/org/jivesoftware/openfire/entitycaps/EntityCapabilitiesManager.java