protected void compressionSuccessful() throws XmlPullParserException, IOException
    {
        final Document document = getStreamHeader();
        final Element features = DocumentHelper.createElement(QName.get("features", "stream", "http://etherx.jabber.org/streams"));
        document.getRootElement().add(features);

        // Include SASL mechanisms only if client has not been authenticated
        if (!socketReader.session.isAuthenticated()) {
            // Include available SASL Mechanisms
            final Element saslMechanisms = SASLAuthentication.getSASLMechanisms(socketReader.session);
            if (saslMechanisms != null) {
                features.add(saslMechanisms);
            }
        }
        // Include specific features such as resource binding and session establishment for client sessions.
        final List<Element> specificFeatures = socketReader.session.getAvailableStreamFeatures();
        if (specificFeatures != null) {
            for (final Element feature : specificFeatures) {
                features.add(feature);
            }
        }

        socketReader.connection.deliverRawText(StringUtils.asUnclosedStream(document));
    }
After compression was successful we should open a new stream and offer
new stream features such as resource binding and session establishment. Notice that
resource binding and session establishment should only be offered to clients (i.e. not
to servers or external components)
xmppserver/src/main/java/org/jivesoftware/openfire/net/SocketReadingMode.java