public static Optional<UserIdentity> get(final HttpServletRequest request) {
        return Optional.ofNullable(request)
                .flatMap(req -> get(req.getSession(false)));
    }
Set the userIdentity on the session, creating the session as required
stroom-security/stroom-security-common-impl/src/main/java/stroom/security/common/impl/UserIdentitySessionUtil.java