public class DeviceCompleteRequest extends Object implements Serializable
/api/device/complete API.
In the device flow, an end-user accesses the verification endpoint of the authorization server where she interacts with the verification endpoint and inputs a user code. The verification endpoint checks if the user code is valid and then asks the end-user whether she approves or rejects the authorization request which the user code represents.
After the authorization server receives the decision of the end-user, it
should call Authlete's /api/device/complete API to tell Authlete
the decision.
When the end-user was authenticated and authorization was granted to the
client by the end-user, the authorization server should call the API with
result=AUTHORIZED. In this successful
case, the subject request parameter is mandatory. The API will
update the database record so that /api/auth/token API can generate
an access token later.
If the scope parameter of the device authorization request included
the openid scope, an ID token is generated. In this case, sub,
authTime, acr and claims request parameters in the
API call to /api/device/complete affect the ID token.
When the authorization server receives the decision of the end-user and it
indicates that she has rejected to give authorization to the client, the
authorization server should call the API with
result=ACCESS_DENIED. In this case,
the API will update the database record so that the /api/auth/token
API can generate an error response later. If errorDescription and
errorUri request parameters are given to the
/api/device/complete API, they will be used as the values of
error_description and error_uri response parameters in the
error response from the token endpoint.
When the authorization server could not get decision from the end-user for
some reasons, the authorization server should call the API with
result=TRANSACTION_FAILED. In
this error case, the API will behave in the same way as in the case of
ACCESS_DENIED. The only difference is that expired_token
is used as the value of the error response parameter instead of
access_denied.
| Modifier and Type | Class and Description |
|---|---|
static class |
DeviceCompleteRequest.Result
Types of results of end-user authentication and authorization.
|
| Constructor and Description |
|---|
DeviceCompleteRequest() |
| Modifier and Type | Method and Description |
|---|---|
String |
getAcr()
Get the reference of the authentication context class which the
end-user authentication satisfied.
|
long |
getAuthTime()
Get the time at which the end-user was authenticated.
|
String |
getClaims()
Get additional claims which will be embedded in the ID token.
|
String |
getErrorDescription()
Get the description of the error.
|
URI |
getErrorUri()
Get the URI of a document which describes the error in detail.
|
Property[] |
getProperties()
Get the extra properties associated with the access token that will be
issued.
|
DeviceCompleteRequest.Result |
getResult()
Get the result of end-user authentication and authorization.
|
String[] |
getScopes()
Get scopes associated with the access token.
|
String |
getSub()
Get the value of the
sub claim that should be used in the ID
token. |
String |
getSubject()
Get the subject (= unique identifier) of the end-user who has granted
authorization to the client application.
|
String |
getUserCode()
Get the user code input by the end-user.
|
DeviceCompleteRequest |
setAcr(String acr)
Set the reference of the authentication context class which the
end-user authentication satisfied.
|
DeviceCompleteRequest |
setAuthTime(long authTime)
Set the time at which the end-user was authenticated.
|
DeviceCompleteRequest |
setClaims(Map<String,Object> claims)
Set additional claims which will be embedded in the ID token.
|
DeviceCompleteRequest |
setClaims(String claims)
Set additional claims which will be embedded in the ID token.
|
DeviceCompleteRequest |
setErrorDescription(String description)
Set the description of the error.
|
DeviceCompleteRequest |
setErrorUri(URI uri)
Set the URI of a document which describes the error in detail.
|
DeviceCompleteRequest |
setProperties(Property[] properties)
Set extra properties associated with the access token that will be
issued.
|
DeviceCompleteRequest |
setResult(DeviceCompleteRequest.Result result)
Set the result of end-user authentication and authorization.
|
DeviceCompleteRequest |
setScopes(String[] scopes)
Set scopes associated with the access token.
|
DeviceCompleteRequest |
setSub(String sub)
Set the value of the
sub claim that should be used in the ID
token. |
DeviceCompleteRequest |
setSubject(String subject)
Set the subject (= unique identifier) of the end-user who has granted
authorization to the client application.
|
DeviceCompleteRequest |
setUserCode(String userCode)
Set the user code input by the end-user.
|
public String getUserCode()
public DeviceCompleteRequest setUserCode(String userCode)
userCode - The user code.this object.public DeviceCompleteRequest.Result getResult()
public DeviceCompleteRequest setResult(DeviceCompleteRequest.Result result)
result - The result of end-user authentication and authorization.this object.public String getSubject()
This subject property is used as the value of the subject
associated with the access token and as the value of the sub
claim in the ID token.
Note that, if getSub() returns a non-empty value, it is used
as the value of the sub claim in the ID token. However, even
in the case, the value of the subject associated with the access token
is still the value of this subject property.
getSub()public DeviceCompleteRequest setSubject(String subject)
getResult() returns AUTHORIZED.
This subject property is used as the value of the subject
associated with the access token and as the value of the sub
claim in the ID token.
Note that, if getSub() returns a non-empty value, it is used
as the value of the sub claim in the ID token. However, even
in the case, the value of the subject associated with the access token
is still the value set by this method.
subject - The subject (= unique identifier) of the end-user.this object.setSub(String)public String getSub()
sub claim that should be used in the ID
token. If this method returns null or its value is empty, the
value returned by getSubject() is used as the value of the
sub claim. The main purpose of this sub property is
to hide the actual value of the subject from client applications.
Note that the value of the subject request parameter is used
as the value of the subject associated with the access token regardless
of whether this sub property is a non-empty value or not. In
other words, this sub property affects only the sub
claim in the ID token.
sub claim.getSubject()public DeviceCompleteRequest setSub(String sub)
sub claim that should be used in the ID
token. If this method returns null or its value is empty, the
value returned by getSubject() is used as the value of the
sub claim. The main purpose of this sub property is
to hide the actual value of the subject from client applications.
Note that the value of the subject request parameter is used
as the value of the subject associated with the access token regardless
of whether this sub property is a non-empty value or not. In
other words, this sub property affects only the sub
claim in the ID token.
sub - The value of the sub claim.this object.setSubject(String)public long getAuthTime()
public DeviceCompleteRequest setAuthTime(long authTime)
auth_time claim will be
embedded in the ID token.authTime - The time at which the end-user was authenticated.
It is the number of seconds since 1970-01-01.this object.public String getAcr()
public DeviceCompleteRequest setAcr(String acr)
acr claim will be embedded
in the ID token.acr - The authentication context class reference.this object.public String getClaims()
setClaims(String) for
details about the format.setClaims(String)public DeviceCompleteRequest setClaims(String claims)
The authorization server implementation is required to retrieve values of requested claims of the end-user from its database and format them in JSON format.
For example, if "given_name" claim,
"family_name" claim and "email" claim are
requested, the authorization server implementation should generate
a JSON object like the following:
{
"given_name": "Takahiko",
"family_name": "Kawasaki",
"email": "takahiko.kawasaki@example.com"
}
and set its string representation by this method.
See OpenID Connect Core 1.0, 5.1. Standard Claims for further details about the format.
claims - Additional claims in JSON format.this object.public DeviceCompleteRequest setClaims(Map<String,Object> claims)
The argument is converted into a JSON string and passed to
setClaims(String) method.
claims - Additional claims. Keys are claim names.this object.public Property[] getProperties()
public DeviceCompleteRequest setProperties(Property[] properties)
Keys of extra properties will be used as labels of top-level entries
in a JSON response returned from the authorization server. An example
is example_parameter, which you can find in 5.1. Successful
Response in RFC 6749. The following code snippet is an example
to set one extra property having example_parameter as its
key and example_value as its value.
Property[] properties = { newProperty("example_parameter", "example_value") }; request.setProperties(properties);
Note that there is an upper limit on the total size of extra properties. On Authlete side, the properties will be (1) converted to a multidimensional string array, (2) converted to JSON, (3) encrypted by AES/CBC/PKCS5Padding, (4) encoded by base64url, and then stored into the database. The length of the resultant string must not exceed 65,535 in bytes. This is the upper limit, but we think it is big enough.
properties - Extra properties.this object.public String[] getScopes()
null is returned from
this method, replacement is not performed.public DeviceCompleteRequest setScopes(String[] scopes)
null (the
default value) is set, the scopes specified in the original device
authorization request are used. In other cases, the scopes given to
this method will replace the original scopes contained in the original
request.
Even scopes that are not included in the original request can be included.
scopes - Scopes associated with the access token. If a non-null value is
set, the original scopes requested by the client application are
replaced.this object.public String getErrorDescription()
error_description property in the response to the client.public DeviceCompleteRequest setErrorDescription(String description)
error_description property in the response to the client.
If this optional request parameter is given, its value is used as the
value of the error_description property, but it is used only
when the result is not AUTHORIZED.
To comply with the specification strictly, the description must not include characters outside the set %x20-21 / %x23-5B / %x5D-7E.
description - The description of the error.this object.public URI getErrorUri()
error_uri property in the response to the
client.public DeviceCompleteRequest setErrorUri(URI uri)
error_uri property in the response to the
client.
If this optional request parameter is given, its value is used as the
value of the error_uri property, but it is used only when the
result is not AUTHORIZED.
uri - The URI of a document which describes the error in detail.this object.Copyright © 2019. All rights reserved.