public void setAuthToken(AuthToken auth, @Nonnull String resource) {
        final JID jid;
        if (auth.isAnonymous()) {
            jid = new JID(resource, getServerName(), resource);
        } else {
            jid = new JID(auth.getUsername(), getServerName(), resource);
        }
        setAddress(jid);
        authToken = auth;
        setStatus(Session.Status.AUTHENTICATED);

        // Set default privacy list for this session
        if (!auth.isAnonymous()) {
            setDefaultList( PrivacyListManager.getInstance().getDefaultPrivacyList( auth.getUsername() ) );
        }
        // Add session to the session manager. The session will be added to the routing table as well
        sessionManager.addSession(this);
    }
Initialize the session with a valid authentication token and
resource name. This automatically upgrades the session's
status to authenticated and enables many features that are not
available until authenticated (obtaining managers for example).

@param auth the authentication token obtained from the AuthFactory.
@param resource the resource this session authenticated under.
xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalClientSession.java