@@ -14,21 +14,21 @@ |
||
14 | 14 | */ |
15 | 15 | class X509CertificateChainParameter extends JWKParameter |
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,16 +13,16 @@ |
||
13 | 13 | */ |
14 | 14 | class YCoordinateParameter extends CoordinateParameter |
15 | 15 | { |
16 | - use Base64URLValue; |
|
16 | + use Base64URLValue; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - * |
|
21 | - * @param string $coord Y coordinate in base64url encoding |
|
22 | - */ |
|
23 | - public function __construct(string $coord) |
|
24 | - { |
|
25 | - $this->_validateEncoding($coord); |
|
26 | - parent::__construct(self::PARAM_Y_COORDINATE, $coord); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + * |
|
21 | + * @param string $coord Y coordinate in base64url encoding |
|
22 | + */ |
|
23 | + public function __construct(string $coord) |
|
24 | + { |
|
25 | + $this->_validateEncoding($coord); |
|
26 | + parent::__construct(self::PARAM_Y_COORDINATE, $coord); |
|
27 | + } |
|
28 | 28 | } |
@@ -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 | } |
@@ -13,16 +13,16 @@ |
||
13 | 13 | */ |
14 | 14 | class XCoordinateParameter extends CoordinateParameter |
15 | 15 | { |
16 | - use Base64URLValue; |
|
16 | + use Base64URLValue; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - * |
|
21 | - * @param string $coord X coordinate in base64url encoding |
|
22 | - */ |
|
23 | - public function __construct(string $coord) |
|
24 | - { |
|
25 | - $this->_validateEncoding($coord); |
|
26 | - parent::__construct(self::PARAM_X_COORDINATE, $coord); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + * |
|
21 | + * @param string $coord X coordinate in base64url encoding |
|
22 | + */ |
|
23 | + public function __construct(string $coord) |
|
24 | + { |
|
25 | + $this->_validateEncoding($coord); |
|
26 | + parent::__construct(self::PARAM_X_COORDINATE, $coord); |
|
27 | + } |
|
28 | 28 | } |
@@ -14,158 +14,158 @@ |
||
14 | 14 | */ |
15 | 15 | class Claims implements \Countable, \IteratorAggregate |
16 | 16 | { |
17 | - use TypedClaims; |
|
17 | + use TypedClaims; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Claims. |
|
21 | - * |
|
22 | - * @var Claim[] $_claims |
|
23 | - */ |
|
24 | - protected $_claims; |
|
19 | + /** |
|
20 | + * Claims. |
|
21 | + * |
|
22 | + * @var Claim[] $_claims |
|
23 | + */ |
|
24 | + protected $_claims; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Constructor. |
|
28 | - * |
|
29 | - * @param Claim ...$claims Zero or more claims |
|
30 | - */ |
|
31 | - public function __construct(Claim ...$claims) |
|
32 | - { |
|
33 | - $this->_claims = array(); |
|
34 | - foreach ($claims as $claim) { |
|
35 | - $this->_claims[$claim->name()] = $claim; |
|
36 | - } |
|
37 | - } |
|
26 | + /** |
|
27 | + * Constructor. |
|
28 | + * |
|
29 | + * @param Claim ...$claims Zero or more claims |
|
30 | + */ |
|
31 | + public function __construct(Claim ...$claims) |
|
32 | + { |
|
33 | + $this->_claims = array(); |
|
34 | + foreach ($claims as $claim) { |
|
35 | + $this->_claims[$claim->name()] = $claim; |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Initialize from a JSON string. |
|
41 | - * |
|
42 | - * @param string $json JSON |
|
43 | - * @throws \UnexpectedValueException If JSON is malformed |
|
44 | - * @return self |
|
45 | - */ |
|
46 | - public static function fromJSON(string $json): self |
|
47 | - { |
|
48 | - $claims = array(); |
|
49 | - $fields = json_decode($json, true, 32, JSON_BIGINT_AS_STRING); |
|
50 | - if (!is_array($fields)) { |
|
51 | - throw new \UnexpectedValueException("Invalid JSON."); |
|
52 | - } |
|
53 | - foreach ($fields as $name => $value) { |
|
54 | - $claims[] = Claim::fromNameAndValue($name, $value); |
|
55 | - } |
|
56 | - return new self(...$claims); |
|
57 | - } |
|
39 | + /** |
|
40 | + * Initialize from a JSON string. |
|
41 | + * |
|
42 | + * @param string $json JSON |
|
43 | + * @throws \UnexpectedValueException If JSON is malformed |
|
44 | + * @return self |
|
45 | + */ |
|
46 | + public static function fromJSON(string $json): self |
|
47 | + { |
|
48 | + $claims = array(); |
|
49 | + $fields = json_decode($json, true, 32, JSON_BIGINT_AS_STRING); |
|
50 | + if (!is_array($fields)) { |
|
51 | + throw new \UnexpectedValueException("Invalid JSON."); |
|
52 | + } |
|
53 | + foreach ($fields as $name => $value) { |
|
54 | + $claims[] = Claim::fromNameAndValue($name, $value); |
|
55 | + } |
|
56 | + return new self(...$claims); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Get self with Claim objects added. |
|
61 | - * |
|
62 | - * @param Claim ...$claims One or more Claim objects |
|
63 | - * @return self |
|
64 | - */ |
|
65 | - public function withClaims(Claim ...$claims): self |
|
66 | - { |
|
67 | - $obj = clone $this; |
|
68 | - foreach ($claims as $claim) { |
|
69 | - $obj->_claims[$claim->name()] = $claim; |
|
70 | - } |
|
71 | - return $obj; |
|
72 | - } |
|
59 | + /** |
|
60 | + * Get self with Claim objects added. |
|
61 | + * |
|
62 | + * @param Claim ...$claims One or more Claim objects |
|
63 | + * @return self |
|
64 | + */ |
|
65 | + public function withClaims(Claim ...$claims): self |
|
66 | + { |
|
67 | + $obj = clone $this; |
|
68 | + foreach ($claims as $claim) { |
|
69 | + $obj->_claims[$claim->name()] = $claim; |
|
70 | + } |
|
71 | + return $obj; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Get all claims. |
|
76 | - * |
|
77 | - * @return Claim[] |
|
78 | - */ |
|
79 | - public function all(): array |
|
80 | - { |
|
81 | - return $this->_claims; |
|
82 | - } |
|
74 | + /** |
|
75 | + * Get all claims. |
|
76 | + * |
|
77 | + * @return Claim[] |
|
78 | + */ |
|
79 | + public function all(): array |
|
80 | + { |
|
81 | + return $this->_claims; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Check whether claim is present. |
|
86 | - * |
|
87 | - * @param string $name Claim name |
|
88 | - * @return true |
|
89 | - */ |
|
90 | - public function has(string $name): bool |
|
91 | - { |
|
92 | - return isset($this->_claims[$name]); |
|
93 | - } |
|
84 | + /** |
|
85 | + * Check whether claim is present. |
|
86 | + * |
|
87 | + * @param string $name Claim name |
|
88 | + * @return true |
|
89 | + */ |
|
90 | + public function has(string $name): bool |
|
91 | + { |
|
92 | + return isset($this->_claims[$name]); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Get claim by name. |
|
97 | - * |
|
98 | - * @param string $name Claim name |
|
99 | - * @throws \LogicException If claim is not present |
|
100 | - * @return Claim |
|
101 | - */ |
|
102 | - public function get(string $name): Claim |
|
103 | - { |
|
104 | - if (!isset($this->_claims[$name])) { |
|
105 | - throw new \LogicException("Claim $name not set."); |
|
106 | - } |
|
107 | - return $this->_claims[$name]; |
|
108 | - } |
|
95 | + /** |
|
96 | + * Get claim by name. |
|
97 | + * |
|
98 | + * @param string $name Claim name |
|
99 | + * @throws \LogicException If claim is not present |
|
100 | + * @return Claim |
|
101 | + */ |
|
102 | + public function get(string $name): Claim |
|
103 | + { |
|
104 | + if (!isset($this->_claims[$name])) { |
|
105 | + throw new \LogicException("Claim $name not set."); |
|
106 | + } |
|
107 | + return $this->_claims[$name]; |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Convert to a JSON. |
|
112 | - * |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public function toJSON(): string |
|
116 | - { |
|
117 | - $data = array(); |
|
118 | - foreach ($this->_claims as $claim) { |
|
119 | - $data[$claim->name()] = $claim->value(); |
|
120 | - } |
|
121 | - return json_encode((object) $data, JSON_UNESCAPED_SLASHES); |
|
122 | - } |
|
110 | + /** |
|
111 | + * Convert to a JSON. |
|
112 | + * |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public function toJSON(): string |
|
116 | + { |
|
117 | + $data = array(); |
|
118 | + foreach ($this->_claims as $claim) { |
|
119 | + $data[$claim->name()] = $claim->value(); |
|
120 | + } |
|
121 | + return json_encode((object) $data, JSON_UNESCAPED_SLASHES); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Check whether a claims set is valid in the given context. |
|
126 | - * |
|
127 | - * @param ValidationContext $ctx Validation context |
|
128 | - * @return bool |
|
129 | - */ |
|
130 | - public function isValid(ValidationContext $ctx): bool |
|
131 | - { |
|
132 | - try { |
|
133 | - $ctx->validate($this); |
|
134 | - } catch (\RuntimeException $e) { |
|
135 | - return false; |
|
136 | - } |
|
137 | - return true; |
|
138 | - } |
|
124 | + /** |
|
125 | + * Check whether a claims set is valid in the given context. |
|
126 | + * |
|
127 | + * @param ValidationContext $ctx Validation context |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + public function isValid(ValidationContext $ctx): bool |
|
131 | + { |
|
132 | + try { |
|
133 | + $ctx->validate($this); |
|
134 | + } catch (\RuntimeException $e) { |
|
135 | + return false; |
|
136 | + } |
|
137 | + return true; |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * Get the number of claims. |
|
142 | - * |
|
143 | - * @see \Countable::count() |
|
144 | - * @return int |
|
145 | - */ |
|
146 | - public function count(): int |
|
147 | - { |
|
148 | - return count($this->_claims); |
|
149 | - } |
|
140 | + /** |
|
141 | + * Get the number of claims. |
|
142 | + * |
|
143 | + * @see \Countable::count() |
|
144 | + * @return int |
|
145 | + */ |
|
146 | + public function count(): int |
|
147 | + { |
|
148 | + return count($this->_claims); |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * Get iterator for Claim objects keyed by claim name. |
|
153 | - * |
|
154 | - * @see \IteratorAggregate::getIterator() |
|
155 | - * @return \ArrayIterator |
|
156 | - */ |
|
157 | - public function getIterator(): \ArrayIterator |
|
158 | - { |
|
159 | - return new \ArrayIterator($this->_claims); |
|
160 | - } |
|
151 | + /** |
|
152 | + * Get iterator for Claim objects keyed by claim name. |
|
153 | + * |
|
154 | + * @see \IteratorAggregate::getIterator() |
|
155 | + * @return \ArrayIterator |
|
156 | + */ |
|
157 | + public function getIterator(): \ArrayIterator |
|
158 | + { |
|
159 | + return new \ArrayIterator($this->_claims); |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * Convert to string. |
|
164 | - * |
|
165 | - * @return string |
|
166 | - */ |
|
167 | - public function __toString() |
|
168 | - { |
|
169 | - return $this->toJSON(); |
|
170 | - } |
|
162 | + /** |
|
163 | + * Convert to string. |
|
164 | + * |
|
165 | + * @return string |
|
166 | + */ |
|
167 | + public function __toString() |
|
168 | + { |
|
169 | + return $this->toJSON(); |
|
170 | + } |
|
171 | 171 | } |
@@ -13,24 +13,24 @@ |
||
13 | 13 | */ |
14 | 14 | class AudienceClaim extends RegisteredClaim |
15 | 15 | { |
16 | - /** |
|
17 | - * Constructor. |
|
18 | - * |
|
19 | - * @param string ...$audiences One or more audiences |
|
20 | - */ |
|
21 | - public function __construct(string ...$audiences) |
|
22 | - { |
|
23 | - parent::__construct(self::NAME_AUDIENCE, $audiences, |
|
24 | - new ContainsValidator()); |
|
25 | - } |
|
16 | + /** |
|
17 | + * Constructor. |
|
18 | + * |
|
19 | + * @param string ...$audiences One or more audiences |
|
20 | + */ |
|
21 | + public function __construct(string ...$audiences) |
|
22 | + { |
|
23 | + parent::__construct(self::NAME_AUDIENCE, $audiences, |
|
24 | + new ContainsValidator()); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * |
|
29 | - * {@inheritdoc} |
|
30 | - */ |
|
31 | - public static function fromJSONValue($value): self |
|
32 | - { |
|
33 | - $value = (array) $value; |
|
34 | - return new self(...$value); |
|
35 | - } |
|
27 | + /** |
|
28 | + * |
|
29 | + * {@inheritdoc} |
|
30 | + */ |
|
31 | + public static function fromJSONValue($value): self |
|
32 | + { |
|
33 | + $value = (array) $value; |
|
34 | + return new self(...$value); |
|
35 | + } |
|
36 | 36 | } |
@@ -13,25 +13,25 @@ |
||
13 | 13 | */ |
14 | 14 | class IssuedAtClaim extends RegisteredClaim |
15 | 15 | { |
16 | - use NumericDateClaim; |
|
16 | + use NumericDateClaim; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - * |
|
21 | - * @param int $issue_time Issued at time |
|
22 | - */ |
|
23 | - public function __construct(int $issue_time) |
|
24 | - { |
|
25 | - parent::__construct(self::NAME_ISSUED_AT, $issue_time); |
|
26 | - } |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + * |
|
21 | + * @param int $issue_time Issued at time |
|
22 | + */ |
|
23 | + public function __construct(int $issue_time) |
|
24 | + { |
|
25 | + parent::__construct(self::NAME_ISSUED_AT, $issue_time); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Initialize with time set to current time |
|
30 | - * |
|
31 | - * @return self |
|
32 | - */ |
|
33 | - public static function now(): self |
|
34 | - { |
|
35 | - return new self(time()); |
|
36 | - } |
|
28 | + /** |
|
29 | + * Initialize with time set to current time |
|
30 | + * |
|
31 | + * @return self |
|
32 | + */ |
|
33 | + public static function now(): self |
|
34 | + { |
|
35 | + return new self(time()); |
|
36 | + } |
|
37 | 37 | } |
@@ -9,12 +9,12 @@ |
||
9 | 9 | */ |
10 | 10 | class GreaterValidator extends Validator |
11 | 11 | { |
12 | - /** |
|
13 | - * |
|
14 | - * {@inheritdoc} |
|
15 | - */ |
|
16 | - public function validate($value, $constraint): bool |
|
17 | - { |
|
18 | - return $value > $constraint; |
|
19 | - } |
|
12 | + /** |
|
13 | + * |
|
14 | + * {@inheritdoc} |
|
15 | + */ |
|
16 | + public function validate($value, $constraint): bool |
|
17 | + { |
|
18 | + return $value > $constraint; |
|
19 | + } |
|
20 | 20 | } |
@@ -9,24 +9,24 @@ |
||
9 | 9 | */ |
10 | 10 | abstract class Validator |
11 | 11 | { |
12 | - /** |
|
13 | - * Check whether value is valid by given constraint. |
|
14 | - * |
|
15 | - * @param mixed $value Value to assert |
|
16 | - * @param mixed $constraint Constraint |
|
17 | - * @return bool True if value is valid |
|
18 | - */ |
|
19 | - abstract public function validate($value, $constraint): bool; |
|
12 | + /** |
|
13 | + * Check whether value is valid by given constraint. |
|
14 | + * |
|
15 | + * @param mixed $value Value to assert |
|
16 | + * @param mixed $constraint Constraint |
|
17 | + * @return bool True if value is valid |
|
18 | + */ |
|
19 | + abstract public function validate($value, $constraint): bool; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Functor method. |
|
23 | - * |
|
24 | - * @param mixed $value |
|
25 | - * @param mixed $constraint |
|
26 | - * @return bool |
|
27 | - */ |
|
28 | - public function __invoke($value, $constraint): bool |
|
29 | - { |
|
30 | - return $this->validate($value, $constraint); |
|
31 | - } |
|
21 | + /** |
|
22 | + * Functor method. |
|
23 | + * |
|
24 | + * @param mixed $value |
|
25 | + * @param mixed $constraint |
|
26 | + * @return bool |
|
27 | + */ |
|
28 | + public function __invoke($value, $constraint): bool |
|
29 | + { |
|
30 | + return $this->validate($value, $constraint); |
|
31 | + } |
|
32 | 32 | } |