ErrorResponse
, Message
, Response
AuthenticationErrorResponse
@Immutable public class AuthorizationErrorResponse extends AuthorizationResponse implements ErrorResponse
access_denied
. For a complete list see OAuth 2.0 (RFC 6749),
sections 4.1.2.1 and 4.2.2.1.
If the authorisation request fails due to a missing, invalid, or
mismatching redirect_uri
, or if the client_id
is missing or
invalid, a response must not be sent back to the requesting
client. Instead, the authorisation server should simply display the error
to the resource owner.
Standard authorisation errors:
OAuth2Error.INVALID_REQUEST
OAuth2Error.UNAUTHORIZED_CLIENT
OAuth2Error.ACCESS_DENIED
OAuth2Error.UNSUPPORTED_RESPONSE_TYPE
OAuth2Error.INVALID_SCOPE
OAuth2Error.SERVER_ERROR
OAuth2Error.TEMPORARILY_UNAVAILABLE
Example HTTP response:
HTTP/1.1 302 Found Location: https://client.example.com/cb? error=invalid_request &error_description=the%20request%20is%20not%20valid%20or%20malformed &state=af0ifjsldkj
Related specifications:
Constructor | Description |
---|---|
AuthorizationErrorResponse(URI redirectURI,
ErrorObject error,
State state,
ResponseMode rm) |
Creates a new authorisation error response.
|
Modifier and Type | Method | Description |
---|---|---|
ErrorObject |
getErrorObject() |
Gets the error associated with the error response.
|
static Set<ErrorObject> |
getStandardErrors() |
Gets the standard OAuth 2.0 errors for an Authorisation error
response.
|
ResponseMode |
impliedResponseMode() |
Determines the implied response mode.
|
boolean |
indicatesSuccess() |
Checks if the response indicates success.
|
static AuthorizationErrorResponse |
parse(HTTPRequest httpRequest) |
Parses an authorisation error response from the specified HTTP
request at the client redirection (callback) URI.
|
static AuthorizationErrorResponse |
parse(HTTPResponse httpResponse) |
Parses an authorisation error response from the specified initial
HTTP 302 redirect response generated at the authorisation endpoint.
|
static AuthorizationErrorResponse |
parse(URI uri) |
Parses an authorisation error response.
|
static AuthorizationErrorResponse |
parse(URI redirectURI,
Map<String,List<String>> params) |
Parses an authorisation error response.
|
Map<String,List<String>> |
toParameters() |
Returns the parameters of this authorisation response.
|
getRedirectionURI, getResponseMode, getState, toErrorResponse, toHTTPRequest, toHTTPResponse, toSuccessResponse, toURI
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toHTTPResponse
public AuthorizationErrorResponse(URI redirectURI, ErrorObject error, State state, ResponseMode rm)
redirectURI
- The base redirection URI. Must not be
null
.error
- The error. Should match one of the
standard errors
for an
authorisation error response. Must not be
null
.state
- The state, null
if not requested.rm
- The implied response mode, null
if
unknown.public static Set<ErrorObject> getStandardErrors()
public boolean indicatesSuccess()
Response
indicatesSuccess
in interface Response
true
if the response indicates success, else
false
.public ErrorObject getErrorObject()
ErrorResponse
getErrorObject
in interface ErrorResponse
null
if none.public ResponseMode impliedResponseMode()
AuthorizationResponse
impliedResponseMode
in class AuthorizationResponse
public Map<String,List<String>> toParameters()
AuthorizationResponse
Example parameters (authorisation success):
access_token = 2YotnFZFEjr1zCsicMWpAA state = xyz token_type = example expires_in = 3600
toParameters
in class AuthorizationResponse
public static AuthorizationErrorResponse parse(URI redirectURI, Map<String,List<String>> params) throws ParseException
redirectURI
- The base redirection URI. Must not be
null
.params
- The response parameters to parse. Must not be
null
.ParseException
- If the parameters couldn't be parsed to an
authorisation error response.public static AuthorizationErrorResponse parse(URI uri) throws ParseException
Use a relative URI if the host, port and path details are not known:
URI relUrl = new URI("https:///?error=invalid_request");
Example URI:
https://client.example.com/cb? error=invalid_request &error_description=the%20request%20is%20not%20valid%20or%20malformed &state=af0ifjsldkj
uri
- The URI to parse. Can be absolute or relative, with a
fragment or query string containing the authorisation
response parameters. Must not be null
.ParseException
- If the URI couldn't be parsed to an
authorisation error response.public static AuthorizationErrorResponse parse(HTTPResponse httpResponse) throws ParseException
Example HTTP response:
HTTP/1.1 302 Found Location: https://client.example.com/cb?error=invalid_request&state=af0ifjsldkj
httpResponse
- The HTTP response to parse. Must not be
null
.ParseException
- If the HTTP response couldn't be parsed to an
authorisation error response.parse(HTTPRequest)
public static AuthorizationErrorResponse parse(HTTPRequest httpRequest) throws ParseException
query
, fragment
and form_post
response
modes.
Example HTTP request (authorisation success):
GET /cb?error=invalid_request&state=af0ifjsldkj HTTP/1.1 Host: client.example.com
httpRequest
- The HTTP request to parse. Must not be
null
.ParseException
- If the HTTP request couldn't be parsed to an
authorisation error response.parse(HTTPResponse)
Copyright © 2018 Connect2id Ltd.. All rights reserved.