Class UserContext

java.lang.Object
org.graylog.security.UserContext

public class UserContext extends Object
  • Constructor Details

    • UserContext

      public UserContext(String userId, org.apache.shiro.subject.Subject subject, UserService userService)
  • Method Details

    • runAs

      public static <T> T runAs(String username, Callable<T> callable)
      Build a temporary Shiro Subject and run the callable within that context
      Type Parameters:
      T - The return type of the callable.
      Parameters:
      username - The username of the subject
      callable - The callable to be executed
      Returns:
      whatever the callable returns.
    • runAs

      public static void runAs(String username, Runnable runnable)
      Build a temporary Shiro Subject and run the callable within that context
      Parameters:
      username - The username of the subject
      runnable - The runnable to be executed
    • getUserId

      public String getUserId()
    • getUser

      public User getUser()
    • isOwner

      protected boolean isOwner(GRN entity)
    • hasAllPermission

      public boolean hasAllPermission()
      Checks if the user is permitted to do everything
      Returns:
      The check result
    • isPermitted

      public boolean isPermitted(String permission, GRN target)
    • isPermitted

      public boolean isPermitted(String permission, String id)
    • isPermitted

      public boolean isPermitted(String permission)