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 | 9 | private $defaultScope = ''; |
|
92 | |||
93 | /** |
||
94 | * New server instance. |
||
95 | * |
||
96 | * @param ClientRepositoryInterface $clientRepository |
||
97 | * @param AccessTokenRepositoryInterface $accessTokenRepository |
||
98 | * @param ScopeRepositoryInterface $scopeRepository |
||
99 | 9 | * @param CryptKey|string $privateKey |
|
100 | 9 | * @param string|Key $encryptionKey |
|
101 | 9 | * @param null|ResponseTypeInterface $responseType |
|
102 | */ |
||
103 | 9 | public function __construct( |
|
122 | |||
123 | 7 | /** |
|
124 | 7 | * Enable a grant type on the server. |
|
125 | 7 | * |
|
126 | 7 | * @param GrantTypeInterface $grantType |
|
127 | 7 | * @param null|\DateInterval $accessTokenTTL |
|
128 | 7 | */ |
|
129 | 7 | public function enableGrantType(GrantTypeInterface $grantType, \DateInterval $accessTokenTTL = null) |
|
146 | 3 | ||
147 | 2 | /** |
|
148 | 2 | * Validate an authorization request |
|
149 | * |
||
150 | * @param ServerRequestInterface $request |
||
151 | * |
||
152 | 1 | * @throws OAuthServerException |
|
153 | * |
||
154 | * @return AuthorizationRequest |
||
155 | */ |
||
156 | public function validateAuthorizationRequest(ServerRequestInterface $request) |
||
166 | 1 | ||
167 | 1 | /** |
|
168 | * Complete an authorization request |
||
169 | * |
||
170 | * @param AuthorizationRequest $authRequest |
||
171 | * @param ResponseInterface $response |
||
172 | * |
||
173 | * @return ResponseInterface |
||
174 | */ |
||
175 | public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response) |
||
181 | |||
182 | 4 | /** |
|
183 | 4 | * Return an access token response. |
|
184 | 1 | * |
|
185 | * @param ServerRequestInterface $request |
||
186 | 3 | * @param ResponseInterface $response |
|
187 | 3 | * |
|
188 | 3 | * @throws OAuthServerException |
|
189 | 3 | * |
|
190 | * @return ResponseInterface |
||
191 | */ |
||
192 | 2 | public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response) |
|
211 | 4 | ||
212 | 4 | /** |
|
213 | * @param IntrospectionResponse $reponseType |
||
214 | 4 | */ |
|
215 | public function setIntrospectionReponseType(IntrospectionResponse $reponseType) |
||
219 | |||
220 | /** |
||
221 | * Get the introspection response |
||
222 | * |
||
223 | * @return IntrospectionResponse |
||
224 | 3 | */ |
|
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 | * Return an introspection response. |
||
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 | protected function getResponseType() |
||
297 | |||
298 | /** |
||
299 | * Set the default scope for the authorization server. |
||
300 | * |
||
301 | * @param string $defaultScope |
||
302 | */ |
||
303 | public function setDefaultScope($defaultScope) |
||
307 | } |
||
308 |