@Override
    public List<Element> getAvailableStreamFeatures() {
        // Offer authenticate and registration only if TLS was not required or if required
        // then the connection is already encrypted
        if (conn.getConfiguration().getTlsPolicy() == Connection.TLSPolicy.required && !conn.isEncrypted()) {
            return Collections.emptyList();
        }

        final List<Element> result = new LinkedList<>();

        // Include Stream Compression Mechanism
        if (conn.getConfiguration().getCompressionPolicy() != Connection.CompressionPolicy.disabled && !conn.isCompressed()) {
            final Element compression = DocumentHelper.createElement(QName.get("compression", "http://jabber.org/features/compress"));
            compression.addElement("method").addText("zlib");
            result.add(compression);
        }

        // If a server supports roster versioning, 
        // then it MUST advertise the following stream feature during stream negotiation.
        if (RosterManager.isRosterVersioningEnabled()) {
            result.add(DocumentHelper.createElement(QName.get("ver", "urn:xmpp:features:rosterver")));
        }

        if (getAuthToken() == null) {
            // Advertise that the server supports Non-SASL Authentication
            if ( XMPPServer.getInstance().getIQRouter().supports( "jabber:iq:auth" ) ) {
                result.add(DocumentHelper.createElement(QName.get("auth", "http://jabber.org/features/iq-auth")));
            }
            // Advertise that the server supports In-Band Registration
            if (XMPPServer.getInstance().getIQRegisterHandler().isInbandRegEnabled()) {
                result.add(DocumentHelper.createElement(QName.get("register", "http://jabber.org/features/iq-register")));
            }
        }
        else {
            // If the session has been authenticated then offer resource binding,
            // and session establishment
            result.add(DocumentHelper.createElement(QName.get("bind", "urn:ietf:params:xml:ns:xmpp-bind")));
            final Element session = DocumentHelper.createElement(QName.get("session", "urn:ietf:params:xml:ns:xmpp-session"));
            session.addElement("optional");
            result.add(session);

            // Offer XEP-0198 stream management capabilities if enabled.
            if(StreamManager.isStreamManagementActive()) {
                result.add(DocumentHelper.createElement(QName.get("sm", StreamManager.NAMESPACE_V2)));
                result.add(DocumentHelper.createElement(QName.get("sm", StreamManager.NAMESPACE_V3)));
            }

            // Offer XEP-0352 Client State Indication capabilities if enabled
            if (CsiManager.ENABLED.getValue()) {
                result.add(DocumentHelper.createElement(QName.get("csi", CsiManager.NAMESPACE)));
            }
         }

        // Add XEP-0115 entity capabilities for the server, so that peer can skip service discovery. Make this user-specific (OF-2841).
        final String ver = EntityCapabilitiesManager.getLocalDomainVerHash(this.authToken != null && !this.authToken.isAnonymous() ? this.authToken.getUsername() : null);
        if ( ver != null ) {
            final Element c = DocumentHelper.createElement(QName.get("c", "http://jabber.org/protocol/caps"));
            c.addAttribute("hash", "sha-1");
            c.addAttribute("node", EntityCapabilitiesManager.OPENFIRE_IDENTIFIER_NODE);
            c.addAttribute("ver", ver);
            result.add(c);
        }

        if (!ConnectionSettings.Client.STREAM_LIMITS_ADVERTISEMENT_DISABLED.getValue()) {
            final Element limits = DocumentHelper.createElement(QName.get("limits", "urn:xmpp:stream-limits:0"));
            limits.addElement("max-bytes").addText(String.valueOf(XMLLightweightParser.XMPP_PARSER_BUFFER_SIZE.getValue()));
            final Duration timeout = ConnectionSettings.Client.IDLE_TIMEOUT_PROPERTY.getValue();
            if (!timeout.isNegative() && !timeout.isZero()) {
                limits.addElement("idle-seconds").addText(String.valueOf(timeout.toSeconds()));
            }
            result.add(limits);
        }

        return result;
    }
Set the presence of this session

@param presence The presence for the session
xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalClientSession.java