Class AuthorizationException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- net.openid.appauth.AuthorizationException
-
- All Implemented Interfaces:
Serializable
public final class AuthorizationException extends Exception
Returned as a response to OAuth2 requests if they fail.Specifically:
-
The
response
totoken requests
, -
The
response
toconfiguration retrieval
.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AuthorizationException.AuthorizationRequestErrors
Error codes related to failed authorization requests.static class
AuthorizationException.GeneralErrors
Error codes specific to AppAuth for Android, rather than those defined in the OAuth2 and OpenID specifications.static class
AuthorizationException.RegistrationRequestErrors
Error codes related to failed registration requests.static class
AuthorizationException.TokenRequestErrors
Error codes related to failed token requests.
-
Field Summary
Fields Modifier and Type Field Description int
code
The error code describing the class of problem encountered from the set defined in this class.String
error
The error string as it is found in the OAuth2 protocol.String
errorDescription
The human readable error message associated with this exception, if available.Uri
errorUri
A URI identifying a human-readable web page with information about this error.static String
EXTRA_EXCEPTION
The extra string that used to store anAuthorizationException
in an intent bytoIntent()
.static String
PARAM_ERROR
The OAuth2 parameter used to indicate the type of error during an authorization or token request.static String
PARAM_ERROR_DESCRIPTION
The OAuth2 parameter used to provide a human readable description of the error which occurred.static String
PARAM_ERROR_URI
The OAuth2 parameter used to provide a URI to a human-readable page which describes the error.int
type
The type of the error.static int
TYPE_GENERAL_ERROR
The error type used for all errors that are not specific to OAuth related responses.static int
TYPE_OAUTH_AUTHORIZATION_ERROR
The error type for OAuth specific errors on the authorization endpoint.static int
TYPE_OAUTH_REGISTRATION_ERROR
The error type for OAuth specific errors on the registration endpoint.static int
TYPE_OAUTH_TOKEN_ERROR
The error type for OAuth specific errors on the token endpoint.static int
TYPE_RESOURCE_SERVER_AUTHORIZATION_ERROR
The error type for authorization errors encountered out of band on the resource server.
-
Constructor Summary
Constructors Constructor Description AuthorizationException(int type, int code, String error, String errorDescription, Uri errorUri, Throwable rootCause)
Instantiates an authorization request with optional root cause information.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
static AuthorizationException
fromIntent(Intent data)
Extracts anAuthorizationException
from an intent produced bytoIntent()
.static AuthorizationException
fromJson(String jsonStr)
Reconstructs anAuthorizationException
from the JSON produced bytoJsonString()
.static AuthorizationException
fromJson(JSONObject json)
Reconstructs anAuthorizationException
from the JSON produced bytoJson()
.static AuthorizationException
fromOAuthRedirect(Uri redirectUri)
Creates an exception from an OAuth redirect URI that describes an authorization failure.static AuthorizationException
fromOAuthTemplate(AuthorizationException ex, String errorOverride, String errorDescriptionOverride, Uri errorUriOverride)
Creates an exception based on one of the existing values defined inAuthorizationException.AuthorizationRequestErrors
orAuthorizationException.TokenRequestErrors
, adding information retrieved from OAuth error response.static AuthorizationException
fromTemplate(AuthorizationException ex, Throwable rootCause)
Creates an exception based on one of the existing values defined inAuthorizationException.GeneralErrors
,AuthorizationException.AuthorizationRequestErrors
orAuthorizationException.TokenRequestErrors
, providing a root cause.int
hashCode()
Intent
toIntent()
Creates an intent from this exception.JSONObject
toJson()
Produces a JSON representation of the authorization exception, for transmission or storage.String
toJsonString()
Provides a JSON string representation of an authorization exception, for transmission or storage.String
toString()
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
Field Detail
-
EXTRA_EXCEPTION
public static final String EXTRA_EXCEPTION
The extra string that used to store anAuthorizationException
in an intent bytoIntent()
.- See Also:
- Constant Field Values
-
PARAM_ERROR
public static final String PARAM_ERROR
The OAuth2 parameter used to indicate the type of error during an authorization or token request.- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 4.1.2.1 https://tools.ietf.org/html/rfc6749#section-4.1.2.1”
, Constant Field Values
-
PARAM_ERROR_DESCRIPTION
public static final String PARAM_ERROR_DESCRIPTION
The OAuth2 parameter used to provide a human readable description of the error which occurred.- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 4.1.2.1 https://tools.ietf.org/html/rfc6749#section-4.1.2.1”
, Constant Field Values
-
PARAM_ERROR_URI
public static final String PARAM_ERROR_URI
The OAuth2 parameter used to provide a URI to a human-readable page which describes the error.- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 4.1.2.1 https://tools.ietf.org/html/rfc6749#section-4.1.2.1”
, Constant Field Values
-
TYPE_GENERAL_ERROR
public static final int TYPE_GENERAL_ERROR
The error type used for all errors that are not specific to OAuth related responses.- See Also:
- Constant Field Values
-
TYPE_OAUTH_AUTHORIZATION_ERROR
public static final int TYPE_OAUTH_AUTHORIZATION_ERROR
The error type for OAuth specific errors on the authorization endpoint.This error type is used when the server responds to an authorization request with an explicit OAuth error, as defined by the OAuth2 specification, section 4.1.2.1. If the authorization response is invalid and not explicitly an error response, another error type will be used.
- See Also:
“The OAuth 2.0 Authorization Framework (RFC 6749), Section 4.1.2.1 https://tools.ietf.org/html/rfc6749#section-4.1.2.1”
, Constant Field Values
-
TYPE_OAUTH_TOKEN_ERROR
public static final int TYPE_OAUTH_TOKEN_ERROR
The error type for OAuth specific errors on the token endpoint.This error type is used when the server responds with HTTP 400 and an OAuth error, as defined by the OAuth2 specification, section 5.2. If an HTTP 400 response does not parse as an OAuth error (i.e. no ‘error’ field is present or the JSON is invalid), another error domain will be used.
- See Also:
- Constant Field Values
-
TYPE_RESOURCE_SERVER_AUTHORIZATION_ERROR
public static final int TYPE_RESOURCE_SERVER_AUTHORIZATION_ERROR
The error type for authorization errors encountered out of band on the resource server.- See Also:
- Constant Field Values
-
TYPE_OAUTH_REGISTRATION_ERROR
public static final int TYPE_OAUTH_REGISTRATION_ERROR
The error type for OAuth specific errors on the registration endpoint.- See Also:
- Constant Field Values
-
type
public final int type
The type of the error.
-
code
public final int code
The error code describing the class of problem encountered from the set defined in this class.
-
errorDescription
@Nullable public final String errorDescription
The human readable error message associated with this exception, if available.
-
-
Method Detail
-
fromTemplate
public static AuthorizationException fromTemplate(@NonNull AuthorizationException ex, @Nullable Throwable rootCause)
Creates an exception based on one of the existing values defined inAuthorizationException.GeneralErrors
,AuthorizationException.AuthorizationRequestErrors
orAuthorizationException.TokenRequestErrors
, providing a root cause.
-
fromOAuthTemplate
public static AuthorizationException fromOAuthTemplate(@NonNull AuthorizationException ex, @Nullable String errorOverride, @Nullable String errorDescriptionOverride, @Nullable Uri errorUriOverride)
Creates an exception based on one of the existing values defined inAuthorizationException.AuthorizationRequestErrors
orAuthorizationException.TokenRequestErrors
, adding information retrieved from OAuth error response.
-
fromOAuthRedirect
public static AuthorizationException fromOAuthRedirect(@NonNull Uri redirectUri)
Creates an exception from an OAuth redirect URI that describes an authorization failure.
-
fromJson
public static AuthorizationException fromJson(@NonNull String jsonStr) throws JSONException
Reconstructs anAuthorizationException
from the JSON produced bytoJsonString()
.- Throws:
JSONException
- if the JSON is malformed or missing required properties
-
fromJson
public static AuthorizationException fromJson(@NonNull JSONObject json) throws JSONException
Reconstructs anAuthorizationException
from the JSON produced bytoJson()
.- Throws:
JSONException
- if the JSON is malformed or missing required properties
-
fromIntent
@Nullable public static AuthorizationException fromIntent(Intent data)
Extracts anAuthorizationException
from an intent produced bytoIntent()
.This is used to retrieve an error response in the handler registered for a call to
AuthorizationService.performAuthorizationRequest(net.openid.appauth.AuthorizationRequest, android.app.PendingIntent)
.
-
toJson
@NonNull public JSONObject toJson()
Produces a JSON representation of the authorization exception, for transmission or storage.This does not include any provided root cause.
-
toJsonString
@NonNull public String toJsonString()
Provides a JSON string representation of an authorization exception, for transmission or storage.This does not include any provided root cause.
-
toIntent
@NonNull public Intent toIntent()
Creates an intent from this exception.Used to carry error responses to the handling activity specified in calls to
AuthorizationService.performAuthorizationRequest(net.openid.appauth.AuthorizationRequest, android.app.PendingIntent)
.
-
-