public boolean isAnonymousUser() {
        if (isAnonymous == null) {
            // Cache the result only when sure that it can't change anymore, which is after authentication has happened.
            if (isInitialized()) {
                ClusterTask task = getRemoteSessionTask(RemoteSessionTask.Operation.isAnonymous);
                Object result = doSynchronousClusterTask(task);
                isAnonymous = result != null && (Boolean) result;
            } else {
                return false; // non-authenticated sessions are not identified as anonymous.
            }
        }

        return isAnonymous;
    }
Surrogate for client sessions hosted in some remote cluster node.

@author Gaston Dombiak
xmppserver/src/main/java/org/jivesoftware/openfire/session/RemoteClientSession.java