public void startTLS(boolean clientMode, boolean directTLS) throws IOException {
        if (!isEncrypted) {
            isEncrypted = true;

            // Prepare for TLS
            final ClientAuth clientAuth;
            if (session instanceof IncomingServerSession)
            {
                clientAuth = ClientAuth.needed;
            }
            else
            {
                clientAuth = ClientAuth.wanted;
            }
            tlsStreamHandler = new TLSStreamHandler(socket, getConfiguration(), clientMode);
            if (!clientMode && !directTLS) {
                // Indicate the client that the server is ready to negotiate TLS
                deliverRawText("<proceed xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>");
            }
            // Start handshake
            tlsStreamHandler.start();
            // Use new wrapped writers
            writer = new BufferedWriter(new OutputStreamWriter(tlsStreamHandler.getOutputStream(), StandardCharsets.UTF_8));
            xmlSerializer = new XMLSocketWriter(writer, this);
        }
    }
Returns the stream handler responsible for encrypting the plain connection and providing
the corresponding input and output streams.

@return the stream handler responsible for encrypting the plain connection and providing
        the corresponding input and output streams.
xmppserver/src/main/java/org/jivesoftware/openfire/net/SocketConnection.java