@@ -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 | } |
@@ -15,121 +15,121 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class JWTParameter extends Parameter |
| 17 | 17 | { |
| 18 | - // registered parameter names |
|
| 19 | - const PARAM_ALGORITHM = "alg"; |
|
| 20 | - const PARAM_JWK_SET_URL = "jku"; |
|
| 21 | - const PARAM_JSON_WEB_KEY = "jwk"; |
|
| 22 | - const PARAM_KEY_ID = "kid"; |
|
| 23 | - const PARAM_X509_URL = "x5u"; |
|
| 24 | - const PARAM_X509_CERTIFICATE_CHAIN = "x5c"; |
|
| 25 | - const PARAM_X509_CERTIFICATE_SHA1_THUMBPRINT = "x5t"; |
|
| 26 | - const PARAM_X509_CERTIFICATE_SHA256_THUMBPRINT = "x5t#S256"; |
|
| 27 | - const PARAM_TYPE = "typ"; |
|
| 28 | - const PARAM_CONTENT_TYPE = "cty"; |
|
| 29 | - const PARAM_CRITICAL = "crit"; |
|
| 30 | - const PARAM_ENCRYPTION_ALGORITHM = "enc"; |
|
| 31 | - const PARAM_COMPRESSION_ALGORITHM = "zip"; |
|
| 32 | - const PARAM_EPHEMERAL_PUBLIC_KEY = "epk"; |
|
| 33 | - const PARAM_AGREEMENT_PARTYUINFO = "apu"; |
|
| 34 | - const PARAM_AGREEMENT_PARTYVINFO = "apv"; |
|
| 35 | - const PARAM_INITIALIZATION_VECTOR = "iv"; |
|
| 36 | - const PARAM_AUTHENTICATION_TAG = "tag"; |
|
| 37 | - const PARAM_PBES2_SALT_INPUT = "p2s"; |
|
| 38 | - const PARAM_PBES2_COUNT = "p2c"; |
|
| 39 | - const PARAM_BASE64URL_ENCODE_PAYLOAD = "b64"; |
|
| 18 | + // registered parameter names |
|
| 19 | + const PARAM_ALGORITHM = "alg"; |
|
| 20 | + const PARAM_JWK_SET_URL = "jku"; |
|
| 21 | + const PARAM_JSON_WEB_KEY = "jwk"; |
|
| 22 | + const PARAM_KEY_ID = "kid"; |
|
| 23 | + const PARAM_X509_URL = "x5u"; |
|
| 24 | + const PARAM_X509_CERTIFICATE_CHAIN = "x5c"; |
|
| 25 | + const PARAM_X509_CERTIFICATE_SHA1_THUMBPRINT = "x5t"; |
|
| 26 | + const PARAM_X509_CERTIFICATE_SHA256_THUMBPRINT = "x5t#S256"; |
|
| 27 | + const PARAM_TYPE = "typ"; |
|
| 28 | + const PARAM_CONTENT_TYPE = "cty"; |
|
| 29 | + const PARAM_CRITICAL = "crit"; |
|
| 30 | + const PARAM_ENCRYPTION_ALGORITHM = "enc"; |
|
| 31 | + const PARAM_COMPRESSION_ALGORITHM = "zip"; |
|
| 32 | + const PARAM_EPHEMERAL_PUBLIC_KEY = "epk"; |
|
| 33 | + const PARAM_AGREEMENT_PARTYUINFO = "apu"; |
|
| 34 | + const PARAM_AGREEMENT_PARTYVINFO = "apv"; |
|
| 35 | + const PARAM_INITIALIZATION_VECTOR = "iv"; |
|
| 36 | + const PARAM_AUTHENTICATION_TAG = "tag"; |
|
| 37 | + const PARAM_PBES2_SALT_INPUT = "p2s"; |
|
| 38 | + const PARAM_PBES2_COUNT = "p2c"; |
|
| 39 | + const PARAM_BASE64URL_ENCODE_PAYLOAD = "b64"; |
|
| 40 | 40 | |
| 41 | - // shorthand aliases for parameter names |
|
| 42 | - const P_ALG = self::PARAM_ALGORITHM; |
|
| 43 | - const P_JKU = self::PARAM_JWK_SET_URL; |
|
| 44 | - const P_JWK = self::PARAM_JSON_WEB_KEY; |
|
| 45 | - const P_KID = self::PARAM_KEY_ID; |
|
| 46 | - const P_X5U = self::PARAM_X509_URL; |
|
| 47 | - const P_X5C = self::PARAM_X509_CERTIFICATE_CHAIN; |
|
| 48 | - const P_X5T = self::PARAM_X509_CERTIFICATE_SHA1_THUMBPRINT; |
|
| 49 | - const P_X5TS256 = self::PARAM_X509_CERTIFICATE_SHA256_THUMBPRINT; |
|
| 50 | - const P_TYP = self::PARAM_TYPE; |
|
| 51 | - const P_CTY = self::PARAM_CONTENT_TYPE; |
|
| 52 | - const P_CRIT = self::PARAM_CRITICAL; |
|
| 53 | - const P_ENC = self::PARAM_ENCRYPTION_ALGORITHM; |
|
| 54 | - const P_ZIP = self::PARAM_COMPRESSION_ALGORITHM; |
|
| 55 | - const P_EPK = self::PARAM_EPHEMERAL_PUBLIC_KEY; |
|
| 56 | - const P_APU = self::PARAM_AGREEMENT_PARTYUINFO; |
|
| 57 | - const P_APV = self::PARAM_AGREEMENT_PARTYVINFO; |
|
| 58 | - const P_IV = self::PARAM_INITIALIZATION_VECTOR; |
|
| 59 | - const P_TAG = self::PARAM_AUTHENTICATION_TAG; |
|
| 60 | - const P_P2S = self::PARAM_PBES2_SALT_INPUT; |
|
| 61 | - const P_P2C = self::PARAM_PBES2_COUNT; |
|
| 62 | - const P_B64 = self::PARAM_BASE64URL_ENCODE_PAYLOAD; |
|
| 41 | + // shorthand aliases for parameter names |
|
| 42 | + const P_ALG = self::PARAM_ALGORITHM; |
|
| 43 | + const P_JKU = self::PARAM_JWK_SET_URL; |
|
| 44 | + const P_JWK = self::PARAM_JSON_WEB_KEY; |
|
| 45 | + const P_KID = self::PARAM_KEY_ID; |
|
| 46 | + const P_X5U = self::PARAM_X509_URL; |
|
| 47 | + const P_X5C = self::PARAM_X509_CERTIFICATE_CHAIN; |
|
| 48 | + const P_X5T = self::PARAM_X509_CERTIFICATE_SHA1_THUMBPRINT; |
|
| 49 | + const P_X5TS256 = self::PARAM_X509_CERTIFICATE_SHA256_THUMBPRINT; |
|
| 50 | + const P_TYP = self::PARAM_TYPE; |
|
| 51 | + const P_CTY = self::PARAM_CONTENT_TYPE; |
|
| 52 | + const P_CRIT = self::PARAM_CRITICAL; |
|
| 53 | + const P_ENC = self::PARAM_ENCRYPTION_ALGORITHM; |
|
| 54 | + const P_ZIP = self::PARAM_COMPRESSION_ALGORITHM; |
|
| 55 | + const P_EPK = self::PARAM_EPHEMERAL_PUBLIC_KEY; |
|
| 56 | + const P_APU = self::PARAM_AGREEMENT_PARTYUINFO; |
|
| 57 | + const P_APV = self::PARAM_AGREEMENT_PARTYVINFO; |
|
| 58 | + const P_IV = self::PARAM_INITIALIZATION_VECTOR; |
|
| 59 | + const P_TAG = self::PARAM_AUTHENTICATION_TAG; |
|
| 60 | + const P_P2S = self::PARAM_PBES2_SALT_INPUT; |
|
| 61 | + const P_P2C = self::PARAM_PBES2_COUNT; |
|
| 62 | + const P_B64 = self::PARAM_BASE64URL_ENCODE_PAYLOAD; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Mapping from registered JWT parameter name to class name. |
|
| 66 | - * |
|
| 67 | - * @internal |
|
| 68 | - * |
|
| 69 | - * @var array |
|
| 70 | - */ |
|
| 71 | - const MAP_NAME_TO_CLASS = array( |
|
| 72 | - /* @formatter:off */ |
|
| 73 | - self::P_ALG => AlgorithmParameter::class, |
|
| 74 | - self::P_JKU => JWKSetURLParameter::class, |
|
| 75 | - self::P_JWK => JSONWebKeyParameter::class, |
|
| 76 | - self::P_KID => KeyIDParameter::class, |
|
| 77 | - self::P_X5U => X509URLParameter::class, |
|
| 78 | - self::P_X5C => X509CertificateChainParameter::class, |
|
| 79 | - self::P_X5T => X509CertificateSHA1ThumbprintParameter::class, |
|
| 80 | - self::P_X5TS256 => X509CertificateSHA256ThumbprintParameter::class, |
|
| 81 | - self::P_TYP => TypeParameter::class, |
|
| 82 | - self::P_CTY => ContentTypeParameter::class, |
|
| 83 | - self::P_CRIT => CriticalParameter::class, |
|
| 84 | - self::P_ENC => EncryptionAlgorithmParameter::class, |
|
| 85 | - self::P_ZIP => CompressionAlgorithmParameter::class, |
|
| 86 | - self::P_IV => InitializationVectorParameter::class, |
|
| 87 | - self::P_TAG => AuthenticationTagParameter::class, |
|
| 88 | - self::P_P2S => PBES2SaltInputParameter::class, |
|
| 89 | - self::P_P2C => PBES2CountParameter::class, |
|
| 90 | - self::P_B64 => B64PayloadParameter::class |
|
| 91 | - /* @formatter:on */ |
|
| 92 | - ); |
|
| 64 | + /** |
|
| 65 | + * Mapping from registered JWT parameter name to class name. |
|
| 66 | + * |
|
| 67 | + * @internal |
|
| 68 | + * |
|
| 69 | + * @var array |
|
| 70 | + */ |
|
| 71 | + const MAP_NAME_TO_CLASS = array( |
|
| 72 | + /* @formatter:off */ |
|
| 73 | + self::P_ALG => AlgorithmParameter::class, |
|
| 74 | + self::P_JKU => JWKSetURLParameter::class, |
|
| 75 | + self::P_JWK => JSONWebKeyParameter::class, |
|
| 76 | + self::P_KID => KeyIDParameter::class, |
|
| 77 | + self::P_X5U => X509URLParameter::class, |
|
| 78 | + self::P_X5C => X509CertificateChainParameter::class, |
|
| 79 | + self::P_X5T => X509CertificateSHA1ThumbprintParameter::class, |
|
| 80 | + self::P_X5TS256 => X509CertificateSHA256ThumbprintParameter::class, |
|
| 81 | + self::P_TYP => TypeParameter::class, |
|
| 82 | + self::P_CTY => ContentTypeParameter::class, |
|
| 83 | + self::P_CRIT => CriticalParameter::class, |
|
| 84 | + self::P_ENC => EncryptionAlgorithmParameter::class, |
|
| 85 | + self::P_ZIP => CompressionAlgorithmParameter::class, |
|
| 86 | + self::P_IV => InitializationVectorParameter::class, |
|
| 87 | + self::P_TAG => AuthenticationTagParameter::class, |
|
| 88 | + self::P_P2S => PBES2SaltInputParameter::class, |
|
| 89 | + self::P_P2C => PBES2CountParameter::class, |
|
| 90 | + self::P_B64 => B64PayloadParameter::class |
|
| 91 | + /* @formatter:on */ |
|
| 92 | + ); |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Constructor. |
|
| 96 | - * |
|
| 97 | - * @param string $name Parameter name |
|
| 98 | - * @param mixed $value Parameter value |
|
| 99 | - */ |
|
| 100 | - public function __construct(string $name, $value) |
|
| 101 | - { |
|
| 102 | - $this->_name = $name; |
|
| 103 | - $this->_value = $value; |
|
| 104 | - } |
|
| 94 | + /** |
|
| 95 | + * Constructor. |
|
| 96 | + * |
|
| 97 | + * @param string $name Parameter name |
|
| 98 | + * @param mixed $value Parameter value |
|
| 99 | + */ |
|
| 100 | + public function __construct(string $name, $value) |
|
| 101 | + { |
|
| 102 | + $this->_name = $name; |
|
| 103 | + $this->_value = $value; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Initialize from a name and a value. |
|
| 108 | - * |
|
| 109 | - * Returns a parameter specific object if one is implemented. |
|
| 110 | - * |
|
| 111 | - * @param string $name Parameter name |
|
| 112 | - * @param mixed $value Parameter value |
|
| 113 | - * @return self |
|
| 114 | - */ |
|
| 115 | - public static function fromNameAndValue(string $name, $value): self |
|
| 116 | - { |
|
| 117 | - if (array_key_exists($name, self::MAP_NAME_TO_CLASS)) { |
|
| 118 | - $cls = self::MAP_NAME_TO_CLASS[$name]; |
|
| 119 | - return $cls::fromJSONValue($value); |
|
| 120 | - } |
|
| 121 | - return new self($name, $value); |
|
| 122 | - } |
|
| 106 | + /** |
|
| 107 | + * Initialize from a name and a value. |
|
| 108 | + * |
|
| 109 | + * Returns a parameter specific object if one is implemented. |
|
| 110 | + * |
|
| 111 | + * @param string $name Parameter name |
|
| 112 | + * @param mixed $value Parameter value |
|
| 113 | + * @return self |
|
| 114 | + */ |
|
| 115 | + public static function fromNameAndValue(string $name, $value): self |
|
| 116 | + { |
|
| 117 | + if (array_key_exists($name, self::MAP_NAME_TO_CLASS)) { |
|
| 118 | + $cls = self::MAP_NAME_TO_CLASS[$name]; |
|
| 119 | + return $cls::fromJSONValue($value); |
|
| 120 | + } |
|
| 121 | + return new self($name, $value); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Initialize from a JSON value. |
|
| 126 | - * |
|
| 127 | - * @param mixed $value |
|
| 128 | - * @return self |
|
| 129 | - */ |
|
| 130 | - public static function fromJSONValue($value) |
|
| 131 | - { |
|
| 132 | - throw new \BadMethodCallException( |
|
| 133 | - __FUNCTION__ . " must be implemented in a derived class."); |
|
| 134 | - } |
|
| 124 | + /** |
|
| 125 | + * Initialize from a JSON value. |
|
| 126 | + * |
|
| 127 | + * @param mixed $value |
|
| 128 | + * @return self |
|
| 129 | + */ |
|
| 130 | + public static function fromJSONValue($value) |
|
| 131 | + { |
|
| 132 | + throw new \BadMethodCallException( |
|
| 133 | + __FUNCTION__ . " must be implemented in a derived class."); |
|
| 134 | + } |
|
| 135 | 135 | } |
@@ -13,15 +13,15 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class JWKSetURLParameter extends JWTParameter |
| 15 | 15 | { |
| 16 | - use StringParameterValue; |
|
| 16 | + use StringParameterValue; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Constructor. |
|
| 20 | - * |
|
| 21 | - * @param string $uri |
|
| 22 | - */ |
|
| 23 | - public function __construct(string $uri) |
|
| 24 | - { |
|
| 25 | - parent::__construct(self::PARAM_JWK_SET_URL, $uri); |
|
| 26 | - } |
|
| 18 | + /** |
|
| 19 | + * Constructor. |
|
| 20 | + * |
|
| 21 | + * @param string $uri |
|
| 22 | + */ |
|
| 23 | + public function __construct(string $uri) |
|
| 24 | + { |
|
| 25 | + parent::__construct(self::PARAM_JWK_SET_URL, $uri); |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -14,21 +14,21 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class X509CertificateChainParameter extends JWTParameter |
| 16 | 16 | { |
| 17 | - use ArrayParameterValue; |
|
| 17 | + use ArrayParameterValue; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param string ...$certs Base64 encoded DER certificates |
|
| 23 | - */ |
|
| 24 | - public function __construct(string ...$certs) |
|
| 25 | - { |
|
| 26 | - foreach ($certs as $cert) { |
|
| 27 | - if (!Base64::isValid($cert)) { |
|
| 28 | - throw new \UnexpectedValueException( |
|
| 29 | - "Certificate must be base64 encoded."); |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - parent::__construct(self::PARAM_X509_CERTIFICATE_CHAIN, $certs); |
|
| 33 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param string ...$certs Base64 encoded DER certificates |
|
| 23 | + */ |
|
| 24 | + public function __construct(string ...$certs) |
|
| 25 | + { |
|
| 26 | + foreach ($certs as $cert) { |
|
| 27 | + if (!Base64::isValid($cert)) { |
|
| 28 | + throw new \UnexpectedValueException( |
|
| 29 | + "Certificate must be base64 encoded."); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + parent::__construct(self::PARAM_X509_CERTIFICATE_CHAIN, $certs); |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -13,35 +13,35 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class JSONWebKeyParameter extends JWTParameter |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Constructor. |
|
| 18 | - * |
|
| 19 | - * @param JWK $jwk |
|
| 20 | - */ |
|
| 21 | - public function __construct(JWK $jwk) |
|
| 22 | - { |
|
| 23 | - parent::__construct(self::PARAM_JSON_WEB_KEY, $jwk->toArray()); |
|
| 24 | - } |
|
| 16 | + /** |
|
| 17 | + * Constructor. |
|
| 18 | + * |
|
| 19 | + * @param JWK $jwk |
|
| 20 | + */ |
|
| 21 | + public function __construct(JWK $jwk) |
|
| 22 | + { |
|
| 23 | + parent::__construct(self::PARAM_JSON_WEB_KEY, $jwk->toArray()); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * |
|
| 28 | - * {@inheritdoc} |
|
| 29 | - */ |
|
| 30 | - public static function fromJSONValue($value): self |
|
| 31 | - { |
|
| 32 | - if (!is_array($value)) { |
|
| 33 | - throw new \UnexpectedValueException("jwk must be an array."); |
|
| 34 | - } |
|
| 35 | - return new static(JWK::fromArray($value)); |
|
| 36 | - } |
|
| 26 | + /** |
|
| 27 | + * |
|
| 28 | + * {@inheritdoc} |
|
| 29 | + */ |
|
| 30 | + public static function fromJSONValue($value): self |
|
| 31 | + { |
|
| 32 | + if (!is_array($value)) { |
|
| 33 | + throw new \UnexpectedValueException("jwk must be an array."); |
|
| 34 | + } |
|
| 35 | + return new static(JWK::fromArray($value)); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Get value as a JWK. |
|
| 40 | - * |
|
| 41 | - * @return JWK |
|
| 42 | - */ |
|
| 43 | - public function jwk(): JWK |
|
| 44 | - { |
|
| 45 | - return JWK::fromArray($this->_value); |
|
| 46 | - } |
|
| 38 | + /** |
|
| 39 | + * Get value as a JWK. |
|
| 40 | + * |
|
| 41 | + * @return JWK |
|
| 42 | + */ |
|
| 43 | + public function jwk(): JWK |
|
| 44 | + { |
|
| 45 | + return JWK::fromArray($this->_value); |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -13,22 +13,22 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class ContentTypeParameter extends JWTParameter |
| 15 | 15 | { |
| 16 | - use StringParameterValue; |
|
| 16 | + use StringParameterValue; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Content type for the nested JWT. |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - const TYPE_JWT = "JWT"; |
|
| 18 | + /** |
|
| 19 | + * Content type for the nested JWT. |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + const TYPE_JWT = "JWT"; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor. |
|
| 27 | - * |
|
| 28 | - * @param string $type |
|
| 29 | - */ |
|
| 30 | - public function __construct(string $type) |
|
| 31 | - { |
|
| 32 | - parent::__construct(self::PARAM_CONTENT_TYPE, $type); |
|
| 33 | - } |
|
| 25 | + /** |
|
| 26 | + * Constructor. |
|
| 27 | + * |
|
| 28 | + * @param string $type |
|
| 29 | + */ |
|
| 30 | + public function __construct(string $type) |
|
| 31 | + { |
|
| 32 | + parent::__construct(self::PARAM_CONTENT_TYPE, $type); |
|
| 33 | + } |
|
| 34 | 34 | } |