private void enable( String namespace, boolean resume )
    {
        boolean offerResume = allowResume();
        // Ensure that resource binding has occurred.
        if (!session.isAuthenticated()) {
            this.namespace = namespace;
            sendUnexpectedError();
            return;
        }

        String smId = null;

        synchronized ( this )
        {
            // Do nothing if already enabled
            if ( isEnabled() )
            {
                sendUnexpectedError();
                return;
            }
            this.namespace = namespace;

            this.resume = resume && offerResume;
            if ( this.resume ) {
                // Create SM-ID.
                smId = Base64.getEncoder().encodeToString((session.getAddress().getResource() + "\0" + session.getStreamID().getID()).getBytes(StandardCharsets.UTF_8));
            }
        }

        // Send confirmation to the requestee.
        Element enabled = new DOMElement(QName.get("enabled", namespace));
        if (this.resume) {
            enabled.addAttribute("resume", "true");
            enabled.addAttribute("id", smId);
            if ( !namespace.equals(NAMESPACE_V2) && LOCATION_ENABLED.getValue() ) {
                // OF-1925: Hint clients to do resumes at the same cluster node.
                enabled.addAttribute("location", XMPPServer.getInstance().getServerInfo().getHostname());
            }

            // OF-1926: Tell clients how long they can be detached.
            if ( MAX_SERVER_ENABLED.getValue() ) {
                final int sessionDetachTime = XMPPServer.getInstance().getSessionManager().getSessionDetachTime();
                if ( sessionDetachTime > 0 ) {
                    enabled.addAttribute("max", String.valueOf(sessionDetachTime/1000));
                }
            }
        }
        session.deliverRawText(enabled.asXML());
    }
Attempts to enable Stream Management for the entity identified by the provided JID.

@param namespace The namespace that defines what version of SM is to be enabled.
@param resume Whether the client is requesting a resumable session.
xmppserver/src/main/java/org/jivesoftware/openfire/streammanagement/StreamManager.java