@@ -10,453 +10,453 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | trait TypedHeader |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Whether parameters are present. |
|
| 15 | - * |
|
| 16 | - * @param string ...$names Parameter names |
|
| 17 | - * @return bool |
|
| 18 | - */ |
|
| 19 | - abstract public function has(...$names); |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Get a parameter. |
|
| 23 | - * |
|
| 24 | - * @param string $name Parameter name |
|
| 25 | - * @throws \LogicException If the parameter is not present |
|
| 26 | - * @return \JWX\JWT\Parameter\JWTParameter |
|
| 27 | - */ |
|
| 28 | - abstract public function get($name); |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Check whether the algorithm parameter is present. |
|
| 32 | - * |
|
| 33 | - * @return bool |
|
| 34 | - */ |
|
| 35 | - public function hasAlgorithm() |
|
| 36 | - { |
|
| 37 | - return $this->has(Parameter\JWTParameter::P_ALG); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Get the algorithm parameter. |
|
| 42 | - * |
|
| 43 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 44 | - * @throws \LogicException If the parameter is not present |
|
| 45 | - * @return \JWX\JWT\Parameter\AlgorithmParameter |
|
| 46 | - */ |
|
| 47 | - public function algorithm() |
|
| 48 | - { |
|
| 49 | - return self::_checkType($this->get(Parameter\JWTParameter::P_ALG), |
|
| 50 | - Parameter\AlgorithmParameter::class); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Check whether the authentication tag parameter is present. |
|
| 55 | - * |
|
| 56 | - * @return bool |
|
| 57 | - */ |
|
| 58 | - public function hasAuthenticationTag() |
|
| 59 | - { |
|
| 60 | - return $this->has(Parameter\JWTParameter::P_TAG); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Get the authentication tag parameter. |
|
| 65 | - * |
|
| 66 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 67 | - * @throws \LogicException If the parameter is not present |
|
| 68 | - * @return \JWX\JWT\Parameter\AuthenticationTagParameter |
|
| 69 | - */ |
|
| 70 | - public function authenticationTag() |
|
| 71 | - { |
|
| 72 | - return self::_checkType($this->get(Parameter\JWTParameter::P_TAG), |
|
| 73 | - Parameter\AuthenticationTagParameter::class); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Check whether the 'base64url-encode payload' parameter is present. |
|
| 78 | - * |
|
| 79 | - * @return bool |
|
| 80 | - */ |
|
| 81 | - public function hasB64Payload() |
|
| 82 | - { |
|
| 83 | - return $this->has(Parameter\JWTParameter::P_B64); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Get the 'base64url-encode payload' parameter. |
|
| 88 | - * |
|
| 89 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 90 | - * @throws \LogicException If the parameter is not present |
|
| 91 | - * @return \JWX\JWT\Parameter\B64PayloadParameter |
|
| 92 | - */ |
|
| 93 | - public function B64Payload() |
|
| 94 | - { |
|
| 95 | - return self::_checkType($this->get(Parameter\JWTParameter::P_B64), |
|
| 96 | - Parameter\B64PayloadParameter::class); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Check whether the compression algorithm parameter is present. |
|
| 101 | - * |
|
| 102 | - * @return bool |
|
| 103 | - */ |
|
| 104 | - public function hasCompressionAlgorithm() |
|
| 105 | - { |
|
| 106 | - return $this->has(Parameter\JWTParameter::P_ZIP); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Get the compression algorithm parameter. |
|
| 111 | - * |
|
| 112 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 113 | - * @throws \LogicException If the parameter is not present |
|
| 114 | - * @return \JWX\JWT\Parameter\CompressionAlgorithmParameter |
|
| 115 | - */ |
|
| 116 | - public function compressionAlgorithm() |
|
| 117 | - { |
|
| 118 | - return self::_checkType($this->get(Parameter\JWTParameter::P_ZIP), |
|
| 119 | - Parameter\CompressionAlgorithmParameter::class); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Check whether the content type parameter is present. |
|
| 124 | - * |
|
| 125 | - * @return bool |
|
| 126 | - */ |
|
| 127 | - public function hasContentType() |
|
| 128 | - { |
|
| 129 | - return $this->has(Parameter\JWTParameter::P_CTY); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Get the content type parameter. |
|
| 134 | - * |
|
| 135 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 136 | - * @throws \LogicException If the parameter is not present |
|
| 137 | - * @return \JWX\JWT\Parameter\ContentTypeParameter |
|
| 138 | - */ |
|
| 139 | - public function contentType() |
|
| 140 | - { |
|
| 141 | - return self::_checkType($this->get(Parameter\JWTParameter::P_CTY), |
|
| 142 | - Parameter\ContentTypeParameter::class); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Check whether the critical parameter is present. |
|
| 147 | - * |
|
| 148 | - * @return bool |
|
| 149 | - */ |
|
| 150 | - public function hasCritical() |
|
| 151 | - { |
|
| 152 | - return $this->has(Parameter\JWTParameter::P_CRIT); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Get the critical parameter. |
|
| 157 | - * |
|
| 158 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 159 | - * @throws \LogicException If the parameter is not present |
|
| 160 | - * @return \JWX\JWT\Parameter\CriticalParameter |
|
| 161 | - */ |
|
| 162 | - public function critical() |
|
| 163 | - { |
|
| 164 | - return self::_checkType($this->get(Parameter\JWTParameter::P_CRIT), |
|
| 165 | - Parameter\CriticalParameter::class); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Check whether the encryption algorithm parameter is present. |
|
| 170 | - * |
|
| 171 | - * @return bool |
|
| 172 | - */ |
|
| 173 | - public function hasEncryptionAlgorithm() |
|
| 174 | - { |
|
| 175 | - return $this->has(Parameter\JWTParameter::P_ENC); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Get the encryption algorithm parameter. |
|
| 180 | - * |
|
| 181 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 182 | - * @throws \LogicException If the parameter is not present |
|
| 183 | - * @return \JWX\JWT\Parameter\EncryptionAlgorithmParameter |
|
| 184 | - */ |
|
| 185 | - public function encryptionAlgorithm() |
|
| 186 | - { |
|
| 187 | - return self::_checkType($this->get(Parameter\JWTParameter::P_ENC), |
|
| 188 | - Parameter\EncryptionAlgorithmParameter::class); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Check whether the initialization vector parameter is present. |
|
| 193 | - * |
|
| 194 | - * @return bool |
|
| 195 | - */ |
|
| 196 | - public function hasInitializationVector() |
|
| 197 | - { |
|
| 198 | - return $this->has(Parameter\JWTParameter::P_IV); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Get the initialization vector parameter. |
|
| 203 | - * |
|
| 204 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 205 | - * @throws \LogicException If the parameter is not present |
|
| 206 | - * @return \JWX\JWT\Parameter\InitializationVectorParameter |
|
| 207 | - */ |
|
| 208 | - public function initializationVector() |
|
| 209 | - { |
|
| 210 | - return self::_checkType($this->get(Parameter\JWTParameter::P_IV), |
|
| 211 | - Parameter\InitializationVectorParameter::class); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * Check whether the JSON web key parameter is present. |
|
| 216 | - * |
|
| 217 | - * @return bool |
|
| 218 | - */ |
|
| 219 | - public function hasJSONWebKey() |
|
| 220 | - { |
|
| 221 | - return $this->has(Parameter\JWTParameter::P_JWK); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Get the JSON web key parameter. |
|
| 226 | - * |
|
| 227 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 228 | - * @throws \LogicException If the parameter is not present |
|
| 229 | - * @return \JWX\JWT\Parameter\JSONWebKeyParameter |
|
| 230 | - */ |
|
| 231 | - public function JSONWebKey() |
|
| 232 | - { |
|
| 233 | - return self::_checkType($this->get(Parameter\JWTParameter::P_JWK), |
|
| 234 | - Parameter\JSONWebKeyParameter::class); |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Check whether the JWK set URL parameter is present. |
|
| 239 | - * |
|
| 240 | - * @return bool |
|
| 241 | - */ |
|
| 242 | - public function hasJWKSetURL() |
|
| 243 | - { |
|
| 244 | - return $this->has(Parameter\JWTParameter::P_JKU); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * Get the JWK set URL parameter. |
|
| 249 | - * |
|
| 250 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 251 | - * @throws \LogicException If the parameter is not present |
|
| 252 | - * @return \JWX\JWT\Parameter\JWKSetURLParameter |
|
| 253 | - */ |
|
| 254 | - public function JWKSetURL() |
|
| 255 | - { |
|
| 256 | - return self::_checkType($this->get(Parameter\JWTParameter::P_JKU), |
|
| 257 | - Parameter\JWKSetURLParameter::class); |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * Check whether the key ID parameter is present. |
|
| 262 | - * |
|
| 263 | - * @return bool |
|
| 264 | - */ |
|
| 265 | - public function hasKeyID() |
|
| 266 | - { |
|
| 267 | - return $this->has(Parameter\JWTParameter::P_KID); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * Get the key ID parameter. |
|
| 272 | - * |
|
| 273 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 274 | - * @throws \LogicException If the parameter is not present |
|
| 275 | - * @return \JWX\JWT\Parameter\KeyIDParameter |
|
| 276 | - */ |
|
| 277 | - public function keyID() |
|
| 278 | - { |
|
| 279 | - return self::_checkType($this->get(Parameter\JWTParameter::P_KID), |
|
| 280 | - Parameter\KeyIDParameter::class); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * Check whether the PBES2 count parameter is present. |
|
| 285 | - * |
|
| 286 | - * @return bool |
|
| 287 | - */ |
|
| 288 | - public function hasPBES2Count() |
|
| 289 | - { |
|
| 290 | - return $this->has(Parameter\JWTParameter::P_P2C); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Get the PBES2 count parameter. |
|
| 295 | - * |
|
| 296 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 297 | - * @throws \LogicException If the parameter is not present |
|
| 298 | - * @return \JWX\JWT\Parameter\PBES2CountParameter |
|
| 299 | - */ |
|
| 300 | - public function PBES2Count() |
|
| 301 | - { |
|
| 302 | - return self::_checkType($this->get(Parameter\JWTParameter::P_P2C), |
|
| 303 | - Parameter\PBES2CountParameter::class); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * Check whether the PBES2 salt input parameter is present. |
|
| 308 | - * |
|
| 309 | - * @return bool |
|
| 310 | - */ |
|
| 311 | - public function hasPBES2SaltInput() |
|
| 312 | - { |
|
| 313 | - return $this->has(Parameter\JWTParameter::P_P2S); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * Get the PBES2 salt input parameter. |
|
| 318 | - * |
|
| 319 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 320 | - * @throws \LogicException If the parameter is not present |
|
| 321 | - * @return \JWX\JWT\Parameter\PBES2SaltInputParameter |
|
| 322 | - */ |
|
| 323 | - public function PBES2SaltInput() |
|
| 324 | - { |
|
| 325 | - return self::_checkType($this->get(Parameter\JWTParameter::P_P2S), |
|
| 326 | - Parameter\PBES2SaltInputParameter::class); |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * Check whether the type parameter is present. |
|
| 331 | - * |
|
| 332 | - * @return bool |
|
| 333 | - */ |
|
| 334 | - public function hasType() |
|
| 335 | - { |
|
| 336 | - return $this->has(Parameter\JWTParameter::P_TYP); |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * Get the type parameter. |
|
| 341 | - * |
|
| 342 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 343 | - * @throws \LogicException If the parameter is not present |
|
| 344 | - * @return \JWX\JWT\Parameter\TypeParameter |
|
| 345 | - */ |
|
| 346 | - public function type() |
|
| 347 | - { |
|
| 348 | - return self::_checkType($this->get(Parameter\JWTParameter::P_TYP), |
|
| 349 | - Parameter\TypeParameter::class); |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * Check whether the X.509 certificate chain parameter is present. |
|
| 354 | - * |
|
| 355 | - * @return bool |
|
| 356 | - */ |
|
| 357 | - public function hasX509CertificateChain() |
|
| 358 | - { |
|
| 359 | - return $this->has(Parameter\JWTParameter::P_X5C); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * Get the X.509 certificate chain parameter. |
|
| 364 | - * |
|
| 365 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 366 | - * @throws \LogicException If the parameter is not present |
|
| 367 | - * @return \JWX\JWT\Parameter\X509CertificateChainParameter |
|
| 368 | - */ |
|
| 369 | - public function X509CertificateChain() |
|
| 370 | - { |
|
| 371 | - return self::_checkType($this->get(Parameter\JWTParameter::P_X5C), |
|
| 372 | - Parameter\X509CertificateChainParameter::class); |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * Check whether the X.509 certificate SHA-1 thumbprint parameter is |
|
| 377 | - * present. |
|
| 378 | - * |
|
| 379 | - * @return bool |
|
| 380 | - */ |
|
| 381 | - public function hasX509CertificateSHA1Thumbprint() |
|
| 382 | - { |
|
| 383 | - return $this->has(Parameter\JWTParameter::P_X5T); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * Get the X.509 certificate SHA-1 thumbprint parameter. |
|
| 388 | - * |
|
| 389 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 390 | - * @throws \LogicException If the parameter is not present |
|
| 391 | - * @return \JWX\JWT\Parameter\X509CertificateSHA1ThumbprintParameter |
|
| 392 | - */ |
|
| 393 | - public function X509CertificateSHA1Thumbprint() |
|
| 394 | - { |
|
| 395 | - return self::_checkType($this->get(Parameter\JWTParameter::P_X5T), |
|
| 396 | - Parameter\X509CertificateSHA1ThumbprintParameter::class); |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * Check whether the X.509 certificate SHA-256 thumbprint parameter is |
|
| 401 | - * present. |
|
| 402 | - * |
|
| 403 | - * @return bool |
|
| 404 | - */ |
|
| 405 | - public function hasX509CertificateSHA256Thumbprint() |
|
| 406 | - { |
|
| 407 | - return $this->has(Parameter\JWTParameter::P_X5TS256); |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * Get the X.509 certificate SHA-256 thumbprint parameter. |
|
| 412 | - * |
|
| 413 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 414 | - * @throws \LogicException If the parameter is not present |
|
| 415 | - * @return \JWX\JWT\Parameter\X509CertificateSHA256ThumbprintParameter |
|
| 416 | - */ |
|
| 417 | - public function X509CertificateSHA256Thumbprint() |
|
| 418 | - { |
|
| 419 | - return self::_checkType($this->get(Parameter\JWTParameter::P_X5TS256), |
|
| 420 | - Parameter\X509CertificateSHA256ThumbprintParameter::class); |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - /** |
|
| 424 | - * Check whether the X.509 URL parameter is present. |
|
| 425 | - * |
|
| 426 | - * @return bool |
|
| 427 | - */ |
|
| 428 | - public function hasX509URL() |
|
| 429 | - { |
|
| 430 | - return $this->has(Parameter\JWTParameter::P_X5U); |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * Get the X.509 URL parameter. |
|
| 435 | - * |
|
| 436 | - * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 437 | - * @throws \LogicException If the parameter is not present |
|
| 438 | - * @return \JWX\JWT\Parameter\X509URLParameter |
|
| 439 | - */ |
|
| 440 | - public function X509URL() |
|
| 441 | - { |
|
| 442 | - return self::_checkType($this->get(Parameter\JWTParameter::P_X5U), |
|
| 443 | - Parameter\X509URLParameter::class); |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - /** |
|
| 447 | - * Check that the parameter is an instance of the given class. |
|
| 448 | - * |
|
| 449 | - * @param \JWX\JWT\Parameter\JWTParameter $param Parameter |
|
| 450 | - * @param string $cls Class name |
|
| 451 | - * @throws \UnexpectedValueException |
|
| 452 | - * @return \JWX\JWT\Parameter\JWTParameter |
|
| 453 | - */ |
|
| 454 | - private static function _checkType(Parameter\JWTParameter $param, $cls) |
|
| 455 | - { |
|
| 456 | - if (!$param instanceof $cls) { |
|
| 457 | - throw new \UnexpectedValueException( |
|
| 458 | - "$cls expected, got " . get_class($param)); |
|
| 459 | - } |
|
| 460 | - return $param; |
|
| 461 | - } |
|
| 13 | + /** |
|
| 14 | + * Whether parameters are present. |
|
| 15 | + * |
|
| 16 | + * @param string ...$names Parameter names |
|
| 17 | + * @return bool |
|
| 18 | + */ |
|
| 19 | + abstract public function has(...$names); |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Get a parameter. |
|
| 23 | + * |
|
| 24 | + * @param string $name Parameter name |
|
| 25 | + * @throws \LogicException If the parameter is not present |
|
| 26 | + * @return \JWX\JWT\Parameter\JWTParameter |
|
| 27 | + */ |
|
| 28 | + abstract public function get($name); |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Check whether the algorithm parameter is present. |
|
| 32 | + * |
|
| 33 | + * @return bool |
|
| 34 | + */ |
|
| 35 | + public function hasAlgorithm() |
|
| 36 | + { |
|
| 37 | + return $this->has(Parameter\JWTParameter::P_ALG); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Get the algorithm parameter. |
|
| 42 | + * |
|
| 43 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 44 | + * @throws \LogicException If the parameter is not present |
|
| 45 | + * @return \JWX\JWT\Parameter\AlgorithmParameter |
|
| 46 | + */ |
|
| 47 | + public function algorithm() |
|
| 48 | + { |
|
| 49 | + return self::_checkType($this->get(Parameter\JWTParameter::P_ALG), |
|
| 50 | + Parameter\AlgorithmParameter::class); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Check whether the authentication tag parameter is present. |
|
| 55 | + * |
|
| 56 | + * @return bool |
|
| 57 | + */ |
|
| 58 | + public function hasAuthenticationTag() |
|
| 59 | + { |
|
| 60 | + return $this->has(Parameter\JWTParameter::P_TAG); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Get the authentication tag parameter. |
|
| 65 | + * |
|
| 66 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 67 | + * @throws \LogicException If the parameter is not present |
|
| 68 | + * @return \JWX\JWT\Parameter\AuthenticationTagParameter |
|
| 69 | + */ |
|
| 70 | + public function authenticationTag() |
|
| 71 | + { |
|
| 72 | + return self::_checkType($this->get(Parameter\JWTParameter::P_TAG), |
|
| 73 | + Parameter\AuthenticationTagParameter::class); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Check whether the 'base64url-encode payload' parameter is present. |
|
| 78 | + * |
|
| 79 | + * @return bool |
|
| 80 | + */ |
|
| 81 | + public function hasB64Payload() |
|
| 82 | + { |
|
| 83 | + return $this->has(Parameter\JWTParameter::P_B64); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Get the 'base64url-encode payload' parameter. |
|
| 88 | + * |
|
| 89 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 90 | + * @throws \LogicException If the parameter is not present |
|
| 91 | + * @return \JWX\JWT\Parameter\B64PayloadParameter |
|
| 92 | + */ |
|
| 93 | + public function B64Payload() |
|
| 94 | + { |
|
| 95 | + return self::_checkType($this->get(Parameter\JWTParameter::P_B64), |
|
| 96 | + Parameter\B64PayloadParameter::class); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Check whether the compression algorithm parameter is present. |
|
| 101 | + * |
|
| 102 | + * @return bool |
|
| 103 | + */ |
|
| 104 | + public function hasCompressionAlgorithm() |
|
| 105 | + { |
|
| 106 | + return $this->has(Parameter\JWTParameter::P_ZIP); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Get the compression algorithm parameter. |
|
| 111 | + * |
|
| 112 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 113 | + * @throws \LogicException If the parameter is not present |
|
| 114 | + * @return \JWX\JWT\Parameter\CompressionAlgorithmParameter |
|
| 115 | + */ |
|
| 116 | + public function compressionAlgorithm() |
|
| 117 | + { |
|
| 118 | + return self::_checkType($this->get(Parameter\JWTParameter::P_ZIP), |
|
| 119 | + Parameter\CompressionAlgorithmParameter::class); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Check whether the content type parameter is present. |
|
| 124 | + * |
|
| 125 | + * @return bool |
|
| 126 | + */ |
|
| 127 | + public function hasContentType() |
|
| 128 | + { |
|
| 129 | + return $this->has(Parameter\JWTParameter::P_CTY); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Get the content type parameter. |
|
| 134 | + * |
|
| 135 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 136 | + * @throws \LogicException If the parameter is not present |
|
| 137 | + * @return \JWX\JWT\Parameter\ContentTypeParameter |
|
| 138 | + */ |
|
| 139 | + public function contentType() |
|
| 140 | + { |
|
| 141 | + return self::_checkType($this->get(Parameter\JWTParameter::P_CTY), |
|
| 142 | + Parameter\ContentTypeParameter::class); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Check whether the critical parameter is present. |
|
| 147 | + * |
|
| 148 | + * @return bool |
|
| 149 | + */ |
|
| 150 | + public function hasCritical() |
|
| 151 | + { |
|
| 152 | + return $this->has(Parameter\JWTParameter::P_CRIT); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Get the critical parameter. |
|
| 157 | + * |
|
| 158 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 159 | + * @throws \LogicException If the parameter is not present |
|
| 160 | + * @return \JWX\JWT\Parameter\CriticalParameter |
|
| 161 | + */ |
|
| 162 | + public function critical() |
|
| 163 | + { |
|
| 164 | + return self::_checkType($this->get(Parameter\JWTParameter::P_CRIT), |
|
| 165 | + Parameter\CriticalParameter::class); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Check whether the encryption algorithm parameter is present. |
|
| 170 | + * |
|
| 171 | + * @return bool |
|
| 172 | + */ |
|
| 173 | + public function hasEncryptionAlgorithm() |
|
| 174 | + { |
|
| 175 | + return $this->has(Parameter\JWTParameter::P_ENC); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Get the encryption algorithm parameter. |
|
| 180 | + * |
|
| 181 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 182 | + * @throws \LogicException If the parameter is not present |
|
| 183 | + * @return \JWX\JWT\Parameter\EncryptionAlgorithmParameter |
|
| 184 | + */ |
|
| 185 | + public function encryptionAlgorithm() |
|
| 186 | + { |
|
| 187 | + return self::_checkType($this->get(Parameter\JWTParameter::P_ENC), |
|
| 188 | + Parameter\EncryptionAlgorithmParameter::class); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Check whether the initialization vector parameter is present. |
|
| 193 | + * |
|
| 194 | + * @return bool |
|
| 195 | + */ |
|
| 196 | + public function hasInitializationVector() |
|
| 197 | + { |
|
| 198 | + return $this->has(Parameter\JWTParameter::P_IV); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Get the initialization vector parameter. |
|
| 203 | + * |
|
| 204 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 205 | + * @throws \LogicException If the parameter is not present |
|
| 206 | + * @return \JWX\JWT\Parameter\InitializationVectorParameter |
|
| 207 | + */ |
|
| 208 | + public function initializationVector() |
|
| 209 | + { |
|
| 210 | + return self::_checkType($this->get(Parameter\JWTParameter::P_IV), |
|
| 211 | + Parameter\InitializationVectorParameter::class); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Check whether the JSON web key parameter is present. |
|
| 216 | + * |
|
| 217 | + * @return bool |
|
| 218 | + */ |
|
| 219 | + public function hasJSONWebKey() |
|
| 220 | + { |
|
| 221 | + return $this->has(Parameter\JWTParameter::P_JWK); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Get the JSON web key parameter. |
|
| 226 | + * |
|
| 227 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 228 | + * @throws \LogicException If the parameter is not present |
|
| 229 | + * @return \JWX\JWT\Parameter\JSONWebKeyParameter |
|
| 230 | + */ |
|
| 231 | + public function JSONWebKey() |
|
| 232 | + { |
|
| 233 | + return self::_checkType($this->get(Parameter\JWTParameter::P_JWK), |
|
| 234 | + Parameter\JSONWebKeyParameter::class); |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Check whether the JWK set URL parameter is present. |
|
| 239 | + * |
|
| 240 | + * @return bool |
|
| 241 | + */ |
|
| 242 | + public function hasJWKSetURL() |
|
| 243 | + { |
|
| 244 | + return $this->has(Parameter\JWTParameter::P_JKU); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * Get the JWK set URL parameter. |
|
| 249 | + * |
|
| 250 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 251 | + * @throws \LogicException If the parameter is not present |
|
| 252 | + * @return \JWX\JWT\Parameter\JWKSetURLParameter |
|
| 253 | + */ |
|
| 254 | + public function JWKSetURL() |
|
| 255 | + { |
|
| 256 | + return self::_checkType($this->get(Parameter\JWTParameter::P_JKU), |
|
| 257 | + Parameter\JWKSetURLParameter::class); |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * Check whether the key ID parameter is present. |
|
| 262 | + * |
|
| 263 | + * @return bool |
|
| 264 | + */ |
|
| 265 | + public function hasKeyID() |
|
| 266 | + { |
|
| 267 | + return $this->has(Parameter\JWTParameter::P_KID); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * Get the key ID parameter. |
|
| 272 | + * |
|
| 273 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 274 | + * @throws \LogicException If the parameter is not present |
|
| 275 | + * @return \JWX\JWT\Parameter\KeyIDParameter |
|
| 276 | + */ |
|
| 277 | + public function keyID() |
|
| 278 | + { |
|
| 279 | + return self::_checkType($this->get(Parameter\JWTParameter::P_KID), |
|
| 280 | + Parameter\KeyIDParameter::class); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * Check whether the PBES2 count parameter is present. |
|
| 285 | + * |
|
| 286 | + * @return bool |
|
| 287 | + */ |
|
| 288 | + public function hasPBES2Count() |
|
| 289 | + { |
|
| 290 | + return $this->has(Parameter\JWTParameter::P_P2C); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * Get the PBES2 count parameter. |
|
| 295 | + * |
|
| 296 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 297 | + * @throws \LogicException If the parameter is not present |
|
| 298 | + * @return \JWX\JWT\Parameter\PBES2CountParameter |
|
| 299 | + */ |
|
| 300 | + public function PBES2Count() |
|
| 301 | + { |
|
| 302 | + return self::_checkType($this->get(Parameter\JWTParameter::P_P2C), |
|
| 303 | + Parameter\PBES2CountParameter::class); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * Check whether the PBES2 salt input parameter is present. |
|
| 308 | + * |
|
| 309 | + * @return bool |
|
| 310 | + */ |
|
| 311 | + public function hasPBES2SaltInput() |
|
| 312 | + { |
|
| 313 | + return $this->has(Parameter\JWTParameter::P_P2S); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * Get the PBES2 salt input parameter. |
|
| 318 | + * |
|
| 319 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 320 | + * @throws \LogicException If the parameter is not present |
|
| 321 | + * @return \JWX\JWT\Parameter\PBES2SaltInputParameter |
|
| 322 | + */ |
|
| 323 | + public function PBES2SaltInput() |
|
| 324 | + { |
|
| 325 | + return self::_checkType($this->get(Parameter\JWTParameter::P_P2S), |
|
| 326 | + Parameter\PBES2SaltInputParameter::class); |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * Check whether the type parameter is present. |
|
| 331 | + * |
|
| 332 | + * @return bool |
|
| 333 | + */ |
|
| 334 | + public function hasType() |
|
| 335 | + { |
|
| 336 | + return $this->has(Parameter\JWTParameter::P_TYP); |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * Get the type parameter. |
|
| 341 | + * |
|
| 342 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 343 | + * @throws \LogicException If the parameter is not present |
|
| 344 | + * @return \JWX\JWT\Parameter\TypeParameter |
|
| 345 | + */ |
|
| 346 | + public function type() |
|
| 347 | + { |
|
| 348 | + return self::_checkType($this->get(Parameter\JWTParameter::P_TYP), |
|
| 349 | + Parameter\TypeParameter::class); |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * Check whether the X.509 certificate chain parameter is present. |
|
| 354 | + * |
|
| 355 | + * @return bool |
|
| 356 | + */ |
|
| 357 | + public function hasX509CertificateChain() |
|
| 358 | + { |
|
| 359 | + return $this->has(Parameter\JWTParameter::P_X5C); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * Get the X.509 certificate chain parameter. |
|
| 364 | + * |
|
| 365 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 366 | + * @throws \LogicException If the parameter is not present |
|
| 367 | + * @return \JWX\JWT\Parameter\X509CertificateChainParameter |
|
| 368 | + */ |
|
| 369 | + public function X509CertificateChain() |
|
| 370 | + { |
|
| 371 | + return self::_checkType($this->get(Parameter\JWTParameter::P_X5C), |
|
| 372 | + Parameter\X509CertificateChainParameter::class); |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * Check whether the X.509 certificate SHA-1 thumbprint parameter is |
|
| 377 | + * present. |
|
| 378 | + * |
|
| 379 | + * @return bool |
|
| 380 | + */ |
|
| 381 | + public function hasX509CertificateSHA1Thumbprint() |
|
| 382 | + { |
|
| 383 | + return $this->has(Parameter\JWTParameter::P_X5T); |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * Get the X.509 certificate SHA-1 thumbprint parameter. |
|
| 388 | + * |
|
| 389 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 390 | + * @throws \LogicException If the parameter is not present |
|
| 391 | + * @return \JWX\JWT\Parameter\X509CertificateSHA1ThumbprintParameter |
|
| 392 | + */ |
|
| 393 | + public function X509CertificateSHA1Thumbprint() |
|
| 394 | + { |
|
| 395 | + return self::_checkType($this->get(Parameter\JWTParameter::P_X5T), |
|
| 396 | + Parameter\X509CertificateSHA1ThumbprintParameter::class); |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * Check whether the X.509 certificate SHA-256 thumbprint parameter is |
|
| 401 | + * present. |
|
| 402 | + * |
|
| 403 | + * @return bool |
|
| 404 | + */ |
|
| 405 | + public function hasX509CertificateSHA256Thumbprint() |
|
| 406 | + { |
|
| 407 | + return $this->has(Parameter\JWTParameter::P_X5TS256); |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * Get the X.509 certificate SHA-256 thumbprint parameter. |
|
| 412 | + * |
|
| 413 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 414 | + * @throws \LogicException If the parameter is not present |
|
| 415 | + * @return \JWX\JWT\Parameter\X509CertificateSHA256ThumbprintParameter |
|
| 416 | + */ |
|
| 417 | + public function X509CertificateSHA256Thumbprint() |
|
| 418 | + { |
|
| 419 | + return self::_checkType($this->get(Parameter\JWTParameter::P_X5TS256), |
|
| 420 | + Parameter\X509CertificateSHA256ThumbprintParameter::class); |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + /** |
|
| 424 | + * Check whether the X.509 URL parameter is present. |
|
| 425 | + * |
|
| 426 | + * @return bool |
|
| 427 | + */ |
|
| 428 | + public function hasX509URL() |
|
| 429 | + { |
|
| 430 | + return $this->has(Parameter\JWTParameter::P_X5U); |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + /** |
|
| 434 | + * Get the X.509 URL parameter. |
|
| 435 | + * |
|
| 436 | + * @throws \UnexpectedValueException If the parameter has a wrong class |
|
| 437 | + * @throws \LogicException If the parameter is not present |
|
| 438 | + * @return \JWX\JWT\Parameter\X509URLParameter |
|
| 439 | + */ |
|
| 440 | + public function X509URL() |
|
| 441 | + { |
|
| 442 | + return self::_checkType($this->get(Parameter\JWTParameter::P_X5U), |
|
| 443 | + Parameter\X509URLParameter::class); |
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + /** |
|
| 447 | + * Check that the parameter is an instance of the given class. |
|
| 448 | + * |
|
| 449 | + * @param \JWX\JWT\Parameter\JWTParameter $param Parameter |
|
| 450 | + * @param string $cls Class name |
|
| 451 | + * @throws \UnexpectedValueException |
|
| 452 | + * @return \JWX\JWT\Parameter\JWTParameter |
|
| 453 | + */ |
|
| 454 | + private static function _checkType(Parameter\JWTParameter $param, $cls) |
|
| 455 | + { |
|
| 456 | + if (!$param instanceof $cls) { |
|
| 457 | + throw new \UnexpectedValueException( |
|
| 458 | + "$cls expected, got " . get_class($param)); |
|
| 459 | + } |
|
| 460 | + return $param; |
|
| 461 | + } |
|
| 462 | 462 | } |
@@ -13,53 +13,53 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class JOSE extends Header |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Constructor. |
|
| 18 | - * |
|
| 19 | - * @param Header ...$headers One or more headers to merge |
|
| 20 | - */ |
|
| 21 | - public function __construct(Header ...$headers) |
|
| 22 | - { |
|
| 23 | - $params = array(); |
|
| 24 | - foreach ($headers as $header) { |
|
| 25 | - foreach ($header->parameters() as $param) { |
|
| 26 | - if (isset($params[$param->name()])) { |
|
| 27 | - throw new \UnexpectedValueException("Duplicate parameter."); |
|
| 28 | - } |
|
| 29 | - $params[$param->name()] = $param; |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - parent::__construct(...array_values($params)); |
|
| 33 | - } |
|
| 16 | + /** |
|
| 17 | + * Constructor. |
|
| 18 | + * |
|
| 19 | + * @param Header ...$headers One or more headers to merge |
|
| 20 | + */ |
|
| 21 | + public function __construct(Header ...$headers) |
|
| 22 | + { |
|
| 23 | + $params = array(); |
|
| 24 | + foreach ($headers as $header) { |
|
| 25 | + foreach ($header->parameters() as $param) { |
|
| 26 | + if (isset($params[$param->name()])) { |
|
| 27 | + throw new \UnexpectedValueException("Duplicate parameter."); |
|
| 28 | + } |
|
| 29 | + $params[$param->name()] = $param; |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + parent::__construct(...array_values($params)); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Get self merged with another Header. |
|
| 37 | - * |
|
| 38 | - * @param Header $header |
|
| 39 | - * @return self |
|
| 40 | - */ |
|
| 41 | - public function withHeader(Header $header) |
|
| 42 | - { |
|
| 43 | - return new self($this, $header); |
|
| 44 | - } |
|
| 35 | + /** |
|
| 36 | + * Get self merged with another Header. |
|
| 37 | + * |
|
| 38 | + * @param Header $header |
|
| 39 | + * @return self |
|
| 40 | + */ |
|
| 41 | + public function withHeader(Header $header) |
|
| 42 | + { |
|
| 43 | + return new self($this, $header); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Whether JOSE is for a JWS. |
|
| 48 | - * |
|
| 49 | - * @return bool |
|
| 50 | - */ |
|
| 51 | - public function isJWS() |
|
| 52 | - { |
|
| 53 | - return $this->hasAlgorithm() && !$this->hasEncryptionAlgorithm(); |
|
| 54 | - } |
|
| 46 | + /** |
|
| 47 | + * Whether JOSE is for a JWS. |
|
| 48 | + * |
|
| 49 | + * @return bool |
|
| 50 | + */ |
|
| 51 | + public function isJWS() |
|
| 52 | + { |
|
| 53 | + return $this->hasAlgorithm() && !$this->hasEncryptionAlgorithm(); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Whether JOSE is for a JWE. |
|
| 58 | - * |
|
| 59 | - * @return bool |
|
| 60 | - */ |
|
| 61 | - public function isJWE() |
|
| 62 | - { |
|
| 63 | - return $this->hasEncryptionAlgorithm(); |
|
| 64 | - } |
|
| 56 | + /** |
|
| 57 | + * Whether JOSE is for a JWE. |
|
| 58 | + * |
|
| 59 | + * @return bool |
|
| 60 | + */ |
|
| 61 | + public function isJWE() |
|
| 62 | + { |
|
| 63 | + return $this->hasEncryptionAlgorithm(); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -7,10 +7,10 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | interface HeaderParameters |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Get an array of JOSE header parameters representing this object. |
|
| 12 | - * |
|
| 13 | - * @return \JWX\JWT\Parameter\JWTParameter[] |
|
| 14 | - */ |
|
| 15 | - public function headerParameters(); |
|
| 10 | + /** |
|
| 11 | + * Get an array of JOSE header parameters representing this object. |
|
| 12 | + * |
|
| 13 | + * @return \JWX\JWT\Parameter\JWTParameter[] |
|
| 14 | + */ |
|
| 15 | + public function headerParameters(); |
|
| 16 | 16 | } |
@@ -24,308 +24,308 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | class ValidationContext |
| 26 | 26 | { |
| 27 | - /** |
|
| 28 | - * Reference time. |
|
| 29 | - * |
|
| 30 | - * @var int $_refTime |
|
| 31 | - */ |
|
| 32 | - protected $_refTime; |
|
| 27 | + /** |
|
| 28 | + * Reference time. |
|
| 29 | + * |
|
| 30 | + * @var int $_refTime |
|
| 31 | + */ |
|
| 32 | + protected $_refTime; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Leeway in seconds for the reference time constraints. |
|
| 36 | - * |
|
| 37 | - * @var int $_leeway |
|
| 38 | - */ |
|
| 39 | - protected $_leeway; |
|
| 34 | + /** |
|
| 35 | + * Leeway in seconds for the reference time constraints. |
|
| 36 | + * |
|
| 37 | + * @var int $_leeway |
|
| 38 | + */ |
|
| 39 | + protected $_leeway; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Validation constraints. |
|
| 43 | - * |
|
| 44 | - * @var array $_constraints |
|
| 45 | - */ |
|
| 46 | - protected $_constraints; |
|
| 41 | + /** |
|
| 42 | + * Validation constraints. |
|
| 43 | + * |
|
| 44 | + * @var array $_constraints |
|
| 45 | + */ |
|
| 46 | + protected $_constraints; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Explicitly defined validators for named claims. |
|
| 50 | - * |
|
| 51 | - * @var Validator[] $_validators |
|
| 52 | - */ |
|
| 53 | - protected $_validators; |
|
| 48 | + /** |
|
| 49 | + * Explicitly defined validators for named claims. |
|
| 50 | + * |
|
| 51 | + * @var Validator[] $_validators |
|
| 52 | + */ |
|
| 53 | + protected $_validators; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Set of JSON Web Keys usable for the validation. |
|
| 57 | - * |
|
| 58 | - * @var JWKSet $_keys |
|
| 59 | - */ |
|
| 60 | - protected $_keys; |
|
| 55 | + /** |
|
| 56 | + * Set of JSON Web Keys usable for the validation. |
|
| 57 | + * |
|
| 58 | + * @var JWKSet $_keys |
|
| 59 | + */ |
|
| 60 | + protected $_keys; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Whether to allow unsecured JWT's, that is, claims without integrity |
|
| 64 | - * protection nor encryption. |
|
| 65 | - * |
|
| 66 | - * @var bool $_allowUnsecured |
|
| 67 | - */ |
|
| 68 | - protected $_allowUnsecured; |
|
| 62 | + /** |
|
| 63 | + * Whether to allow unsecured JWT's, that is, claims without integrity |
|
| 64 | + * protection nor encryption. |
|
| 65 | + * |
|
| 66 | + * @var bool $_allowUnsecured |
|
| 67 | + */ |
|
| 68 | + protected $_allowUnsecured; |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Constructor. |
|
| 72 | - * |
|
| 73 | - * @param array $constraints Optional array of constraints for the |
|
| 74 | - * registered claims |
|
| 75 | - * @param JWKSet $keys Optional set of JSON Web Keys used for signature |
|
| 76 | - * validation and/or decryption |
|
| 77 | - */ |
|
| 78 | - public function __construct(array $constraints = null, JWKSet $keys = null) |
|
| 79 | - { |
|
| 80 | - $this->_refTime = time(); |
|
| 81 | - $this->_leeway = 60; |
|
| 82 | - $this->_constraints = $constraints ? $constraints : array(); |
|
| 83 | - $this->_validators = array(); |
|
| 84 | - $this->_keys = $keys ? $keys : new JWKSet(); |
|
| 85 | - $this->_allowUnsecured = false; |
|
| 86 | - } |
|
| 70 | + /** |
|
| 71 | + * Constructor. |
|
| 72 | + * |
|
| 73 | + * @param array $constraints Optional array of constraints for the |
|
| 74 | + * registered claims |
|
| 75 | + * @param JWKSet $keys Optional set of JSON Web Keys used for signature |
|
| 76 | + * validation and/or decryption |
|
| 77 | + */ |
|
| 78 | + public function __construct(array $constraints = null, JWKSet $keys = null) |
|
| 79 | + { |
|
| 80 | + $this->_refTime = time(); |
|
| 81 | + $this->_leeway = 60; |
|
| 82 | + $this->_constraints = $constraints ? $constraints : array(); |
|
| 83 | + $this->_validators = array(); |
|
| 84 | + $this->_keys = $keys ? $keys : new JWKSet(); |
|
| 85 | + $this->_allowUnsecured = false; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Initialize with a single JSON Web Key. |
|
| 90 | - * |
|
| 91 | - * @param JWK $key JSON Web Key |
|
| 92 | - * @param array $constraints Optional constraints |
|
| 93 | - * @return self |
|
| 94 | - */ |
|
| 95 | - public static function fromJWK(JWK $key, array $constraints = null) |
|
| 96 | - { |
|
| 97 | - return new self($constraints, new JWKSet($key)); |
|
| 98 | - } |
|
| 88 | + /** |
|
| 89 | + * Initialize with a single JSON Web Key. |
|
| 90 | + * |
|
| 91 | + * @param JWK $key JSON Web Key |
|
| 92 | + * @param array $constraints Optional constraints |
|
| 93 | + * @return self |
|
| 94 | + */ |
|
| 95 | + public static function fromJWK(JWK $key, array $constraints = null) |
|
| 96 | + { |
|
| 97 | + return new self($constraints, new JWKSet($key)); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Get self with the reference time. |
|
| 102 | - * |
|
| 103 | - * @param int|null $ts Unix timestamp |
|
| 104 | - * @return self |
|
| 105 | - */ |
|
| 106 | - public function withReferenceTime($ts) |
|
| 107 | - { |
|
| 108 | - $obj = clone $this; |
|
| 109 | - $obj->_refTime = $ts; |
|
| 110 | - return $obj; |
|
| 111 | - } |
|
| 100 | + /** |
|
| 101 | + * Get self with the reference time. |
|
| 102 | + * |
|
| 103 | + * @param int|null $ts Unix timestamp |
|
| 104 | + * @return self |
|
| 105 | + */ |
|
| 106 | + public function withReferenceTime($ts) |
|
| 107 | + { |
|
| 108 | + $obj = clone $this; |
|
| 109 | + $obj->_refTime = $ts; |
|
| 110 | + return $obj; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Check whether the reference time is set. |
|
| 115 | - * |
|
| 116 | - * @return bool |
|
| 117 | - */ |
|
| 118 | - public function hasReferenceTime() |
|
| 119 | - { |
|
| 120 | - return isset($this->_refTime); |
|
| 121 | - } |
|
| 113 | + /** |
|
| 114 | + * Check whether the reference time is set. |
|
| 115 | + * |
|
| 116 | + * @return bool |
|
| 117 | + */ |
|
| 118 | + public function hasReferenceTime() |
|
| 119 | + { |
|
| 120 | + return isset($this->_refTime); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Get the reference time. |
|
| 125 | - * |
|
| 126 | - * @throws \LogicException |
|
| 127 | - * @return int |
|
| 128 | - */ |
|
| 129 | - public function referenceTime() |
|
| 130 | - { |
|
| 131 | - if (!$this->hasReferenceTime()) { |
|
| 132 | - throw new \LogicException("Reference time not set."); |
|
| 133 | - } |
|
| 134 | - return $this->_refTime; |
|
| 135 | - } |
|
| 123 | + /** |
|
| 124 | + * Get the reference time. |
|
| 125 | + * |
|
| 126 | + * @throws \LogicException |
|
| 127 | + * @return int |
|
| 128 | + */ |
|
| 129 | + public function referenceTime() |
|
| 130 | + { |
|
| 131 | + if (!$this->hasReferenceTime()) { |
|
| 132 | + throw new \LogicException("Reference time not set."); |
|
| 133 | + } |
|
| 134 | + return $this->_refTime; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Get self with the reference time leeway. |
|
| 139 | - * |
|
| 140 | - * @param int $seconds |
|
| 141 | - * @return self |
|
| 142 | - */ |
|
| 143 | - public function withLeeway($seconds) |
|
| 144 | - { |
|
| 145 | - $obj = clone $this; |
|
| 146 | - $obj->_leeway = $seconds; |
|
| 147 | - return $obj; |
|
| 148 | - } |
|
| 137 | + /** |
|
| 138 | + * Get self with the reference time leeway. |
|
| 139 | + * |
|
| 140 | + * @param int $seconds |
|
| 141 | + * @return self |
|
| 142 | + */ |
|
| 143 | + public function withLeeway($seconds) |
|
| 144 | + { |
|
| 145 | + $obj = clone $this; |
|
| 146 | + $obj->_leeway = $seconds; |
|
| 147 | + return $obj; |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Get the reference time leeway. |
|
| 152 | - * |
|
| 153 | - * @return int |
|
| 154 | - */ |
|
| 155 | - public function leeway() |
|
| 156 | - { |
|
| 157 | - return $this->_leeway; |
|
| 158 | - } |
|
| 150 | + /** |
|
| 151 | + * Get the reference time leeway. |
|
| 152 | + * |
|
| 153 | + * @return int |
|
| 154 | + */ |
|
| 155 | + public function leeway() |
|
| 156 | + { |
|
| 157 | + return $this->_leeway; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * Get self with a validation constraint. |
|
| 162 | - * |
|
| 163 | - * If the claim does not provide its own validator, an explicit validator |
|
| 164 | - * must be given. |
|
| 165 | - * |
|
| 166 | - * @param string $name Claim name |
|
| 167 | - * @param mixed $constraint Value to check claim against |
|
| 168 | - * @param Validator|null $validator Optional explicit validator |
|
| 169 | - * @return self |
|
| 170 | - */ |
|
| 171 | - public function withConstraint($name, $constraint, |
|
| 172 | - Validator $validator = null) |
|
| 173 | - { |
|
| 174 | - $obj = clone $this; |
|
| 175 | - $obj->_constraints[$name] = $constraint; |
|
| 176 | - if ($validator) { |
|
| 177 | - $obj->_validators[$name] = $validator; |
|
| 178 | - } |
|
| 179 | - return $obj; |
|
| 180 | - } |
|
| 160 | + /** |
|
| 161 | + * Get self with a validation constraint. |
|
| 162 | + * |
|
| 163 | + * If the claim does not provide its own validator, an explicit validator |
|
| 164 | + * must be given. |
|
| 165 | + * |
|
| 166 | + * @param string $name Claim name |
|
| 167 | + * @param mixed $constraint Value to check claim against |
|
| 168 | + * @param Validator|null $validator Optional explicit validator |
|
| 169 | + * @return self |
|
| 170 | + */ |
|
| 171 | + public function withConstraint($name, $constraint, |
|
| 172 | + Validator $validator = null) |
|
| 173 | + { |
|
| 174 | + $obj = clone $this; |
|
| 175 | + $obj->_constraints[$name] = $constraint; |
|
| 176 | + if ($validator) { |
|
| 177 | + $obj->_validators[$name] = $validator; |
|
| 178 | + } |
|
| 179 | + return $obj; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Get self with the issuer constraint. |
|
| 184 | - * |
|
| 185 | - * @param string $issuer Issuer name |
|
| 186 | - * @return self |
|
| 187 | - */ |
|
| 188 | - public function withIssuer($issuer) |
|
| 189 | - { |
|
| 190 | - return $this->withConstraint(RegisteredClaim::NAME_ISSUER, $issuer); |
|
| 191 | - } |
|
| 182 | + /** |
|
| 183 | + * Get self with the issuer constraint. |
|
| 184 | + * |
|
| 185 | + * @param string $issuer Issuer name |
|
| 186 | + * @return self |
|
| 187 | + */ |
|
| 188 | + public function withIssuer($issuer) |
|
| 189 | + { |
|
| 190 | + return $this->withConstraint(RegisteredClaim::NAME_ISSUER, $issuer); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Get self with the subject constraint. |
|
| 195 | - * |
|
| 196 | - * @param string $subject Subject name |
|
| 197 | - * @return self |
|
| 198 | - */ |
|
| 199 | - public function withSubject($subject) |
|
| 200 | - { |
|
| 201 | - return $this->withConstraint(RegisteredClaim::NAME_SUBJECT, $subject); |
|
| 202 | - } |
|
| 193 | + /** |
|
| 194 | + * Get self with the subject constraint. |
|
| 195 | + * |
|
| 196 | + * @param string $subject Subject name |
|
| 197 | + * @return self |
|
| 198 | + */ |
|
| 199 | + public function withSubject($subject) |
|
| 200 | + { |
|
| 201 | + return $this->withConstraint(RegisteredClaim::NAME_SUBJECT, $subject); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - /** |
|
| 205 | - * Get self with the audience constraint. |
|
| 206 | - * |
|
| 207 | - * @param string $audience Audience name |
|
| 208 | - * @return self |
|
| 209 | - */ |
|
| 210 | - public function withAudience($audience) |
|
| 211 | - { |
|
| 212 | - return $this->withConstraint(RegisteredClaim::NAME_AUDIENCE, $audience); |
|
| 213 | - } |
|
| 204 | + /** |
|
| 205 | + * Get self with the audience constraint. |
|
| 206 | + * |
|
| 207 | + * @param string $audience Audience name |
|
| 208 | + * @return self |
|
| 209 | + */ |
|
| 210 | + public function withAudience($audience) |
|
| 211 | + { |
|
| 212 | + return $this->withConstraint(RegisteredClaim::NAME_AUDIENCE, $audience); |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Get self with the JWT ID constraint. |
|
| 217 | - * |
|
| 218 | - * @param string $id JWT ID |
|
| 219 | - * @return self |
|
| 220 | - */ |
|
| 221 | - public function withID($id) |
|
| 222 | - { |
|
| 223 | - return $this->withConstraint(RegisteredClaim::NAME_JWT_ID, $id); |
|
| 224 | - } |
|
| 215 | + /** |
|
| 216 | + * Get self with the JWT ID constraint. |
|
| 217 | + * |
|
| 218 | + * @param string $id JWT ID |
|
| 219 | + * @return self |
|
| 220 | + */ |
|
| 221 | + public function withID($id) |
|
| 222 | + { |
|
| 223 | + return $this->withConstraint(RegisteredClaim::NAME_JWT_ID, $id); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Check whether a named constraint is present. |
|
| 228 | - * |
|
| 229 | - * @param string $name Claim name |
|
| 230 | - * @return bool |
|
| 231 | - */ |
|
| 232 | - public function hasConstraint($name) |
|
| 233 | - { |
|
| 234 | - return isset($this->_constraints[$name]); |
|
| 235 | - } |
|
| 226 | + /** |
|
| 227 | + * Check whether a named constraint is present. |
|
| 228 | + * |
|
| 229 | + * @param string $name Claim name |
|
| 230 | + * @return bool |
|
| 231 | + */ |
|
| 232 | + public function hasConstraint($name) |
|
| 233 | + { |
|
| 234 | + return isset($this->_constraints[$name]); |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Get a constraint value by the claim name. |
|
| 239 | - * |
|
| 240 | - * @param string $name Claim name |
|
| 241 | - * @throws \LogicException If constraint is not set |
|
| 242 | - * @return mixed Constraint value |
|
| 243 | - */ |
|
| 244 | - public function constraint($name) |
|
| 245 | - { |
|
| 246 | - if (!$this->hasConstraint($name)) { |
|
| 247 | - throw new \LogicException("Constraint $name not set."); |
|
| 248 | - } |
|
| 249 | - return $this->_constraints[$name]; |
|
| 250 | - } |
|
| 237 | + /** |
|
| 238 | + * Get a constraint value by the claim name. |
|
| 239 | + * |
|
| 240 | + * @param string $name Claim name |
|
| 241 | + * @throws \LogicException If constraint is not set |
|
| 242 | + * @return mixed Constraint value |
|
| 243 | + */ |
|
| 244 | + public function constraint($name) |
|
| 245 | + { |
|
| 246 | + if (!$this->hasConstraint($name)) { |
|
| 247 | + throw new \LogicException("Constraint $name not set."); |
|
| 248 | + } |
|
| 249 | + return $this->_constraints[$name]; |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - /** |
|
| 253 | - * Check whether a validator is defined for the given claim name. |
|
| 254 | - * |
|
| 255 | - * @param string $name Claim name |
|
| 256 | - * @return bool |
|
| 257 | - */ |
|
| 258 | - public function hasValidator($name) |
|
| 259 | - { |
|
| 260 | - return isset($this->_validators[$name]); |
|
| 261 | - } |
|
| 252 | + /** |
|
| 253 | + * Check whether a validator is defined for the given claim name. |
|
| 254 | + * |
|
| 255 | + * @param string $name Claim name |
|
| 256 | + * @return bool |
|
| 257 | + */ |
|
| 258 | + public function hasValidator($name) |
|
| 259 | + { |
|
| 260 | + return isset($this->_validators[$name]); |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - /** |
|
| 264 | - * Get explicitly defined validator by the claim name. |
|
| 265 | - * |
|
| 266 | - * @param string $name Claim name |
|
| 267 | - * @throws \LogicException If validator is not set |
|
| 268 | - * @return Validator |
|
| 269 | - */ |
|
| 270 | - public function validator($name) |
|
| 271 | - { |
|
| 272 | - if (!$this->hasValidator($name)) { |
|
| 273 | - throw new \LogicException("Validator $name not set."); |
|
| 274 | - } |
|
| 275 | - return $this->_validators[$name]; |
|
| 276 | - } |
|
| 263 | + /** |
|
| 264 | + * Get explicitly defined validator by the claim name. |
|
| 265 | + * |
|
| 266 | + * @param string $name Claim name |
|
| 267 | + * @throws \LogicException If validator is not set |
|
| 268 | + * @return Validator |
|
| 269 | + */ |
|
| 270 | + public function validator($name) |
|
| 271 | + { |
|
| 272 | + if (!$this->hasValidator($name)) { |
|
| 273 | + throw new \LogicException("Validator $name not set."); |
|
| 274 | + } |
|
| 275 | + return $this->_validators[$name]; |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - /** |
|
| 279 | - * Get a set of JSON Web Keys defined in this context. |
|
| 280 | - * |
|
| 281 | - * @return JWKSet |
|
| 282 | - */ |
|
| 283 | - public function keys() |
|
| 284 | - { |
|
| 285 | - return $this->_keys; |
|
| 286 | - } |
|
| 278 | + /** |
|
| 279 | + * Get a set of JSON Web Keys defined in this context. |
|
| 280 | + * |
|
| 281 | + * @return JWKSet |
|
| 282 | + */ |
|
| 283 | + public function keys() |
|
| 284 | + { |
|
| 285 | + return $this->_keys; |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - /** |
|
| 289 | - * Get self with 'allow unsecured' flag set. |
|
| 290 | - * |
|
| 291 | - * If the unsecured JWT's are allowed, claims shall be considered valid even |
|
| 292 | - * though they are not signed nor encrypted. |
|
| 293 | - * |
|
| 294 | - * @param bool $allow Whether to allow unsecured JWT's |
|
| 295 | - * @return self |
|
| 296 | - */ |
|
| 297 | - public function withUnsecuredAllowed($allow) |
|
| 298 | - { |
|
| 299 | - $obj = clone $this; |
|
| 300 | - $obj->_allowUnsecured = (bool) $allow; |
|
| 301 | - return $obj; |
|
| 302 | - } |
|
| 288 | + /** |
|
| 289 | + * Get self with 'allow unsecured' flag set. |
|
| 290 | + * |
|
| 291 | + * If the unsecured JWT's are allowed, claims shall be considered valid even |
|
| 292 | + * though they are not signed nor encrypted. |
|
| 293 | + * |
|
| 294 | + * @param bool $allow Whether to allow unsecured JWT's |
|
| 295 | + * @return self |
|
| 296 | + */ |
|
| 297 | + public function withUnsecuredAllowed($allow) |
|
| 298 | + { |
|
| 299 | + $obj = clone $this; |
|
| 300 | + $obj->_allowUnsecured = (bool) $allow; |
|
| 301 | + return $obj; |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - /** |
|
| 305 | - * Check whether the unsecured JWT's are allowed. |
|
| 306 | - * |
|
| 307 | - * @return bool |
|
| 308 | - */ |
|
| 309 | - public function isUnsecuredAllowed() |
|
| 310 | - { |
|
| 311 | - return $this->_allowUnsecured; |
|
| 312 | - } |
|
| 304 | + /** |
|
| 305 | + * Check whether the unsecured JWT's are allowed. |
|
| 306 | + * |
|
| 307 | + * @return bool |
|
| 308 | + */ |
|
| 309 | + public function isUnsecuredAllowed() |
|
| 310 | + { |
|
| 311 | + return $this->_allowUnsecured; |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - /** |
|
| 315 | - * Validate claims. |
|
| 316 | - * |
|
| 317 | - * @param Claims $claims |
|
| 318 | - * @throws ValidationException If any of the claims is not valid |
|
| 319 | - * @return self |
|
| 320 | - */ |
|
| 321 | - public function validate(Claims $claims) |
|
| 322 | - { |
|
| 323 | - foreach ($claims as $claim) { |
|
| 324 | - if (!$claim->validateWithContext($this)) { |
|
| 325 | - throw new ValidationException( |
|
| 326 | - "Validation of claim '" . $claim->name() . "' failed."); |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - return $this; |
|
| 330 | - } |
|
| 314 | + /** |
|
| 315 | + * Validate claims. |
|
| 316 | + * |
|
| 317 | + * @param Claims $claims |
|
| 318 | + * @throws ValidationException If any of the claims is not valid |
|
| 319 | + * @return self |
|
| 320 | + */ |
|
| 321 | + public function validate(Claims $claims) |
|
| 322 | + { |
|
| 323 | + foreach ($claims as $claim) { |
|
| 324 | + if (!$claim->validateWithContext($this)) { |
|
| 325 | + throw new ValidationException( |
|
| 326 | + "Validation of claim '" . $claim->name() . "' failed."); |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + return $this; |
|
| 330 | + } |
|
| 331 | 331 | } |
@@ -8,12 +8,12 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class LessOrEqualValidator extends Validator |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * |
|
| 13 | - * {@inheritdoc} |
|
| 14 | - */ |
|
| 15 | - public function validate($value, $constraint) |
|
| 16 | - { |
|
| 17 | - return $value <= $constraint; |
|
| 18 | - } |
|
| 11 | + /** |
|
| 12 | + * |
|
| 13 | + * {@inheritdoc} |
|
| 14 | + */ |
|
| 15 | + public function validate($value, $constraint) |
|
| 16 | + { |
|
| 17 | + return $value <= $constraint; |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -10,15 +10,15 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class ContainsValidator extends Validator |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * |
|
| 15 | - * {@inheritdoc} |
|
| 16 | - */ |
|
| 17 | - public function validate($value, $constraint) |
|
| 18 | - { |
|
| 19 | - if (is_array($value)) { |
|
| 20 | - return in_array($constraint, $value); |
|
| 21 | - } |
|
| 22 | - return $value == $constraint; |
|
| 23 | - } |
|
| 13 | + /** |
|
| 14 | + * |
|
| 15 | + * {@inheritdoc} |
|
| 16 | + */ |
|
| 17 | + public function validate($value, $constraint) |
|
| 18 | + { |
|
| 19 | + if (is_array($value)) { |
|
| 20 | + return in_array($constraint, $value); |
|
| 21 | + } |
|
| 22 | + return $value == $constraint; |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -8,12 +8,12 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class GreaterOrEqualValidator extends Validator |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * |
|
| 13 | - * {@inheritdoc} |
|
| 14 | - */ |
|
| 15 | - public function validate($value, $constraint) |
|
| 16 | - { |
|
| 17 | - return $value >= $constraint; |
|
| 18 | - } |
|
| 11 | + /** |
|
| 12 | + * |
|
| 13 | + * {@inheritdoc} |
|
| 14 | + */ |
|
| 15 | + public function validate($value, $constraint) |
|
| 16 | + { |
|
| 17 | + return $value >= $constraint; |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class LessValidator extends Validator |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * |
|
| 12 | - * {@inheritdoc} |
|
| 13 | - */ |
|
| 14 | - public function validate($value, $constraint) |
|
| 15 | - { |
|
| 16 | - return $value < $constraint; |
|
| 17 | - } |
|
| 10 | + /** |
|
| 11 | + * |
|
| 12 | + * {@inheritdoc} |
|
| 13 | + */ |
|
| 14 | + public function validate($value, $constraint) |
|
| 15 | + { |
|
| 16 | + return $value < $constraint; |
|
| 17 | + } |
|
| 18 | 18 | } |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class GreaterValidator extends Validator |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * |
|
| 12 | - * {@inheritdoc} |
|
| 13 | - */ |
|
| 14 | - public function validate($value, $constraint) |
|
| 15 | - { |
|
| 16 | - return $value > $constraint; |
|
| 17 | - } |
|
| 10 | + /** |
|
| 11 | + * |
|
| 12 | + * {@inheritdoc} |
|
| 13 | + */ |
|
| 14 | + public function validate($value, $constraint) |
|
| 15 | + { |
|
| 16 | + return $value > $constraint; |
|
| 17 | + } |
|
| 18 | 18 | } |