StandardIntrospectionResponse extends ApiResponse
Response from Authlete's /api/auth/introspection/standard API.
Note that /api/auth/introspection/standard
API and
/api/auth/introspection
API are different.
The /api/auth/introspection/standard
API exists to help your
authorization server provide its own introspection API which complies with
RFC 7662 (OAuth 2.0 Token
Introspection).
Authlete's /api/auth/introspection/standard
API returns JSON which can
be mapped to this class. The implementation of the introspection endpoint
of your authorization server should retrieve the value of the action
parameter (which can be obtained by getAction()
method of this class)
from the response and take the following steps according to the value.
When the value returned from getAction()
method is
StandardIntrospectionAction::$INTERNAL_SERVER_ERROR
, it means that the
request from your system to Authlete (StandardIntrospectionRequest
) was
wrong or that an error occurred in Authlete. In either case, from a
viewpoint of the client application, it is an error on the server side.
Therefore, the introspection endpoint of your authorization server should
generate a response to the client application with the HTTP status of
500 Internal Server Error
.
In this case, getResponseContent()
method returns a JSON string which
describes the error, so it can be used as the entity body of the response
if you want. Note that, however,
RFC 7662 does not mention anything
about the format of the response body of error responses.
The following illustrates an example response which the introspection endpoint of your authorization server generates and returns to the client application.
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
(The value returned from getResponseContent())
When the value returned from getAction()
method is
StandardIntrospectionAction::$BAD_REQUEST
, it means that the request
from the client application is invalid. This happens when the request
from the client did not include the token
request parameter. The HTTP
status of the response returned to the client application should be
400 Bad Request
. See
2.1. Introspection Request
of RFC 7662 for details about
requirements for introspection requests.
In this case, getResponseContent()
method returns a JSON string which
describes the error, so it can be used as the entity body of the response
if you want. Note that, however,
RFC 7662 does not mention anything
about the format of the response body of error responses.
The following illustrates an example response which the introspection endpoint of your authorization server generates and returns to the client application.
HTTP/1.1 400 Bad Request
Content-Type: application/json
(The value returned from getResponseContent())
When the value returned from getAction()
method is
StandardIntrospectionAction::$BAD_REQUEST
, it means that the request
from the client application is valid. The HTTP status of the response
returned to the client application must be 200 OK
and its content type
must be application/json
.
In this case, getResponseContent()
method returns a JSON string which
complies with the introspection response defined in
2.2. Introspection Response
of RFC 7662.
The following illustrates an example response which the introspection endpoint of your authorization server generates and returns to the client application.
HTTP/1.1 200 OK
Content-Type: application/json
(The value returned from getResponseContent())
Note that RFC 7662 says "To prevent token scanning attacks, the endpoint
MUST also require some form of authorization to access this endpoint".
This means that you have to protect your introspection endpoint in some
way or other. Authlete does not care about how your introspection endpoint
is protected. In most cases, as mentioned in RFC 7662, 401 Unauthorized
is a proper response when an introspection request does not satisfy
authorization requirements imposed by your introspection endpoint.
Table of Contents
- copyFromArray() : mixed
- Copy the content of the given array into this object.
- copyToArray() : mixed
- Copy the content of this object into the given array.
- fromArray() : static
- Convert an array into an instance of this class.
- fromJson() : static
- Convert a JSON string into an instance of this class.
- getAction() : StandardIntrospectionAction
- Get the next action that the introspection endpoint of your authorization server should take.
- getResponseContent() : string
- Get the response content which can be used as the entity body of the response returned to the client application.
- getResultCode() : string
- Get the code of the result of an Authlete API call.
- getResultMessage() : string
- Get the message of the result of an Authlete API call.
- setAction() : StandardIntrospectionResponse
- Set the next action that the introspection endpoint of your authorization server should take.
- setResponseContent() : StandardIntrospectionResponse
- Set the response content which can be used as the entity body of the response returned to the client application.
- setResultCode() : ApiResponse
- Set the code of the result of an Authlete API call.
- setResultMessage() : ApiResponse
- Set the message of the result of an Authlete API call.
- toArray() : array<string|int, mixed>
- Convert this object into an array.
- toJson() : string
- Convert this object into a JSON string.
Methods
copyFromArray()
Copy the content of the given array into this object.
public
copyFromArray(array<string|int, mixed> &$array) : mixed
Parameters
- $array : array<string|int, mixed>
Return values
mixed —copyToArray()
Copy the content of this object into the given array.
public
copyToArray(array<string|int, mixed> &$array) : mixed
Parameters
- $array : array<string|int, mixed>
Return values
mixed —fromArray()
Convert an array into an instance of this class.
public
static fromArray([array<string|int, mixed> $array = null ]) : static
This static function returns a new instance of this class.
If $array
is null
, null
is returned.
Parameters
- $array : array<string|int, mixed> = null
-
An array
Return values
static —An instance of this class.
fromJson()
Convert a JSON string into an instance of this class.
public
static fromJson(string $json) : static
This static function returns a new instance of this class.
If $json
is null
or the type of $json
is not string
,
null
is returned.
Parameters
- $json : string
-
A JSON string.
Return values
static —An instance of this class.
getAction()
Get the next action that the introspection endpoint of your authorization server should take.
public
getAction() : StandardIntrospectionAction
Return values
StandardIntrospectionAction —The next action that the introspection endpoint of your authorization server should take.
getResponseContent()
Get the response content which can be used as the entity body of the response returned to the client application.
public
getResponseContent() : string
Return values
string —The response content which can be used as the entity body of the response returned to the client application.
getResultCode()
Get the code of the result of an Authlete API call.
public
getResultCode() : string
Return values
string —The result code.
getResultMessage()
Get the message of the result of an Authlete API call.
public
getResultMessage() : string
Return values
string —The result message.
setAction()
Set the next action that the introspection endpoint of your authorization server should take.
public
setAction([StandardIntrospectionAction $action = null ]) : StandardIntrospectionResponse
Parameters
- $action : StandardIntrospectionAction = null
-
The next action that the introspection endpoint of your authorization server should take.
Return values
StandardIntrospectionResponse —$this
object.
setResponseContent()
Set the response content which can be used as the entity body of the response returned to the client application.
public
setResponseContent(string $responseContent) : StandardIntrospectionResponse
Parameters
- $responseContent : string
-
The response content which can be used as the entity body of the response returned to the client application.
Return values
StandardIntrospectionResponse —$this
object.
setResultCode()
Set the code of the result of an Authlete API call.
public
setResultCode(string $resultCode) : ApiResponse
Parameters
- $resultCode : string
-
The result code.
Return values
ApiResponse —$this
object.
setResultMessage()
Set the message of the result of an Authlete API call.
public
setResultMessage(string $resultMessage) : ApiResponse
Parameters
- $resultMessage : string
-
The result message.
Return values
ApiResponse —$this
object.
toArray()
Convert this object into an array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array.
toJson()
Convert this object into a JSON string.
public
toJson(int $options) : string
Parameters
- $options : int
-
Options passed to
json_encode()
. This parameter is optional and its default value is 0.
Return values
string —A JSON string.