Package com.nimbusds.openid.connect.sdk
Class AuthenticationSuccessResponse
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.AuthorizationResponse
-
- com.nimbusds.oauth2.sdk.AuthorizationSuccessResponse
-
- com.nimbusds.openid.connect.sdk.AuthenticationSuccessResponse
-
- All Implemented Interfaces:
Message
,Response
,SuccessResponse
,AuthenticationResponse
@Immutable public class AuthenticationSuccessResponse extends AuthorizationSuccessResponse implements AuthenticationResponse
OpenID Connect authentication success response. Used to return an authorisation code, access token and / or ID Token at the Authorisation endpoint.Example HTTP response with code and ID Token (code flow):
HTTP/1.1 302 Found Location: https://client.example.org/cb# code=Qcb0Orv1zh30vL1MPRsbm-diHiMwcLyZvn1arpZv-Jxf_11jnpEX3Tgfvk &id_token=eyJhbGciOiJSUzI1NiJ9.ew0KICAgICJpc3MiOiAiaHR0cDovL3Nlc nZlci5leGFtcGxlLmNvbSIsDQogICAgInVzZXJfaWQiOiAiMjQ4Mjg5NzYxMDAxI iwNCiAgICAiYXVkIjogInM2QmhkUmtxdDMiLA0KICAgICJub25jZSI6ICJuLTBTN l9XekEyTWoiLA0KICAgICJleHAiOiAxMzExMjgxOTcwLA0KICAgICJpYXQiOiAxM zExMjgwOTcwLA0KICAgICJjX2hhc2giOiAiTERrdEtkb1FhazNQazBjblh4Q2x0Q mdfckNfM1RLVWI5T0xrNWZLTzl1QSINCn0.D6JxCgpOwlyuK7DPRu5hFOIJRSRDT B7TQNRbOw9Vg9WroDi_XNzaqXCFSDH_YqcE-CBhoxD-Iq4eQL4E2jIjil47u7i68 Nheev7d8AJk4wfRimgpDhQX5K8YyGDWrTs7bhsMTPAPVa9bLIBndDZ2mEdmPcmR9 mXcwJI3IGF9JOaStYXJXMYWUMCmQARZEKG9JxIYPZNhFsqKe4TYQEmrq2s_HHQwk XCGAmLBdptHY-Zx277qtidojQQFXzbD2Ak1ONT5sFjy3yxPnE87pNVtOEST5GJac O1O88gmvmjNayu1-f5mr5Uc70QC6DjlKem3cUN5kudAQ4sLvFkUr8gkIQ
Related specifications:
- OpenID Connect Core 1.0, section 3.1.2.5, 3.1.2.6, 3.2.2.5, 3.2.2.6, 3.3.2.5 and 3.3.2.6
- OpenID Connect Session Management 1.0 - draft 23, section 3
- OAuth 2.0 (RFC 6749), section 3.1
- OAuth 2.0 Multiple Response Type Encoding Practices 1.0
- OAuth 2.0 Form Post Response Mode 1.0
- Financial-grade API: JWT Secured Authorization Response Mode for OAuth 2.0 (JARM)
- OAuth 2.0 Authorization Server Issuer Identification (RFC 9207)
-
-
Constructor Summary
Constructors Constructor Description AuthenticationSuccessResponse(URI redirectURI, com.nimbusds.jwt.JWT jwtResponse, ResponseMode rm)
Creates a new JSON Web Token (JWT) secured OpenID Connect authentication success response.AuthenticationSuccessResponse(URI redirectURI, AuthorizationCode code, com.nimbusds.jwt.JWT idToken, AccessToken accessToken, State state, State sessionState, Issuer issuer, ResponseMode rm)
Creates a new OpenID Connect authentication success response.AuthenticationSuccessResponse(URI redirectURI, AuthorizationCode code, com.nimbusds.jwt.JWT idToken, AccessToken accessToken, State state, State sessionState, ResponseMode rm)
Creates a new OpenID Connect authentication success response.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.nimbusds.jwt.JWT
getIDToken()
Gets the requested ID token.State
getSessionState()
Gets the session state for session management.ResponseMode
impliedResponseMode()
Determines the implied response mode.ResponseType
impliedResponseType()
Returns the implied response type.static AuthenticationSuccessResponse
parse(HTTPRequest httpRequest)
Parses an OpenID Connect authentication success response from the specified HTTP request at the client redirection (callback) URI.static AuthenticationSuccessResponse
parse(HTTPResponse httpResponse)
Parses an OpenID Connect authentication success response from the specified initial HTTP 302 redirect response generated at the authorisation endpoint.static AuthenticationSuccessResponse
parse(URI uri)
Parses an OpenID Connect authentication success response.static AuthenticationSuccessResponse
parse(URI redirectURI, Map<String,List<String>> params)
Parses an OpenID Connect authentication success response.AuthenticationErrorResponse
toErrorResponse()
Casts this response to an authorisation error response.Map<String,List<String>>
toParameters()
Returns the parameters of this authorisation response.AuthenticationSuccessResponse
toSuccessResponse()
Casts this response to an authorisation success response.-
Methods inherited from class com.nimbusds.oauth2.sdk.AuthorizationSuccessResponse
getAccessToken, getAuthorizationCode, indicatesSuccess
-
Methods inherited from class com.nimbusds.oauth2.sdk.AuthorizationResponse
getIssuer, getJWTResponse, getRedirectionURI, getResponseMode, getState, parse, parse, parse, parse, parseResponseParameters, parseResponseParameters, toHTTPRequest, toHTTPResponse, toURI
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.nimbusds.openid.connect.sdk.AuthenticationResponse
getRedirectionURI, getState
-
Methods inherited from interface com.nimbusds.oauth2.sdk.Response
indicatesSuccess, toHTTPResponse
-
-
-
-
Constructor Detail
-
AuthenticationSuccessResponse
public AuthenticationSuccessResponse(URI redirectURI, AuthorizationCode code, com.nimbusds.jwt.JWT idToken, AccessToken accessToken, State state, State sessionState, ResponseMode rm)
Creates a new OpenID Connect authentication success response.- Parameters:
redirectURI
- The requested redirection URI. Must not benull
.code
- The authorisation code,null
if not requested.idToken
- The ID token (ready for output),null
if not requested.accessToken
- The UserInfo access token,null
if not requested.state
- The state,null
if not requested.sessionState
- The session state,null
if session management is not supported.rm
- The response mode,null
if not specified.
-
AuthenticationSuccessResponse
public AuthenticationSuccessResponse(URI redirectURI, AuthorizationCode code, com.nimbusds.jwt.JWT idToken, AccessToken accessToken, State state, State sessionState, Issuer issuer, ResponseMode rm)
Creates a new OpenID Connect authentication success response.- Parameters:
redirectURI
- The requested redirection URI. Must not benull
.code
- The authorisation code,null
if not requested.idToken
- The ID token (ready for output),null
if not requested.accessToken
- The UserInfo access token,null
if not requested.state
- The state,null
if not requested.sessionState
- The session state,null
if session management is not supported.rm
- The response mode,null
if not specified.
-
AuthenticationSuccessResponse
public AuthenticationSuccessResponse(URI redirectURI, com.nimbusds.jwt.JWT jwtResponse, ResponseMode rm)
Creates a new JSON Web Token (JWT) secured OpenID Connect authentication success response.- Parameters:
redirectURI
- The requested redirection URI. Must not benull
.jwtResponse
- The JWT-secured response. Must not benull
.rm
- The response mode,null
if not specified.
-
-
Method Detail
-
impliedResponseType
public ResponseType impliedResponseType()
Description copied from class:AuthorizationSuccessResponse
Returns the implied response type.- Overrides:
impliedResponseType
in classAuthorizationSuccessResponse
- Returns:
- The implied response type.
-
impliedResponseMode
public ResponseMode impliedResponseMode()
Description copied from class:AuthorizationResponse
Determines the implied response mode.- Overrides:
impliedResponseMode
in classAuthorizationSuccessResponse
- Returns:
- The implied response mode.
-
getIDToken
public com.nimbusds.jwt.JWT getIDToken()
Gets the requested ID token.- Returns:
- The ID token (ready for output),
null
if not requested.
-
getSessionState
public State getSessionState()
Gets the session state for session management.- Returns:
- The session store,
null
if session management is not supported.
-
toParameters
public Map<String,List<String>> toParameters()
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
- Overrides:
toParameters
in classAuthorizationSuccessResponse
- Returns:
- The parameters as a map.
-
toSuccessResponse
public AuthenticationSuccessResponse toSuccessResponse()
Description copied from class:AuthorizationResponse
Casts this response to an authorisation success response.- Specified by:
toSuccessResponse
in interfaceAuthenticationResponse
- Overrides:
toSuccessResponse
in classAuthorizationResponse
- Returns:
- The authorisation success response.
-
toErrorResponse
public AuthenticationErrorResponse toErrorResponse()
Description copied from class:AuthorizationResponse
Casts this response to an authorisation error response.- Specified by:
toErrorResponse
in interfaceAuthenticationResponse
- Overrides:
toErrorResponse
in classAuthorizationResponse
- Returns:
- The authorisation error response.
-
parse
public static AuthenticationSuccessResponse parse(URI redirectURI, Map<String,List<String>> params) throws ParseException
Parses an OpenID Connect authentication success response.- Parameters:
redirectURI
- The base redirection URI. Must not benull
.params
- The response parameters to parse. Must not benull
.- Returns:
- The OpenID Connect authentication success response.
- Throws:
ParseException
- If the parameters couldn't be parsed to an OpenID Connect authentication success response.
-
parse
public static AuthenticationSuccessResponse parse(URI uri) throws ParseException
Parses an OpenID Connect authentication success response.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
- Parameters:
uri
- The URI to parse. Can be absolute or relative, with a fragment or query string containing the authentication response parameters. Must not benull
.- Returns:
- The OpenID Connect authentication success response.
- Throws:
ParseException
- If the redirection URI couldn't be parsed to an OpenID Connect authentication success response.
-
parse
public static AuthenticationSuccessResponse parse(HTTPResponse httpResponse) throws ParseException
Parses an OpenID Connect authentication success response from the specified initial HTTP 302 redirect response generated at the authorisation endpoint.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 benull
.- Returns:
- The OpenID Connect authentication success response.
- Throws:
ParseException
- If the HTTP response couldn't be parsed to an OpenID Connect authentication success response.- See Also:
parse(HTTPRequest)
-
parse
public static AuthenticationSuccessResponse parse(HTTPRequest httpRequest) throws ParseException
Parses an OpenID Connect authentication success response from the specified HTTP request at the client redirection (callback) URI. Applies toquery
,fragment
andform_post
response modes.Example HTTP request (authentication success):
GET /cb?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz HTTP/1.1 Host: client.example.com
- Parameters:
httpRequest
- The HTTP request to parse. Must not benull
.- Returns:
- The authentication success response.
- Throws:
ParseException
- If the HTTP request couldn't be parsed to an OpenID Connect authentication success response.- See Also:
parse(HTTPResponse)
-
-