@@ -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\JWK\Parameter; |
| 6 | 6 | |
@@ -13,18 +13,18 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class PublicKeyUseParameter extends JWKParameter |
| 15 | 15 | { |
| 16 | - use StringParameterValue; |
|
| 16 | + use StringParameterValue; |
|
| 17 | 17 | |
| 18 | - const USE_SIGNATURE = 'sig'; |
|
| 19 | - const USE_ENCRYPTION = 'enc'; |
|
| 18 | + const USE_SIGNATURE = 'sig'; |
|
| 19 | + const USE_ENCRYPTION = 'enc'; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Constructor. |
|
| 23 | - * |
|
| 24 | - * @param string $use Intended use of the public key |
|
| 25 | - */ |
|
| 26 | - public function __construct(string $use) |
|
| 27 | - { |
|
| 28 | - parent::__construct(self::PARAM_PUBLIC_KEY_USE, $use); |
|
| 29 | - } |
|
| 21 | + /** |
|
| 22 | + * Constructor. |
|
| 23 | + * |
|
| 24 | + * @param string $use Intended use of the public key |
|
| 25 | + */ |
|
| 26 | + public function __construct(string $use) |
|
| 27 | + { |
|
| 28 | + parent::__construct(self::PARAM_PUBLIC_KEY_USE, $use); |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -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\JWK\Parameter; |
| 6 | 6 | |
@@ -13,30 +13,30 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class KeyTypeParameter extends JWKParameter |
| 15 | 15 | { |
| 16 | - use StringParameterValue; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * Octet sequence key type. |
|
| 20 | - */ |
|
| 21 | - const TYPE_OCT = 'oct'; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * RSA key type. |
|
| 25 | - */ |
|
| 26 | - const TYPE_RSA = 'RSA'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Elliptic curve key type. |
|
| 30 | - */ |
|
| 31 | - const TYPE_EC = 'EC'; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Constructor. |
|
| 35 | - * |
|
| 36 | - * @param string $type Key type |
|
| 37 | - */ |
|
| 38 | - public function __construct(string $type) |
|
| 39 | - { |
|
| 40 | - parent::__construct(self::PARAM_KEY_TYPE, $type); |
|
| 41 | - } |
|
| 16 | + use StringParameterValue; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * Octet sequence key type. |
|
| 20 | + */ |
|
| 21 | + const TYPE_OCT = 'oct'; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * RSA key type. |
|
| 25 | + */ |
|
| 26 | + const TYPE_RSA = 'RSA'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Elliptic curve key type. |
|
| 30 | + */ |
|
| 31 | + const TYPE_EC = 'EC'; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Constructor. |
|
| 35 | + * |
|
| 36 | + * @param string $type Key type |
|
| 37 | + */ |
|
| 38 | + public function __construct(string $type) |
|
| 39 | + { |
|
| 40 | + parent::__construct(self::PARAM_KEY_TYPE, $type); |
|
| 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\JWK\Parameter; |
| 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\JWK\Parameter; |
| 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\JWK\Parameter; |
| 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\JWK\Parameter; |
| 6 | 6 | |
@@ -14,131 +14,131 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class JWKParameter extends Parameter |
| 16 | 16 | { |
| 17 | - // registered parameter names |
|
| 18 | - const PARAM_KEY_TYPE = 'kty'; |
|
| 19 | - const PARAM_PUBLIC_KEY_USE = 'use'; |
|
| 20 | - const PARAM_KEY_OPERATIONS = 'key_ops'; |
|
| 21 | - const PARAM_ALGORITHM = 'alg'; |
|
| 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_CURVE = 'crv'; |
|
| 28 | - const PARAM_X_COORDINATE = 'x'; |
|
| 29 | - const PARAM_Y_COORDINATE = 'y'; |
|
| 30 | - const PARAM_ECC_PRIVATE_KEY = 'd'; |
|
| 31 | - const PARAM_MODULUS = 'n'; |
|
| 32 | - const PARAM_EXPONENT = 'e'; |
|
| 33 | - const PARAM_PRIVATE_EXPONENT = 'd'; |
|
| 34 | - const PARAM_FIRST_PRIME_FACTOR = 'p'; |
|
| 35 | - const PARAM_SECOND_PRIME_FACTOR = 'q'; |
|
| 36 | - const PARAM_FIRST_FACTOR_CRT_EXPONENT = 'dp'; |
|
| 37 | - const PARAM_SECOND_FACTOR_CRT_EXPONENT = 'dq'; |
|
| 38 | - const PARAM_FIRST_CRT_COEFFICIENT = 'qi'; |
|
| 39 | - const PARAM_OTHER_PRIMES_INFO = 'oth'; |
|
| 40 | - const PARAM_KEY_VALUE = 'k'; |
|
| 17 | + // registered parameter names |
|
| 18 | + const PARAM_KEY_TYPE = 'kty'; |
|
| 19 | + const PARAM_PUBLIC_KEY_USE = 'use'; |
|
| 20 | + const PARAM_KEY_OPERATIONS = 'key_ops'; |
|
| 21 | + const PARAM_ALGORITHM = 'alg'; |
|
| 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_CURVE = 'crv'; |
|
| 28 | + const PARAM_X_COORDINATE = 'x'; |
|
| 29 | + const PARAM_Y_COORDINATE = 'y'; |
|
| 30 | + const PARAM_ECC_PRIVATE_KEY = 'd'; |
|
| 31 | + const PARAM_MODULUS = 'n'; |
|
| 32 | + const PARAM_EXPONENT = 'e'; |
|
| 33 | + const PARAM_PRIVATE_EXPONENT = 'd'; |
|
| 34 | + const PARAM_FIRST_PRIME_FACTOR = 'p'; |
|
| 35 | + const PARAM_SECOND_PRIME_FACTOR = 'q'; |
|
| 36 | + const PARAM_FIRST_FACTOR_CRT_EXPONENT = 'dp'; |
|
| 37 | + const PARAM_SECOND_FACTOR_CRT_EXPONENT = 'dq'; |
|
| 38 | + const PARAM_FIRST_CRT_COEFFICIENT = 'qi'; |
|
| 39 | + const PARAM_OTHER_PRIMES_INFO = 'oth'; |
|
| 40 | + const PARAM_KEY_VALUE = 'k'; |
|
| 41 | 41 | |
| 42 | - // shorthand aliases for parameter names |
|
| 43 | - const P_KTY = self::PARAM_KEY_TYPE; |
|
| 44 | - const P_USE = self::PARAM_PUBLIC_KEY_USE; |
|
| 45 | - const P_KEY_OPS = self::PARAM_KEY_OPERATIONS; |
|
| 46 | - const P_ALG = self::PARAM_ALGORITHM; |
|
| 47 | - const P_KID = self::PARAM_KEY_ID; |
|
| 48 | - const P_X5U = self::PARAM_X509_URL; |
|
| 49 | - const P_X5C = self::PARAM_X509_CERTIFICATE_CHAIN; |
|
| 50 | - const P_X5T = self::PARAM_X509_CERTIFICATE_SHA1_THUMBPRINT; |
|
| 51 | - const P_X5TS256 = self::PARAM_X509_CERTIFICATE_SHA256_THUMBPRINT; |
|
| 52 | - const P_CRV = self::PARAM_CURVE; |
|
| 53 | - const P_X = self::PARAM_X_COORDINATE; |
|
| 54 | - const P_Y = self::PARAM_Y_COORDINATE; |
|
| 55 | - const P_ECC_D = self::PARAM_ECC_PRIVATE_KEY; |
|
| 56 | - const P_N = self::PARAM_MODULUS; |
|
| 57 | - const P_E = self::PARAM_EXPONENT; |
|
| 58 | - const P_RSA_D = self::PARAM_PRIVATE_EXPONENT; |
|
| 59 | - const P_P = self::PARAM_FIRST_PRIME_FACTOR; |
|
| 60 | - const P_Q = self::PARAM_SECOND_PRIME_FACTOR; |
|
| 61 | - const P_DP = self::PARAM_FIRST_FACTOR_CRT_EXPONENT; |
|
| 62 | - const P_DQ = self::PARAM_SECOND_FACTOR_CRT_EXPONENT; |
|
| 63 | - const P_QI = self::PARAM_FIRST_CRT_COEFFICIENT; |
|
| 64 | - const P_OTH = self::PARAM_OTHER_PRIMES_INFO; |
|
| 65 | - const P_K = self::PARAM_KEY_VALUE; |
|
| 42 | + // shorthand aliases for parameter names |
|
| 43 | + const P_KTY = self::PARAM_KEY_TYPE; |
|
| 44 | + const P_USE = self::PARAM_PUBLIC_KEY_USE; |
|
| 45 | + const P_KEY_OPS = self::PARAM_KEY_OPERATIONS; |
|
| 46 | + const P_ALG = self::PARAM_ALGORITHM; |
|
| 47 | + const P_KID = self::PARAM_KEY_ID; |
|
| 48 | + const P_X5U = self::PARAM_X509_URL; |
|
| 49 | + const P_X5C = self::PARAM_X509_CERTIFICATE_CHAIN; |
|
| 50 | + const P_X5T = self::PARAM_X509_CERTIFICATE_SHA1_THUMBPRINT; |
|
| 51 | + const P_X5TS256 = self::PARAM_X509_CERTIFICATE_SHA256_THUMBPRINT; |
|
| 52 | + const P_CRV = self::PARAM_CURVE; |
|
| 53 | + const P_X = self::PARAM_X_COORDINATE; |
|
| 54 | + const P_Y = self::PARAM_Y_COORDINATE; |
|
| 55 | + const P_ECC_D = self::PARAM_ECC_PRIVATE_KEY; |
|
| 56 | + const P_N = self::PARAM_MODULUS; |
|
| 57 | + const P_E = self::PARAM_EXPONENT; |
|
| 58 | + const P_RSA_D = self::PARAM_PRIVATE_EXPONENT; |
|
| 59 | + const P_P = self::PARAM_FIRST_PRIME_FACTOR; |
|
| 60 | + const P_Q = self::PARAM_SECOND_PRIME_FACTOR; |
|
| 61 | + const P_DP = self::PARAM_FIRST_FACTOR_CRT_EXPONENT; |
|
| 62 | + const P_DQ = self::PARAM_SECOND_FACTOR_CRT_EXPONENT; |
|
| 63 | + const P_QI = self::PARAM_FIRST_CRT_COEFFICIENT; |
|
| 64 | + const P_OTH = self::PARAM_OTHER_PRIMES_INFO; |
|
| 65 | + const P_K = self::PARAM_KEY_VALUE; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Mapping from registered JWK parameter name to class name. |
|
| 69 | - * |
|
| 70 | - * Note that ECC private key and RSA private key cannot be mapped since |
|
| 71 | - * they share the same parameter name 'd'. |
|
| 72 | - * |
|
| 73 | - * @internal |
|
| 74 | - * |
|
| 75 | - * @var array |
|
| 76 | - */ |
|
| 77 | - const MAP_NAME_TO_CLASS = [ |
|
| 78 | - self::P_KTY => KeyTypeParameter::class, |
|
| 79 | - self::P_USE => PublicKeyUseParameter::class, |
|
| 80 | - self::P_KEY_OPS => KeyOperationsParameter::class, |
|
| 81 | - self::P_ALG => AlgorithmParameter::class, |
|
| 82 | - self::P_KID => KeyIDParameter::class, |
|
| 83 | - self::P_X5U => X509URLParameter::class, |
|
| 84 | - self::P_X5C => X509CertificateChainParameter::class, |
|
| 85 | - self::P_X5T => X509CertificateSHA1ThumbprintParameter::class, |
|
| 86 | - self::P_X5TS256 => X509CertificateSHA256ThumbprintParameter::class, |
|
| 87 | - self::P_CRV => CurveParameter::class, |
|
| 88 | - self::P_X => XCoordinateParameter::class, |
|
| 89 | - self::P_Y => YCoordinateParameter::class, |
|
| 90 | - self::P_N => ModulusParameter::class, |
|
| 91 | - self::P_E => ExponentParameter::class, |
|
| 92 | - self::P_P => FirstPrimeFactorParameter::class, |
|
| 93 | - self::P_Q => SecondPrimeFactorParameter::class, |
|
| 94 | - self::P_DP => FirstFactorCRTExponentParameter::class, |
|
| 95 | - self::P_DQ => SecondFactorCRTExponentParameter::class, |
|
| 96 | - self::P_QI => FirstCRTCoefficientParameter::class, |
|
| 97 | - self::P_OTH => OtherPrimesInfoParameter::class, |
|
| 98 | - self::P_K => KeyValueParameter::class, |
|
| 99 | - ]; |
|
| 67 | + /** |
|
| 68 | + * Mapping from registered JWK parameter name to class name. |
|
| 69 | + * |
|
| 70 | + * Note that ECC private key and RSA private key cannot be mapped since |
|
| 71 | + * they share the same parameter name 'd'. |
|
| 72 | + * |
|
| 73 | + * @internal |
|
| 74 | + * |
|
| 75 | + * @var array |
|
| 76 | + */ |
|
| 77 | + const MAP_NAME_TO_CLASS = [ |
|
| 78 | + self::P_KTY => KeyTypeParameter::class, |
|
| 79 | + self::P_USE => PublicKeyUseParameter::class, |
|
| 80 | + self::P_KEY_OPS => KeyOperationsParameter::class, |
|
| 81 | + self::P_ALG => AlgorithmParameter::class, |
|
| 82 | + self::P_KID => KeyIDParameter::class, |
|
| 83 | + self::P_X5U => X509URLParameter::class, |
|
| 84 | + self::P_X5C => X509CertificateChainParameter::class, |
|
| 85 | + self::P_X5T => X509CertificateSHA1ThumbprintParameter::class, |
|
| 86 | + self::P_X5TS256 => X509CertificateSHA256ThumbprintParameter::class, |
|
| 87 | + self::P_CRV => CurveParameter::class, |
|
| 88 | + self::P_X => XCoordinateParameter::class, |
|
| 89 | + self::P_Y => YCoordinateParameter::class, |
|
| 90 | + self::P_N => ModulusParameter::class, |
|
| 91 | + self::P_E => ExponentParameter::class, |
|
| 92 | + self::P_P => FirstPrimeFactorParameter::class, |
|
| 93 | + self::P_Q => SecondPrimeFactorParameter::class, |
|
| 94 | + self::P_DP => FirstFactorCRTExponentParameter::class, |
|
| 95 | + self::P_DQ => SecondFactorCRTExponentParameter::class, |
|
| 96 | + self::P_QI => FirstCRTCoefficientParameter::class, |
|
| 97 | + self::P_OTH => OtherPrimesInfoParameter::class, |
|
| 98 | + self::P_K => KeyValueParameter::class, |
|
| 99 | + ]; |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Constructor. |
|
| 103 | - * |
|
| 104 | - * @param string $name Parameter name |
|
| 105 | - * @param mixed $value Parameter value |
|
| 106 | - */ |
|
| 107 | - public function __construct(string $name, $value) |
|
| 108 | - { |
|
| 109 | - $this->_name = $name; |
|
| 110 | - $this->_value = $value; |
|
| 111 | - } |
|
| 101 | + /** |
|
| 102 | + * Constructor. |
|
| 103 | + * |
|
| 104 | + * @param string $name Parameter name |
|
| 105 | + * @param mixed $value Parameter value |
|
| 106 | + */ |
|
| 107 | + public function __construct(string $name, $value) |
|
| 108 | + { |
|
| 109 | + $this->_name = $name; |
|
| 110 | + $this->_value = $value; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Initialize from a name and a value. |
|
| 115 | - * |
|
| 116 | - * Returns a parameter specific object if one is implemented. |
|
| 117 | - * |
|
| 118 | - * @param string $name Parameter name |
|
| 119 | - * @param mixed $value Parameter value |
|
| 120 | - * |
|
| 121 | - * @return self |
|
| 122 | - */ |
|
| 123 | - public static function fromNameAndValue(string $name, $value): self |
|
| 124 | - { |
|
| 125 | - if (array_key_exists($name, self::MAP_NAME_TO_CLASS)) { |
|
| 126 | - $cls = self::MAP_NAME_TO_CLASS[$name]; |
|
| 127 | - return $cls::fromJSONValue($value); |
|
| 128 | - } |
|
| 129 | - return new self($name, $value); |
|
| 130 | - } |
|
| 113 | + /** |
|
| 114 | + * Initialize from a name and a value. |
|
| 115 | + * |
|
| 116 | + * Returns a parameter specific object if one is implemented. |
|
| 117 | + * |
|
| 118 | + * @param string $name Parameter name |
|
| 119 | + * @param mixed $value Parameter value |
|
| 120 | + * |
|
| 121 | + * @return self |
|
| 122 | + */ |
|
| 123 | + public static function fromNameAndValue(string $name, $value): self |
|
| 124 | + { |
|
| 125 | + if (array_key_exists($name, self::MAP_NAME_TO_CLASS)) { |
|
| 126 | + $cls = self::MAP_NAME_TO_CLASS[$name]; |
|
| 127 | + return $cls::fromJSONValue($value); |
|
| 128 | + } |
|
| 129 | + return new self($name, $value); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Initialize from a JSON value. |
|
| 134 | - * |
|
| 135 | - * @param mixed $value |
|
| 136 | - * |
|
| 137 | - * @return JWKParameter |
|
| 138 | - */ |
|
| 139 | - public static function fromJSONValue($value): Parameter |
|
| 140 | - { |
|
| 141 | - throw new \BadMethodCallException( |
|
| 142 | - __FUNCTION__ . ' must be implemented in a derived class.'); |
|
| 143 | - } |
|
| 132 | + /** |
|
| 133 | + * Initialize from a JSON value. |
|
| 134 | + * |
|
| 135 | + * @param mixed $value |
|
| 136 | + * |
|
| 137 | + * @return JWKParameter |
|
| 138 | + */ |
|
| 139 | + public static function fromJSONValue($value): Parameter |
|
| 140 | + { |
|
| 141 | + throw new \BadMethodCallException( |
|
| 142 | + __FUNCTION__ . ' must be implemented in a derived class.'); |
|
| 143 | + } |
|
| 144 | 144 | } |
@@ -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\JWK\Parameter; |
| 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\JWK\Parameter; |
| 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\JWK\Parameter; |
| 6 | 6 | |