Class GMResponse
- java.lang.Object
-
- com.authlete.common.dto.ApiResponse
-
- com.authlete.common.dto.GMResponse
-
- All Implemented Interfaces:
Serializable
public class GMResponse extends ApiResponse
Response from Authlete's/api/gm
API.Authlete's
/api/gm
API returns JSON which can be mapped to this class. The implementation of the grant management endpoint should retrieve the value of"action"
from the response and take the following steps according to the value.OK
-
When the value of
"action"
is"OK"
, it means that the access token which the client application presented is valid and information about the grant has been retrieved successfully. In this case, the implementation of the endpoint should return an HTTP response with the status code200 OK
and the content typeapplication/json
to the client application.getResponseContent()
returns a response in JSON format when"action"
is"OK"
, so a response to the client application can be built like below.HTTP/1.1 200 OK Cache-Control: no-store Pragma: no-cache Content-Type: application/json (The value returned from
getResponseContent()
) NO_CONTENT
-
When the value of
"action"
is"NO_CONTENT"
, it means that the access token which the client application presented is valid and the grant was revoked successfully. In this case, the implementation of the endpoint should return an HTTP response with the status code204 No Content
to the client application. UNAUTHORIZED
-
When the value of
"action"
is"UNAUTHORIZED"
, it means that the grant management request includes no access token or the access token is invalid. In this case, the implementation of the endpoint should return an HTTP response with the status code401 Unauthorized
.The specification does not describe details about error response format, but in error cases,
getResponseContent()
returns information about the error in the format suitable as a value for theWWW-Authenticate
HTTP header. The implementation of the endpoint may use the string when building an error response. The following is an example.HTTP/1.1 401 Unauthorized WWW-Authenticate: (The value returned from
getResponseContent()
) Cache-Control: no-store Pragma: no-cache FORBIDDEN
-
When the value of
"action"
is"FORBIDDEN"
, it means that the access token cannot be used to manage the grant ID. In this case, the implementation of the endpoint should return an HTTP response with the status code403 Forbidden
. The error response can be built like below in the same way for the case ofUNAUTHORIZED
.HTTP/1.1 403 Forbidden WWW-Authenticate: (The value returned from
getResponseContent()
) Cache-Control: no-store Pragma: no-cache NOT_FOUND
-
When the value of
"action"
is"NOT_FOUND"
, it means that the grant ID was not found. In this case, the implementation of the endpoint should return an HTTP response with the status code404 Not Found
. The error response can be built like below in the same way for the case ofUNAUTHORIZED
.HTTP/1.1 404 Not Found WWW-Authenticate: (The value returned from
getResponseContent()
) Cache-Control: no-store Pragma: no-cache CALL_ERROR
-
When the value of
"action"
is"CALLER_ERROR"
, it means that the API call is wrong. For example, thegmAction
request parameter, which is mandatory, is missing. The implementation of the endpoint should be fixed. In this case, it's up to the implementation how to respond to the client application. A simple implementation would return an HTTP response with the status code500 Internal Server Error
like below.HTTP/1.1 500 Internal Server Error WWW-Authenticate: (The value returned from
getResponseContent()
) Cache-Control: no-store Pragma: no-cache AUTHLETE_ERROR
-
When the value of
"action"
is"AUTHLETE_ERROR"
, it means that an error occurred on Authlete side. In this case, it's up to the implementation how to respond to the client application. A simple implementation would return an HTTP response with the status code500 Internal Server Error
like below.HTTP/1.1 500 Internal Server Error WWW-Authenticate: (The value returned from
getResponseContent()
) Cache-Control: no-store Pragma: no-cache
DPoP Nonce (Authlete 3.0 onwards)
Since version 3.0, Authlete recognizes the
nonce
claim in DPoP proof JWTs. If the presented access token is bound to a public key through the DPoP mechanism, and if thenonce
claim is required (= if the service'sdpopNonceRequired
property istrue
, or the value of thedpopNonceRequired
request parameter passed to the Authlete API istrue
), the Authlete API checks whether thenonce
claim in the presented DPoP proof JWT is identical to the expected value.If the
dpopNonce
response parameter from the API is not null, its value is the expected nonce value for DPoP proof JWT. The expected value needs to be conveyed to the client application as the value of theDPoP-Nonce
HTTP header.DPoP-Nonce: (The value returned from
getDpopNonce()
)See RFC 9449 OAuth 2.0 Demonstrating Proof of Possession (DPoP) for details.
- Since:
- 3.1, Authlete 2.3.0
- See Also:
- Grant Management for OAuth 2.0, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GMResponse.Action
The next action the service implementation should take.
-
Constructor Summary
Constructors Constructor Description GMResponse()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GMResponse.Action
getAction()
Get the next action that the authorization server should take.String
getDpopNonce()
Get the expected nonce value for DPoP proof JWT, which should be used as the value of theDPoP-Nonce
HTTP header.String
getResponseContent()
Get the response content which can be used to build a response to the client application.GMResponse
setAction(GMResponse.Action action)
Set the next action that the authorization server should take.GMResponse
setDpopNonce(String dpopNonce)
Set the expected nonce value for DPoP proof JWT, which should be used as the value of theDPoP-Nonce
HTTP header.GMResponse
setResponseContent(String content)
Set the response content which can be used to build a response to the client application.-
Methods inherited from class com.authlete.common.dto.ApiResponse
getResultCode, getResultMessage, setResultCode, setResultMessage
-
-
-
-
Method Detail
-
getAction
public GMResponse.Action getAction()
Get the next action that the authorization server should take.- Returns:
- The next action that the authorization server should take.
-
setAction
public GMResponse setAction(GMResponse.Action action)
Set the next action that the authorization server should take.- Parameters:
action
- The next action that the authorization server should take.- Returns:
this
object.
-
getResponseContent
public String getResponseContent()
Get the response content which can be used to build a response to the client application.- Returns:
- The content of the response to the client application.
-
setResponseContent
public GMResponse setResponseContent(String content)
Set the response content which can be used to build a response to the client application.- Parameters:
content
- The content of the response to the client application.- Returns:
this
object.
-
getDpopNonce
public String getDpopNonce()
Get the expected nonce value for DPoP proof JWT, which should be used as the value of theDPoP-Nonce
HTTP header.When this response parameter is not null, the implementation of the grant management endpoint should add the
DPoP-Nonce
HTTP header in the response from the endpoint to the client application, using the value of this response parameter as the value of the HTTP header.DPoP-Nonce: (The value of this
dpopNonce
response parameter)- Returns:
- The expected nonce value for DPoP proof JWT.
- Since:
- 3.82, Authlete 3.0
- See Also:
- RFC 9449 OAuth 2.0 Demonstrating Proof of Possession (DPoP)
-
setDpopNonce
public GMResponse setDpopNonce(String dpopNonce)
Set the expected nonce value for DPoP proof JWT, which should be used as the value of theDPoP-Nonce
HTTP header.When this response parameter is not null, the implementation of the grant management endpoint should add the
DPoP-Nonce
HTTP header in the response from the endpoint to the client application, using the value of this response parameter as the value of the HTTP header.DPoP-Nonce: (The value of this
dpopNonce
response parameter)- Parameters:
dpopNonce
- The expected nonce value for DPoP proof JWT.- Returns:
this
object.- Since:
- 3.82, Authlete 3.0
- See Also:
- RFC 9449 OAuth 2.0 Demonstrating Proof of Possession (DPoP)
-
-