Class DeviceCompleteRequest
- java.lang.Object
-
- com.authlete.common.dto.DeviceCompleteRequest
-
- All Implemented Interfaces:
Serializable
public class DeviceCompleteRequest extends Object implements Serializable
Request to Authlete's/api/device/completeAPI.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/completeAPI 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, thesubjectrequest parameter is mandatory. The API will update the database record so that/api/auth/tokenAPI can generate an access token later.If the
scopeparameter of the device authorization request included theopenidscope, an ID token is generated. In this case,sub,authTime,acrandclaimsrequest parameters in the API call to/api/device/completeaffect 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/tokenAPI can generate an error response later. IferrorDescriptionanderrorUrirequest parameters are given to the/api/device/completeAPI, they will be used as the values oferror_descriptionanderror_uriresponse 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 ofACCESS_DENIED. The only difference is thatexpired_tokenis used as the value of theerrorresponse parameter instead ofaccess_denied.- Since:
- 2.42
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDeviceCompleteRequest.ResultTypes of results of end-user authentication and authorization.
-
Constructor Summary
Constructors Constructor Description DeviceCompleteRequest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetAccessTokenDuration()Get the duration of the access token that may be issued as a result of the Authlete API call.StringgetAcr()Get the reference of the authentication context class which the end-user authentication satisfied.longgetAuthTime()Get the time at which the end-user was authenticated.StringgetClaims()Get additional claims which will be embedded in the ID token.String[]getConsentedClaims()Get the claims that the user has consented for the client application to know.StringgetErrorDescription()Get the description of the error.URIgetErrorUri()Get the URI of a document which describes the error in detail.StringgetIdtHeaderParams()Get JSON that represents additional JWS header parameters for the ID token that may be issued from the token endpoint.StringgetIdTokenAudType()Get the type of theaudclaim of the ID token being issued.StringgetJwtAtClaims()Get the additional claims in JSON object format that are added to the payload part of the JWT access token.Property[]getProperties()Get the extra properties associated with the access token that will be issued.longgetRefreshTokenDuration()Get the duration of the refresh token that may be issued as a result of the Authlete API call.DeviceCompleteRequest.ResultgetResult()Get the result of end-user authentication and authorization.String[]getScopes()Get scopes associated with the access token.StringgetSub()Get the value of thesubclaim that should be used in the ID token.StringgetSubject()Get the subject (= unique identifier) of the end-user who has granted authorization to the client application.StringgetUserCode()Get the user code input by the end-user.DeviceCompleteRequestsetAccessTokenDuration(long duration)Set the duration of the access token that may be issued as a result of the Authlete API call.DeviceCompleteRequestsetAcr(String acr)Set the reference of the authentication context class which the end-user authentication satisfied.DeviceCompleteRequestsetAuthTime(long authTime)Set the time at which the end-user was authenticated.DeviceCompleteRequestsetClaims(String claims)Set additional claims which will be embedded in the ID token.DeviceCompleteRequestsetClaims(Map<String,Object> claims)Set additional claims which will be embedded in the ID token.DeviceCompleteRequestsetConsentedClaims(String[] claims)Set the claims that the user has consented for the client application to know.DeviceCompleteRequestsetErrorDescription(String description)Set the description of the error.DeviceCompleteRequestsetErrorUri(URI uri)Set the URI of a document which describes the error in detail.DeviceCompleteRequestsetIdtHeaderParams(String params)Set JSON that represents additional JWS header parameters for the ID token that may be issued from the token endpoint.DeviceCompleteRequestsetIdTokenAudType(String type)Set the type of theaudclaim of the ID token being issued.DeviceCompleteRequestsetJwtAtClaims(String claims)Set the additional claims in JSON object format that are added to the payload part of the JWT access token.DeviceCompleteRequestsetProperties(Property[] properties)Set extra properties associated with the access token that will be issued.DeviceCompleteRequestsetRefreshTokenDuration(long duration)Set the duration of the refresh token that may be issued as a result of the Authlete API call.DeviceCompleteRequestsetResult(DeviceCompleteRequest.Result result)Set the result of end-user authentication and authorization.DeviceCompleteRequestsetScopes(String[] scopes)Set scopes associated with the access token.DeviceCompleteRequestsetSub(String sub)Set the value of thesubclaim that should be used in the ID token.DeviceCompleteRequestsetSubject(String subject)Set the subject (= unique identifier) of the end-user who has granted authorization to the client application.DeviceCompleteRequestsetUserCode(String userCode)Set the user code input by the end-user.
-
-
-
Method Detail
-
getUserCode
public String getUserCode()
Get the user code input by the end-user.- Returns:
- The user code.
-
setUserCode
public DeviceCompleteRequest setUserCode(String userCode)
Set the user code input by the end-user. This request parameter is mandatory.- Parameters:
userCode- The user code.- Returns:
thisobject.
-
getResult
public DeviceCompleteRequest.Result getResult()
Get the result of end-user authentication and authorization.- Returns:
- The result of end-user authentication and authorization.
-
setResult
public DeviceCompleteRequest setResult(DeviceCompleteRequest.Result result)
Set the result of end-user authentication and authorization. This request parameter is mandatory.- Parameters:
result- The result of end-user authentication and authorization.- Returns:
thisobject.
-
getSubject
public String getSubject()
Get the subject (= unique identifier) of the end-user who has granted authorization to the client application.This
subjectproperty is used as the value of the subject associated with the access token and as the value of thesubclaim in the ID token.Note that, if
getSub()returns a non-empty value, it is used as the value of thesubclaim in the ID token. However, even in the case, the value of the subject associated with the access token is still the value of thissubjectproperty.- Returns:
- The subject (= unique identifier) of the end-user.
- See Also:
getSub()
-
setSubject
public DeviceCompleteRequest setSubject(String subject)
Set the subject (= unique identifier) of the end-user who has granted authorization to the client application. This request parameter is mandatory whengetResult()returnsAUTHORIZED.This
subjectproperty is used as the value of the subject associated with the access token and as the value of thesubclaim in the ID token.Note that, if
getSub()returns a non-empty value, it is used as the value of thesubclaim 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.- Parameters:
subject- The subject (= unique identifier) of the end-user.- Returns:
thisobject.- See Also:
setSub(String)
-
getSub
public String getSub()
Get the value of thesubclaim that should be used in the ID token. If this method returnsnullor its value is empty, the value returned bygetSubject()is used as the value of thesubclaim. The main purpose of thissubproperty is to hide the actual value of the subject from client applications.Note that the value of the
subjectrequest parameter is used as the value of the subject associated with the access token regardless of whether thissubproperty is a non-empty value or not. In other words, thissubproperty affects only thesubclaim in the ID token.- Returns:
- The value of the
subclaim. - Since:
- 2.44
- See Also:
getSubject()
-
setSub
public DeviceCompleteRequest setSub(String sub)
Set the value of thesubclaim that should be used in the ID token. If this method returnsnullor its value is empty, the value returned bygetSubject()is used as the value of thesubclaim. The main purpose of thissubproperty is to hide the actual value of the subject from client applications.Note that the value of the
subjectrequest parameter is used as the value of the subject associated with the access token regardless of whether thissubproperty is a non-empty value or not. In other words, thissubproperty affects only thesubclaim in the ID token.- Parameters:
sub- The value of thesubclaim.- Returns:
thisobject.- Since:
- 2.44
- See Also:
setSubject(String)
-
getAuthTime
public long getAuthTime()
Get the time at which the end-user was authenticated.- Returns:
- The time at which the end-user was authenticated. It is the number of seconds since 1970-01-01.
- Since:
- 2.44
-
setAuthTime
public DeviceCompleteRequest setAuthTime(long authTime)
Set the time at which the end-user was authenticated. When this request parameter holds a positive number, theauth_timeclaim will be embedded in the ID token.- Parameters:
authTime- The time at which the end-user was authenticated. It is the number of seconds since 1970-01-01.- Returns:
thisobject.- Since:
- 2.44
-
getAcr
public String getAcr()
Get the reference of the authentication context class which the end-user authentication satisfied.- Returns:
- The authentication context class reference.
- Since:
- 2.44
-
setAcr
public DeviceCompleteRequest setAcr(String acr)
Set the reference of the authentication context class which the end-user authentication satisfied. When this request parameter holds a non-null value, theacrclaim will be embedded in the ID token.- Parameters:
acr- The authentication context class reference.- Returns:
thisobject.- Since:
- 2.44
-
getClaims
public String getClaims()
Get additional claims which will be embedded in the ID token.- Returns:
- Additional claims in JSON format which will be embedded in the
ID token. See the description of
setClaims(String)for details about the format. - Since:
- 2.44
- See Also:
setClaims(String)
-
setClaims
public DeviceCompleteRequest setClaims(String claims)
Set additional claims which will be embedded in the ID token.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.
- Parameters:
claims- Additional claims in JSON format.- Returns:
thisobject.- Since:
- 2.44
- See Also:
- OpenID Connect Core 1.0, 5.1. Standard Claims
-
setClaims
public DeviceCompleteRequest setClaims(Map<String,Object> claims)
Set additional claims which will be embedded in the ID token.The argument is converted into a JSON string and passed to
setClaims(String)method.- Parameters:
claims- Additional claims. Keys are claim names.- Returns:
thisobject.- Since:
- 2.44
-
getProperties
public Property[] getProperties()
Get the extra properties associated with the access token that will be issued.- Returns:
- Extra properties.
-
setProperties
public DeviceCompleteRequest setProperties(Property[] properties)
Set extra properties associated with the access token that will be issued.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 havingexample_parameteras its key andexample_valueas 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.
- Parameters:
properties- Extra properties.- Returns:
thisobject.
-
getScopes
public String[] getScopes()
Get scopes associated with the access token. If this method returns a non-null value, the set of scopes will be used instead of the scopes specified in the original device authorization request.- Returns:
- Scopes to replace the scopes specified in the original device
authorization request with. When
nullis returned from this method, replacement is not performed.
-
setScopes
public DeviceCompleteRequest setScopes(String[] scopes)
Set scopes associated with the access token. Ifnull(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.
- Parameters:
scopes- Scopes associated with the access token. If a non-null value is set, the original scopes requested by the client application are replaced.- Returns:
thisobject.
-
getIdtHeaderParams
public String getIdtHeaderParams()
Get JSON that represents additional JWS header parameters for the ID token that may be issued from the token endpoint.- Returns:
- JSON that represents additional JWS header parameters for the ID token.
- Since:
- 2.79
-
setIdtHeaderParams
public DeviceCompleteRequest setIdtHeaderParams(String params)
Set JSON that represents additional JWS header parameters for the ID token that may be issued from the token endpoint.- Parameters:
params- JSON that represents additional JWS header parameters for the ID token.- Returns:
thisobject.- Since:
- 2.79
-
getConsentedClaims
public String[] getConsentedClaims()
Get the claims that the user has consented for the client application to know.See the description of
setConsentedClaims(String[])for details.- Returns:
- Consented claims.
- Since:
- 3.7
-
setConsentedClaims
public DeviceCompleteRequest setConsentedClaims(String[] claims)
Set the claims that the user has consented for the client application to know.If the
claimsrequest parameter holds JSON, Authlete extracts claims from the JSON and embeds them in an ID token (cf.setClaims(String)). However, the claims are not necessarily identical to the set of claims that the user has actually consented for the client application to know.For example, if the user has allowed the
profilescope to be tied to an access token being issued, it technically means that the user has consented for the client application to know the following claims based on the mapping defined in OpenID Connect Core 1.0 Section 5.4. Requesting Claims using Scope Values:name,family_name,given_name,middle_name,nickname,preferred_username,profile,picture,website,gender,birthdate,zoneinfo,localeandupdated_at. However, JSON of theclaimsrequest parameter does not necessarily include all the claims. It may be simply because the authorization server does not support other claims or because the authorization server intends to return requested claims from the UserInfo Endpoint instead of embedding them in an ID token, or for some other reasons. Therefore, Authlete does not assume that the claims in the JSON of theclaimsrequest parameter represent the complete set of consented claims.This
consentedClaimsrequest parameter (supported from Authlete 2.3) can be used to convey the exact set of consented claims to Authlete. Authlete saves the information into its database and makes them referrable in responses from the/api/auth/introspectionAPI and the/api/auth/userinfoAPI.In addition, the information conveyed via this
When this request parameter is missing or its value is empty, Authlete computes the set of consented claims from the consented scopes (e.g.consentedClaimsrequest parameter is used to compute the exact value of theclaimsparameter in responses from the Grant Management Endpoint, which is defined in Grant Management for OAuth 2.0.profile) and the claims in the JSON of theclaimsrequest parameter although Authlete knows the possibility that the computed set may be different from the actual set of consented claims. Especially, the computed set may not include claims that the authorization server returns from the UserInfo Endpoint. Therefore, if you want to control the exact set of consented claims, utilize this request parameter.- Parameters:
claims- Consented claims.- Returns:
thisobject.- Since:
- 3.7
-
getErrorDescription
public String getErrorDescription()
Get the description of the error. This corresponds to theerror_descriptionproperty in the response to the client.- Returns:
- The description of the error.
-
setErrorDescription
public DeviceCompleteRequest setErrorDescription(String description)
Set the description of the error. This corresponds to theerror_descriptionproperty in the response to the client.If this optional request parameter is given, its value is used as the value of the
error_descriptionproperty, but it is used only when the result is notAUTHORIZED.To comply with the specification strictly, the description must not include characters outside the set %x20-21 / %x23-5B / %x5D-7E.
- Parameters:
description- The description of the error.- Returns:
thisobject.
-
getErrorUri
public URI getErrorUri()
Get the URI of a document which describes the error in detail. This corresponds to theerror_uriproperty in the response to the client.- Returns:
- The URI of a document which describes the error in detail.
-
setErrorUri
public DeviceCompleteRequest setErrorUri(URI uri)
Set the URI of a document which describes the error in detail. This corresponds to theerror_uriproperty in the response to the client.If this optional request parameter is given, its value is used as the value of the
error_uriproperty, but it is used only when the result is notAUTHORIZED.- Parameters:
uri- The URI of a document which describes the error in detail.- Returns:
thisobject.
-
getJwtAtClaims
public String getJwtAtClaims()
Get the additional claims in JSON object format that are added to the payload part of the JWT access token.This request parameter has a meaning only when the format of access tokens issued by this service is JWT. In other words, it has a meaning only when the
accessTokenSignAlgproperty of theServiceholds a non-null value. See the description of thegetAccessTokenSignAlg()method for details.- Returns:
- Additional claims that are added to the payload part of the JWT access token.
- Since:
- 3.23
-
setJwtAtClaims
public DeviceCompleteRequest setJwtAtClaims(String claims)
Set the additional claims in JSON object format that are added to the payload part of the JWT access token.This request parameter has a meaning only when the format of access tokens issued by this service is JWT. In other words, it has a meaning only when the
accessTokenSignAlgproperty of theServiceholds a non-null value. See the description of thegetAccessTokenSignAlg()method for details.- Parameters:
claims- Additional claims that are added to the payload part of the JWT access token.- Returns:
thisobject.- Since:
- 3.23
-
getAccessTokenDuration
public long getAccessTokenDuration()
Get the duration of the access token that may be issued as a result of the Authlete API call.When this request parameter holds a positive integer, it is used as the duration of the access token. In other cases, this request parameter is ignored.
- Returns:
- The duration of the access token in seconds.
- Since:
- 4.8, Authlete 2.3.20, Authlete 3.0
-
setAccessTokenDuration
public DeviceCompleteRequest setAccessTokenDuration(long duration)
Set the duration of the access token that may be issued as a result of the Authlete API call.When this request parameter holds a positive integer, it is used as the duration of the access token. In other cases, this request parameter is ignored.
- Parameters:
duration- The duration of the access token in seconds.- Returns:
thisrequest parameter.- Since:
- 4.8, Authlete 2.3.20, Authlete 3.0
-
getRefreshTokenDuration
public long getRefreshTokenDuration()
Get the duration of the refresh token that may be issued as a result of the Authlete API call.When this request parameter holds a positive integer, it is used as the duration of the refresh token. In other cases, this request parameter is ignored.
- Returns:
- The duration of the refresh token in seconds.
- Since:
- 4.8, Authlete 2.3.20, Authlete 3.0
-
setRefreshTokenDuration
public DeviceCompleteRequest setRefreshTokenDuration(long duration)
Set the duration of the refresh token that may be issued as a result of the Authlete API call.When this request parameter holds a positive integer, it is used as the duration of the refresh token. In other cases, this request parameter is ignored.
- Parameters:
duration- The duration of the refresh token in seconds.- Returns:
thisobject.- Since:
- 4.8, Authlete 2.3.20, Authlete 3.0
-
getIdTokenAudType
public String getIdTokenAudType()
Get the type of theaudclaim of the ID token being issued. Valid values are as follows.Value Description "array"The type of the audclaim is always an array of strings."string"The type of the audclaim is always a single string.null The type of the audclaim remains the same as before.This request parameter takes precedence over the
idTokenAudTypeproperty ofService(cf.Service.getIdTokenAudType()).- Returns:
- The type of the
audclaim in ID tokens. - Since:
- 3.57, Authlete 2.3.3
-
setIdTokenAudType
public DeviceCompleteRequest setIdTokenAudType(String type)
Set the type of theaudclaim of the ID token being issued. Valid values are as follows.Value Description "array"The type of the audclaim is always an array of strings."string"The type of the audclaim is always a single string.null The type of the audclaim remains the same as before.This request parameter takes precedence over the
idTokenAudTypeproperty ofService(cf.Service.getIdTokenAudType()).- Parameters:
type- The type of theaudclaim in ID tokens.- Returns:
thisobject.- Since:
- 3.57, Authlete 2.3.3
-
-