Class AuthorizationException

All Implemented Interfaces:
Serializable

public class AuthorizationException extends SecurityException
Exception thrown when authorization to some resource fails.
See Also:
  • Constructor Details

    • AuthorizationException

      public AuthorizationException(String username, AuthorizationException.Reason reason)
      Construct authorization exception.
      Parameters:
      username - the attempted login
      reason - the reason for the exception
    • AuthorizationException

      public AuthorizationException(AuthorizationException.Reason reason, Object id)
      Construct authorization exception related to some primary key.
      Parameters:
      reason - the reason for the exception
      id - the object ID
    • AuthorizationException

      public AuthorizationException(AuthorizationException.Reason reason, Object id, Throwable cause)
      Construct authorization exception related to some primary key and cause.
      Parameters:
      reason - the reason for the exception
      id - the object ID
      cause - a cause
      Since:
      1.3
  • Method Details

    • requireNonNullObject

      public static <T> T requireNonNullObject(T object, Object id)
      Helper for validating an object is not null, throwing an exception otherwise.
      Type Parameters:
      T - the object type
      Parameters:
      object - the object that must not be null
      id - the ID associated with the object
      Returns:
      object
      Throws:
      AuthorizationException - with a AuthorizationException.Reason.UNKNOWN_OBJECT if object is null
      Since:
      1.2
    • getEmail

      public String getEmail()
      Get the attempted login.
      Returns:
      login value (or null if not available)
    • getId

      public Object getId()
      Get the primary key.
      Returns:
      the primary key (or null if not available)
    • getReason

      public AuthorizationException.Reason getReason()
      Get the authorization exception reason.
      Returns:
      reason
    • getMessage

      public String getMessage()
      Overrides:
      getMessage in class Throwable