com.nimbusds.oauth2.sdk
Class AuthorizationSuccessResponse

java.lang.Object
  extended by com.nimbusds.oauth2.sdk.AuthorizationResponse
      extended by com.nimbusds.oauth2.sdk.AuthorizationSuccessResponse
All Implemented Interfaces:
Message, Response, SuccessResponse
Direct Known Subclasses:
OIDCAuthorizationSuccessResponse

@Immutable
public class AuthorizationSuccessResponse
extends AuthorizationResponse
implements SuccessResponse

Authorisation success response. Used to return an authorisation code or access token at the Authorisation endpoint. This class is immutable.

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:

Author:
Vladimir Dzhuvinov

Constructor Summary
AuthorizationSuccessResponse(URL redirectURI, AccessToken accessToken, State state)
          Creates a new authorisation success response in the implicit flow (implicit grant).
AuthorizationSuccessResponse(URL redirectURI, AuthorizationCode code, AccessToken accessToken, State state)
          Creates a new authorisation success response.
AuthorizationSuccessResponse(URL redirectURI, AuthorizationCode code, State state)
          Creates a new authorisation success response in the code flow (authorisation code grant).
 
Method Summary
 AccessToken getAccessToken()
          Gets the access token.
 AuthorizationCode getAuthorizationCode()
          Gets the authorisation code.
 ResponseType getImpliedResponseType()
          Gets the implied response type.
static AuthorizationSuccessResponse parse(HTTPResponse httpResponse)
          Parses an authorisation success response.
static AuthorizationSuccessResponse parse(URL uri)
          Parses an authorisation success response.
static AuthorizationSuccessResponse parse(URL redirectURI, Map<String,String> params)
          Parses an authorisation success response.
 Map<String,String> toParameters()
          Returns the parameters of this authorisation response.
 URL toURI()
          Returns the URI representation (redirect URI + fragment / query string) of this authorisation response.
 
Methods inherited from class com.nimbusds.oauth2.sdk.AuthorizationResponse
getRedirectURI, getState, toHTTPResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.nimbusds.oauth2.sdk.Response
toHTTPResponse
 

Constructor Detail

AuthorizationSuccessResponse

public AuthorizationSuccessResponse(URL redirectURI,
                                    AuthorizationCode code,
                                    State state)
Creates a new authorisation success response in the code flow (authorisation code grant).

Parameters:
redirectURI - The base redirect URI. Must not be null.
code - The authorisation code. Must not be null.
state - The state, null if not requested.

AuthorizationSuccessResponse

public AuthorizationSuccessResponse(URL redirectURI,
                                    AccessToken accessToken,
                                    State state)
Creates a new authorisation success response in the implicit flow (implicit grant).

Parameters:
redirectURI - The base redirect URI. Must not be null.
accessToken - The access token. Must not be null.
state - The state, null if not requested.

AuthorizationSuccessResponse

public AuthorizationSuccessResponse(URL redirectURI,
                                    AuthorizationCode code,
                                    AccessToken accessToken,
                                    State state)
Creates a new authorisation success response.

Parameters:
redirectURI - The base redirect 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 requested.
Method Detail

getImpliedResponseType

public ResponseType getImpliedResponseType()
Gets the implied response type.

Returns:
The implied response type.

getAuthorizationCode

public AuthorizationCode getAuthorizationCode()
Gets the authorisation code.

Returns:
The authorisation code, null if not requested.

getAccessToken

public AccessToken getAccessToken()
Gets the access token.

Returns:
The access token, null if not requested.

toParameters

public Map<String,String> toParameters()
                                throws SerializeException
Description copied from class: AuthorizationResponse
Returns the parameters of this authorisation response.

Example parameters (authorisation success):

 access_token = 2YotnFZFEjr1zCsicMWpAA
 state = xyz
 token_type = example
 expires_in = 3600
 

Specified by:
toParameters in class AuthorizationResponse
Returns:
The parameters as a map.
Throws:
SerializeException - If this response couldn't be serialised to a parameters map.

toURI

public URL toURI()
          throws SerializeException
Description copied from class: AuthorizationResponse
Returns the URI representation (redirect URI + fragment / query string) of this authorisation response.

Example URI:

 http://example.com/cb#access_token=2YotnFZFEjr1zCsicMWpAA
 &state=xyz
 &token_type=example
 &expires_in=3600
 

Specified by:
toURI in class AuthorizationResponse
Returns:
The URI representation of this authorisation response.
Throws:
SerializeException - If this response couldn't be serialised to a URI.

parse

public static AuthorizationSuccessResponse parse(URL redirectURI,
                                                 Map<String,String> params)
                                          throws ParseException
Parses an authorisation success response.

Parameters:
redirectURI - The base redirect URI. Must not be null.
params - The response parameters to parse. Must not be null.
Returns:
The authorisation success response.
Throws:
ParseException - If the parameters couldn't be parsed to an authorisation success response.

parse

public static AuthorizationSuccessResponse parse(URL uri)
                                          throws ParseException
Parses an authorisation success response.

Example URI:

 https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz
 

Parameters:
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.
Returns:
The authorisation success response.
Throws:
ParseException - If the redirect URI couldn't be parsed to an authorisation success response.

parse

public static AuthorizationSuccessResponse parse(HTTPResponse httpResponse)
                                          throws ParseException
Parses an authorisation success response.

Example HTTP response:

 HTTP/1.1 302 Found
 Location: https://client.example.com/cb?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz
 

Parameters:
httpResponse - The HTTP response to parse. Must not be null.
Returns:
The authorisation success response.
Throws:
ParseException - If the HTTP response couldn't be parsed to an authorisation success response.


Copyright © 2013 NimbusDS. All Rights Reserved.