protected boolean negotiateTLS() {
        if (connection.getConfiguration().getTlsPolicy() == Connection.TLSPolicy.disabled) {
            // Send a not_authorized error and close the underlying connection
            connection.close(new StreamError(StreamError.Condition.not_authorized, "A request to negotiate TLS is denied, as TLS has been disabled by configuration."));
            // Log a warning so that admins can track this case from the server side
            Log.warn("TLS requested by initiator when TLS was never offered by server. Closing connection: {}", connection);
            return false;
        }
        // Client requested to encrypt the connection using TLS. Negotiate TLS.
        try {
            startTLS();
        }
        catch (Exception e) {
            Log.error("Error while negotiating TLS with connection {}", connection, e);
            connection.deliverRawText("<failure xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>");
            connection.close();
            return false;
        }
        return true;
    }
Tries to encrypt the connection using TLS. If the connection is encrypted then reset
the parser to use the new encrypted reader. But if the connection failed to be encrypted
then send a <failure> stanza and close the connection.

@return true if the connection was encrypted.
xmppserver/src/main/java/org/jivesoftware/openfire/net/StanzaHandler.java