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