@Immutable public class AuthorizationRequest extends AbstractRequest
Extending classes may define additional request parameters as well as enforce tighter requirements on the base parameters.
Example HTTP request:
https://server.example.com/authorize? response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
Related specifications:
Modifier and Type | Class and Description |
---|---|
static class |
AuthorizationRequest.Builder
Builder for constructing authorisation requests.
|
Constructor and Description |
---|
AuthorizationRequest(URI uri,
ResponseType rt,
ClientID clientID)
Creates a new minimal authorisation request.
|
AuthorizationRequest(URI uri,
ResponseType rt,
ClientID clientID,
URI redirectURI,
Scope scope,
State state)
Creates a new authorisation request.
|
Modifier and Type | Method and Description |
---|---|
ClientID |
getClientID()
Gets the client identifier.
|
URI |
getRedirectionURI()
Gets the redirection URI.
|
ResponseType |
getResponseType()
Gets the response type.
|
Scope |
getScope()
Gets the scope.
|
State |
getState()
Gets the state.
|
static AuthorizationRequest |
parse(HTTPRequest httpRequest)
Parses an authorisation request from the specified HTTP request.
|
static AuthorizationRequest |
parse(Map<String,String> params)
Parses an authorisation request from the specified parameters.
|
static AuthorizationRequest |
parse(String query)
Parses an authorisation request from the specified URI query string.
|
static AuthorizationRequest |
parse(URI uri)
Parses an authorisation request from the specified URI.
|
static AuthorizationRequest |
parse(URI uri,
Map<String,String> params)
Parses an authorisation request from the specified parameters.
|
static AuthorizationRequest |
parse(URI uri,
String query)
Parses an authorisation request from the specified URI query string.
|
HTTPRequest |
toHTTPRequest()
Returns the matching HTTP request.
|
HTTPRequest |
toHTTPRequest(HTTPRequest.Method method)
Returns the matching HTTP request.
|
Map<String,String> |
toParameters()
Returns the parameters for this authorisation request.
|
String |
toQueryString()
Returns the URI query string for this authorisation request.
|
URI |
toURI()
Returns the complete URI representation for this authorisation
request, consisting of the
authorization
endpoint URI with the query string appended. |
getEndpointURI
public AuthorizationRequest(URI uri, ResponseType rt, ClientID clientID)
uri
- The URI of the authorisation endpoint. May be
null
if the toHTTPRequest(com.nimbusds.oauth2.sdk.http.HTTPRequest.Method)
method
will not be used.rt
- The response type. Corresponds to the
response_type
parameter. Must not be
null
.clientID
- The client identifier. Corresponds to the
client_id
parameter. Must not be
null
.public AuthorizationRequest(URI uri, ResponseType rt, ClientID clientID, URI redirectURI, Scope scope, State state)
uri
- The URI of the authorisation endpoint. May be
null
if the toHTTPRequest(com.nimbusds.oauth2.sdk.http.HTTPRequest.Method)
method
will not be used.rt
- The response type. Corresponds to the
response_type
parameter. Must not be
null
.clientID
- The client identifier. Corresponds to the
client_id
parameter. Must not be
null
.redirectURI
- The redirection URI. Corresponds to the optional
redirect_uri
parameter. null
if
not specified.scope
- The request scope. Corresponds to the optional
scope
parameter. null
if not
specified.state
- The state. Corresponds to the recommended
state
parameter. null
if not
specified.public ResponseType getResponseType()
response_type
parameter.public ClientID getClientID()
client_id
parameter.public URI getRedirectionURI()
redirection_uri
parameter.null
if not specified.public Scope getScope()
scope
parameter.null
if not specified.public State getState()
state
parameter.null
if not specified.public Map<String,String> toParameters() throws SerializeException
Example parameters:
response_type = code client_id = s6BhdRkqt3 state = xyz redirect_uri = https://client.example.com/cb
SerializeException
- If this authorisation request couldn't be
serialised to an parameters map.public String toQueryString() throws SerializeException
Note that the '?' character preceding the query string in an URI is not included in the returned string.
Example URI query string:
response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
SerializeException
- If this authorisation request couldn't be
serialised to an URI query string.public URI toURI() throws SerializeException
authorization
endpoint URI
with the query string
appended.
Example URI:
https://server.example.com/authorize? response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
SerializeException
- If this authorisation request couldn't be
serialised to a URI.public HTTPRequest toHTTPRequest(HTTPRequest.Method method) throws SerializeException
method
- The HTTP request method which can be GET or POST. Must
not be null
.SerializeException
- If the authorisation request message
couldn't be serialised to an HTTP
request.public HTTPRequest toHTTPRequest() throws SerializeException
Request
SerializeException
- If the request message couldn't be
serialised to an HTTP request.public static AuthorizationRequest parse(Map<String,String> params) throws ParseException
Example parameters:
response_type = code client_id = s6BhdRkqt3 state = xyz redirect_uri = https://client.example.com/cb
params
- The parameters. Must not be null
.ParseException
- If the parameters couldn't be parsed to an
authorisation request.public static AuthorizationRequest parse(URI uri, Map<String,String> params) throws ParseException
Example parameters:
response_type = code client_id = s6BhdRkqt3 state = xyz redirect_uri = https://client.example.com/cb
uri
- The URI of the authorisation endpoint. May be
null
if the toHTTPRequest()
method
will not be used.params
- The parameters. Must not be null
.ParseException
- If the parameters couldn't be parsed to an
authorisation request.public static AuthorizationRequest parse(String query) throws ParseException
Example URI query string:
response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
query
- The URI query string. Must not be null
.ParseException
- If the query string couldn't be parsed to an
authorisation request.public static AuthorizationRequest parse(URI uri, String query) throws ParseException
Example URI query string:
response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
uri
- The URI of the authorisation endpoint. May be
null
if the toHTTPRequest()
method
will not be used.query
- The URI query string. Must not be null
.ParseException
- If the query string couldn't be parsed to an
authorisation request.public static AuthorizationRequest parse(URI uri) throws ParseException
Example URI:
https://server.example.com/authorize? response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
uri
- The URI. Must not be null
.ParseException
- If the URI couldn't be parsed to an
authorisation request.public static AuthorizationRequest parse(HTTPRequest httpRequest) throws ParseException
Example HTTP request (GET):
https://server.example.com/authorize? response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
httpRequest
- The HTTP request. Must not be null
.ParseException
- If the HTTP request couldn't be parsed to an
authorisation request.Copyright © 2014 NimbusDS. All Rights Reserved.