private void transferConnectionToNewSession(String newStreamId, ServerSession.AuthenticationMethod existingAuthMethod) {
        session = createLocalOutgoingServerSession(newStreamId, connection);

        // Transfer new session to existing connection
        connection.reinit(session);
        if (isSessionAuthenticated.isDone()) {
            ((LocalOutgoingServerSession) session).addOutgoingDomainPair(domainPair);
            ((LocalOutgoingServerSession) session).setAuthenticationMethod(existingAuthMethod);
        } else {
            LOG.debug("Session not authenticated yet, unable to setAuthenticationMethod().");
        }
    }
Transfer an existing connection to a new session when a new streamID is detected. Also transfers existing
authentication method if previously set.
@param newStreamId new stream ID for the new session
@param existingAuthMethod authentication method used previously (possibly null)
xmppserver/src/main/java/org/jivesoftware/openfire/net/RespondingServerStanzaHandler.java