1 | <?php |
||
8 | class IntrospectionResponse extends AbstractResponseType |
||
9 | { |
||
10 | /** |
||
11 | * @var Token |
||
12 | */ |
||
13 | protected $token; |
||
14 | |||
15 | /** |
||
16 | * Set the token against the response |
||
17 | * |
||
18 | * @param Token $token |
||
19 | */ |
||
20 | 3 | public function setToken(Token $token) |
|
24 | |||
25 | 8 | private function hasToken() |
|
29 | |||
30 | /** |
||
31 | * @return array |
||
32 | */ |
||
33 | 3 | private function validTokenResponse() |
|
48 | |||
49 | /** |
||
50 | * @return array |
||
51 | */ |
||
52 | 5 | private function invalidTokenResponse() |
|
58 | |||
59 | /** |
||
60 | * Extract the introspection params from the token |
||
61 | * |
||
62 | * @return array |
||
63 | */ |
||
64 | 8 | public function getIntrospectionParams() |
|
70 | |||
71 | /** |
||
72 | * @param ResponseInterface $response |
||
73 | * |
||
74 | * @return ResponseInterface |
||
75 | */ |
||
76 | 2 | public function generateHttpResponse(ResponseInterface $response) |
|
77 | { |
||
78 | 2 | $responseParams = $this->getIntrospectionParams(); |
|
79 | |||
80 | $response = $response |
||
81 | 2 | ->withStatus(200) |
|
82 | 2 | ->withHeader('pragma', 'no-cache') |
|
83 | 2 | ->withHeader('cache-control', 'no-store') |
|
84 | 2 | ->withHeader('content-type', 'application/json; charset=UTF-8'); |
|
85 | |||
86 | 2 | $response->getBody()->write(json_encode($responseParams)); |
|
87 | |||
88 | 2 | return $response; |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * Add custom fields to your Introspection response here, then set your introspection |
||
93 | * reponse in AuthorizationServer::setIntrospectionResponseType() to pull in your version of |
||
94 | * this class rather than the default. |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | 2 | protected function getExtraParams() |
|
102 | } |
||
103 |