code: public static boolean currentUserIsAuthenticated() {
      Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
      return authentication != null && authentication.isAuthenticated() && !currentUserIsAnonymous();
    }
docs: Returns whether the current user is authenticated and not the anonymous user