1 | <?php |
||
16 | class Introspector |
||
17 | { |
||
18 | /** |
||
19 | * @var AccessTokenRepositoryInterface |
||
20 | */ |
||
21 | private $accessTokenRepository; |
||
22 | |||
23 | /** |
||
24 | * @var CryptKey |
||
25 | */ |
||
26 | private $privateKey; |
||
27 | |||
28 | /** |
||
29 | * @var Parser |
||
30 | */ |
||
31 | private $parser; |
||
32 | |||
33 | /** |
||
34 | * New Introspector instance. |
||
35 | * |
||
36 | * @param AccessTokenRepositoryInterface $accessTokenRepository |
||
37 | * @param CryptKey $privateKey |
||
38 | * @param Parser $parser |
||
39 | */ |
||
40 | 9 | public function __construct( |
|
49 | |||
50 | /** |
||
51 | * Validate the request |
||
52 | * |
||
53 | * @param ServerRequestInterface $request |
||
54 | * |
||
55 | * @throws OAuthServerException |
||
56 | */ |
||
57 | 2 | public function validateIntrospectionRequest(ServerRequestInterface $request) |
|
58 | { |
||
59 | 2 | if ($request->getMethod() !== 'POST') { |
|
60 | 1 | throw OAuthServerException::accessDenied('Invalid request method'); |
|
61 | } |
||
62 | 1 | } |
|
63 | |||
64 | /** |
||
65 | * Return an introspection response. |
||
66 | * |
||
67 | * @param ServerRequestInterface $request |
||
68 | * @param IntrospectionResponse $responseType |
||
69 | * |
||
70 | * @return IntrospectionResponse |
||
71 | */ |
||
72 | 7 | public function respondToIntrospectionRequest( |
|
88 | |||
89 | /** |
||
90 | * Validate the JWT and make sure it has not expired or been revoked |
||
91 | * |
||
92 | * @return bool |
||
93 | */ |
||
94 | 6 | private function isTokenValid(Token $token) |
|
98 | |||
99 | /** |
||
100 | * Validate the JWT token. |
||
101 | * |
||
102 | * @param Token $token |
||
103 | * |
||
104 | * @return bool |
||
105 | */ |
||
106 | 6 | private function verifyToken(Token $token) |
|
113 | |||
114 | /** |
||
115 | * Ensure access token hasn't expired |
||
116 | * |
||
117 | * @param Token $token |
||
118 | * |
||
119 | * @return bool |
||
120 | */ |
||
121 | 5 | private function isTokenExpired(Token $token) |
|
127 | |||
128 | /** |
||
129 | * Check if the given access token is revoked. |
||
130 | * |
||
131 | * @param Token $token |
||
132 | * |
||
133 | * @return bool |
||
134 | */ |
||
135 | 4 | private function isTokenRevoked(Token $token) |
|
139 | |||
140 | /** |
||
141 | * Create active introspection response. |
||
142 | * |
||
143 | * @param Token $token |
||
144 | * |
||
145 | * @return IntrospectionResponse |
||
146 | */ |
||
147 | 3 | private function setTokenOnResponse(Token $token, IntrospectionResponse $responseType) |
|
153 | } |
||
154 |