1414 */
1515
1616use Doctrine \ORM \Mapping as ORM ;
17- use Exception ;
18- use InvalidArgumentException ;
19- use JsonException ;
2017use League \OAuth2 \Client \Token \AccessToken ;
2118use League \OAuth2 \Client \Token \AccessTokenInterface ;
2219use Neos \Flow \Annotations as Flow ;
@@ -89,13 +86,6 @@ class Authorization
8986 */
9087 protected $ encryptionService ;
9188
92- /**
93- * @param string $authorizationId
94- * @param string $serviceName
95- * @param string $clientId
96- * @param string $grantType
97- * @param string $scope
98- */
9989 public function __construct (string $ authorizationId , string $ serviceName , string $ clientId , string $ grantType , string $ scope )
10090 {
10191 $ this ->authorizationId = $ authorizationId ;
@@ -105,9 +95,6 @@ public function __construct(string $authorizationId, string $serviceName, string
10595 $ this ->scope = $ scope ;
10696 }
10797
108- /**
109- * @param EncryptionService $encryptionService
110- */
11198 public function injectEncryptionService (EncryptionService $ encryptionService ): void
11299 {
113100 $ this ->encryptionService = $ encryptionService ;
@@ -116,128 +103,84 @@ public function injectEncryptionService(EncryptionService $encryptionService): v
116103 /**
117104 * Calculate an authorization identifier (for this model) from the given parameters.
118105 *
119- * @param string $serviceType
120- * @param string $serviceName
121- * @param string $clientId
122- * @return string
123106 * @throws OAuthClientException
124107 */
125108 public static function generateAuthorizationIdForAuthorizationCodeGrant (string $ serviceType , string $ serviceName , string $ clientId ): string
126109 {
127110 try {
128111 return $ serviceType . '- ' . $ serviceName . '- ' . Uuid::uuid4 ()->toString ();
129112 // @codeCoverageIgnoreStart
130- } catch (Exception $ e ) {
113+ } catch (\ Exception $ e ) {
131114 throw new OAuthClientException (sprintf ('Failed generating authorization id for %s %s ' , $ serviceName , $ clientId ), 1597311416 , $ e );
132115 }
133116 // @codeCoverageIgnoreEnd
134117 }
135118
136119 /**
137120 * Calculate an authorization identifier (for this model) from the given parameters.
138- *
139- * @param string $serviceName
140- * @param string $clientId
141- * @param string $clientSecret
142- * @param string $scope
143- * @param array $additionalParameters
144- * @return string
145121 */
146122 public static function generateAuthorizationIdForClientCredentialsGrant (string $ serviceName , string $ clientId , string $ clientSecret , string $ scope , array $ additionalParameters = []): string
147123 {
148124 try {
149125 $ additionalParametersJson = json_encode ($ additionalParameters , JSON_THROW_ON_ERROR );
150- } catch (JsonException $ e ) {
126+ } catch (\ JsonException ) {
151127 $ additionalParametersJson = '' ;
152128 }
153129 return hash ('sha512 ' , $ serviceName . $ clientId . $ clientSecret . $ scope . $ additionalParametersJson . self ::GRANT_CLIENT_CREDENTIALS );
154130 }
155131
156- /**
157- * @return string
158- */
159132 public function getAuthorizationId (): string
160133 {
161134 return $ this ->authorizationId ;
162135 }
163136
164- /**
165- * @return string
166- */
167137 public function getServiceName (): string
168138 {
169139 return $ this ->serviceName ;
170140 }
171141
172- /**
173- * @return string
174- */
175142 public function getClientId (): string
176143 {
177144 return $ this ->clientId ;
178145 }
179146
180- /**
181- * @return string
182- */
183147 public function getGrantType (): string
184148 {
185149 return $ this ->grantType ;
186150 }
187151
188- /**
189- * @return string
190- * @return void
191- */
192152 public function getScope (): string
193153 {
194154 return $ this ->scope ;
195155 }
196156
197- /**
198- * @param string $scope
199- */
200157 public function setScope (string $ scope ): void
201158 {
202159 $ this ->scope = $ scope ;
203160 }
204161
205- /**
206- * @return string
207- */
208162 public function getSerializedAccessToken (): string
209163 {
210164 return $ this ->serializedAccessToken ?? '' ;
211165 }
212166
213- /**
214- * @param string $serializedAccessToken
215- */
216167 public function setSerializedAccessToken (string $ serializedAccessToken ): void
217168 {
218169 $ this ->serializedAccessToken = $ serializedAccessToken ;
219170 }
220171
221- /**
222- * @return string
223- */
224172 public function getEncryptedSerializedAccessToken (): string
225173 {
226174 return $ this ->encryptedSerializedAccessToken ?? '' ;
227175 }
228176
229- /**
230- * @param string $encryptedSerializedAccessToken
231- */
232177 public function setEncryptedSerializedAccessToken (string $ encryptedSerializedAccessToken ): void
233178 {
234179 $ this ->encryptedSerializedAccessToken = $ encryptedSerializedAccessToken ;
235180 }
236181
237182 /**
238- * @param AccessTokenInterface $accessToken
239- * @return void
240- * @throws InvalidArgumentException
183+ * @throws \InvalidArgumentException
241184 */
242185 public function setAccessToken (AccessTokenInterface $ accessToken ): void
243186 {
@@ -248,19 +191,19 @@ public function setAccessToken(AccessTokenInterface $accessToken): void
248191
249192 try {
250193 if ($ this ->encryptionService !== null && $ this ->encryptionService ->isConfigured ()) {
251- $ this ->encryptedSerializedAccessToken = $ this ->encryptionService ->encryptAndEncode (json_encode ($ accessToken , JSON_THROW_ON_ERROR , 512 ));
194+ $ this ->encryptedSerializedAccessToken = $ this ->encryptionService ->encryptAndEncode (json_encode ($ accessToken , JSON_THROW_ON_ERROR ));
252195 } else {
253- $ this ->serializedAccessToken = json_encode ($ accessToken , JSON_THROW_ON_ERROR , 512 );
196+ $ this ->serializedAccessToken = json_encode ($ accessToken , JSON_THROW_ON_ERROR );
254197 }
255198 // @codeCoverageIgnoreStart
256- } catch (JsonException | Exception $ e ) {
257- throw new InvalidArgumentException ('Failed serializing the given access token ' , 1602515717 , $ e );
199+ } catch (\ JsonException | \ Exception $ e ) {
200+ throw new \ InvalidArgumentException ('Failed serializing the given access token ' , 1602515717 , $ e );
258201 // @codeCoverageIgnoreEnd
259202 }
260203 }
261204
262205 /**
263- * @return AccessToken
206+ * @throws \SodiumException
264207 */
265208 public function getAccessToken (): ?AccessToken
266209 {
@@ -279,22 +222,16 @@ public function getAccessToken(): ?AccessToken
279222 $ deserializedAccessToken = json_decode ($ this ->serializedAccessToken , true , 512 , JSON_THROW_ON_ERROR );
280223 return new AccessToken ($ deserializedAccessToken );
281224 }
282- } catch (JsonException $ e ) {
225+ } catch (\ JsonException ) {
283226 }
284227 return null ;
285228 }
286229
287- /**
288- * @return \DateTimeImmutable
289- */
290230 public function getExpires (): ?\DateTimeImmutable
291231 {
292232 return $ this ->expires ;
293233 }
294234
295- /**
296- * @param \DateTimeImmutable $expires
297- */
298235 public function setExpires (\DateTimeImmutable $ expires ): void
299236 {
300237 $ this ->expires = $ expires ;
0 commit comments