Package javax.ws.rs
Class NotAuthorizedException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- javax.ws.rs.WebApplicationException
-
- javax.ws.rs.ClientErrorException
-
- javax.ws.rs.NotAuthorizedException
-
- All Implemented Interfaces:
java.io.Serializable
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.
AuthorizationHTTP header is missing in the request, -
or - in case the request already contains the HTTP
Authorizationheader - then the exception indicates that authorization has been refused for the credentials contained in the request header.
- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.Object>challengesprivate static longserialVersionUID
-
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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.List<java.lang.Object>cacheChallenges(java.lang.Object challenge, java.lang.Object[] moreChallenges)private static ResponsecreateUnauthorizedResponse(java.lang.Object challenge, java.lang.Object[] otherChallenges)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 javax.ws.rs.WebApplicationException
getResponse, validate, validate
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
challenges
private transient java.util.List<java.lang.Object> challenges
-
-
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 thechallengeparameter isnull.
-
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 theThrowable.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 thechallengeparameter isnull.
-
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 HTTP401.
-
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 theThrowable.getMessage()method).response- error response.- Throws:
java.lang.IllegalArgumentException- in case the status code set in the response is not HTTP401.
-
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 theThrowable.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 HTTP401.
-
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 theThrowable.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 HTTP401.
-
-
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.
-
createUnauthorizedResponse
private static Response createUnauthorizedResponse(java.lang.Object challenge, java.lang.Object[] otherChallenges)
-
cacheChallenges
private static java.util.List<java.lang.Object> cacheChallenges(java.lang.Object challenge, java.lang.Object[] moreChallenges)
-
-