Package javax.ws.rs

Class NotAuthorizedException



  • public class NotAuthorizedException
    extends ClientErrorException
    A runtime exception indicating request authorization failure caused by one of the following scenarios:
    • a client did not send the required authorization credentials to access the requested resource, i.e. Authorization HTTP header is missing in the request,
    • or - in case the request already contains the HTTP Authorization header - then the exception indicates that authorization has been refused for the credentials contained in the request header.
    Since:
    2.0
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      NotAuthorizedException​(java.lang.Object challenge, java.lang.Object... moreChallenges)
      Construct a new "not authorized" exception.
      NotAuthorizedException​(java.lang.String message, java.lang.Object challenge, java.lang.Object... moreChallenges)
      Construct a new "not authorized" exception.
      NotAuthorizedException​(java.lang.String message, java.lang.Throwable cause, java.lang.Object challenge, java.lang.Object... moreChallenges)
      Construct a new "not authorized" exception.
      NotAuthorizedException​(java.lang.String message, Response response)
      Construct a new "not authorized" exception.
      NotAuthorizedException​(java.lang.String message, Response response, java.lang.Throwable cause)
      Construct a new "not authorized" exception.
      NotAuthorizedException​(java.lang.Throwable cause, java.lang.Object challenge, java.lang.Object... moreChallenges)
      Construct a new "not authorized" exception.
      NotAuthorizedException​(Response response)
      Construct a new "not authorized" exception.
      NotAuthorizedException​(Response response, java.lang.Throwable cause)
      Construct a new "not authorized" exception.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.Object> getChallenges​()
      Get the list of authorization challenges associated with the exception and applicable to the resource requested by the client.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
    • Constructor Detail

      • NotAuthorizedException

        public NotAuthorizedException​(java.lang.Object challenge,
                                      java.lang.Object... moreChallenges)
        Construct a new "not authorized" exception.
        Parameters:
        challenge - authorization challenge applicable to the resource requested by the client.
        moreChallenges - additional authorization challenge applicable to the requested resource.
        Throws:
        java.lang.NullPointerException - in case the challenge parameter is null.
      • NotAuthorizedException

        public NotAuthorizedException​(java.lang.String message,
                                      java.lang.Object challenge,
                                      java.lang.Object... moreChallenges)
        Construct a new "not authorized" exception.
        Parameters:
        message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method).
        challenge - authorization challenge applicable to the resource requested by the client.
        moreChallenges - additional authorization challenge applicable to the requested resource.
        Throws:
        java.lang.NullPointerException - in case the challenge parameter is null.
      • NotAuthorizedException

        public NotAuthorizedException​(Response response)
        Construct a new "not authorized" exception.
        Parameters:
        response - error response.
        Throws:
        java.lang.IllegalArgumentException - in case the status code set in the response is not HTTP 401.
      • NotAuthorizedException

        public NotAuthorizedException​(java.lang.String message,
                                      Response response)
        Construct a new "not authorized" exception.
        Parameters:
        message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method).
        response - error response.
        Throws:
        java.lang.IllegalArgumentException - in case the status code set in the response is not HTTP 401.
      • NotAuthorizedException

        public NotAuthorizedException​(java.lang.Throwable cause,
                                      java.lang.Object challenge,
                                      java.lang.Object... moreChallenges)
        Construct a new "not authorized" exception.
        Parameters:
        cause - the underlying cause of the exception.
        challenge - authorization challenge applicable to the requested resource.
        moreChallenges - additional authorization challenge applicable to the requested resource.
      • NotAuthorizedException

        public NotAuthorizedException​(java.lang.String message,
                                      java.lang.Throwable cause,
                                      java.lang.Object challenge,
                                      java.lang.Object... moreChallenges)
        Construct a new "not authorized" exception.
        Parameters:
        message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method).
        cause - the underlying cause of the exception.
        challenge - authorization challenge applicable to the requested resource.
        moreChallenges - additional authorization challenge applicable to the requested resource.
      • NotAuthorizedException

        public NotAuthorizedException​(Response response,
                                      java.lang.Throwable cause)
        Construct a new "not authorized" exception.
        Parameters:
        response - error response.
        cause - the underlying cause of the exception.
        Throws:
        java.lang.IllegalArgumentException - in case the status code set in the response is not HTTP 401.
      • NotAuthorizedException

        public NotAuthorizedException​(java.lang.String message,
                                      Response response,
                                      java.lang.Throwable cause)
        Construct a new "not authorized" exception.
        Parameters:
        message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method).
        response - error response.
        cause - the underlying cause of the exception.
        Throws:
        java.lang.IllegalArgumentException - in case the status code set in the response is not HTTP 401.
    • Method Detail

      • getChallenges

        public java.util.List<java.lang.Object> getChallenges​()
        Get the list of authorization challenges associated with the exception and applicable to the resource requested by the client.
        Returns:
        list of authorization challenges applicable to the resource requested by the client.