Class AuthUtils

java.lang.Object
com.axelor.auth.AuthUtils

public class AuthUtils extends Object
  • Constructor Details

    • AuthUtils

      public AuthUtils()
  • Method Details

    • setCurrentUser

      public static void setCurrentUser(User user)
      For internal use only.
    • getCurrentUser

      public static User getCurrentUser()
      For internal use only.
    • removeCurrentUser

      public static void removeCurrentUser()
      For internal use only.
    • getSubject

      public static org.apache.shiro.subject.Subject getSubject()
    • getUser

      public static User getUser()
      Retrieves the current user associated with the thread or session.

      It first uses the current user stored in the thread-local (set for batch / audit purpose) if provided. Else it attempts to retrieve the user based on the principal associated with the current subject

      Returns:
      the current user if available; otherwise null
    • getUser

      public static User getUser(String code)
    • isActive

      public static boolean isActive(User user)
    • isAdmin

      public static boolean isAdmin(User user)
    • isTechnicalStaff

      public static boolean isTechnicalStaff(User user)
    • hasRole

      public static boolean hasRole(User user, String... roles)