1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace Sop\JWX\JWK; |
6
|
|
|
|
7
|
|
|
use Sop\JWX\JWK\Parameter\JWKParameter; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Trait for JWK to provide parameter accessor methods for typed return values. |
11
|
|
|
*/ |
12
|
|
|
trait TypedJWK |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Whether parameters are present. |
16
|
|
|
* |
17
|
|
|
* @param string ...$names Parameter names |
18
|
|
|
* |
19
|
|
|
* @return bool |
20
|
|
|
*/ |
21
|
|
|
abstract public function has(string ...$names): bool; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Get a parameter. |
25
|
|
|
* |
26
|
|
|
* @param string $name Parameter name |
27
|
|
|
* |
28
|
|
|
* @return JWKParameter |
29
|
|
|
*/ |
30
|
|
|
abstract public function get(string $name): JWKParameter; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Check whether the algorithm parameter is present. |
34
|
|
|
* |
35
|
|
|
* @return bool |
36
|
|
|
*/ |
37
|
61 |
|
public function hasAlgorithmParameter(): bool |
38
|
|
|
{ |
39
|
61 |
|
return $this->has(Parameter\JWKParameter::P_ALG); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Get the algorithm parameter. |
44
|
|
|
* |
45
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
46
|
|
|
* @throws \LogicException If the parameter is not present |
47
|
|
|
* |
48
|
|
|
* @return Parameter\AlgorithmParameter |
49
|
|
|
*/ |
50
|
20 |
|
public function algorithmParameter(): Parameter\AlgorithmParameter |
51
|
|
|
{ |
52
|
20 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_ALG), |
|
|
|
|
53
|
20 |
|
Parameter\AlgorithmParameter::class); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Check whether the curve parameter is present. |
58
|
|
|
* |
59
|
|
|
* @return bool |
60
|
|
|
*/ |
61
|
1 |
|
public function hasCurveParameter(): bool |
62
|
|
|
{ |
63
|
1 |
|
return $this->has(Parameter\JWKParameter::P_CRV); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Get the curve parameter. |
68
|
|
|
* |
69
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
70
|
|
|
* @throws \LogicException If the parameter is not present |
71
|
|
|
* |
72
|
|
|
* @return Parameter\CurveParameter |
73
|
|
|
*/ |
74
|
20 |
|
public function curveParameter(): Parameter\CurveParameter |
75
|
|
|
{ |
76
|
20 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_CRV), |
|
|
|
|
77
|
20 |
|
Parameter\CurveParameter::class); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Check whether the ECC private key parameter is present. |
82
|
|
|
* |
83
|
|
|
* @return bool |
84
|
|
|
*/ |
85
|
1 |
|
public function hasECCPrivateKeyParameter(): bool |
86
|
|
|
{ |
87
|
1 |
|
return $this->has(Parameter\JWKParameter::P_ECC_D); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Get the ECC private key parameter. |
92
|
|
|
* |
93
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
94
|
|
|
* @throws \LogicException If the parameter is not present |
95
|
|
|
* |
96
|
|
|
* @return Parameter\ECCPrivateKeyParameter |
97
|
|
|
*/ |
98
|
6 |
|
public function ECCPrivateKeyParameter(): Parameter\ECCPrivateKeyParameter |
99
|
|
|
{ |
100
|
6 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_ECC_D), |
|
|
|
|
101
|
6 |
|
Parameter\ECCPrivateKeyParameter::class); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Check whether the exponent parameter is present. |
106
|
|
|
* |
107
|
|
|
* @return bool |
108
|
|
|
*/ |
109
|
1 |
|
public function hasExponentParameter(): bool |
110
|
|
|
{ |
111
|
1 |
|
return $this->has(Parameter\JWKParameter::P_E); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Get the exponent parameter. |
116
|
|
|
* |
117
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
118
|
|
|
* @throws \LogicException If the parameter is not present |
119
|
|
|
* |
120
|
|
|
* @return Parameter\ExponentParameter |
121
|
|
|
*/ |
122
|
41 |
|
public function exponentParameter(): Parameter\ExponentParameter |
123
|
|
|
{ |
124
|
41 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_E), |
|
|
|
|
125
|
41 |
|
Parameter\ExponentParameter::class); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Check whether the first CRT coefficient parameter is present. |
130
|
|
|
* |
131
|
|
|
* @return bool |
132
|
|
|
*/ |
133
|
1 |
|
public function hasFirstCRTCoefficientParameter(): bool |
134
|
|
|
{ |
135
|
1 |
|
return $this->has(Parameter\JWKParameter::P_QI); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Get the first CRT coefficient parameter. |
140
|
|
|
* |
141
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
142
|
|
|
* @throws \LogicException If the parameter is not present |
143
|
|
|
* |
144
|
|
|
* @return Parameter\FirstCRTCoefficientParameter |
145
|
|
|
*/ |
146
|
17 |
|
public function firstCRTCoefficientParameter(): Parameter\FirstCRTCoefficientParameter |
147
|
|
|
{ |
148
|
17 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_QI), |
|
|
|
|
149
|
17 |
|
Parameter\FirstCRTCoefficientParameter::class); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Check whether the first factor CRT exponent parameter is present. |
154
|
|
|
* |
155
|
|
|
* @return bool |
156
|
|
|
*/ |
157
|
1 |
|
public function hasFirstFactorCRTExponentParameter(): bool |
158
|
|
|
{ |
159
|
1 |
|
return $this->has(Parameter\JWKParameter::P_DP); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Get the first factor CRT exponent parameter. |
164
|
|
|
* |
165
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
166
|
|
|
* @throws \LogicException If the parameter is not present |
167
|
|
|
* |
168
|
|
|
* @return Parameter\FirstFactorCRTExponentParameter |
169
|
|
|
*/ |
170
|
17 |
|
public function firstFactorCRTExponentParameter(): Parameter\FirstFactorCRTExponentParameter |
171
|
|
|
{ |
172
|
17 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_DP), |
|
|
|
|
173
|
17 |
|
Parameter\FirstFactorCRTExponentParameter::class); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Check whether the first prime factor parameter is present. |
178
|
|
|
* |
179
|
|
|
* @return bool |
180
|
|
|
*/ |
181
|
1 |
|
public function hasFirstPrimeFactorParameter(): bool |
182
|
|
|
{ |
183
|
1 |
|
return $this->has(Parameter\JWKParameter::P_P); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Get the first prime factor parameter. |
188
|
|
|
* |
189
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
190
|
|
|
* @throws \LogicException If the parameter is not present |
191
|
|
|
* |
192
|
|
|
* @return Parameter\FirstPrimeFactorParameter |
193
|
|
|
*/ |
194
|
17 |
|
public function firstPrimeFactorParameter(): Parameter\FirstPrimeFactorParameter |
195
|
|
|
{ |
196
|
17 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_P), |
|
|
|
|
197
|
17 |
|
Parameter\FirstPrimeFactorParameter::class); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Check whether the key ID parameter is present. |
202
|
|
|
* |
203
|
|
|
* @return bool |
204
|
|
|
*/ |
205
|
1 |
|
public function hasKeyIDParameter(): bool |
206
|
|
|
{ |
207
|
1 |
|
return $this->has(Parameter\JWKParameter::P_KID); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* Get the key ID parameter. |
212
|
|
|
* |
213
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
214
|
|
|
* @throws \LogicException If the parameter is not present |
215
|
|
|
* |
216
|
|
|
* @return Parameter\KeyIDParameter |
217
|
|
|
*/ |
218
|
1 |
|
public function keyIDParameter(): Parameter\KeyIDParameter |
219
|
|
|
{ |
220
|
1 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_KID), |
|
|
|
|
221
|
1 |
|
Parameter\KeyIDParameter::class); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Check whether the key operations parameter is present. |
226
|
|
|
* |
227
|
|
|
* @return bool |
228
|
|
|
*/ |
229
|
1 |
|
public function hasKeyOperationsParameter(): bool |
230
|
|
|
{ |
231
|
1 |
|
return $this->has(Parameter\JWKParameter::P_KEY_OPS); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* Get the key operations parameter. |
236
|
|
|
* |
237
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
238
|
|
|
* @throws \LogicException If the parameter is not present |
239
|
|
|
* |
240
|
|
|
* @return Parameter\KeyOperationsParameter |
241
|
|
|
*/ |
242
|
1 |
|
public function keyOperationsParameter(): Parameter\KeyOperationsParameter |
243
|
|
|
{ |
244
|
1 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_KEY_OPS), |
|
|
|
|
245
|
1 |
|
Parameter\KeyOperationsParameter::class); |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* Check whether the key type parameter is present. |
250
|
|
|
* |
251
|
|
|
* @return bool |
252
|
|
|
*/ |
253
|
1 |
|
public function hasKeyTypeParameter(): bool |
254
|
|
|
{ |
255
|
1 |
|
return $this->has(Parameter\JWKParameter::P_KTY); |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* Get the key type parameter. |
260
|
|
|
* |
261
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
262
|
|
|
* @throws \LogicException If the parameter is not present |
263
|
|
|
* |
264
|
|
|
* @return Parameter\KeyTypeParameter |
265
|
|
|
*/ |
266
|
130 |
|
public function keyTypeParameter(): Parameter\KeyTypeParameter |
267
|
|
|
{ |
268
|
130 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_KTY), |
|
|
|
|
269
|
130 |
|
Parameter\KeyTypeParameter::class); |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* Check whether the key value parameter is present. |
274
|
|
|
* |
275
|
|
|
* @return bool |
276
|
|
|
*/ |
277
|
1 |
|
public function hasKeyValueParameter(): bool |
278
|
|
|
{ |
279
|
1 |
|
return $this->has(Parameter\JWKParameter::P_K); |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* Get the key value parameter. |
284
|
|
|
* |
285
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
286
|
|
|
* @throws \LogicException If the parameter is not present |
287
|
|
|
* |
288
|
|
|
* @return Parameter\KeyValueParameter |
289
|
|
|
*/ |
290
|
40 |
|
public function keyValueParameter(): Parameter\KeyValueParameter |
291
|
|
|
{ |
292
|
40 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_K), |
|
|
|
|
293
|
40 |
|
Parameter\KeyValueParameter::class); |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* Check whether the modulus parameter is present. |
298
|
|
|
* |
299
|
|
|
* @return bool |
300
|
|
|
*/ |
301
|
1 |
|
public function hasModulusParameter(): bool |
302
|
|
|
{ |
303
|
1 |
|
return $this->has(Parameter\JWKParameter::P_N); |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* Get the modulus parameter. |
308
|
|
|
* |
309
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
310
|
|
|
* @throws \LogicException If the parameter is not present |
311
|
|
|
* |
312
|
|
|
* @return Parameter\ModulusParameter |
313
|
|
|
*/ |
314
|
41 |
|
public function modulusParameter(): Parameter\ModulusParameter |
315
|
|
|
{ |
316
|
41 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_N), |
|
|
|
|
317
|
41 |
|
Parameter\ModulusParameter::class); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Check whether the other primes info parameter is present. |
322
|
|
|
* |
323
|
|
|
* @return bool |
324
|
|
|
*/ |
325
|
1 |
|
public function hasOtherPrimesInfoParameter(): bool |
326
|
|
|
{ |
327
|
1 |
|
return $this->has(Parameter\JWKParameter::P_OTH); |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
/** |
331
|
|
|
* Get the other primes info parameter. |
332
|
|
|
* |
333
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
334
|
|
|
* @throws \LogicException If the parameter is not present |
335
|
|
|
* |
336
|
|
|
* @return Parameter\OtherPrimesInfoParameter |
337
|
|
|
*/ |
338
|
1 |
|
public function otherPrimesInfoParameter(): Parameter\OtherPrimesInfoParameter |
339
|
|
|
{ |
340
|
1 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_OTH), |
|
|
|
|
341
|
1 |
|
Parameter\OtherPrimesInfoParameter::class); |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* Check whether the private exponent parameter is present. |
346
|
|
|
* |
347
|
|
|
* @return bool |
348
|
|
|
*/ |
349
|
1 |
|
public function hasPrivateExponentParameter(): bool |
350
|
|
|
{ |
351
|
1 |
|
return $this->has(Parameter\JWKParameter::P_RSA_D); |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
/** |
355
|
|
|
* Get the private exponent parameter. |
356
|
|
|
* |
357
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
358
|
|
|
* @throws \LogicException If the parameter is not present |
359
|
|
|
* |
360
|
|
|
* @return Parameter\PrivateExponentParameter |
361
|
|
|
*/ |
362
|
17 |
|
public function privateExponentParameter(): Parameter\PrivateExponentParameter |
363
|
|
|
{ |
364
|
17 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_RSA_D), |
|
|
|
|
365
|
17 |
|
Parameter\PrivateExponentParameter::class); |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
/** |
369
|
|
|
* Check whether the public key use parameter is present. |
370
|
|
|
* |
371
|
|
|
* @return bool |
372
|
|
|
*/ |
373
|
1 |
|
public function hasPublicKeyUseParameter(): bool |
374
|
|
|
{ |
375
|
1 |
|
return $this->has(Parameter\JWKParameter::P_USE); |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
/** |
379
|
|
|
* Get the public key use parameter. |
380
|
|
|
* |
381
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
382
|
|
|
* @throws \LogicException If the parameter is not present |
383
|
|
|
* |
384
|
|
|
* @return Parameter\PublicKeyUseParameter |
385
|
|
|
*/ |
386
|
1 |
|
public function publicKeyUseParameter(): Parameter\PublicKeyUseParameter |
387
|
|
|
{ |
388
|
1 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_USE), |
|
|
|
|
389
|
1 |
|
Parameter\PublicKeyUseParameter::class); |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* Check whether the second factor CRT exponent parameter is present. |
394
|
|
|
* |
395
|
|
|
* @return bool |
396
|
|
|
*/ |
397
|
1 |
|
public function hasSecondFactorCRTExponentParameter(): bool |
398
|
|
|
{ |
399
|
1 |
|
return $this->has(Parameter\JWKParameter::P_DQ); |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
/** |
403
|
|
|
* Get the second factor CRT exponent parameter. |
404
|
|
|
* |
405
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
406
|
|
|
* @throws \LogicException If the parameter is not present |
407
|
|
|
* |
408
|
|
|
* @return Parameter\SecondFactorCRTExponentParameter |
409
|
|
|
*/ |
410
|
17 |
|
public function secondFactorCRTExponentParameter(): Parameter\SecondFactorCRTExponentParameter |
411
|
|
|
{ |
412
|
17 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_DQ), |
|
|
|
|
413
|
17 |
|
Parameter\SecondFactorCRTExponentParameter::class); |
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
/** |
417
|
|
|
* Check whether the second prime factor parameter is present. |
418
|
|
|
* |
419
|
|
|
* @return bool |
420
|
|
|
*/ |
421
|
1 |
|
public function hasSecondPrimeFactorParameter(): bool |
422
|
|
|
{ |
423
|
1 |
|
return $this->has(Parameter\JWKParameter::P_Q); |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
/** |
427
|
|
|
* Get the second prime factor parameter. |
428
|
|
|
* |
429
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
430
|
|
|
* @throws \LogicException If the parameter is not present |
431
|
|
|
* |
432
|
|
|
* @return Parameter\SecondPrimeFactorParameter |
433
|
|
|
*/ |
434
|
17 |
|
public function secondPrimeFactorParameter(): Parameter\SecondPrimeFactorParameter |
435
|
|
|
{ |
436
|
17 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_Q), |
|
|
|
|
437
|
17 |
|
Parameter\SecondPrimeFactorParameter::class); |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* Check whether the X.509 certificate chain parameter is present. |
442
|
|
|
* |
443
|
|
|
* @return bool |
444
|
|
|
*/ |
445
|
1 |
|
public function hasX509CertificateChainParameter(): bool |
446
|
|
|
{ |
447
|
1 |
|
return $this->has(Parameter\JWKParameter::P_X5C); |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
/** |
451
|
|
|
* Get the X.509 certificate chain parameter. |
452
|
|
|
* |
453
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
454
|
|
|
* @throws \LogicException If the parameter is not present |
455
|
|
|
* |
456
|
|
|
* @return Parameter\X509CertificateChainParameter |
457
|
|
|
*/ |
458
|
1 |
|
public function X509CertificateChainParameter(): Parameter\X509CertificateChainParameter |
459
|
|
|
{ |
460
|
1 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_X5C), |
|
|
|
|
461
|
1 |
|
Parameter\X509CertificateChainParameter::class); |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* Check whether the X.509 certificate SHA-1 thumbprint parameter is |
466
|
|
|
* present. |
467
|
|
|
* |
468
|
|
|
* @return bool |
469
|
|
|
*/ |
470
|
1 |
|
public function hasX509CertificateSHA1ThumbprintParameter(): bool |
471
|
|
|
{ |
472
|
1 |
|
return $this->has(Parameter\JWKParameter::P_X5T); |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* Get the X.509 certificate SHA-1 thumbprint parameter. |
477
|
|
|
* |
478
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
479
|
|
|
* @throws \LogicException If the parameter is not present |
480
|
|
|
* |
481
|
|
|
* @return Parameter\X509CertificateSHA1ThumbprintParameter |
482
|
|
|
*/ |
483
|
1 |
|
public function X509CertificateSHA1ThumbprintParameter(): Parameter\X509CertificateSHA1ThumbprintParameter |
484
|
|
|
{ |
485
|
1 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_X5T), |
|
|
|
|
486
|
1 |
|
Parameter\X509CertificateSHA1ThumbprintParameter::class); |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
/** |
490
|
|
|
* Check whether the X.509 certificate SHA-256 thumbprint parameter is |
491
|
|
|
* present. |
492
|
|
|
* |
493
|
|
|
* @return bool |
494
|
|
|
*/ |
495
|
1 |
|
public function hasX509CertificateSHA256ThumbprintParameter(): bool |
496
|
|
|
{ |
497
|
1 |
|
return $this->has(Parameter\JWKParameter::P_X5TS256); |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
/** |
501
|
|
|
* Get the X.509 certificate SHA-256 thumbprint parameter. |
502
|
|
|
* |
503
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
504
|
|
|
* @throws \LogicException If the parameter is not present |
505
|
|
|
* |
506
|
|
|
* @return Parameter\X509CertificateSHA256ThumbprintParameter |
507
|
|
|
*/ |
508
|
1 |
|
public function X509CertificateSHA256ThumbprintParameter(): Parameter\X509CertificateSHA256ThumbprintParameter |
509
|
|
|
{ |
510
|
1 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_X5TS256), |
|
|
|
|
511
|
1 |
|
Parameter\X509CertificateSHA256ThumbprintParameter::class); |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
/** |
515
|
|
|
* Check whether the X.509 URL parameter is present. |
516
|
|
|
* |
517
|
|
|
* @return bool |
518
|
|
|
*/ |
519
|
1 |
|
public function hasX509URLParameter(): bool |
520
|
|
|
{ |
521
|
1 |
|
return $this->has(Parameter\JWKParameter::P_X5U); |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
/** |
525
|
|
|
* Get the X.509 URL parameter. |
526
|
|
|
* |
527
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
528
|
|
|
* @throws \LogicException If the parameter is not present |
529
|
|
|
* |
530
|
|
|
* @return Parameter\X509URLParameter |
531
|
|
|
*/ |
532
|
1 |
|
public function X509URLParameter(): Parameter\X509URLParameter |
533
|
|
|
{ |
534
|
1 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_X5U), |
|
|
|
|
535
|
1 |
|
Parameter\X509URLParameter::class); |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* Check whether the X coordinate parameter is present. |
540
|
|
|
* |
541
|
|
|
* @return bool |
542
|
|
|
*/ |
543
|
1 |
|
public function hasXCoordinateParameter(): bool |
544
|
|
|
{ |
545
|
1 |
|
return $this->has(Parameter\JWKParameter::P_X); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
/** |
549
|
|
|
* Get the X coordinate parameter. |
550
|
|
|
* |
551
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
552
|
|
|
* @throws \LogicException If the parameter is not present |
553
|
|
|
* |
554
|
|
|
* @return Parameter\XCoordinateParameter |
555
|
|
|
*/ |
556
|
16 |
|
public function XCoordinateParameter(): Parameter\XCoordinateParameter |
557
|
|
|
{ |
558
|
16 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_X), |
|
|
|
|
559
|
16 |
|
Parameter\XCoordinateParameter::class); |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
/** |
563
|
|
|
* Check whether the Y coordinate parameter is present. |
564
|
|
|
* |
565
|
|
|
* @return bool |
566
|
|
|
*/ |
567
|
1 |
|
public function hasYCoordinateParameter(): bool |
568
|
|
|
{ |
569
|
1 |
|
return $this->has(Parameter\JWKParameter::P_Y); |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
/** |
573
|
|
|
* Get the Y coordinate parameter. |
574
|
|
|
* |
575
|
|
|
* @throws \UnexpectedValueException If the parameter has a wrong class |
576
|
|
|
* @throws \LogicException If the parameter is not present |
577
|
|
|
* |
578
|
|
|
* @return Parameter\YCoordinateParameter |
579
|
|
|
*/ |
580
|
16 |
|
public function YCoordinateParameter(): Parameter\YCoordinateParameter |
581
|
|
|
{ |
582
|
16 |
|
return self::_checkType($this->get(Parameter\JWKParameter::P_Y), |
|
|
|
|
583
|
16 |
|
Parameter\YCoordinateParameter::class); |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
/** |
587
|
|
|
* Check that the parameter is an instance of the given class. |
588
|
|
|
* |
589
|
|
|
* @param Parameter\JWKParameter $param Parameter |
590
|
|
|
* @param string $cls Class name |
591
|
|
|
* |
592
|
|
|
* @throws \UnexpectedValueException |
593
|
|
|
* |
594
|
|
|
* @return Parameter\JWKParameter |
595
|
|
|
*/ |
596
|
181 |
|
private static function _checkType(Parameter\JWKParameter $param, string $cls): Parameter\JWKParameter |
597
|
|
|
{ |
598
|
181 |
|
if (!$param instanceof $cls) { |
599
|
1 |
|
throw new \UnexpectedValueException( |
600
|
1 |
|
"{$cls} expected, got " . get_class($param)); |
601
|
|
|
} |
602
|
180 |
|
return $param; |
603
|
|
|
} |
604
|
|
|
} |
605
|
|
|
|