1 | <?php |
||
29 | class AuthorizationServer implements EmitterAwareInterface |
||
30 | { |
||
31 | use EmitterAwareTrait; |
||
32 | |||
33 | /** |
||
34 | * @var GrantTypeInterface[] |
||
35 | */ |
||
36 | protected $enabledGrantTypes = []; |
||
37 | |||
38 | /** |
||
39 | * @var \DateInterval[] |
||
40 | */ |
||
41 | protected $grantTypeAccessTokenTTL = []; |
||
42 | |||
43 | /** |
||
44 | * @var CryptKey |
||
45 | */ |
||
46 | protected $privateKey; |
||
47 | |||
48 | /** |
||
49 | * @var CryptKey |
||
50 | */ |
||
51 | protected $publicKey; |
||
52 | |||
53 | /** |
||
54 | * @var null|ResponseTypeInterface |
||
55 | */ |
||
56 | protected $responseType; |
||
57 | |||
58 | /** |
||
59 | * @var null|IntrospectionResponse |
||
60 | */ |
||
61 | protected $introspectionResponseType; |
||
62 | |||
63 | /** |
||
64 | * @var null|Introspector |
||
65 | */ |
||
66 | protected $introspector; |
||
67 | |||
68 | /** |
||
69 | * @var ClientRepositoryInterface |
||
70 | */ |
||
71 | private $clientRepository; |
||
72 | |||
73 | /** |
||
74 | * @var AccessTokenRepositoryInterface |
||
75 | */ |
||
76 | private $accessTokenRepository; |
||
77 | |||
78 | /** |
||
79 | * @var ScopeRepositoryInterface |
||
80 | */ |
||
81 | private $scopeRepository; |
||
82 | |||
83 | /** |
||
84 | * @var string|Key |
||
85 | */ |
||
86 | private $encryptionKey; |
||
87 | |||
88 | /** |
||
89 | * @var string |
||
90 | */ |
||
91 | private $defaultScope = ''; |
||
92 | |||
93 | /** |
||
94 | * New server instance. |
||
95 | * |
||
96 | * @param ClientRepositoryInterface $clientRepository |
||
97 | * @param AccessTokenRepositoryInterface $accessTokenRepository |
||
98 | * @param ScopeRepositoryInterface $scopeRepository |
||
99 | * @param CryptKey|string $privateKey |
||
100 | * @param string|Key $encryptionKey |
||
101 | * @param null|ResponseTypeInterface $responseType |
||
102 | */ |
||
103 | 9 | public function __construct( |
|
122 | |||
123 | /** |
||
124 | * Enable a grant type on the server. |
||
125 | * |
||
126 | * @param GrantTypeInterface $grantType |
||
127 | * @param null|\DateInterval $accessTokenTTL |
||
128 | */ |
||
129 | 7 | public function enableGrantType(GrantTypeInterface $grantType, \DateInterval $accessTokenTTL = null) |
|
146 | |||
147 | /** |
||
148 | * Validate an authorization request |
||
149 | * |
||
150 | * @param ServerRequestInterface $request |
||
151 | * |
||
152 | * @throws OAuthServerException |
||
153 | * |
||
154 | * @return AuthorizationRequest |
||
155 | */ |
||
156 | 3 | public function validateAuthorizationRequest(ServerRequestInterface $request) |
|
166 | |||
167 | /** |
||
168 | * Complete an authorization request |
||
169 | * |
||
170 | * @param AuthorizationRequest $authRequest |
||
171 | * @param ResponseInterface $response |
||
172 | * |
||
173 | * @return ResponseInterface |
||
174 | */ |
||
175 | 1 | public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response) |
|
181 | |||
182 | /** |
||
183 | * Return an access token response. |
||
184 | * |
||
185 | * @param ServerRequestInterface $request |
||
186 | * @param ResponseInterface $response |
||
187 | * |
||
188 | * @throws OAuthServerException |
||
189 | * |
||
190 | * @return ResponseInterface |
||
191 | */ |
||
192 | 4 | public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response) |
|
211 | |||
212 | /** |
||
213 | * @param IntrospectionResponse $reponseType |
||
214 | */ |
||
215 | public function setIntrospectionReponseType(IntrospectionResponse $reponseType) |
||
219 | |||
220 | /** |
||
221 | * Get the introspection response |
||
222 | * |
||
223 | * @return IntrospectionResponse |
||
224 | */ |
||
225 | protected function getIntrospectionResponseType() |
||
233 | |||
234 | /** |
||
235 | * Return an introspection response. |
||
236 | * |
||
237 | * @param ServerRequestInterface $request |
||
238 | * @param ResponseInterface $response |
||
239 | * |
||
240 | * @return ResponseInterface |
||
241 | */ |
||
242 | public function respondToIntrospectionRequest(ServerRequestInterface $request, ResponseInterface $response) |
||
253 | |||
254 | /** |
||
255 | * Validate an introspection request. |
||
256 | * |
||
257 | * @param ServerRequestInterface $request |
||
258 | */ |
||
259 | public function validateIntrospectionRequest(ServerRequestInterface $request) |
||
264 | |||
265 | /** |
||
266 | * Returns the introspector. |
||
267 | * |
||
268 | * @return Introspector |
||
269 | */ |
||
270 | private function getIntrospector() |
||
278 | |||
279 | /** |
||
280 | * Get the token type that grants will return in the HTTP response. |
||
281 | * |
||
282 | * @return ResponseTypeInterface |
||
283 | */ |
||
284 | 4 | protected function getResponseType() |
|
297 | |||
298 | /** |
||
299 | * Set the default scope for the authorization server. |
||
300 | * |
||
301 | * @param string $defaultScope |
||
302 | */ |
||
303 | 3 | public function setDefaultScope($defaultScope) |
|
307 | } |
||
308 |