1 | <?php |
||
31 | trait TypedHeader |
||
32 | { |
||
33 | /** |
||
34 | * Whether parameters are present. |
||
35 | * |
||
36 | * @param string ...$names Parameter names |
||
37 | * @return bool |
||
38 | */ |
||
39 | abstract public function has(...$names); |
||
40 | |||
41 | /** |
||
42 | * Get a parameter. |
||
43 | * |
||
44 | * @param string $name Parameter name |
||
45 | * @return JWTParameter |
||
46 | */ |
||
47 | abstract public function get($name); |
||
48 | |||
49 | /** |
||
50 | * Check whether the algorithm parameter is present. |
||
51 | * |
||
52 | * @return bool |
||
53 | */ |
||
54 | 9 | public function hasAlgorithm() { |
|
57 | |||
58 | /** |
||
59 | * Get the algorithm parameter. |
||
60 | * |
||
61 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
62 | * @throws \LogicException If the parameter is not present |
||
63 | * @return AlgorithmParameter |
||
64 | */ |
||
65 | 17 | public function algorithm() { |
|
69 | |||
70 | /** |
||
71 | * Check whether the authentication tag parameter is present. |
||
72 | * |
||
73 | * @return bool |
||
74 | */ |
||
75 | 6 | public function hasAuthenticationTag() { |
|
78 | |||
79 | /** |
||
80 | * Get the authentication tag parameter. |
||
81 | * |
||
82 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
83 | * @throws \LogicException If the parameter is not present |
||
84 | * @return AuthenticationTagParameter |
||
85 | */ |
||
86 | 5 | public function authenticationTag() { |
|
90 | |||
91 | /** |
||
92 | * Check whether the 'base64url-encode payload' parameter is present. |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | 27 | public function hasB64Payload() { |
|
99 | |||
100 | /** |
||
101 | * Get the 'base64url-encode payload' parameter. |
||
102 | * |
||
103 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
104 | * @throws \LogicException If the parameter is not present |
||
105 | * @return B64PayloadParameter |
||
106 | */ |
||
107 | 4 | public function B64Payload() { |
|
111 | |||
112 | /** |
||
113 | * Check whether the compression algorithm parameter is present. |
||
114 | * |
||
115 | * @return bool |
||
116 | */ |
||
117 | 12 | public function hasCompressionAlgorithm() { |
|
120 | |||
121 | /** |
||
122 | * Get the compression algorithm parameter. |
||
123 | * |
||
124 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
125 | * @throws \LogicException If the parameter is not present |
||
126 | * @return CompressionAlgorithmParameter |
||
127 | */ |
||
128 | 3 | public function compressionAlgorithm() { |
|
132 | |||
133 | /** |
||
134 | * Check whether the content type parameter is present. |
||
135 | * |
||
136 | * @return bool |
||
137 | */ |
||
138 | 6 | public function hasContentType() { |
|
141 | |||
142 | /** |
||
143 | * Get the content type parameter. |
||
144 | * |
||
145 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
146 | * @throws \LogicException If the parameter is not present |
||
147 | * @return ContentTypeParameter |
||
148 | */ |
||
149 | 4 | public function contentType() { |
|
153 | |||
154 | /** |
||
155 | * Check whether the critical parameter is present. |
||
156 | * |
||
157 | * @return bool |
||
158 | */ |
||
159 | 3 | public function hasCritical() { |
|
162 | |||
163 | /** |
||
164 | * Get the critical parameter. |
||
165 | * |
||
166 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
167 | * @throws \LogicException If the parameter is not present |
||
168 | * @return CriticalParameter |
||
169 | */ |
||
170 | 2 | public function critical() { |
|
174 | |||
175 | /** |
||
176 | * Check whether the encryption algorithm parameter is present. |
||
177 | * |
||
178 | * @return bool |
||
179 | */ |
||
180 | 5 | public function hasEncryptionAlgorithm() { |
|
183 | |||
184 | /** |
||
185 | * Get the encryption algorithm parameter. |
||
186 | * |
||
187 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
188 | * @throws \LogicException If the parameter is not present |
||
189 | * @return EncryptionAlgorithmParameter |
||
190 | */ |
||
191 | 2 | public function encryptionAlgorithm() { |
|
195 | |||
196 | /** |
||
197 | * Check whether the initialization vector parameter is present. |
||
198 | * |
||
199 | * @return bool |
||
200 | */ |
||
201 | 1 | public function hasInitializationVector() { |
|
204 | |||
205 | /** |
||
206 | * Get the initialization vector parameter. |
||
207 | * |
||
208 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
209 | * @throws \LogicException If the parameter is not present |
||
210 | * @return InitializationVectorParameter |
||
211 | */ |
||
212 | 1 | public function initializationVector() { |
|
216 | |||
217 | /** |
||
218 | * Check whether the JSON web key parameter is present. |
||
219 | * |
||
220 | * @return bool |
||
221 | */ |
||
222 | 1 | public function hasJSONWebKey() { |
|
225 | |||
226 | /** |
||
227 | * Get the JSON web key parameter. |
||
228 | * |
||
229 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
230 | * @throws \LogicException If the parameter is not present |
||
231 | * @return JSONWebKeyParameter |
||
232 | */ |
||
233 | 1 | public function JSONWebKey() { |
|
237 | |||
238 | /** |
||
239 | * Check whether the JWK set URL parameter is present. |
||
240 | * |
||
241 | * @return bool |
||
242 | */ |
||
243 | 1 | public function hasJWKSetURL() { |
|
246 | |||
247 | /** |
||
248 | * Get the JWK set URL parameter. |
||
249 | * |
||
250 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
251 | * @throws \LogicException If the parameter is not present |
||
252 | * @return JWKSetURLParameter |
||
253 | */ |
||
254 | 1 | public function JWKSetURL() { |
|
258 | |||
259 | /** |
||
260 | * Check whether the key ID parameter is present. |
||
261 | * |
||
262 | * @return bool |
||
263 | */ |
||
264 | 1 | public function hasKeyID() { |
|
267 | |||
268 | /** |
||
269 | * Get the key ID parameter. |
||
270 | * |
||
271 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
272 | * @throws \LogicException If the parameter is not present |
||
273 | * @return KeyIDParameter |
||
274 | */ |
||
275 | 1 | public function keyID() { |
|
279 | |||
280 | /** |
||
281 | * Check whether the PBES2 count parameter is present. |
||
282 | * |
||
283 | * @return bool |
||
284 | */ |
||
285 | 1 | public function hasPBES2Count() { |
|
288 | |||
289 | /** |
||
290 | * Get the PBES2 count parameter. |
||
291 | * |
||
292 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
293 | * @throws \LogicException If the parameter is not present |
||
294 | * @return PBES2CountParameter |
||
295 | */ |
||
296 | 5 | public function PBES2Count() { |
|
300 | |||
301 | /** |
||
302 | * Check whether the PBES2 salt input parameter is present. |
||
303 | * |
||
304 | * @return bool |
||
305 | */ |
||
306 | 1 | public function hasPBES2SaltInput() { |
|
309 | |||
310 | /** |
||
311 | * Get the PBES2 salt input parameter. |
||
312 | * |
||
313 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
314 | * @throws \LogicException If the parameter is not present |
||
315 | * @return PBES2SaltInputParameter |
||
316 | */ |
||
317 | 5 | public function PBES2SaltInput() { |
|
321 | |||
322 | /** |
||
323 | * Check whether the type parameter is present. |
||
324 | * |
||
325 | * @return bool |
||
326 | */ |
||
327 | 1 | public function hasType() { |
|
330 | |||
331 | /** |
||
332 | * Get the type parameter. |
||
333 | * |
||
334 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
335 | * @throws \LogicException If the parameter is not present |
||
336 | * @return TypeParameter |
||
337 | */ |
||
338 | 1 | public function type() { |
|
342 | |||
343 | /** |
||
344 | * Check whether the X.509 certificate chain parameter is present. |
||
345 | * |
||
346 | * @return bool |
||
347 | */ |
||
348 | 1 | public function hasX509CertificateChain() { |
|
351 | |||
352 | /** |
||
353 | * Get the X.509 certificate chain parameter. |
||
354 | * |
||
355 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
356 | * @throws \LogicException If the parameter is not present |
||
357 | * @return X509CertificateChainParameter |
||
358 | */ |
||
359 | 1 | public function X509CertificateChain() { |
|
363 | |||
364 | /** |
||
365 | * Check whether the X.509 certificate SHA-1 thumbprint parameter is |
||
366 | * present. |
||
367 | * |
||
368 | * @return bool |
||
369 | */ |
||
370 | 1 | public function hasX509CertificateSHA1Thumbprint() { |
|
373 | |||
374 | /** |
||
375 | * Get the X.509 certificate SHA-1 thumbprint parameter. |
||
376 | * |
||
377 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
378 | * @throws \LogicException If the parameter is not present |
||
379 | * @return X509CertificateSHA1ThumbprintParameter |
||
380 | */ |
||
381 | 1 | public function X509CertificateSHA1Thumbprint() { |
|
385 | |||
386 | /** |
||
387 | * Check whether the X.509 certificate SHA-256 thumbprint parameter is |
||
388 | * present. |
||
389 | * |
||
390 | * @return bool |
||
391 | */ |
||
392 | 1 | public function hasX509CertificateSHA256Thumbprint() { |
|
395 | |||
396 | /** |
||
397 | * Get the X.509 certificate SHA-256 thumbprint parameter. |
||
398 | * |
||
399 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
400 | * @throws \LogicException If the parameter is not present |
||
401 | * @return X509CertificateSHA256ThumbprintParameter |
||
402 | */ |
||
403 | 1 | public function X509CertificateSHA256Thumbprint() { |
|
407 | |||
408 | /** |
||
409 | * Check whether the X.509 URL parameter is present. |
||
410 | * |
||
411 | * @return bool |
||
412 | */ |
||
413 | 1 | public function hasX509URL() { |
|
416 | |||
417 | /** |
||
418 | * Get the X.509 URL parameter. |
||
419 | * |
||
420 | * @throws \UnexpectedValueException If the parameter has a wrong class |
||
421 | * @throws \LogicException If the parameter is not present |
||
422 | * @return X509URLParameter |
||
423 | */ |
||
424 | 1 | public function X509URL() { |
|
428 | |||
429 | /** |
||
430 | * Check that the parameter is an instance of the given class. |
||
431 | * |
||
432 | * @param JWTParameter $param Parameter |
||
433 | * @param string $cls Class name |
||
434 | * @throws \UnexpectedValueException |
||
435 | * @return JWTParameter |
||
436 | */ |
||
437 | 47 | private static function _checkType(JWTParameter $param, $cls) { |
|
444 | } |
||
445 |