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
responsetotoken requests, -
The
responsetoconfiguration retrieval.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAuthorizationException.AuthorizationRequestErrorsError codes related to failed authorization requests.static classAuthorizationException.GeneralErrorsError codes specific to AppAuth for Android, rather than those defined in the OAuth2 and OpenID specifications.static classAuthorizationException.RegistrationRequestErrorsError codes related to failed registration requests.static classAuthorizationException.TokenRequestErrorsError codes related to failed token requests.
-
Field Summary
Fields Modifier and Type Field Description intcodeThe error code describing the class of problem encountered from the set defined in this class.StringerrorThe error string as it is found in the OAuth2 protocol.StringerrorDescriptionThe human readable error message associated with this exception, if available.UrierrorUriA URI identifying a human-readable web page with information about this error.static StringEXTRA_EXCEPTIONThe extra string that used to store anAuthorizationExceptionin an intent bytoIntent().static StringPARAM_ERRORThe OAuth2 parameter used to indicate the type of error during an authorization or token request.static StringPARAM_ERROR_DESCRIPTIONThe OAuth2 parameter used to provide a human readable description of the error which occurred.static StringPARAM_ERROR_URIThe OAuth2 parameter used to provide a URI to a human-readable page which describes the error.inttypeThe type of the error.static intTYPE_GENERAL_ERRORThe error type used for all errors that are not specific to OAuth related responses.static intTYPE_OAUTH_AUTHORIZATION_ERRORThe error type for OAuth specific errors on the authorization endpoint.static intTYPE_OAUTH_REGISTRATION_ERRORThe error type for OAuth specific errors on the registration endpoint.static intTYPE_OAUTH_TOKEN_ERRORThe error type for OAuth specific errors on the token endpoint.static intTYPE_RESOURCE_SERVER_AUTHORIZATION_ERRORThe 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 booleanequals(Object obj)static AuthorizationExceptionfromIntent(Intent data)Extracts anAuthorizationExceptionfrom an intent produced bytoIntent().static AuthorizationExceptionfromJson(String jsonStr)Reconstructs anAuthorizationExceptionfrom the JSON produced bytoJsonString().static AuthorizationExceptionfromJson(JSONObject json)Reconstructs anAuthorizationExceptionfrom the JSON produced bytoJson().static AuthorizationExceptionfromOAuthRedirect(Uri redirectUri)Creates an exception from an OAuth redirect URI that describes an authorization failure.static AuthorizationExceptionfromOAuthTemplate(AuthorizationException ex, String errorOverride, String errorDescriptionOverride, Uri errorUriOverride)Creates an exception based on one of the existing values defined inAuthorizationException.AuthorizationRequestErrorsorAuthorizationException.TokenRequestErrors, adding information retrieved from OAuth error response.static AuthorizationExceptionfromTemplate(AuthorizationException ex, Throwable rootCause)Creates an exception based on one of the existing values defined inAuthorizationException.GeneralErrors,AuthorizationException.AuthorizationRequestErrorsorAuthorizationException.TokenRequestErrors, providing a root cause.inthashCode()IntenttoIntent()Creates an intent from this exception.JSONObjecttoJson()Produces a JSON representation of the authorization exception, for transmission or storage.StringtoJsonString()Provides a JSON string representation of an authorization exception, for transmission or storage.StringtoString()-
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 anAuthorizationExceptionin 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.AuthorizationRequestErrorsorAuthorizationException.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.AuthorizationRequestErrorsorAuthorizationException.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 anAuthorizationExceptionfrom 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 anAuthorizationExceptionfrom the JSON produced bytoJson().- Throws:
JSONException- if the JSON is malformed or missing required properties
-
fromIntent
@Nullable public static AuthorizationException fromIntent(Intent data)
Extracts anAuthorizationExceptionfrom 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).
-
-