@@ -9,10 +9,10 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | interface AlgorithmParameterValue |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Get algorithm type as an 'alg' parameter value. |
|
| 14 | - * |
|
| 15 | - * @return string |
|
| 16 | - */ |
|
| 17 | - public function algorithmParamValue(): string; |
|
| 12 | + /** |
|
| 13 | + * Get algorithm type as an 'alg' parameter value. |
|
| 14 | + * |
|
| 15 | + * @return string |
|
| 16 | + */ |
|
| 17 | + public function algorithmParamValue(): string; |
|
| 18 | 18 | } |
@@ -13,17 +13,17 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class X509CertificateSHA256ThumbprintParameter extends JWTParameter |
| 15 | 15 | { |
| 16 | - use Base64URLValue; |
|
| 16 | + use Base64URLValue; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Constructor. |
|
| 20 | - * |
|
| 21 | - * @param string $thumbprint Base64url encoded SHA-256 hash |
|
| 22 | - */ |
|
| 23 | - public function __construct(string $thumbprint) |
|
| 24 | - { |
|
| 25 | - $this->_validateEncoding($thumbprint); |
|
| 26 | - parent::__construct(self::PARAM_X509_CERTIFICATE_SHA256_THUMBPRINT, |
|
| 27 | - $thumbprint); |
|
| 28 | - } |
|
| 18 | + /** |
|
| 19 | + * Constructor. |
|
| 20 | + * |
|
| 21 | + * @param string $thumbprint Base64url encoded SHA-256 hash |
|
| 22 | + */ |
|
| 23 | + public function __construct(string $thumbprint) |
|
| 24 | + { |
|
| 25 | + $this->_validateEncoding($thumbprint); |
|
| 26 | + parent::__construct(self::PARAM_X509_CERTIFICATE_SHA256_THUMBPRINT, |
|
| 27 | + $thumbprint); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -13,27 +13,27 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class CompressionAlgorithmParameter extends JWTParameter |
| 15 | 15 | { |
| 16 | - use StringParameterValue; |
|
| 16 | + use StringParameterValue; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Constructor. |
|
| 20 | - * |
|
| 21 | - * @param string $algo |
|
| 22 | - */ |
|
| 23 | - public function __construct(string $algo) |
|
| 24 | - { |
|
| 25 | - parent::__construct(self::PARAM_COMPRESSION_ALGORITHM, $algo); |
|
| 26 | - } |
|
| 18 | + /** |
|
| 19 | + * Constructor. |
|
| 20 | + * |
|
| 21 | + * @param string $algo |
|
| 22 | + */ |
|
| 23 | + public function __construct(string $algo) |
|
| 24 | + { |
|
| 25 | + parent::__construct(self::PARAM_COMPRESSION_ALGORITHM, $algo); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Initialize from CompressionAlgorithmParameterValue. |
|
| 30 | - * |
|
| 31 | - * @param CompressionAlgorithmParameterValue $value |
|
| 32 | - * @return self |
|
| 33 | - */ |
|
| 34 | - public static function fromAlgorithm( |
|
| 35 | - CompressionAlgorithmParameterValue $value): self |
|
| 36 | - { |
|
| 37 | - return new self($value->compressionParamValue()); |
|
| 38 | - } |
|
| 28 | + /** |
|
| 29 | + * Initialize from CompressionAlgorithmParameterValue. |
|
| 30 | + * |
|
| 31 | + * @param CompressionAlgorithmParameterValue $value |
|
| 32 | + * @return self |
|
| 33 | + */ |
|
| 34 | + public static function fromAlgorithm( |
|
| 35 | + CompressionAlgorithmParameterValue $value): self |
|
| 36 | + { |
|
| 37 | + return new self($value->compressionParamValue()); |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -14,26 +14,26 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class AlgorithmParameter extends JWTParameter |
| 16 | 16 | { |
| 17 | - use StringParameterValue; |
|
| 17 | + use StringParameterValue; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param string $algo Algorithm name |
|
| 23 | - */ |
|
| 24 | - public function __construct(string $algo) |
|
| 25 | - { |
|
| 26 | - parent::__construct(self::PARAM_ALGORITHM, $algo); |
|
| 27 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param string $algo Algorithm name |
|
| 23 | + */ |
|
| 24 | + public function __construct(string $algo) |
|
| 25 | + { |
|
| 26 | + parent::__construct(self::PARAM_ALGORITHM, $algo); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Initialize from AlgorithmParameterValue. |
|
| 31 | - * |
|
| 32 | - * @param AlgorithmParameterValue $value |
|
| 33 | - * @return self |
|
| 34 | - */ |
|
| 35 | - public static function fromAlgorithm(AlgorithmParameterValue $value): self |
|
| 36 | - { |
|
| 37 | - return new self($value->algorithmParamValue()); |
|
| 38 | - } |
|
| 29 | + /** |
|
| 30 | + * Initialize from AlgorithmParameterValue. |
|
| 31 | + * |
|
| 32 | + * @param AlgorithmParameterValue $value |
|
| 33 | + * @return self |
|
| 34 | + */ |
|
| 35 | + public static function fromAlgorithm(AlgorithmParameterValue $value): self |
|
| 36 | + { |
|
| 37 | + return new self($value->algorithmParamValue()); |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -13,26 +13,26 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class AuthenticationTagParameter extends JWTParameter |
| 15 | 15 | { |
| 16 | - use Base64URLValue; |
|
| 16 | + use Base64URLValue; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Constructor. |
|
| 20 | - * |
|
| 21 | - * @param string $tag Base64url encoded authentication tag |
|
| 22 | - */ |
|
| 23 | - public function __construct(string $tag) |
|
| 24 | - { |
|
| 25 | - $this->_validateEncoding($tag); |
|
| 26 | - parent::__construct(self::PARAM_AUTHENTICATION_TAG, $tag); |
|
| 27 | - } |
|
| 18 | + /** |
|
| 19 | + * Constructor. |
|
| 20 | + * |
|
| 21 | + * @param string $tag Base64url encoded authentication tag |
|
| 22 | + */ |
|
| 23 | + public function __construct(string $tag) |
|
| 24 | + { |
|
| 25 | + $this->_validateEncoding($tag); |
|
| 26 | + parent::__construct(self::PARAM_AUTHENTICATION_TAG, $tag); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Get the authentication tag. |
|
| 31 | - * |
|
| 32 | - * @return string |
|
| 33 | - */ |
|
| 34 | - public function authenticationTag(): string |
|
| 35 | - { |
|
| 36 | - return $this->string(); |
|
| 37 | - } |
|
| 29 | + /** |
|
| 30 | + * Get the authentication tag. |
|
| 31 | + * |
|
| 32 | + * @return string |
|
| 33 | + */ |
|
| 34 | + public function authenticationTag(): string |
|
| 35 | + { |
|
| 36 | + return $this->string(); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -13,37 +13,37 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class PBES2SaltInputParameter extends JWTParameter |
| 15 | 15 | { |
| 16 | - use Base64URLValue; |
|
| 16 | + use Base64URLValue; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Constructor. |
|
| 20 | - * |
|
| 21 | - * @param string $salt Base64url encoded salt input value |
|
| 22 | - */ |
|
| 23 | - public function __construct(string $salt) |
|
| 24 | - { |
|
| 25 | - $this->_validateEncoding($salt); |
|
| 26 | - parent::__construct(self::PARAM_PBES2_SALT_INPUT, $salt); |
|
| 27 | - } |
|
| 18 | + /** |
|
| 19 | + * Constructor. |
|
| 20 | + * |
|
| 21 | + * @param string $salt Base64url encoded salt input value |
|
| 22 | + */ |
|
| 23 | + public function __construct(string $salt) |
|
| 24 | + { |
|
| 25 | + $this->_validateEncoding($salt); |
|
| 26 | + parent::__construct(self::PARAM_PBES2_SALT_INPUT, $salt); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Get salt input value. |
|
| 31 | - * |
|
| 32 | - * @return string |
|
| 33 | - */ |
|
| 34 | - public function saltInput(): string |
|
| 35 | - { |
|
| 36 | - return $this->string(); |
|
| 37 | - } |
|
| 29 | + /** |
|
| 30 | + * Get salt input value. |
|
| 31 | + * |
|
| 32 | + * @return string |
|
| 33 | + */ |
|
| 34 | + public function saltInput(): string |
|
| 35 | + { |
|
| 36 | + return $this->string(); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Get computed salt value. |
|
| 41 | - * |
|
| 42 | - * @param AlgorithmParameter $algo |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 45 | - public function salt(AlgorithmParameter $algo): string |
|
| 46 | - { |
|
| 47 | - return $algo->value() . "\0" . $this->saltInput(); |
|
| 48 | - } |
|
| 39 | + /** |
|
| 40 | + * Get computed salt value. |
|
| 41 | + * |
|
| 42 | + * @param AlgorithmParameter $algo |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | + public function salt(AlgorithmParameter $algo): string |
|
| 46 | + { |
|
| 47 | + return $algo->value() . "\0" . $this->saltInput(); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -13,50 +13,50 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class CriticalParameter extends JWTParameter |
| 15 | 15 | { |
| 16 | - use ArrayParameterValue; |
|
| 16 | + use ArrayParameterValue; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Constructor. |
|
| 20 | - * |
|
| 21 | - * @param string ...$names |
|
| 22 | - */ |
|
| 23 | - public function __construct(string ...$names) |
|
| 24 | - { |
|
| 25 | - parent::__construct(self::PARAM_CRITICAL, $names); |
|
| 26 | - } |
|
| 18 | + /** |
|
| 19 | + * Constructor. |
|
| 20 | + * |
|
| 21 | + * @param string ...$names |
|
| 22 | + */ |
|
| 23 | + public function __construct(string ...$names) |
|
| 24 | + { |
|
| 25 | + parent::__construct(self::PARAM_CRITICAL, $names); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Get self with parameter name added. |
|
| 30 | - * |
|
| 31 | - * @param string $name |
|
| 32 | - * @return self |
|
| 33 | - */ |
|
| 34 | - public function withParamName(string $name): self |
|
| 35 | - { |
|
| 36 | - $obj = clone $this; |
|
| 37 | - $obj->_value[] = $name; |
|
| 38 | - $obj->_value = array_values(array_unique($obj->_value)); |
|
| 39 | - return $obj; |
|
| 40 | - } |
|
| 28 | + /** |
|
| 29 | + * Get self with parameter name added. |
|
| 30 | + * |
|
| 31 | + * @param string $name |
|
| 32 | + * @return self |
|
| 33 | + */ |
|
| 34 | + public function withParamName(string $name): self |
|
| 35 | + { |
|
| 36 | + $obj = clone $this; |
|
| 37 | + $obj->_value[] = $name; |
|
| 38 | + $obj->_value = array_values(array_unique($obj->_value)); |
|
| 39 | + return $obj; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Check whether given parameter name is critical. |
|
| 44 | - * |
|
| 45 | - * @param string $name |
|
| 46 | - * @return bool |
|
| 47 | - */ |
|
| 48 | - public function has(string $name): bool |
|
| 49 | - { |
|
| 50 | - return false !== array_search($name, $this->_value); |
|
| 51 | - } |
|
| 42 | + /** |
|
| 43 | + * Check whether given parameter name is critical. |
|
| 44 | + * |
|
| 45 | + * @param string $name |
|
| 46 | + * @return bool |
|
| 47 | + */ |
|
| 48 | + public function has(string $name): bool |
|
| 49 | + { |
|
| 50 | + return false !== array_search($name, $this->_value); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Get critical header parameter names. |
|
| 55 | - * |
|
| 56 | - * @return string[] |
|
| 57 | - */ |
|
| 58 | - public function names(): array |
|
| 59 | - { |
|
| 60 | - return $this->_value; |
|
| 61 | - } |
|
| 53 | + /** |
|
| 54 | + * Get critical header parameter names. |
|
| 55 | + * |
|
| 56 | + * @return string[] |
|
| 57 | + */ |
|
| 58 | + public function names(): array |
|
| 59 | + { |
|
| 60 | + return $this->_value; |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -13,15 +13,15 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class TypeParameter extends JWTParameter |
| 15 | 15 | { |
| 16 | - use StringParameterValue; |
|
| 16 | + use StringParameterValue; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Constructor. |
|
| 20 | - * |
|
| 21 | - * @param string $type |
|
| 22 | - */ |
|
| 23 | - public function __construct(string $type) |
|
| 24 | - { |
|
| 25 | - parent::__construct(self::PARAM_TYPE, $type); |
|
| 26 | - } |
|
| 18 | + /** |
|
| 19 | + * Constructor. |
|
| 20 | + * |
|
| 21 | + * @param string $type |
|
| 22 | + */ |
|
| 23 | + public function __construct(string $type) |
|
| 24 | + { |
|
| 25 | + parent::__construct(self::PARAM_TYPE, $type); |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -11,24 +11,24 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class B64PayloadParameter extends JWTParameter |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Constructor. |
|
| 16 | - * |
|
| 17 | - * @param bool $flag |
|
| 18 | - */ |
|
| 19 | - public function __construct(bool $flag) |
|
| 20 | - { |
|
| 21 | - parent::__construct(self::PARAM_BASE64URL_ENCODE_PAYLOAD, $flag); |
|
| 22 | - } |
|
| 14 | + /** |
|
| 15 | + * Constructor. |
|
| 16 | + * |
|
| 17 | + * @param bool $flag |
|
| 18 | + */ |
|
| 19 | + public function __construct(bool $flag) |
|
| 20 | + { |
|
| 21 | + parent::__construct(self::PARAM_BASE64URL_ENCODE_PAYLOAD, $flag); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Initialize from a JSON value. |
|
| 26 | - * |
|
| 27 | - * @param bool $value |
|
| 28 | - * @return self |
|
| 29 | - */ |
|
| 30 | - public static function fromJSONValue($value): self |
|
| 31 | - { |
|
| 32 | - return new self(boolval($value)); |
|
| 33 | - } |
|
| 24 | + /** |
|
| 25 | + * Initialize from a JSON value. |
|
| 26 | + * |
|
| 27 | + * @param bool $value |
|
| 28 | + * @return self |
|
| 29 | + */ |
|
| 30 | + public static function fromJSONValue($value): self |
|
| 31 | + { |
|
| 32 | + return new self(boolval($value)); |
|
| 33 | + } |
|
| 34 | 34 | } |