@Override
    public <T> T asUserResult(final UserIdentity userIdentity, final Supplier<T> supplier) {
        T result;
        boolean success = false;
        try {
            pushUser(userIdentity);
            success = true;
            result = supplier.get();
        } finally {
            if (success) {
                popUser();
            }
        }
        return result;
    }
Run the supplied code as the specified user.
stroom-security/stroom-security-impl/src/main/java/stroom/security/impl/SecurityContextImpl.java