Class SecurityUtils


  • public class SecurityUtils
    extends Object
    • Method Detail

      • getCurrentUsername

        @Nullable
        @CheckForNull
        public static String getCurrentUsername()
        Returns the username of the current authentication.
        Returns:
        username or null if 1) the current authentication is null or 2) the currently authenticated principal is the system.
      • currentUserHasRole

        public static boolean currentUserHasRole​(String... roles)
        Returns whether the current user has at least one of the given roles
      • currentUserIsSuOrSystem

        public static boolean currentUserIsSuOrSystem()
        Returns whether the current user is a superuser or the system user.
      • currentUserIsSu

        public static boolean currentUserIsSu()
        Returns whether the current user is a super user
      • currentUserIsSystem

        public static boolean currentUserIsSystem()
        Returns whether the current user is the system user.
      • currentUserIsAuthenticated

        public static boolean currentUserIsAuthenticated()
        Returns whether the current user is authenticated and not the anonymous user
      • currentUserIsAnonymous

        public static boolean currentUserIsAnonymous()