@@ -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 | } |
@@ -9,37 +9,37 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | abstract class Parameter |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Parameter name. |
|
| 14 | - * |
|
| 15 | - * @var string $_name |
|
| 16 | - */ |
|
| 17 | - protected $_name; |
|
| 12 | + /** |
|
| 13 | + * Parameter name. |
|
| 14 | + * |
|
| 15 | + * @var string $_name |
|
| 16 | + */ |
|
| 17 | + protected $_name; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Parameter value. |
|
| 21 | - * |
|
| 22 | - * @var mixed $_value |
|
| 23 | - */ |
|
| 24 | - protected $_value; |
|
| 19 | + /** |
|
| 20 | + * Parameter value. |
|
| 21 | + * |
|
| 22 | + * @var mixed $_value |
|
| 23 | + */ |
|
| 24 | + protected $_value; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Get the parameter name. |
|
| 28 | - * |
|
| 29 | - * @return string |
|
| 30 | - */ |
|
| 31 | - public function name(): string |
|
| 32 | - { |
|
| 33 | - return $this->_name; |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * Get the parameter name. |
|
| 28 | + * |
|
| 29 | + * @return string |
|
| 30 | + */ |
|
| 31 | + public function name(): string |
|
| 32 | + { |
|
| 33 | + return $this->_name; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Get the parameter value. |
|
| 38 | - * |
|
| 39 | - * @return mixed |
|
| 40 | - */ |
|
| 41 | - public function value() |
|
| 42 | - { |
|
| 43 | - return $this->_value; |
|
| 44 | - } |
|
| 36 | + /** |
|
| 37 | + * Get the parameter value. |
|
| 38 | + * |
|
| 39 | + * @return mixed |
|
| 40 | + */ |
|
| 41 | + public function value() |
|
| 42 | + { |
|
| 43 | + return $this->_value; |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -11,51 +11,51 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | trait Base64URLValue |
| 13 | 13 | { |
| 14 | - use StringParameterValue; |
|
| 14 | + use StringParameterValue; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Get the parameter value. |
|
| 18 | - * |
|
| 19 | - * @return string |
|
| 20 | - */ |
|
| 21 | - abstract public function value(); |
|
| 16 | + /** |
|
| 17 | + * Get the parameter value. |
|
| 18 | + * |
|
| 19 | + * @return string |
|
| 20 | + */ |
|
| 21 | + abstract public function value(); |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Initialize from native value. |
|
| 25 | - * |
|
| 26 | - * Value shall be encoded using Base64url encoding. |
|
| 27 | - * |
|
| 28 | - * @param string $value |
|
| 29 | - * @return self |
|
| 30 | - */ |
|
| 31 | - public static function fromString(string $value) |
|
| 32 | - { |
|
| 33 | - return new static(Base64::urlEncode($value)); |
|
| 34 | - } |
|
| 23 | + /** |
|
| 24 | + * Initialize from native value. |
|
| 25 | + * |
|
| 26 | + * Value shall be encoded using Base64url encoding. |
|
| 27 | + * |
|
| 28 | + * @param string $value |
|
| 29 | + * @return self |
|
| 30 | + */ |
|
| 31 | + public static function fromString(string $value) |
|
| 32 | + { |
|
| 33 | + return new static(Base64::urlEncode($value)); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Validate that value is validly base64url encoded. |
|
| 38 | - * |
|
| 39 | - * @param string $value |
|
| 40 | - * @throws \UnexpectedValueException |
|
| 41 | - * @return self |
|
| 42 | - */ |
|
| 43 | - protected function _validateEncoding(string $value) |
|
| 44 | - { |
|
| 45 | - if (!Base64::isValidURLEncoding($value)) { |
|
| 46 | - throw new \UnexpectedValueException( |
|
| 47 | - "Value must be base64url encoded."); |
|
| 48 | - } |
|
| 49 | - return $this; |
|
| 50 | - } |
|
| 36 | + /** |
|
| 37 | + * Validate that value is validly base64url encoded. |
|
| 38 | + * |
|
| 39 | + * @param string $value |
|
| 40 | + * @throws \UnexpectedValueException |
|
| 41 | + * @return self |
|
| 42 | + */ |
|
| 43 | + protected function _validateEncoding(string $value) |
|
| 44 | + { |
|
| 45 | + if (!Base64::isValidURLEncoding($value)) { |
|
| 46 | + throw new \UnexpectedValueException( |
|
| 47 | + "Value must be base64url encoded."); |
|
| 48 | + } |
|
| 49 | + return $this; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Get the parameter value as a decoded string. |
|
| 54 | - * |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - public function string(): string |
|
| 58 | - { |
|
| 59 | - return Base64::urlDecode($this->value()); |
|
| 60 | - } |
|
| 52 | + /** |
|
| 53 | + * Get the parameter value as a decoded string. |
|
| 54 | + * |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + public function string(): string |
|
| 58 | + { |
|
| 59 | + return Base64::urlDecode($this->value()); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -9,21 +9,21 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | trait StringParameterValue |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Constructor. |
|
| 14 | - * |
|
| 15 | - * @param string $value Parameter value |
|
| 16 | - */ |
|
| 17 | - abstract public function __construct(string $value); |
|
| 12 | + /** |
|
| 13 | + * Constructor. |
|
| 14 | + * |
|
| 15 | + * @param string $value Parameter value |
|
| 16 | + */ |
|
| 17 | + abstract public function __construct(string $value); |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Initialize from a JSON value. |
|
| 21 | - * |
|
| 22 | - * @param string $value |
|
| 23 | - * @return static |
|
| 24 | - */ |
|
| 25 | - public static function fromJSONValue($value) |
|
| 26 | - { |
|
| 27 | - return new static(strval($value)); |
|
| 28 | - } |
|
| 19 | + /** |
|
| 20 | + * Initialize from a JSON value. |
|
| 21 | + * |
|
| 22 | + * @param string $value |
|
| 23 | + * @return static |
|
| 24 | + */ |
|
| 25 | + public static function fromJSONValue($value) |
|
| 26 | + { |
|
| 27 | + return new static(strval($value)); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -14,27 +14,27 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | trait Base64UIntValue |
| 16 | 16 | { |
| 17 | - use Base64URLValue; |
|
| 17 | + use Base64URLValue; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Initialize parameter from base10 number. |
|
| 21 | - * |
|
| 22 | - * @param int|string $number |
|
| 23 | - * @return self |
|
| 24 | - */ |
|
| 25 | - public static function fromNumber($number) |
|
| 26 | - { |
|
| 27 | - $data = BigInt::fromBase10($number)->base256(); |
|
| 28 | - return self::fromString($data); |
|
| 29 | - } |
|
| 19 | + /** |
|
| 20 | + * Initialize parameter from base10 number. |
|
| 21 | + * |
|
| 22 | + * @param int|string $number |
|
| 23 | + * @return self |
|
| 24 | + */ |
|
| 25 | + public static function fromNumber($number) |
|
| 26 | + { |
|
| 27 | + $data = BigInt::fromBase10($number)->base256(); |
|
| 28 | + return self::fromString($data); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Get value as a number. |
|
| 33 | - * |
|
| 34 | - * @return BigInt |
|
| 35 | - */ |
|
| 36 | - public function number(): BigInt |
|
| 37 | - { |
|
| 38 | - return BigInt::fromBase256(Base64::urlDecode($this->value())); |
|
| 39 | - } |
|
| 31 | + /** |
|
| 32 | + * Get value as a number. |
|
| 33 | + * |
|
| 34 | + * @return BigInt |
|
| 35 | + */ |
|
| 36 | + public function number(): BigInt |
|
| 37 | + { |
|
| 38 | + return BigInt::fromBase256(Base64::urlDecode($this->value())); |
|
| 39 | + } |
|
| 40 | 40 | } |