@Immutable public class AuthorizationSuccessResponse extends AuthorizationResponse implements SuccessResponse
Example HTTP response with code (code flow):
HTTP/1.1 302 Found Location: https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz
Example HTTP response with access token (implicit flow):
HTTP/1.1 302 Found Location: http://example.com/cb#access_token=2YotnFZFEjr1zCsicMWpAA &state=xyz&token_type=Bearer&expires_in=3600
Related specifications:
Constructor and Description |
---|
AuthorizationSuccessResponse(URI redirectURI,
AuthorizationCode code,
AccessToken accessToken,
State state,
ResponseMode rm)
Creates a new authorisation success response.
|
Modifier and Type | Method and Description |
---|---|
AccessToken |
getAccessToken()
Gets the access token.
|
AuthorizationCode |
getAuthorizationCode()
Gets the authorisation code.
|
ResponseMode |
impliedResponseMode()
Determines the implied response mode.
|
ResponseType |
impliedResponseType()
Returns the implied response type.
|
boolean |
indicatesSuccess()
Checks if the response indicates success.
|
static AuthorizationSuccessResponse |
parse(HTTPRequest httpRequest)
Parses an authorisation success response from the specified HTTP
request at the client redirection (callback) URI.
|
static AuthorizationSuccessResponse |
parse(HTTPResponse httpResponse)
Parses an authorisation success response from the specified initial
HTTP 302 redirect response generated at the authorisation endpoint.
|
static AuthorizationSuccessResponse |
parse(URI uri)
Parses an authorisation success response.
|
static AuthorizationSuccessResponse |
parse(URI redirectURI,
Map<String,String> params)
Parses an authorisation success response.
|
Map<String,String> |
toParameters()
Returns the parameters of this authorisation response.
|
getRedirectionURI, getResponseMode, getState, toHTTPRequest, toHTTPResponse, toURI
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toHTTPResponse
public AuthorizationSuccessResponse(URI redirectURI, AuthorizationCode code, AccessToken accessToken, State state, ResponseMode rm)
redirectURI
- The base redirection URI. Must not be
null
.code
- The authorisation code, null
if not
requested.accessToken
- The access token, null
if not requested.state
- The state, null
if not specified.rm
- The response mode, null
if not specified.public boolean indicatesSuccess()
Response
indicatesSuccess
in interface Response
true
if the response indicates success, else
false
.public ResponseType impliedResponseType()
public ResponseMode impliedResponseMode()
AuthorizationResponse
impliedResponseMode
in class AuthorizationResponse
public AuthorizationCode getAuthorizationCode()
null
if not requested.public AccessToken getAccessToken()
null
if not requested.public Map<String,String> toParameters()
AuthorizationResponse
Example parameters (authorisation success):
access_token = 2YotnFZFEjr1zCsicMWpAA state = xyz token_type = example expires_in = 3600
toParameters
in class AuthorizationResponse
public static AuthorizationSuccessResponse 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 response.public static AuthorizationSuccessResponse parse(URI uri) throws ParseException
Use a relative URI if the host, port and path details are not known:
URI relUrl = new URI("https:///?code=Qcb0Orv1...&state=af0ifjsldkj");
Example URI:
https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz
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 redirection URI couldn't be parsed to
an authorisation success response.public static AuthorizationSuccessResponse parse(HTTPResponse httpResponse) throws ParseException
Example HTTP response:
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 success response.parse(HTTPRequest)
public static AuthorizationSuccessResponse parse(HTTPRequest httpRequest) throws ParseException
query
, fragment
and form_post
response
modes.
Example HTTP request (authorisation success):
GET /cb?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz 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 success response.parse(HTTPResponse)
Copyright © 2017 Connect2id Ltd.. All rights reserved.