1 | <?php |
||
12 | class Oauth2Subscriber implements SubscriberInterface |
||
13 | { |
||
14 | |||
15 | /** @var AccessToken|null */ |
||
16 | protected $accessToken; |
||
17 | /** @var AccessToken|null */ |
||
18 | protected $refreshToken; |
||
19 | |||
20 | /** @var GrantTypeInterface */ |
||
21 | protected $grantType; |
||
22 | /** @var RefreshTokenGrantTypeInterface */ |
||
23 | protected $refreshTokenGrantType; |
||
24 | |||
25 | /** |
||
26 | * Create a new Oauth2 subscriber. |
||
27 | * |
||
28 | * @param GrantTypeInterface $grantType |
||
29 | * @param RefreshTokenGrantTypeInterface $refreshTokenGrantType |
||
30 | */ |
||
31 | 5 | public function __construct(GrantTypeInterface $grantType = null, RefreshTokenGrantTypeInterface $refreshTokenGrantType = null) |
|
36 | |||
37 | /** |
||
38 | * @inheritdoc |
||
39 | */ |
||
40 | 4 | public function getEvents() |
|
47 | |||
48 | /** |
||
49 | * @inheritdoc |
||
50 | */ |
||
51 | 1 | public function onError(ErrorEvent $event) |
|
66 | |||
67 | /** |
||
68 | * Get a new access token. |
||
69 | * |
||
70 | * @return AccessToken|null |
||
71 | */ |
||
72 | 4 | protected function acquireAccessToken() |
|
93 | |||
94 | /** |
||
95 | * Add the Authorization header to requests. |
||
96 | * |
||
97 | * @param BeforeEvent $event Event received |
||
98 | */ |
||
99 | 4 | public function onBefore(BeforeEvent $event) |
|
109 | |||
110 | /** |
||
111 | * Get the access token. |
||
112 | * |
||
113 | * @return AccessToken|null Oauth2 access token |
||
114 | */ |
||
115 | 4 | public function getAccessToken() |
|
132 | |||
133 | /** |
||
134 | * Get the refresh token. |
||
135 | * |
||
136 | * @return AccessToken|null |
||
137 | */ |
||
138 | 3 | public function getRefreshToken() |
|
142 | |||
143 | /** |
||
144 | * Set the access token. |
||
145 | * |
||
146 | * @param AccessToken|string $accessToken |
||
147 | * @param string $type |
||
148 | * @param int $expires |
||
149 | */ |
||
150 | 2 | public function setAccessToken($accessToken, $type = null, $expires = null) |
|
160 | |||
161 | /** |
||
162 | * Set the refresh token. |
||
163 | * |
||
164 | * @param AccessToken|string $refreshToken The refresh token |
||
165 | */ |
||
166 | 3 | public function setRefreshToken($refreshToken) |
|
175 | } |
||
176 |