Package com.nimbusds.openid.connect.sdk
Class AuthenticationRequest
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.AbstractRequest
-
- com.nimbusds.oauth2.sdk.AuthorizationRequest
-
- com.nimbusds.openid.connect.sdk.AuthenticationRequest
-
@Immutable public class AuthenticationRequest extends AuthorizationRequest
OpenID Connect authentication request. Intended to authenticate an end-user and request the end-user's authorisation to release information to the client. Supports custom request parameters.Example HTTP request (code flow):
https://server.example.com/op/authorize? response_type=code%20id_token &client_id=s6BhdRkqt3 &redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb &scope=openid &nonce=n-0S6_WzA2Mj &state=af0ifjsldkj
Related specifications:
- OpenID Connect Core 1.0, section 3.1.2.1.
- Proof Key for Code Exchange by OAuth Public Clients (RFC 7636).
- Resource Indicators for OAuth 2.0 (draft-ietf-oauth-resource-indicators-00)
- The OAuth 2.0 Authorization Framework: JWT Secured Authorization Request (JAR) draft-ietf-oauth-jwsreq-17
- Financial-grade API: JWT Secured Authorization Response Mode for OAuth 2.0 (JARM)
- OpenID Connect for Identity Assurance 1.0, section 8.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAuthenticationRequest.BuilderBuilder for constructing OpenID Connect authentication requests.
-
Field Summary
Fields Modifier and Type Field Description static intPURPOSE_MAX_LENGTHThe purpose string parameter maximum length.static intPURPOSE_MIN_LENGTHThe purpose string parameter minimal length.-
Fields inherited from class com.nimbusds.oauth2.sdk.AuthorizationRequest
prompt
-
-
Constructor Summary
Constructors Constructor Description AuthenticationRequest(URI uri, ResponseType rt, ResponseMode rm, Scope scope, ClientID clientID, URI redirectURI, State state, Nonce nonce, Display display, Prompt prompt, int maxAge, List<com.nimbusds.langtag.LangTag> uiLocales, List<com.nimbusds.langtag.LangTag> claimsLocales, com.nimbusds.jwt.JWT idTokenHint, String loginHint, List<ACR> acrValues, ClaimsRequest claims, String purpose, com.nimbusds.jwt.JWT requestObject, URI requestURI, CodeChallenge codeChallenge, CodeChallengeMethod codeChallengeMethod, List<URI> resources, boolean includeGrantedScopes, Map<String,List<String>> customParams)Creates a new OpenID Connect authentication request with extension and custom parameters.AuthenticationRequest(URI uri, ResponseType rt, Scope scope, ClientID clientID, URI redirectURI, State state, Nonce nonce)Creates a new minimal OpenID Connect authentication request.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ACR>getACRValues()Gets the requested Authentication Context Class Reference values.ClaimsRequestgetClaims()Gets the individual claims to be returned.List<com.nimbusds.langtag.LangTag>getClaimsLocales()Gets the end-user's preferred languages and scripts for the claims being returned, ordered by preference.DisplaygetDisplay()Gets the requested display type.com.nimbusds.jwt.JWTgetIDTokenHint()Gets the ID Token hint.StringgetLoginHint()Gets the login hint.intgetMaxAge()Gets the required maximum authentication age.NoncegetNonce()Gets the nonce.StringgetPurpose()Gets the transaction specific purpose.static Set<String>getRegisteredParameterNames()Returns the registered (standard) OpenID Connect authentication request parameter names.List<com.nimbusds.langtag.LangTag>getUILocales()Gets the end-user's preferred languages and scripts for the user interface, ordered by preference.static AuthenticationRequestparse(HTTPRequest httpRequest)Parses an authentication request from the specified HTTP GET or HTTP POST request.static AuthenticationRequestparse(String query)Parses an OpenID Connect authentication request from the specified URI query string.static AuthenticationRequestparse(URI uri)Parses an OpenID Connect authentication request from the specified URI.static AuthenticationRequestparse(URI uri, String query)Parses an OpenID Connect authentication request from the specified URI query string.static AuthenticationRequestparse(URI uri, Map<String,List<String>> params)Parses an OpenID Connect authentication request from the specified URI and query parameters.static AuthenticationRequestparse(Map<String,List<String>> params)Parses an OpenID Connect authentication request from the specified URI query parameters.com.nimbusds.jwt.JWTClaimsSettoJWTClaimsSet()Returns the parameters for this authorisation request as a JSON Web Token (JWT) claims set.Map<String,List<String>>toParameters()Returns the URI query parameters for this authorisation request.-
Methods inherited from class com.nimbusds.oauth2.sdk.AuthorizationRequest
getClientID, getCodeChallenge, getCodeChallengeMethod, getCustomParameter, getCustomParameters, getPrompt, getRedirectionURI, getRequestObject, getRequestURI, getResources, getResponseMode, getResponseType, getScope, getState, impliedResponseMode, includeGrantedScopes, specifiesRequestObject, toHTTPRequest, toHTTPRequest, toQueryString, toURI
-
Methods inherited from class com.nimbusds.oauth2.sdk.AbstractRequest
getEndpointURI
-
-
-
-
Field Detail
-
PURPOSE_MIN_LENGTH
public static final int PURPOSE_MIN_LENGTH
The purpose string parameter minimal length.- See Also:
- Constant Field Values
-
PURPOSE_MAX_LENGTH
public static final int PURPOSE_MAX_LENGTH
The purpose string parameter maximum length.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AuthenticationRequest
public AuthenticationRequest(URI uri, ResponseType rt, Scope scope, ClientID clientID, URI redirectURI, State state, Nonce nonce)
Creates a new minimal OpenID Connect authentication request.- Parameters:
uri- The URI of the OAuth 2.0 authorisation endpoint. May benullif theAuthorizationRequest.toHTTPRequest(com.nimbusds.oauth2.sdk.http.HTTPRequest.Method)method will not be used.rt- The response type. Corresponds to theresponse_typeparameter. Must specify a valid OpenID Connect response type. Must not benull.scope- The request scope. Corresponds to thescopeparameter. Must contain anopenid value. Must not benull.clientID- The client identifier. Corresponds to theclient_idparameter. Must not benull.redirectURI- The redirection URI. Corresponds to theredirect_uriparameter. Must not benull.state- The state. Corresponds to thestateparameter. May benull.nonce- The nonce. Corresponds to thenonceparameter. May benullfor code flow.
-
AuthenticationRequest
public AuthenticationRequest(URI uri, ResponseType rt, ResponseMode rm, Scope scope, ClientID clientID, URI redirectURI, State state, Nonce nonce, Display display, Prompt prompt, int maxAge, List<com.nimbusds.langtag.LangTag> uiLocales, List<com.nimbusds.langtag.LangTag> claimsLocales, com.nimbusds.jwt.JWT idTokenHint, String loginHint, List<ACR> acrValues, ClaimsRequest claims, String purpose, com.nimbusds.jwt.JWT requestObject, URI requestURI, CodeChallenge codeChallenge, CodeChallengeMethod codeChallengeMethod, List<URI> resources, boolean includeGrantedScopes, Map<String,List<String>> customParams)
Creates a new OpenID Connect authentication request with extension and custom parameters.- Parameters:
uri- The URI of the OAuth 2.0 authorisation endpoint. May benullif theAuthorizationRequest.toHTTPRequest(com.nimbusds.oauth2.sdk.http.HTTPRequest.Method)method will not be used.rt- The response type set. Corresponds to theresponse_typeparameter. Must specify a valid OpenID Connect response type. Must not benull.rm- The response mode. Corresponds to the optionalresponse_modeparameter. Use of this parameter is not recommended unless a non-default response mode is requested (e.g. form_post).scope- The request scope. Corresponds to thescopeparameter. Must contain anopenid value. Must not benull.clientID- The client identifier. Corresponds to theclient_idparameter. Must not benull.redirectURI- The redirection URI. Corresponds to theredirect_uriparameter. Must not benullunless set by means of the optionalrequest_object/request_uriparameter.state- The state. Corresponds to the recommendedstateparameter.nullif not specified.nonce- The nonce. Corresponds to thenonceparameter. May benullfor code flow.display- The requested display type. Corresponds to the optionaldisplayparameter.nullif not specified.prompt- The requested prompt. Corresponds to the optionalpromptparameter.nullif not specified.maxAge- The required maximum authentication age, in seconds. Corresponds to the optionalmax_ageparameter. -1 if not specified, zero impliesprompt=login.uiLocales- The preferred languages and scripts for the user interface. Corresponds to the optionalui_localesparameter.nullif not specified.claimsLocales- The preferred languages and scripts for claims being returned. Corresponds to the optionalclaims_localesparameter.nullif not specified.idTokenHint- The ID Token hint. Corresponds to the optionalid_token_hintparameter.nullif not specified.loginHint- The login hint. Corresponds to the optionallogin_hintparameter.nullif not specified.acrValues- The requested Authentication Context Class Reference values. Corresponds to the optionalacr_valuesparameter.nullif not specified.claims- The individual claims to be returned. Corresponds to the optionalclaimsparameter.nullif not specified.purpose- The transaction specific purpose,nullif not specified.requestObject- The request object. Corresponds to the optionalrequestparameter. Must not be specified together with a request object URI.nullif not specified.requestURI- The request object URI. Corresponds to the optionalrequest_uriparameter. Must not be specified together with a request object.nullif not specified.codeChallenge- The code challenge for PKCE,nullif not specified.codeChallengeMethod- The code challenge method for PKCE,nullif not specified.resources- The resource URI(s),nullif not specified.includeGrantedScopes-trueto request incremental authorisation.customParams- Additional custom parameters, empty map ornullif none.
-
-
Method Detail
-
getRegisteredParameterNames
public static Set<String> getRegisteredParameterNames()
Returns the registered (standard) OpenID Connect authentication request parameter names.- Returns:
- The registered OpenID Connect authentication request parameter names, as a unmodifiable set.
-
getNonce
public Nonce getNonce()
Gets the nonce. Corresponds to the conditionally optionalnonceparameter.- Returns:
- The nonce,
nullif not specified.
-
getDisplay
public Display getDisplay()
Gets the requested display type. Corresponds to the optionaldisplayparameter.- Returns:
- The requested display type,
nullif not specified.
-
getMaxAge
public int getMaxAge()
Gets the required maximum authentication age. Corresponds to the optionalmax_ageparameter.- Returns:
- The maximum authentication age, in seconds; -1 if not
specified, zero implies
prompt=login.
-
getUILocales
public List<com.nimbusds.langtag.LangTag> getUILocales()
Gets the end-user's preferred languages and scripts for the user interface, ordered by preference. Corresponds to the optionalui_localesparameter.- Returns:
- The preferred UI locales,
nullif not specified.
-
getClaimsLocales
public List<com.nimbusds.langtag.LangTag> getClaimsLocales()
Gets the end-user's preferred languages and scripts for the claims being returned, ordered by preference. Corresponds to the optionalclaims_localesparameter.- Returns:
- The preferred claims locales,
nullif not specified.
-
getIDTokenHint
public com.nimbusds.jwt.JWT getIDTokenHint()
Gets the ID Token hint. Corresponds to the conditionally optionalid_token_hintparameter.- Returns:
- The ID Token hint,
nullif not specified.
-
getLoginHint
public String getLoginHint()
Gets the login hint. Corresponds to the optionallogin_hintparameter.- Returns:
- The login hint,
nullif not specified.
-
getACRValues
public List<ACR> getACRValues()
Gets the requested Authentication Context Class Reference values. Corresponds to the optionalacr_valuesparameter.- Returns:
- The requested ACR values,
nullif not specified.
-
getClaims
public ClaimsRequest getClaims()
Gets the individual claims to be returned. Corresponds to the optionalclaimsparameter.- Returns:
- The individual claims to be returned,
nullif not specified.
-
getPurpose
public String getPurpose()
Gets the transaction specific purpose. Corresponds to the optionalpurposeparameter.- Returns:
- The purpose,
nullif not specified.
-
toParameters
public Map<String,List<String>> toParameters()
Description copied from class:AuthorizationRequestReturns the URI query parameters for this authorisation request. Query parameters which are part of the authorisation endpoint are not included.Example parameters:
response_type = code client_id = s6BhdRkqt3 state = xyz redirect_uri = https://client.example.com/cb
- Overrides:
toParametersin classAuthorizationRequest- Returns:
- The parameters.
-
toJWTClaimsSet
public com.nimbusds.jwt.JWTClaimsSet toJWTClaimsSet()
Description copied from class:AuthorizationRequestReturns the parameters for this authorisation request as a JSON Web Token (JWT) claims set. Intended for creating a request object.- Overrides:
toJWTClaimsSetin classAuthorizationRequest- Returns:
- The parameters as JWT claim set.
-
parse
public static AuthenticationRequest parse(Map<String,List<String>> params) throws ParseException
Parses an OpenID Connect authentication request from the specified URI query parameters.Example parameters:
response_type = token id_token client_id = s6BhdRkqt3 redirect_uri = https://client.example.com/cb scope = openid profile state = af0ifjsldkj nonce = -0S6_WzA2Mj
- Parameters:
params- The parameters. Must not benull.- Returns:
- The OpenID Connect authentication request.
- Throws:
ParseException- If the parameters couldn't be parsed to an OpenID Connect authentication request.
-
parse
public static AuthenticationRequest parse(URI uri, Map<String,List<String>> params) throws ParseException
Parses an OpenID Connect authentication request from the specified URI and query parameters.Example parameters:
response_type = token id_token client_id = s6BhdRkqt3 redirect_uri = https://client.example.com/cb scope = openid profile state = af0ifjsldkj nonce = -0S6_WzA2Mj
- Parameters:
uri- The URI of the OAuth 2.0 authorisation endpoint. May benullif theAuthorizationRequest.toHTTPRequest(com.nimbusds.oauth2.sdk.http.HTTPRequest.Method)method will not be used.params- The parameters. Must not benull.- Returns:
- The OpenID Connect authentication request.
- Throws:
ParseException- If the parameters couldn't be parsed to an OpenID Connect authentication request.
-
parse
public static AuthenticationRequest parse(String query) throws ParseException
Parses an OpenID Connect authentication request from the specified URI query string.Example URI query string:
response_type=token%20id_token &client_id=s6BhdRkqt3 &redirect_uri=https%3A%2F%2Fclient.example.com%2Fcb &scope=openid%20profile &state=af0ifjsldkj &nonce=n-0S6_WzA2Mj
- Parameters:
query- The URI query string. Must not benull.- Returns:
- The OpenID Connect authentication request.
- Throws:
ParseException- If the query string couldn't be parsed to an OpenID Connect authentication request.
-
parse
public static AuthenticationRequest parse(URI uri, String query) throws ParseException
Parses an OpenID Connect authentication request from the specified URI query string.Example URI query string:
response_type=token%20id_token &client_id=s6BhdRkqt3 &redirect_uri=https%3A%2F%2Fclient.example.com%2Fcb &scope=openid%20profile &state=af0ifjsldkj &nonce=n-0S6_WzA2Mj
- Parameters:
uri- The URI of the OAuth 2.0 authorisation endpoint. May benullif theAuthorizationRequest.toHTTPRequest(com.nimbusds.oauth2.sdk.http.HTTPRequest.Method)method will not be used.query- The URI query string. Must not benull.- Returns:
- The OpenID Connect authentication request.
- Throws:
ParseException- If the query string couldn't be parsed to an OpenID Connect authentication request.
-
parse
public static AuthenticationRequest parse(URI uri) throws ParseException
Parses an OpenID Connect authentication request from the specified URI.Example URI:
https://server.example.com/authorize? response_type=token%20id_token &client_id=s6BhdRkqt3 &redirect_uri=https%3A%2F%2Fclient.example.com%2Fcb &scope=openid%20profile &state=af0ifjsldkj &nonce=n-0S6_WzA2Mj
- Parameters:
uri- The URI. Must not benull.- Returns:
- The OpenID Connect authentication request.
- Throws:
ParseException- If the query string couldn't be parsed to an OpenID Connect authentication request.
-
parse
public static AuthenticationRequest parse(HTTPRequest httpRequest) throws ParseException
Parses an authentication request from the specified HTTP GET or HTTP POST request.Example HTTP request (GET):
https://server.example.com/op/authorize? response_type=code%20id_token &client_id=s6BhdRkqt3 &redirect_uri=https%3A%2F%2Fclient.example.com%2Fcb &scope=openid &nonce=n-0S6_WzA2Mj &state=af0ifjsldkj
- Parameters:
httpRequest- The HTTP request. Must not benull.- Returns:
- The OpenID Connect authentication request.
- Throws:
ParseException- If the HTTP request couldn't be parsed to an OpenID Connect authentication request.
-
-