@@ -15,35 +15,35 @@ |
||
15 | 15 | */ |
16 | 16 | class PBES2HS384A192KWAlgorithm extends PBES2Algorithm |
17 | 17 | { |
18 | - /** |
|
19 | - * {@inheritdoc} |
|
20 | - */ |
|
21 | - public function algorithmParamValue(): string |
|
22 | - { |
|
23 | - return JWA::ALGO_PBES2_HS384_A192KW; |
|
24 | - } |
|
18 | + /** |
|
19 | + * {@inheritdoc} |
|
20 | + */ |
|
21 | + public function algorithmParamValue(): string |
|
22 | + { |
|
23 | + return JWA::ALGO_PBES2_HS384_A192KW; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * {@inheritdoc} |
|
28 | - */ |
|
29 | - protected function _hashAlgo(): string |
|
30 | - { |
|
31 | - return 'sha384'; |
|
32 | - } |
|
26 | + /** |
|
27 | + * {@inheritdoc} |
|
28 | + */ |
|
29 | + protected function _hashAlgo(): string |
|
30 | + { |
|
31 | + return 'sha384'; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * {@inheritdoc} |
|
36 | - */ |
|
37 | - protected function _keyLength(): int |
|
38 | - { |
|
39 | - return 24; |
|
40 | - } |
|
34 | + /** |
|
35 | + * {@inheritdoc} |
|
36 | + */ |
|
37 | + protected function _keyLength(): int |
|
38 | + { |
|
39 | + return 24; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * {@inheritdoc} |
|
44 | - */ |
|
45 | - protected function _kwAlgo(): AESKeyWrapAlgorithm |
|
46 | - { |
|
47 | - return new AESKW192(); |
|
48 | - } |
|
42 | + /** |
|
43 | + * {@inheritdoc} |
|
44 | + */ |
|
45 | + protected function _kwAlgo(): AESKeyWrapAlgorithm |
|
46 | + { |
|
47 | + return new AESKW192(); |
|
48 | + } |
|
49 | 49 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Sop\JWX\JWE\KeyAlgorithm; |
6 | 6 |
@@ -13,19 +13,19 @@ |
||
13 | 13 | */ |
14 | 14 | class RSAESOAEPAlgorithm extends RSAESKeyAlgorithm |
15 | 15 | { |
16 | - /** |
|
17 | - * {@inheritdoc} |
|
18 | - */ |
|
19 | - public function algorithmParamValue(): string |
|
20 | - { |
|
21 | - return JWA::ALGO_RSA_OAEP; |
|
22 | - } |
|
16 | + /** |
|
17 | + * {@inheritdoc} |
|
18 | + */ |
|
19 | + public function algorithmParamValue(): string |
|
20 | + { |
|
21 | + return JWA::ALGO_RSA_OAEP; |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * {@inheritdoc} |
|
26 | - */ |
|
27 | - protected function _paddingScheme(): int |
|
28 | - { |
|
29 | - return OPENSSL_PKCS1_OAEP_PADDING; |
|
30 | - } |
|
24 | + /** |
|
25 | + * {@inheritdoc} |
|
26 | + */ |
|
27 | + protected function _paddingScheme(): int |
|
28 | + { |
|
29 | + return OPENSSL_PKCS1_OAEP_PADDING; |
|
30 | + } |
|
31 | 31 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Sop\JWX\JWE\KeyAlgorithm; |
6 | 6 |
@@ -15,94 +15,94 @@ |
||
15 | 15 | */ |
16 | 16 | class KeyAlgorithmFactory |
17 | 17 | { |
18 | - /** |
|
19 | - * Mapping from algorithm name to class name. |
|
20 | - * |
|
21 | - * @internal |
|
22 | - * |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - const MAP_ALGO_TO_CLASS = [ |
|
26 | - JWA::ALGO_A128KW => A128KWAlgorithm::class, |
|
27 | - JWA::ALGO_A192KW => A192KWAlgorithm::class, |
|
28 | - JWA::ALGO_A128KW => A256KWAlgorithm::class, |
|
29 | - JWA::ALGO_A128GCMKW => A128GCMKWAlgorithm::class, |
|
30 | - JWA::ALGO_A192GCMKW => A192GCMKWAlgorithm::class, |
|
31 | - JWA::ALGO_A256GCMKW => A256GCMKWAlgorithm::class, |
|
32 | - JWA::ALGO_PBES2_HS256_A128KW => PBES2HS256A128KWAlgorithm::class, |
|
33 | - JWA::ALGO_PBES2_HS384_A192KW => PBES2HS384A192KWAlgorithm::class, |
|
34 | - JWA::ALGO_PBES2_HS512_A256KW => PBES2HS512A256KWAlgorithm::class, |
|
35 | - JWA::ALGO_DIR => DirectCEKAlgorithm::class, |
|
36 | - JWA::ALGO_RSA1_5 => RSAESPKCS1Algorithm::class, |
|
37 | - JWA::ALGO_RSA_OAEP => RSAESOAEPAlgorithm::class, |
|
38 | - ]; |
|
39 | - /** |
|
40 | - * Header. |
|
41 | - * |
|
42 | - * @var Header |
|
43 | - */ |
|
44 | - protected $_header; |
|
18 | + /** |
|
19 | + * Mapping from algorithm name to class name. |
|
20 | + * |
|
21 | + * @internal |
|
22 | + * |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + const MAP_ALGO_TO_CLASS = [ |
|
26 | + JWA::ALGO_A128KW => A128KWAlgorithm::class, |
|
27 | + JWA::ALGO_A192KW => A192KWAlgorithm::class, |
|
28 | + JWA::ALGO_A128KW => A256KWAlgorithm::class, |
|
29 | + JWA::ALGO_A128GCMKW => A128GCMKWAlgorithm::class, |
|
30 | + JWA::ALGO_A192GCMKW => A192GCMKWAlgorithm::class, |
|
31 | + JWA::ALGO_A256GCMKW => A256GCMKWAlgorithm::class, |
|
32 | + JWA::ALGO_PBES2_HS256_A128KW => PBES2HS256A128KWAlgorithm::class, |
|
33 | + JWA::ALGO_PBES2_HS384_A192KW => PBES2HS384A192KWAlgorithm::class, |
|
34 | + JWA::ALGO_PBES2_HS512_A256KW => PBES2HS512A256KWAlgorithm::class, |
|
35 | + JWA::ALGO_DIR => DirectCEKAlgorithm::class, |
|
36 | + JWA::ALGO_RSA1_5 => RSAESPKCS1Algorithm::class, |
|
37 | + JWA::ALGO_RSA_OAEP => RSAESOAEPAlgorithm::class, |
|
38 | + ]; |
|
39 | + /** |
|
40 | + * Header. |
|
41 | + * |
|
42 | + * @var Header |
|
43 | + */ |
|
44 | + protected $_header; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Constructor. |
|
48 | - * |
|
49 | - * @param Header $header |
|
50 | - */ |
|
51 | - public function __construct(Header $header) |
|
52 | - { |
|
53 | - $this->_header = $header; |
|
54 | - } |
|
46 | + /** |
|
47 | + * Constructor. |
|
48 | + * |
|
49 | + * @param Header $header |
|
50 | + */ |
|
51 | + public function __construct(Header $header) |
|
52 | + { |
|
53 | + $this->_header = $header; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Get key management algorithm by given JWK. |
|
58 | - * |
|
59 | - * @param JWK $jwk |
|
60 | - * |
|
61 | - * @return KeyManagementAlgorithm |
|
62 | - */ |
|
63 | - public function algoByKey(JWK $jwk): KeyManagementAlgorithm |
|
64 | - { |
|
65 | - $alg = JWA::deriveAlgorithmName($this->_header, $jwk); |
|
66 | - $cls = self::_algoClassByName($alg); |
|
67 | - return $cls::fromJWK($jwk, $this->_header); |
|
68 | - } |
|
56 | + /** |
|
57 | + * Get key management algorithm by given JWK. |
|
58 | + * |
|
59 | + * @param JWK $jwk |
|
60 | + * |
|
61 | + * @return KeyManagementAlgorithm |
|
62 | + */ |
|
63 | + public function algoByKey(JWK $jwk): KeyManagementAlgorithm |
|
64 | + { |
|
65 | + $alg = JWA::deriveAlgorithmName($this->_header, $jwk); |
|
66 | + $cls = self::_algoClassByName($alg); |
|
67 | + return $cls::fromJWK($jwk, $this->_header); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Get key management algorithm using a matching key from given JWK set. |
|
72 | - * |
|
73 | - * @param JWKSet $set |
|
74 | - * |
|
75 | - * @throws \UnexpectedValueException If a key cannot be found |
|
76 | - * |
|
77 | - * @return KeyManagementAlgorithm |
|
78 | - */ |
|
79 | - public function algoByKeys(JWKSet $set): KeyManagementAlgorithm |
|
80 | - { |
|
81 | - if (!$this->_header->hasKeyID()) { |
|
82 | - throw new \UnexpectedValueException('No key ID paremeter.'); |
|
83 | - } |
|
84 | - $id = $this->_header->keyID()->value(); |
|
85 | - if (!$set->hasKeyID($id)) { |
|
86 | - throw new \UnexpectedValueException("No key for ID '{$id}'."); |
|
87 | - } |
|
88 | - return $this->algoByKey($set->keyByID($id)); |
|
89 | - } |
|
70 | + /** |
|
71 | + * Get key management algorithm using a matching key from given JWK set. |
|
72 | + * |
|
73 | + * @param JWKSet $set |
|
74 | + * |
|
75 | + * @throws \UnexpectedValueException If a key cannot be found |
|
76 | + * |
|
77 | + * @return KeyManagementAlgorithm |
|
78 | + */ |
|
79 | + public function algoByKeys(JWKSet $set): KeyManagementAlgorithm |
|
80 | + { |
|
81 | + if (!$this->_header->hasKeyID()) { |
|
82 | + throw new \UnexpectedValueException('No key ID paremeter.'); |
|
83 | + } |
|
84 | + $id = $this->_header->keyID()->value(); |
|
85 | + if (!$set->hasKeyID($id)) { |
|
86 | + throw new \UnexpectedValueException("No key for ID '{$id}'."); |
|
87 | + } |
|
88 | + return $this->algoByKey($set->keyByID($id)); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Get the algorithm implementation class name by an algorithm name. |
|
93 | - * |
|
94 | - * @param string $alg Algorithm name |
|
95 | - * |
|
96 | - * @throws \UnexpectedValueException |
|
97 | - * |
|
98 | - * @return string Class name |
|
99 | - */ |
|
100 | - private static function _algoClassByName(string $alg): string |
|
101 | - { |
|
102 | - if (!array_key_exists($alg, self::MAP_ALGO_TO_CLASS)) { |
|
103 | - throw new \UnexpectedValueException( |
|
104 | - "Algorithm '{$alg}' not supported."); |
|
105 | - } |
|
106 | - return self::MAP_ALGO_TO_CLASS[$alg]; |
|
107 | - } |
|
91 | + /** |
|
92 | + * Get the algorithm implementation class name by an algorithm name. |
|
93 | + * |
|
94 | + * @param string $alg Algorithm name |
|
95 | + * |
|
96 | + * @throws \UnexpectedValueException |
|
97 | + * |
|
98 | + * @return string Class name |
|
99 | + */ |
|
100 | + private static function _algoClassByName(string $alg): string |
|
101 | + { |
|
102 | + if (!array_key_exists($alg, self::MAP_ALGO_TO_CLASS)) { |
|
103 | + throw new \UnexpectedValueException( |
|
104 | + "Algorithm '{$alg}' not supported."); |
|
105 | + } |
|
106 | + return self::MAP_ALGO_TO_CLASS[$alg]; |
|
107 | + } |
|
108 | 108 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Sop\JWX\JWE\KeyAlgorithm; |
6 | 6 |
@@ -12,21 +12,21 @@ |
||
12 | 12 | */ |
13 | 13 | interface CompressionAlgorithm extends CompressionAlgorithmParameterValue, HeaderParameters |
14 | 14 | { |
15 | - /** |
|
16 | - * Compress data. |
|
17 | - * |
|
18 | - * @param string $data Uncompressed data |
|
19 | - * |
|
20 | - * @return string Compressed data |
|
21 | - */ |
|
22 | - public function compress(string $data): string; |
|
15 | + /** |
|
16 | + * Compress data. |
|
17 | + * |
|
18 | + * @param string $data Uncompressed data |
|
19 | + * |
|
20 | + * @return string Compressed data |
|
21 | + */ |
|
22 | + public function compress(string $data): string; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Decompress data. |
|
26 | - * |
|
27 | - * @param string $data Compressed data |
|
28 | - * |
|
29 | - * @return string Uncompressed data |
|
30 | - */ |
|
31 | - public function decompress(string $data): string; |
|
24 | + /** |
|
25 | + * Decompress data. |
|
26 | + * |
|
27 | + * @param string $data Compressed data |
|
28 | + * |
|
29 | + * @return string Uncompressed data |
|
30 | + */ |
|
31 | + public function decompress(string $data): string; |
|
32 | 32 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Sop\JWX\JWE; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Sop\JWX\JWT\Claim; |
6 | 6 |
@@ -14,118 +14,118 @@ |
||
14 | 14 | */ |
15 | 15 | class Claim |
16 | 16 | { |
17 | - /** |
|
18 | - * Claim name. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $_name; |
|
17 | + /** |
|
18 | + * Claim name. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $_name; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Claim value. |
|
26 | - * |
|
27 | - * @var mixed |
|
28 | - */ |
|
29 | - protected $_value; |
|
24 | + /** |
|
25 | + * Claim value. |
|
26 | + * |
|
27 | + * @var mixed |
|
28 | + */ |
|
29 | + protected $_value; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Claim validator. |
|
33 | - * |
|
34 | - * @var null|Validator |
|
35 | - */ |
|
36 | - protected $_validator; |
|
31 | + /** |
|
32 | + * Claim validator. |
|
33 | + * |
|
34 | + * @var null|Validator |
|
35 | + */ |
|
36 | + protected $_validator; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Constructor. |
|
40 | - * |
|
41 | - * @param string $name Claim name |
|
42 | - * @param mixed $value Claim value |
|
43 | - * @param null|Validator $validator Claim validator or null if claim doesn't |
|
44 | - * provide validation |
|
45 | - */ |
|
46 | - public function __construct(string $name, $value, ?Validator $validator = null) |
|
47 | - { |
|
48 | - $this->_name = $name; |
|
49 | - $this->_value = $value; |
|
50 | - $this->_validator = $validator; |
|
51 | - } |
|
38 | + /** |
|
39 | + * Constructor. |
|
40 | + * |
|
41 | + * @param string $name Claim name |
|
42 | + * @param mixed $value Claim value |
|
43 | + * @param null|Validator $validator Claim validator or null if claim doesn't |
|
44 | + * provide validation |
|
45 | + */ |
|
46 | + public function __construct(string $name, $value, ?Validator $validator = null) |
|
47 | + { |
|
48 | + $this->_name = $name; |
|
49 | + $this->_value = $value; |
|
50 | + $this->_validator = $validator; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Initialize from a name and a value. |
|
55 | - * |
|
56 | - * Returns a specific claim object if applicable. |
|
57 | - * |
|
58 | - * @param string $name Claim name |
|
59 | - * @param mixed $value Claim value |
|
60 | - * |
|
61 | - * @return Claim |
|
62 | - */ |
|
63 | - public static function fromNameAndValue(string $name, $value): Claim |
|
64 | - { |
|
65 | - if (array_key_exists($name, RegisteredClaim::MAP_NAME_TO_CLASS)) { |
|
66 | - $cls = RegisteredClaim::MAP_NAME_TO_CLASS[$name]; |
|
67 | - return $cls::fromJSONValue($value); |
|
68 | - } |
|
69 | - return new self($name, $value); |
|
70 | - } |
|
53 | + /** |
|
54 | + * Initialize from a name and a value. |
|
55 | + * |
|
56 | + * Returns a specific claim object if applicable. |
|
57 | + * |
|
58 | + * @param string $name Claim name |
|
59 | + * @param mixed $value Claim value |
|
60 | + * |
|
61 | + * @return Claim |
|
62 | + */ |
|
63 | + public static function fromNameAndValue(string $name, $value): Claim |
|
64 | + { |
|
65 | + if (array_key_exists($name, RegisteredClaim::MAP_NAME_TO_CLASS)) { |
|
66 | + $cls = RegisteredClaim::MAP_NAME_TO_CLASS[$name]; |
|
67 | + return $cls::fromJSONValue($value); |
|
68 | + } |
|
69 | + return new self($name, $value); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Get the claim name. |
|
74 | - * |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function name(): string |
|
78 | - { |
|
79 | - return $this->_name; |
|
80 | - } |
|
72 | + /** |
|
73 | + * Get the claim name. |
|
74 | + * |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function name(): string |
|
78 | + { |
|
79 | + return $this->_name; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Get the claim value. |
|
84 | - * |
|
85 | - * @return mixed |
|
86 | - */ |
|
87 | - public function value() |
|
88 | - { |
|
89 | - return $this->_value; |
|
90 | - } |
|
82 | + /** |
|
83 | + * Get the claim value. |
|
84 | + * |
|
85 | + * @return mixed |
|
86 | + */ |
|
87 | + public function value() |
|
88 | + { |
|
89 | + return $this->_value; |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Validate the claim against a given constraint. |
|
94 | - * |
|
95 | - * @param mixed $constraint Constraint value |
|
96 | - * |
|
97 | - * @return bool True if the claim is valid |
|
98 | - */ |
|
99 | - public function validate($constraint): bool |
|
100 | - { |
|
101 | - // if claim has no validator, consider validation failed |
|
102 | - if (!isset($this->_validator)) { |
|
103 | - return false; |
|
104 | - } |
|
105 | - return $this->_validator->validate($this->_value, $constraint); |
|
106 | - } |
|
92 | + /** |
|
93 | + * Validate the claim against a given constraint. |
|
94 | + * |
|
95 | + * @param mixed $constraint Constraint value |
|
96 | + * |
|
97 | + * @return bool True if the claim is valid |
|
98 | + */ |
|
99 | + public function validate($constraint): bool |
|
100 | + { |
|
101 | + // if claim has no validator, consider validation failed |
|
102 | + if (!isset($this->_validator)) { |
|
103 | + return false; |
|
104 | + } |
|
105 | + return $this->_validator->validate($this->_value, $constraint); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Validate the claim in a given context. |
|
110 | - * |
|
111 | - * Overridden in specific claims that provide default validation. |
|
112 | - * |
|
113 | - * @param ValidationContext $ctx |
|
114 | - * |
|
115 | - * @return bool True if claim is valid |
|
116 | - */ |
|
117 | - public function validateWithContext(ValidationContext $ctx): bool |
|
118 | - { |
|
119 | - // if validator has no constraint for the claim |
|
120 | - if (!$ctx->hasConstraint($this->_name)) { |
|
121 | - return true; |
|
122 | - } |
|
123 | - // if validation context has an explicitly defined validator for the claim |
|
124 | - if ($ctx->hasValidator($this->_name)) { |
|
125 | - return $ctx->validator($this->_name) |
|
126 | - ->validate($this->_value, $ctx->constraint($this->_name)); |
|
127 | - } |
|
128 | - // validate using claim's default validator |
|
129 | - return $this->validate($ctx->constraint($this->_name)); |
|
130 | - } |
|
108 | + /** |
|
109 | + * Validate the claim in a given context. |
|
110 | + * |
|
111 | + * Overridden in specific claims that provide default validation. |
|
112 | + * |
|
113 | + * @param ValidationContext $ctx |
|
114 | + * |
|
115 | + * @return bool True if claim is valid |
|
116 | + */ |
|
117 | + public function validateWithContext(ValidationContext $ctx): bool |
|
118 | + { |
|
119 | + // if validator has no constraint for the claim |
|
120 | + if (!$ctx->hasConstraint($this->_name)) { |
|
121 | + return true; |
|
122 | + } |
|
123 | + // if validation context has an explicitly defined validator for the claim |
|
124 | + if ($ctx->hasValidator($this->_name)) { |
|
125 | + return $ctx->validator($this->_name) |
|
126 | + ->validate($this->_value, $ctx->constraint($this->_name)); |
|
127 | + } |
|
128 | + // validate using claim's default validator |
|
129 | + return $this->validate($ctx->constraint($this->_name)); |
|
130 | + } |
|
131 | 131 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Sop\JWX\JWT; |
6 | 6 |
@@ -29,339 +29,339 @@ |
||
29 | 29 | */ |
30 | 30 | class ValidationContext |
31 | 31 | { |
32 | - /** |
|
33 | - * Reference time. |
|
34 | - * |
|
35 | - * @var int |
|
36 | - */ |
|
37 | - protected $_refTime; |
|
32 | + /** |
|
33 | + * Reference time. |
|
34 | + * |
|
35 | + * @var int |
|
36 | + */ |
|
37 | + protected $_refTime; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Leeway in seconds for the reference time constraints. |
|
41 | - * |
|
42 | - * @var int |
|
43 | - */ |
|
44 | - protected $_leeway; |
|
39 | + /** |
|
40 | + * Leeway in seconds for the reference time constraints. |
|
41 | + * |
|
42 | + * @var int |
|
43 | + */ |
|
44 | + protected $_leeway; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Validation constraints. |
|
48 | - * |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - protected $_constraints; |
|
46 | + /** |
|
47 | + * Validation constraints. |
|
48 | + * |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + protected $_constraints; |
|
52 | 52 | |
53 | - /** |
|
54 | - * Explicitly defined validators for named claims. |
|
55 | - * |
|
56 | - * @var Validator[] |
|
57 | - */ |
|
58 | - protected $_validators; |
|
53 | + /** |
|
54 | + * Explicitly defined validators for named claims. |
|
55 | + * |
|
56 | + * @var Validator[] |
|
57 | + */ |
|
58 | + protected $_validators; |
|
59 | 59 | |
60 | - /** |
|
61 | - * Set of JSON Web Keys usable for the validation. |
|
62 | - * |
|
63 | - * @var JWKSet |
|
64 | - */ |
|
65 | - protected $_keys; |
|
60 | + /** |
|
61 | + * Set of JSON Web Keys usable for the validation. |
|
62 | + * |
|
63 | + * @var JWKSet |
|
64 | + */ |
|
65 | + protected $_keys; |
|
66 | 66 | |
67 | - /** |
|
68 | - * Whether to allow unsecured JWT's, that is, claims without integrity |
|
69 | - * protection nor encryption. |
|
70 | - * |
|
71 | - * @var bool |
|
72 | - */ |
|
73 | - protected $_allowUnsecured; |
|
67 | + /** |
|
68 | + * Whether to allow unsecured JWT's, that is, claims without integrity |
|
69 | + * protection nor encryption. |
|
70 | + * |
|
71 | + * @var bool |
|
72 | + */ |
|
73 | + protected $_allowUnsecured; |
|
74 | 74 | |
75 | - /** |
|
76 | - * Constructor. |
|
77 | - * |
|
78 | - * @param null|array $constraints Optional array of constraints for the |
|
79 | - * registered claims |
|
80 | - * @param null|JWKSet $keys Optional set of JSON Web Keys used for |
|
81 | - * signature validation and/or decryption |
|
82 | - */ |
|
83 | - public function __construct(?array $constraints = null, ?JWKSet $keys = null) |
|
84 | - { |
|
85 | - $this->_refTime = time(); |
|
86 | - $this->_leeway = 60; |
|
87 | - $this->_constraints = $constraints ? $constraints : []; |
|
88 | - $this->_validators = []; |
|
89 | - $this->_keys = $keys ? $keys : new JWKSet(); |
|
90 | - $this->_allowUnsecured = false; |
|
91 | - } |
|
75 | + /** |
|
76 | + * Constructor. |
|
77 | + * |
|
78 | + * @param null|array $constraints Optional array of constraints for the |
|
79 | + * registered claims |
|
80 | + * @param null|JWKSet $keys Optional set of JSON Web Keys used for |
|
81 | + * signature validation and/or decryption |
|
82 | + */ |
|
83 | + public function __construct(?array $constraints = null, ?JWKSet $keys = null) |
|
84 | + { |
|
85 | + $this->_refTime = time(); |
|
86 | + $this->_leeway = 60; |
|
87 | + $this->_constraints = $constraints ? $constraints : []; |
|
88 | + $this->_validators = []; |
|
89 | + $this->_keys = $keys ? $keys : new JWKSet(); |
|
90 | + $this->_allowUnsecured = false; |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Initialize with a single JSON Web Key. |
|
95 | - * |
|
96 | - * @param JWK $key JSON Web Key |
|
97 | - * @param null|array $constraints Optional constraints |
|
98 | - * |
|
99 | - * @return self |
|
100 | - */ |
|
101 | - public static function fromJWK(JWK $key, ?array $constraints = null): self |
|
102 | - { |
|
103 | - return new self($constraints, new JWKSet($key)); |
|
104 | - } |
|
93 | + /** |
|
94 | + * Initialize with a single JSON Web Key. |
|
95 | + * |
|
96 | + * @param JWK $key JSON Web Key |
|
97 | + * @param null|array $constraints Optional constraints |
|
98 | + * |
|
99 | + * @return self |
|
100 | + */ |
|
101 | + public static function fromJWK(JWK $key, ?array $constraints = null): self |
|
102 | + { |
|
103 | + return new self($constraints, new JWKSet($key)); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Get self with the reference time. |
|
108 | - * |
|
109 | - * @param null|int $ts Unix timestamp |
|
110 | - * |
|
111 | - * @return self |
|
112 | - */ |
|
113 | - public function withReferenceTime(?int $ts): self |
|
114 | - { |
|
115 | - $obj = clone $this; |
|
116 | - $obj->_refTime = $ts; |
|
117 | - return $obj; |
|
118 | - } |
|
106 | + /** |
|
107 | + * Get self with the reference time. |
|
108 | + * |
|
109 | + * @param null|int $ts Unix timestamp |
|
110 | + * |
|
111 | + * @return self |
|
112 | + */ |
|
113 | + public function withReferenceTime(?int $ts): self |
|
114 | + { |
|
115 | + $obj = clone $this; |
|
116 | + $obj->_refTime = $ts; |
|
117 | + return $obj; |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Check whether the reference time is set. |
|
122 | - * |
|
123 | - * @return bool |
|
124 | - */ |
|
125 | - public function hasReferenceTime(): bool |
|
126 | - { |
|
127 | - return isset($this->_refTime); |
|
128 | - } |
|
120 | + /** |
|
121 | + * Check whether the reference time is set. |
|
122 | + * |
|
123 | + * @return bool |
|
124 | + */ |
|
125 | + public function hasReferenceTime(): bool |
|
126 | + { |
|
127 | + return isset($this->_refTime); |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Get the reference time. |
|
132 | - * |
|
133 | - * @throws \LogicException |
|
134 | - * |
|
135 | - * @return int |
|
136 | - */ |
|
137 | - public function referenceTime(): int |
|
138 | - { |
|
139 | - if (!$this->hasReferenceTime()) { |
|
140 | - throw new \LogicException('Reference time not set.'); |
|
141 | - } |
|
142 | - return $this->_refTime; |
|
143 | - } |
|
130 | + /** |
|
131 | + * Get the reference time. |
|
132 | + * |
|
133 | + * @throws \LogicException |
|
134 | + * |
|
135 | + * @return int |
|
136 | + */ |
|
137 | + public function referenceTime(): int |
|
138 | + { |
|
139 | + if (!$this->hasReferenceTime()) { |
|
140 | + throw new \LogicException('Reference time not set.'); |
|
141 | + } |
|
142 | + return $this->_refTime; |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Get self with the reference time leeway. |
|
147 | - * |
|
148 | - * @param int $seconds |
|
149 | - * |
|
150 | - * @return self |
|
151 | - */ |
|
152 | - public function withLeeway(int $seconds): self |
|
153 | - { |
|
154 | - $obj = clone $this; |
|
155 | - $obj->_leeway = $seconds; |
|
156 | - return $obj; |
|
157 | - } |
|
145 | + /** |
|
146 | + * Get self with the reference time leeway. |
|
147 | + * |
|
148 | + * @param int $seconds |
|
149 | + * |
|
150 | + * @return self |
|
151 | + */ |
|
152 | + public function withLeeway(int $seconds): self |
|
153 | + { |
|
154 | + $obj = clone $this; |
|
155 | + $obj->_leeway = $seconds; |
|
156 | + return $obj; |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Get the reference time leeway. |
|
161 | - * |
|
162 | - * @return int |
|
163 | - */ |
|
164 | - public function leeway(): int |
|
165 | - { |
|
166 | - return $this->_leeway; |
|
167 | - } |
|
159 | + /** |
|
160 | + * Get the reference time leeway. |
|
161 | + * |
|
162 | + * @return int |
|
163 | + */ |
|
164 | + public function leeway(): int |
|
165 | + { |
|
166 | + return $this->_leeway; |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * Get self with a validation constraint. |
|
171 | - * |
|
172 | - * If the claim does not provide its own validator, an explicit validator |
|
173 | - * must be given. |
|
174 | - * |
|
175 | - * @param string $name Claim name |
|
176 | - * @param mixed $constraint Value to check claim against |
|
177 | - * @param null|Validator $validator Optional explicit validator |
|
178 | - * |
|
179 | - * @return self |
|
180 | - */ |
|
181 | - public function withConstraint(string $name, $constraint, |
|
182 | - ?Validator $validator = null): self |
|
183 | - { |
|
184 | - $obj = clone $this; |
|
185 | - $obj->_constraints[$name] = $constraint; |
|
186 | - if ($validator) { |
|
187 | - $obj->_validators[$name] = $validator; |
|
188 | - } |
|
189 | - return $obj; |
|
190 | - } |
|
169 | + /** |
|
170 | + * Get self with a validation constraint. |
|
171 | + * |
|
172 | + * If the claim does not provide its own validator, an explicit validator |
|
173 | + * must be given. |
|
174 | + * |
|
175 | + * @param string $name Claim name |
|
176 | + * @param mixed $constraint Value to check claim against |
|
177 | + * @param null|Validator $validator Optional explicit validator |
|
178 | + * |
|
179 | + * @return self |
|
180 | + */ |
|
181 | + public function withConstraint(string $name, $constraint, |
|
182 | + ?Validator $validator = null): self |
|
183 | + { |
|
184 | + $obj = clone $this; |
|
185 | + $obj->_constraints[$name] = $constraint; |
|
186 | + if ($validator) { |
|
187 | + $obj->_validators[$name] = $validator; |
|
188 | + } |
|
189 | + return $obj; |
|
190 | + } |
|
191 | 191 | |
192 | - /** |
|
193 | - * Get self with the issuer constraint. |
|
194 | - * |
|
195 | - * @param string $issuer Issuer name |
|
196 | - * |
|
197 | - * @return self |
|
198 | - */ |
|
199 | - public function withIssuer(string $issuer): self |
|
200 | - { |
|
201 | - return $this->withConstraint(RegisteredClaim::NAME_ISSUER, $issuer); |
|
202 | - } |
|
192 | + /** |
|
193 | + * Get self with the issuer constraint. |
|
194 | + * |
|
195 | + * @param string $issuer Issuer name |
|
196 | + * |
|
197 | + * @return self |
|
198 | + */ |
|
199 | + public function withIssuer(string $issuer): self |
|
200 | + { |
|
201 | + return $this->withConstraint(RegisteredClaim::NAME_ISSUER, $issuer); |
|
202 | + } |
|
203 | 203 | |
204 | - /** |
|
205 | - * Get self with the subject constraint. |
|
206 | - * |
|
207 | - * @param string $subject Subject name |
|
208 | - * |
|
209 | - * @return self |
|
210 | - */ |
|
211 | - public function withSubject(string $subject): self |
|
212 | - { |
|
213 | - return $this->withConstraint(RegisteredClaim::NAME_SUBJECT, $subject); |
|
214 | - } |
|
204 | + /** |
|
205 | + * Get self with the subject constraint. |
|
206 | + * |
|
207 | + * @param string $subject Subject name |
|
208 | + * |
|
209 | + * @return self |
|
210 | + */ |
|
211 | + public function withSubject(string $subject): self |
|
212 | + { |
|
213 | + return $this->withConstraint(RegisteredClaim::NAME_SUBJECT, $subject); |
|
214 | + } |
|
215 | 215 | |
216 | - /** |
|
217 | - * Get self with the audience constraint. |
|
218 | - * |
|
219 | - * @param string $audience Audience name |
|
220 | - * |
|
221 | - * @return self |
|
222 | - */ |
|
223 | - public function withAudience(string $audience): self |
|
224 | - { |
|
225 | - return $this->withConstraint(RegisteredClaim::NAME_AUDIENCE, $audience); |
|
226 | - } |
|
216 | + /** |
|
217 | + * Get self with the audience constraint. |
|
218 | + * |
|
219 | + * @param string $audience Audience name |
|
220 | + * |
|
221 | + * @return self |
|
222 | + */ |
|
223 | + public function withAudience(string $audience): self |
|
224 | + { |
|
225 | + return $this->withConstraint(RegisteredClaim::NAME_AUDIENCE, $audience); |
|
226 | + } |
|
227 | 227 | |
228 | - /** |
|
229 | - * Get self with the JWT ID constraint. |
|
230 | - * |
|
231 | - * @param string $id JWT ID |
|
232 | - * |
|
233 | - * @return self |
|
234 | - */ |
|
235 | - public function withID(string $id): self |
|
236 | - { |
|
237 | - return $this->withConstraint(RegisteredClaim::NAME_JWT_ID, $id); |
|
238 | - } |
|
228 | + /** |
|
229 | + * Get self with the JWT ID constraint. |
|
230 | + * |
|
231 | + * @param string $id JWT ID |
|
232 | + * |
|
233 | + * @return self |
|
234 | + */ |
|
235 | + public function withID(string $id): self |
|
236 | + { |
|
237 | + return $this->withConstraint(RegisteredClaim::NAME_JWT_ID, $id); |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * Check whether a named constraint is present. |
|
242 | - * |
|
243 | - * @param string $name Claim name |
|
244 | - * |
|
245 | - * @return bool |
|
246 | - */ |
|
247 | - public function hasConstraint(string $name): bool |
|
248 | - { |
|
249 | - return isset($this->_constraints[$name]); |
|
250 | - } |
|
240 | + /** |
|
241 | + * Check whether a named constraint is present. |
|
242 | + * |
|
243 | + * @param string $name Claim name |
|
244 | + * |
|
245 | + * @return bool |
|
246 | + */ |
|
247 | + public function hasConstraint(string $name): bool |
|
248 | + { |
|
249 | + return isset($this->_constraints[$name]); |
|
250 | + } |
|
251 | 251 | |
252 | - /** |
|
253 | - * Get a constraint value by the claim name. |
|
254 | - * |
|
255 | - * @param string $name Claim name |
|
256 | - * |
|
257 | - * @throws \LogicException If constraint is not set |
|
258 | - * |
|
259 | - * @return mixed Constraint value |
|
260 | - */ |
|
261 | - public function constraint(string $name) |
|
262 | - { |
|
263 | - if (!$this->hasConstraint($name)) { |
|
264 | - throw new \LogicException("Constraint {$name} not set."); |
|
265 | - } |
|
266 | - return $this->_constraints[$name]; |
|
267 | - } |
|
252 | + /** |
|
253 | + * Get a constraint value by the claim name. |
|
254 | + * |
|
255 | + * @param string $name Claim name |
|
256 | + * |
|
257 | + * @throws \LogicException If constraint is not set |
|
258 | + * |
|
259 | + * @return mixed Constraint value |
|
260 | + */ |
|
261 | + public function constraint(string $name) |
|
262 | + { |
|
263 | + if (!$this->hasConstraint($name)) { |
|
264 | + throw new \LogicException("Constraint {$name} not set."); |
|
265 | + } |
|
266 | + return $this->_constraints[$name]; |
|
267 | + } |
|
268 | 268 | |
269 | - /** |
|
270 | - * Check whether a validator is defined for the given claim name. |
|
271 | - * |
|
272 | - * @param string $name Claim name |
|
273 | - * |
|
274 | - * @return bool |
|
275 | - */ |
|
276 | - public function hasValidator(string $name): bool |
|
277 | - { |
|
278 | - return isset($this->_validators[$name]); |
|
279 | - } |
|
269 | + /** |
|
270 | + * Check whether a validator is defined for the given claim name. |
|
271 | + * |
|
272 | + * @param string $name Claim name |
|
273 | + * |
|
274 | + * @return bool |
|
275 | + */ |
|
276 | + public function hasValidator(string $name): bool |
|
277 | + { |
|
278 | + return isset($this->_validators[$name]); |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * Get explicitly defined validator by the claim name. |
|
283 | - * |
|
284 | - * @param string $name Claim name |
|
285 | - * |
|
286 | - * @throws \LogicException If validator is not set |
|
287 | - * |
|
288 | - * @return Validator |
|
289 | - */ |
|
290 | - public function validator(string $name): Validator |
|
291 | - { |
|
292 | - if (!$this->hasValidator($name)) { |
|
293 | - throw new \LogicException("Validator {$name} not set."); |
|
294 | - } |
|
295 | - return $this->_validators[$name]; |
|
296 | - } |
|
281 | + /** |
|
282 | + * Get explicitly defined validator by the claim name. |
|
283 | + * |
|
284 | + * @param string $name Claim name |
|
285 | + * |
|
286 | + * @throws \LogicException If validator is not set |
|
287 | + * |
|
288 | + * @return Validator |
|
289 | + */ |
|
290 | + public function validator(string $name): Validator |
|
291 | + { |
|
292 | + if (!$this->hasValidator($name)) { |
|
293 | + throw new \LogicException("Validator {$name} not set."); |
|
294 | + } |
|
295 | + return $this->_validators[$name]; |
|
296 | + } |
|
297 | 297 | |
298 | - /** |
|
299 | - * Get a set of JSON Web Keys defined in this context. |
|
300 | - * |
|
301 | - * @return JWKSet |
|
302 | - */ |
|
303 | - public function keys(): JWKSet |
|
304 | - { |
|
305 | - return $this->_keys; |
|
306 | - } |
|
298 | + /** |
|
299 | + * Get a set of JSON Web Keys defined in this context. |
|
300 | + * |
|
301 | + * @return JWKSet |
|
302 | + */ |
|
303 | + public function keys(): JWKSet |
|
304 | + { |
|
305 | + return $this->_keys; |
|
306 | + } |
|
307 | 307 | |
308 | - /** |
|
309 | - * Get self with 'allow unsecured' flag set. |
|
310 | - * |
|
311 | - * If the unsecured JWT's are allowed, claims shall be considered valid even |
|
312 | - * though they are not signed nor encrypted. |
|
313 | - * |
|
314 | - * @param bool $allow Whether to allow unsecured JWT's |
|
315 | - * |
|
316 | - * @return self |
|
317 | - */ |
|
318 | - public function withUnsecuredAllowed(bool $allow): self |
|
319 | - { |
|
320 | - $obj = clone $this; |
|
321 | - $obj->_allowUnsecured = $allow; |
|
322 | - return $obj; |
|
323 | - } |
|
308 | + /** |
|
309 | + * Get self with 'allow unsecured' flag set. |
|
310 | + * |
|
311 | + * If the unsecured JWT's are allowed, claims shall be considered valid even |
|
312 | + * though they are not signed nor encrypted. |
|
313 | + * |
|
314 | + * @param bool $allow Whether to allow unsecured JWT's |
|
315 | + * |
|
316 | + * @return self |
|
317 | + */ |
|
318 | + public function withUnsecuredAllowed(bool $allow): self |
|
319 | + { |
|
320 | + $obj = clone $this; |
|
321 | + $obj->_allowUnsecured = $allow; |
|
322 | + return $obj; |
|
323 | + } |
|
324 | 324 | |
325 | - /** |
|
326 | - * Check whether the unsecured JWT's are allowed. |
|
327 | - * |
|
328 | - * @return bool |
|
329 | - */ |
|
330 | - public function isUnsecuredAllowed(): bool |
|
331 | - { |
|
332 | - return $this->_allowUnsecured; |
|
333 | - } |
|
325 | + /** |
|
326 | + * Check whether the unsecured JWT's are allowed. |
|
327 | + * |
|
328 | + * @return bool |
|
329 | + */ |
|
330 | + public function isUnsecuredAllowed(): bool |
|
331 | + { |
|
332 | + return $this->_allowUnsecured; |
|
333 | + } |
|
334 | 334 | |
335 | - /** |
|
336 | - * Validate claims. |
|
337 | - * |
|
338 | - * @param Claims $claims |
|
339 | - * |
|
340 | - * @throws ValidationException If any of the claims is not valid |
|
341 | - * |
|
342 | - * @return self |
|
343 | - */ |
|
344 | - public function validate(Claims $claims): self |
|
345 | - { |
|
346 | - $claimset = iterator_to_array($claims); |
|
347 | - // validate required constraints |
|
348 | - foreach (array_keys($this->_constraints) as $name) { |
|
349 | - if (!isset($claimset[$name])) { |
|
350 | - throw new ValidationException("Claim '{$name}' is required."); |
|
351 | - } |
|
352 | - if (!$claimset[$name]->validateWithContext($this)) { |
|
353 | - throw new ValidationException( |
|
354 | - "Validation of claim '{$name}' failed."); |
|
355 | - } |
|
356 | - unset($claimset[$name]); |
|
357 | - } |
|
358 | - // validate remaining claims using default validators |
|
359 | - foreach ($claimset as $name => $claim) { |
|
360 | - if (!$claim->validateWithContext($this)) { |
|
361 | - throw new ValidationException( |
|
362 | - "Validation of claim '{$name}' failed."); |
|
363 | - } |
|
364 | - } |
|
365 | - return $this; |
|
366 | - } |
|
335 | + /** |
|
336 | + * Validate claims. |
|
337 | + * |
|
338 | + * @param Claims $claims |
|
339 | + * |
|
340 | + * @throws ValidationException If any of the claims is not valid |
|
341 | + * |
|
342 | + * @return self |
|
343 | + */ |
|
344 | + public function validate(Claims $claims): self |
|
345 | + { |
|
346 | + $claimset = iterator_to_array($claims); |
|
347 | + // validate required constraints |
|
348 | + foreach (array_keys($this->_constraints) as $name) { |
|
349 | + if (!isset($claimset[$name])) { |
|
350 | + throw new ValidationException("Claim '{$name}' is required."); |
|
351 | + } |
|
352 | + if (!$claimset[$name]->validateWithContext($this)) { |
|
353 | + throw new ValidationException( |
|
354 | + "Validation of claim '{$name}' failed."); |
|
355 | + } |
|
356 | + unset($claimset[$name]); |
|
357 | + } |
|
358 | + // validate remaining claims using default validators |
|
359 | + foreach ($claimset as $name => $claim) { |
|
360 | + if (!$claim->validateWithContext($this)) { |
|
361 | + throw new ValidationException( |
|
362 | + "Validation of claim '{$name}' failed."); |
|
363 | + } |
|
364 | + } |
|
365 | + return $this; |
|
366 | + } |
|
367 | 367 | } |
@@ -15,28 +15,28 @@ |
||
15 | 15 | */ |
16 | 16 | trait Base64UIntValue |
17 | 17 | { |
18 | - use Base64URLValue; |
|
18 | + use Base64URLValue; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Initialize parameter from base10 number. |
|
22 | - * |
|
23 | - * @param int|string $number |
|
24 | - * |
|
25 | - * @return self |
|
26 | - */ |
|
27 | - public static function fromNumber($number): Parameter |
|
28 | - { |
|
29 | - $data = BigInt::fromBase10($number)->base256(); |
|
30 | - return static::fromString($data); |
|
31 | - } |
|
20 | + /** |
|
21 | + * Initialize parameter from base10 number. |
|
22 | + * |
|
23 | + * @param int|string $number |
|
24 | + * |
|
25 | + * @return self |
|
26 | + */ |
|
27 | + public static function fromNumber($number): Parameter |
|
28 | + { |
|
29 | + $data = BigInt::fromBase10($number)->base256(); |
|
30 | + return static::fromString($data); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Get value as a number. |
|
35 | - * |
|
36 | - * @return BigInt |
|
37 | - */ |
|
38 | - public function number(): BigInt |
|
39 | - { |
|
40 | - return BigInt::fromBase256(Base64::urlDecode($this->value())); |
|
41 | - } |
|
33 | + /** |
|
34 | + * Get value as a number. |
|
35 | + * |
|
36 | + * @return BigInt |
|
37 | + */ |
|
38 | + public function number(): BigInt |
|
39 | + { |
|
40 | + return BigInt::fromBase256(Base64::urlDecode($this->value())); |
|
41 | + } |
|
42 | 42 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Sop\JWX\Parameter\Feature; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Sop\JWX\JWE\EncryptionAlgorithm; |
6 | 6 |
@@ -13,19 +13,19 @@ |
||
13 | 13 | */ |
14 | 14 | class A256GCMAlgorithm extends AESGCMAlgorithm |
15 | 15 | { |
16 | - /** |
|
17 | - * {@inheritdoc} |
|
18 | - */ |
|
19 | - public function encryptionAlgorithmParamValue(): string |
|
20 | - { |
|
21 | - return JWA::ALGO_A256GCM; |
|
22 | - } |
|
16 | + /** |
|
17 | + * {@inheritdoc} |
|
18 | + */ |
|
19 | + public function encryptionAlgorithmParamValue(): string |
|
20 | + { |
|
21 | + return JWA::ALGO_A256GCM; |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * {@inheritdoc} |
|
26 | - */ |
|
27 | - public function keySize(): int |
|
28 | - { |
|
29 | - return 32; |
|
30 | - } |
|
24 | + /** |
|
25 | + * {@inheritdoc} |
|
26 | + */ |
|
27 | + public function keySize(): int |
|
28 | + { |
|
29 | + return 32; |
|
30 | + } |
|
31 | 31 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Sop\JWX\JWE\EncryptionAlgorithm; |
6 | 6 |
@@ -13,19 +13,19 @@ |
||
13 | 13 | */ |
14 | 14 | class A192GCMAlgorithm extends AESGCMAlgorithm |
15 | 15 | { |
16 | - /** |
|
17 | - * {@inheritdoc} |
|
18 | - */ |
|
19 | - public function encryptionAlgorithmParamValue(): string |
|
20 | - { |
|
21 | - return JWA::ALGO_A192GCM; |
|
22 | - } |
|
16 | + /** |
|
17 | + * {@inheritdoc} |
|
18 | + */ |
|
19 | + public function encryptionAlgorithmParamValue(): string |
|
20 | + { |
|
21 | + return JWA::ALGO_A192GCM; |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * {@inheritdoc} |
|
26 | - */ |
|
27 | - public function keySize(): int |
|
28 | - { |
|
29 | - return 24; |
|
30 | - } |
|
24 | + /** |
|
25 | + * {@inheritdoc} |
|
26 | + */ |
|
27 | + public function keySize(): int |
|
28 | + { |
|
29 | + return 24; |
|
30 | + } |
|
31 | 31 | } |