public final class AuthorizationException
extends java.lang.Exception
Returned as a response to OAuth2 requests if they fail. Specifically:
The response to
token requests,
The response
to
configuration retrieval.
| Modifier and Type | Class and 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.
|
| Modifier and Type | Field and Description |
|---|---|
int |
code
The error code describing the class of problem encountered from the set defined in this
class.
|
java.lang.String |
error
The error string as it is found in the OAuth2 protocol.
|
java.lang.String |
errorDescription
The human readable error message associated with this exception, if available.
|
android.net.Uri |
errorUri
A URI identifying a human-readable web page with information about this error.
|
static java.lang.String |
EXTRA_EXCEPTION
The extra string that used to store an
AuthorizationException in an intent by
toIntent(). |
static java.lang.String |
PARAM_ERROR
The OAuth2 parameter used to indicate the type of error during an authorization or
token request.
|
static java.lang.String |
PARAM_ERROR_DESCRIPTION
The OAuth2 parameter used to provide a human readable description of the error which
occurred.
|
static java.lang.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 and Description |
|---|
AuthorizationException(int type,
int code,
java.lang.String error,
java.lang.String errorDescription,
android.net.Uri errorUri,
java.lang.Throwable rootCause)
Instantiates an authorization request with optional root cause information.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
|
static AuthorizationException |
fromIntent(android.content.Intent data)
Extracts an
AuthorizationException from an intent produced by toIntent(). |
static AuthorizationException |
fromJson(org.json.JSONObject json)
Reconstructs an
AuthorizationException from the JSON produced by
toJson(). |
static AuthorizationException |
fromJson(java.lang.String jsonStr)
Reconstructs an
AuthorizationException from the JSON produced by
toJsonString(). |
static AuthorizationException |
fromOAuthRedirect(android.net.Uri redirectUri)
Creates an exception from an OAuth redirect URI that describes an authorization failure.
|
static AuthorizationException |
fromOAuthTemplate(AuthorizationException ex,
java.lang.String errorOverride,
java.lang.String errorDescriptionOverride,
android.net.Uri errorUriOverride)
Creates an exception based on one of the existing values defined in
AuthorizationException.AuthorizationRequestErrors or AuthorizationException.TokenRequestErrors, adding information
retrieved from OAuth error response. |
static AuthorizationException |
fromTemplate(AuthorizationException ex,
java.lang.Throwable rootCause)
Creates an exception based on one of the existing values defined in
AuthorizationException.GeneralErrors, AuthorizationException.AuthorizationRequestErrors or AuthorizationException.TokenRequestErrors,
providing a root cause. |
int |
hashCode() |
android.content.Intent |
toIntent()
Creates an intent from this exception.
|
org.json.JSONObject |
toJson()
Produces a JSON representation of the authorization exception, for transmission or storage.
|
java.lang.String |
toJsonString()
Provides a JSON string representation of an authorization exception, for transmission or
storage.
|
java.lang.String |
toString() |
public static final java.lang.String EXTRA_EXCEPTION
The extra string that used to store an AuthorizationException in an intent by
toIntent().
public static final java.lang.String PARAM_ERROR
The OAuth2 parameter used to indicate the type of error during an authorization or token request.
public static final java.lang.String PARAM_ERROR_DESCRIPTION
The OAuth2 parameter used to provide a human readable description of the error which occurred.
public static final java.lang.String PARAM_ERROR_URI
The OAuth2 parameter used to provide a URI to a human-readable page which describes the error.
public static final int TYPE_GENERAL_ERROR
The error type used for all errors that are not specific to OAuth related responses.
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.
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.
public static final int TYPE_RESOURCE_SERVER_AUTHORIZATION_ERROR
The error type for authorization errors encountered out of band on the resource server.
public static final int TYPE_OAUTH_REGISTRATION_ERROR
The error type for OAuth specific errors on the registration endpoint.
public final int type
The type of the error.
public final int code
The error code describing the class of problem encountered from the set defined in this class.
@Nullable public final java.lang.String error
The error string as it is found in the OAuth2 protocol.
@Nullable public final java.lang.String errorDescription
The human readable error message associated with this exception, if available.
@Nullable public final android.net.Uri errorUri
A URI identifying a human-readable web page with information about this error.
public AuthorizationException(int type,
int code,
@Nullable
java.lang.String error,
@Nullable
java.lang.String errorDescription,
@Nullable
android.net.Uri errorUri,
@Nullable
java.lang.Throwable rootCause)
Instantiates an authorization request with optional root cause information.
public static AuthorizationException fromTemplate(@NonNull AuthorizationException ex, @Nullable java.lang.Throwable rootCause)
Creates an exception based on one of the existing values defined in
AuthorizationException.GeneralErrors, AuthorizationException.AuthorizationRequestErrors or AuthorizationException.TokenRequestErrors,
providing a root cause.
public static AuthorizationException fromOAuthTemplate(@NonNull AuthorizationException ex, @Nullable java.lang.String errorOverride, @Nullable java.lang.String errorDescriptionOverride, @Nullable android.net.Uri errorUriOverride)
Creates an exception based on one of the existing values defined in
AuthorizationException.AuthorizationRequestErrors or AuthorizationException.TokenRequestErrors, adding information
retrieved from OAuth error response.
public static AuthorizationException fromOAuthRedirect(@NonNull android.net.Uri redirectUri)
Creates an exception from an OAuth redirect URI that describes an authorization failure.
public static AuthorizationException fromJson(@NonNull java.lang.String jsonStr) throws org.json.JSONException
Reconstructs an AuthorizationException from the JSON produced by
toJsonString().
org.json.JSONException - if the JSON is malformed or missing required propertiespublic static AuthorizationException fromJson(@NonNull org.json.JSONObject json) throws org.json.JSONException
Reconstructs an AuthorizationException from the JSON produced by
toJson().
org.json.JSONException - if the JSON is malformed or missing required properties@Nullable public static AuthorizationException fromIntent(android.content.Intent data)
Extracts an AuthorizationException from an intent produced by toIntent().
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).
@NonNull public org.json.JSONObject toJson()
Produces a JSON representation of the authorization exception, for transmission or storage. This does not include any provided root cause.
@NonNull public java.lang.String toJsonString()
Provides a JSON string representation of an authorization exception, for transmission or storage. This does not include any provided root cause.
@NonNull public android.content.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).
public boolean equals(java.lang.Object obj)
Exceptions are considered to be equal if their type and code
are the same; all other properties are irrelevant for comparison.
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Throwable