public abstract class AuthorizationResponse extends Object implements Response
Related specifications:
| Modifier | Constructor and Description |
|---|---|
protected |
AuthorizationResponse(URI redirectURI,
State state)
Creates a new authorisation response.
|
| Modifier and Type | Method and Description |
|---|---|
URI |
getRedirectionURI()
Gets the base redirection URI.
|
State |
getState()
Gets the optional state.
|
static AuthorizationResponse |
parse(HTTPResponse httpResponse)
Parses an authorisation response.
|
static AuthorizationResponse |
parse(URI uri)
Parses an authorisation response.
|
static AuthorizationResponse |
parse(URI redirectURI,
Map<String,String> params)
Parses an authorisation response.
|
HTTPResponse |
toHTTPResponse()
Returns the HTTP response for this authorisation response.
|
abstract Map<String,String> |
toParameters()
Returns the parameters of this authorisation response.
|
abstract URI |
toURI()
Returns the URI representation (redirection URI + fragment / query
string) of this authorisation response.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitindicatesSuccessprotected AuthorizationResponse(URI redirectURI, State state)
redirectURI - The base redirection URI. Must not be
null.state - The state, null if not requested.public URI getRedirectionURI()
public abstract Map<String,String> toParameters() throws SerializeException
Example parameters (authorisation success):
access_token = 2YotnFZFEjr1zCsicMWpAA state = xyz token_type = example expires_in = 3600
SerializeException - If this response couldn't be serialised
to a parameters map.public abstract URI toURI() throws SerializeException
Example URI:
http://example.com/cb#access_token=2YotnFZFEjr1zCsicMWpAA &state=xyz &token_type=example &expires_in=3600
SerializeException - If this response couldn't be serialised
to a URI.public HTTPResponse toHTTPResponse() throws SerializeException
Example HTTP response (authorisation success):
HTTP/1.1 302 Found Location: http://example.com/cb#access_token=2YotnFZFEjr1zCsicMWpAA &state=xyz &token_type=example &expires_in=3600
toHTTPResponse in interface ResponseSerializeException - If the response couldn't be serialised to
an HTTP response.public static AuthorizationResponse parse(URI redirectURI, Map<String,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 success or error response.public static AuthorizationResponse parse(URI uri) throws ParseException
Use a relative URI if the host, port and path details are not known:
URI relUrl = new URI("http://?code=Qcb0Orv1...&state=af0ifjsldkj");
AuthorizationResponse = AuthorizationResponse.parse(relURL);
uri - The URI to parse. May be absolute or relative, with a
fragment or query string containing the authorisation
response parameters. Must not be null.ParseException - If no authorisation response parameters were
found in the URL.public static AuthorizationResponse parse(HTTPResponse httpResponse) throws ParseException
Example HTTP response (authorisation success):
HTTP/1.1 302 Found Location: https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz
httpResponse - The HTTP response to parse. Must not be
null.ParseException - If the HTTP response couldn't be parsed to an
authorisation response.Copyright © 2015 Connect2id Ltd.. All Rights Reserved.