@@ -7,12 +7,12 @@ |
||
7 | 7 | */ |
8 | 8 | class EqualsValidator 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 | } |
@@ -11,14 +11,14 @@ |
||
11 | 11 | */ |
12 | 12 | class JWTIDClaim extends RegisteredClaim |
13 | 13 | { |
14 | - /** |
|
15 | - * Constructor. |
|
16 | - * |
|
17 | - * @param string $id JWT unique identifier |
|
18 | - */ |
|
19 | - public function __construct($id) |
|
20 | - { |
|
21 | - parent::__construct(self::NAME_JWT_ID, (string) $id, |
|
22 | - new EqualsValidator()); |
|
23 | - } |
|
14 | + /** |
|
15 | + * Constructor. |
|
16 | + * |
|
17 | + * @param string $id JWT unique identifier |
|
18 | + */ |
|
19 | + public function __construct($id) |
|
20 | + { |
|
21 | + parent::__construct(self::NAME_JWT_ID, (string) $id, |
|
22 | + new EqualsValidator()); |
|
23 | + } |
|
24 | 24 | } |
@@ -13,28 +13,28 @@ |
||
13 | 13 | */ |
14 | 14 | class NotBeforeClaim extends RegisteredClaim |
15 | 15 | { |
16 | - use NumericDateClaim; |
|
17 | - use ReferenceTimeValidation; |
|
16 | + use NumericDateClaim; |
|
17 | + use ReferenceTimeValidation; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Constructor. |
|
21 | - * |
|
22 | - * @param int $not_before Not before time |
|
23 | - */ |
|
24 | - public function __construct($not_before) |
|
25 | - { |
|
26 | - // validate that claim is before or at the constraint (reference time) |
|
27 | - parent::__construct(self::NAME_NOT_BEFORE, intval($not_before), |
|
28 | - new LessOrEqualValidator()); |
|
29 | - } |
|
19 | + /** |
|
20 | + * Constructor. |
|
21 | + * |
|
22 | + * @param int $not_before Not before time |
|
23 | + */ |
|
24 | + public function __construct($not_before) |
|
25 | + { |
|
26 | + // validate that claim is before or at the constraint (reference time) |
|
27 | + parent::__construct(self::NAME_NOT_BEFORE, intval($not_before), |
|
28 | + new LessOrEqualValidator()); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Initialize with time set to current time |
|
33 | - * |
|
34 | - * @return self |
|
35 | - */ |
|
36 | - public static function now() |
|
37 | - { |
|
38 | - return new self(time()); |
|
39 | - } |
|
31 | + /** |
|
32 | + * Initialize with time set to current time |
|
33 | + * |
|
34 | + * @return self |
|
35 | + */ |
|
36 | + public static function now() |
|
37 | + { |
|
38 | + return new self(time()); |
|
39 | + } |
|
40 | 40 | } |
@@ -11,24 +11,24 @@ |
||
11 | 11 | */ |
12 | 12 | class AudienceClaim extends RegisteredClaim |
13 | 13 | { |
14 | - /** |
|
15 | - * Constructor. |
|
16 | - * |
|
17 | - * @param string ...$audiences One or more audiences |
|
18 | - */ |
|
19 | - public function __construct(...$audiences) |
|
20 | - { |
|
21 | - parent::__construct(self::NAME_AUDIENCE, $audiences, |
|
22 | - new ContainsValidator()); |
|
23 | - } |
|
14 | + /** |
|
15 | + * Constructor. |
|
16 | + * |
|
17 | + * @param string ...$audiences One or more audiences |
|
18 | + */ |
|
19 | + public function __construct(...$audiences) |
|
20 | + { |
|
21 | + parent::__construct(self::NAME_AUDIENCE, $audiences, |
|
22 | + new ContainsValidator()); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * |
|
27 | - * {@inheritdoc} |
|
28 | - */ |
|
29 | - public static function fromJSONValue($value) |
|
30 | - { |
|
31 | - $value = (array) $value; |
|
32 | - return new self(...$value); |
|
33 | - } |
|
25 | + /** |
|
26 | + * |
|
27 | + * {@inheritdoc} |
|
28 | + */ |
|
29 | + public static function fromJSONValue($value) |
|
30 | + { |
|
31 | + $value = (array) $value; |
|
32 | + return new self(...$value); |
|
33 | + } |
|
34 | 34 | } |
@@ -11,14 +11,14 @@ |
||
11 | 11 | */ |
12 | 12 | class IssuerClaim extends RegisteredClaim |
13 | 13 | { |
14 | - /** |
|
15 | - * Constructor. |
|
16 | - * |
|
17 | - * @param string $issuer |
|
18 | - */ |
|
19 | - public function __construct($issuer) |
|
20 | - { |
|
21 | - parent::__construct(self::NAME_ISSUER, (string) $issuer, |
|
22 | - new EqualsValidator()); |
|
23 | - } |
|
14 | + /** |
|
15 | + * Constructor. |
|
16 | + * |
|
17 | + * @param string $issuer |
|
18 | + */ |
|
19 | + public function __construct($issuer) |
|
20 | + { |
|
21 | + parent::__construct(self::NAME_ISSUER, (string) $issuer, |
|
22 | + new EqualsValidator()); |
|
23 | + } |
|
24 | 24 | } |
@@ -11,14 +11,14 @@ |
||
11 | 11 | */ |
12 | 12 | class SubjectClaim extends RegisteredClaim |
13 | 13 | { |
14 | - /** |
|
15 | - * Constructor. |
|
16 | - * |
|
17 | - * @param string $subject Subject |
|
18 | - */ |
|
19 | - public function __construct($subject) |
|
20 | - { |
|
21 | - parent::__construct(self::NAME_SUBJECT, (string) $subject, |
|
22 | - new EqualsValidator()); |
|
23 | - } |
|
14 | + /** |
|
15 | + * Constructor. |
|
16 | + * |
|
17 | + * @param string $subject Subject |
|
18 | + */ |
|
19 | + public function __construct($subject) |
|
20 | + { |
|
21 | + parent::__construct(self::NAME_SUBJECT, (string) $subject, |
|
22 | + new EqualsValidator()); |
|
23 | + } |
|
24 | 24 | } |
@@ -11,25 +11,25 @@ |
||
11 | 11 | */ |
12 | 12 | class IssuedAtClaim extends RegisteredClaim |
13 | 13 | { |
14 | - use NumericDateClaim; |
|
14 | + use NumericDateClaim; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Constructor. |
|
18 | - * |
|
19 | - * @param int $issue_time Issued at time |
|
20 | - */ |
|
21 | - public function __construct($issue_time) |
|
22 | - { |
|
23 | - parent::__construct(self::NAME_ISSUED_AT, intval($issue_time)); |
|
24 | - } |
|
16 | + /** |
|
17 | + * Constructor. |
|
18 | + * |
|
19 | + * @param int $issue_time Issued at time |
|
20 | + */ |
|
21 | + public function __construct($issue_time) |
|
22 | + { |
|
23 | + parent::__construct(self::NAME_ISSUED_AT, intval($issue_time)); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Initialize with time set to current time |
|
28 | - * |
|
29 | - * @return self |
|
30 | - */ |
|
31 | - public static function now() |
|
32 | - { |
|
33 | - return new self(time()); |
|
34 | - } |
|
26 | + /** |
|
27 | + * Initialize with time set to current time |
|
28 | + * |
|
29 | + * @return self |
|
30 | + */ |
|
31 | + public static function now() |
|
32 | + { |
|
33 | + return new self(time()); |
|
34 | + } |
|
35 | 35 | } |
@@ -13,18 +13,18 @@ |
||
13 | 13 | */ |
14 | 14 | class ExpirationTimeClaim extends RegisteredClaim |
15 | 15 | { |
16 | - use NumericDateClaim; |
|
17 | - use ReferenceTimeValidation; |
|
16 | + use NumericDateClaim; |
|
17 | + use ReferenceTimeValidation; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Constructor. |
|
21 | - * |
|
22 | - * @param int $exp_time Expiration time |
|
23 | - */ |
|
24 | - public function __construct($exp_time) |
|
25 | - { |
|
26 | - // validate that claim is after the constraint (reference time) |
|
27 | - parent::__construct(self::NAME_EXPIRATION_TIME, intval($exp_time), |
|
28 | - new GreaterValidator()); |
|
29 | - } |
|
19 | + /** |
|
20 | + * Constructor. |
|
21 | + * |
|
22 | + * @param int $exp_time Expiration time |
|
23 | + */ |
|
24 | + public function __construct($exp_time) |
|
25 | + { |
|
26 | + // validate that claim is after the constraint (reference time) |
|
27 | + parent::__construct(self::NAME_EXPIRATION_TIME, intval($exp_time), |
|
28 | + new GreaterValidator()); |
|
29 | + } |
|
30 | 30 | } |
@@ -9,85 +9,85 @@ |
||
9 | 9 | */ |
10 | 10 | abstract class RegisteredClaim extends Claim |
11 | 11 | { |
12 | - // JWT claims |
|
13 | - const NAME_ISSUER = "iss"; |
|
14 | - const NAME_SUBJECT = "sub"; |
|
15 | - const NAME_AUDIENCE = "aud"; |
|
16 | - const NAME_EXPIRATION_TIME = "exp"; |
|
17 | - const NAME_NOT_BEFORE = "nbf"; |
|
18 | - const NAME_ISSUED_AT = "iat"; |
|
19 | - const NAME_JWT_ID = "jti"; |
|
12 | + // JWT claims |
|
13 | + const NAME_ISSUER = "iss"; |
|
14 | + const NAME_SUBJECT = "sub"; |
|
15 | + const NAME_AUDIENCE = "aud"; |
|
16 | + const NAME_EXPIRATION_TIME = "exp"; |
|
17 | + const NAME_NOT_BEFORE = "nbf"; |
|
18 | + const NAME_ISSUED_AT = "iat"; |
|
19 | + const NAME_JWT_ID = "jti"; |
|
20 | 20 | |
21 | - // OpenID claims |
|
22 | - const NAME_FULL_NAME = "name"; |
|
23 | - const NAME_GIVEN_NAME = "given_name"; |
|
24 | - const NAME_FAMILY_NAME = "family_name"; |
|
25 | - const NAME_MIDDLE_NAME = "middle_name"; |
|
26 | - const NAME_NICKNAME = "nickname"; |
|
27 | - const NAME_PREFERRED_USERNAME = "preferred_username"; |
|
28 | - const NAME_PROFILE_URL = "profile"; |
|
29 | - const NAME_PICTURE_URL = "picture"; |
|
30 | - const NAME_WEBSITE_URL = "website"; |
|
31 | - const NAME_EMAIL = "email"; |
|
32 | - const NAME_EMAIL_VERIFIED = "email_verified"; |
|
33 | - const NAME_GENDER = "gender"; |
|
34 | - const NAME_BIRTHDATE = "birthdate"; |
|
35 | - const NAME_TIMEZONE = "zoneinfo"; |
|
36 | - const NAME_LOCALE = "locale"; |
|
37 | - const NAME_PHONE_NUMBER = "phone_number"; |
|
38 | - const NAME_PHONE_NUMBER_VERIFIED = "phone_number_verified"; |
|
39 | - const NAME_ADDRESS = "address"; |
|
40 | - const NAME_UPDATED_AT = "updated_at"; |
|
41 | - const NAME_AUTHORIZED_PARTY = "azp"; |
|
42 | - const NAME_NONCE = "nonce"; |
|
43 | - const NAME_AUTH_TIME = "auth_time"; |
|
44 | - const NAME_ACCESS_TOKEN_HASH = "at_hash"; |
|
45 | - const NAME_CODE_HASH = "c_hash"; |
|
46 | - const NAME_ACR = "acr"; |
|
47 | - const NAME_AMR = "amr"; |
|
48 | - const NAME_SUB_JWK = "sub_jwk"; |
|
21 | + // OpenID claims |
|
22 | + const NAME_FULL_NAME = "name"; |
|
23 | + const NAME_GIVEN_NAME = "given_name"; |
|
24 | + const NAME_FAMILY_NAME = "family_name"; |
|
25 | + const NAME_MIDDLE_NAME = "middle_name"; |
|
26 | + const NAME_NICKNAME = "nickname"; |
|
27 | + const NAME_PREFERRED_USERNAME = "preferred_username"; |
|
28 | + const NAME_PROFILE_URL = "profile"; |
|
29 | + const NAME_PICTURE_URL = "picture"; |
|
30 | + const NAME_WEBSITE_URL = "website"; |
|
31 | + const NAME_EMAIL = "email"; |
|
32 | + const NAME_EMAIL_VERIFIED = "email_verified"; |
|
33 | + const NAME_GENDER = "gender"; |
|
34 | + const NAME_BIRTHDATE = "birthdate"; |
|
35 | + const NAME_TIMEZONE = "zoneinfo"; |
|
36 | + const NAME_LOCALE = "locale"; |
|
37 | + const NAME_PHONE_NUMBER = "phone_number"; |
|
38 | + const NAME_PHONE_NUMBER_VERIFIED = "phone_number_verified"; |
|
39 | + const NAME_ADDRESS = "address"; |
|
40 | + const NAME_UPDATED_AT = "updated_at"; |
|
41 | + const NAME_AUTHORIZED_PARTY = "azp"; |
|
42 | + const NAME_NONCE = "nonce"; |
|
43 | + const NAME_AUTH_TIME = "auth_time"; |
|
44 | + const NAME_ACCESS_TOKEN_HASH = "at_hash"; |
|
45 | + const NAME_CODE_HASH = "c_hash"; |
|
46 | + const NAME_ACR = "acr"; |
|
47 | + const NAME_AMR = "amr"; |
|
48 | + const NAME_SUB_JWK = "sub_jwk"; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Mapping from registered claim name to class name. |
|
52 | - * |
|
53 | - * @internal |
|
54 | - * |
|
55 | - * @var array |
|
56 | - */ |
|
57 | - const MAP_NAME_TO_CLASS = array( |
|
58 | - /* @formatter:off */ |
|
59 | - self::NAME_ISSUER => IssuerClaim::class, |
|
60 | - self::NAME_SUBJECT => SubjectClaim::class, |
|
61 | - self::NAME_AUDIENCE => AudienceClaim::class, |
|
62 | - self::NAME_EXPIRATION_TIME => ExpirationTimeClaim::class, |
|
63 | - self::NAME_NOT_BEFORE => NotBeforeClaim::class, |
|
64 | - self::NAME_ISSUED_AT => IssuedAtClaim::class, |
|
65 | - self::NAME_JWT_ID => JWTIDClaim::class |
|
66 | - /* @formatter:on */ |
|
67 | - ); |
|
50 | + /** |
|
51 | + * Mapping from registered claim name to class name. |
|
52 | + * |
|
53 | + * @internal |
|
54 | + * |
|
55 | + * @var array |
|
56 | + */ |
|
57 | + const MAP_NAME_TO_CLASS = array( |
|
58 | + /* @formatter:off */ |
|
59 | + self::NAME_ISSUER => IssuerClaim::class, |
|
60 | + self::NAME_SUBJECT => SubjectClaim::class, |
|
61 | + self::NAME_AUDIENCE => AudienceClaim::class, |
|
62 | + self::NAME_EXPIRATION_TIME => ExpirationTimeClaim::class, |
|
63 | + self::NAME_NOT_BEFORE => NotBeforeClaim::class, |
|
64 | + self::NAME_ISSUED_AT => IssuedAtClaim::class, |
|
65 | + self::NAME_JWT_ID => JWTIDClaim::class |
|
66 | + /* @formatter:on */ |
|
67 | + ); |
|
68 | 68 | |
69 | - /** |
|
70 | - * Constructor. |
|
71 | - * |
|
72 | - * Defined here for type strictness. Parameters are passed to the |
|
73 | - * superclass. |
|
74 | - * |
|
75 | - * @param mixed ...$args |
|
76 | - */ |
|
77 | - public function __construct(...$args) |
|
78 | - { |
|
79 | - parent::__construct((string) $args[0], $args[1], |
|
80 | - isset($args[2]) ? $args[2] : null); |
|
81 | - } |
|
69 | + /** |
|
70 | + * Constructor. |
|
71 | + * |
|
72 | + * Defined here for type strictness. Parameters are passed to the |
|
73 | + * superclass. |
|
74 | + * |
|
75 | + * @param mixed ...$args |
|
76 | + */ |
|
77 | + public function __construct(...$args) |
|
78 | + { |
|
79 | + parent::__construct((string) $args[0], $args[1], |
|
80 | + isset($args[2]) ? $args[2] : null); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Initialize concrete claim instance from a JSON value. |
|
85 | - * |
|
86 | - * @param mixed $value |
|
87 | - * @return RegisteredClaim |
|
88 | - */ |
|
89 | - public static function fromJSONValue($value) |
|
90 | - { |
|
91 | - return new static($value); |
|
92 | - } |
|
83 | + /** |
|
84 | + * Initialize concrete claim instance from a JSON value. |
|
85 | + * |
|
86 | + * @param mixed $value |
|
87 | + * @return RegisteredClaim |
|
88 | + */ |
|
89 | + public static function fromJSONValue($value) |
|
90 | + { |
|
91 | + return new static($value); |
|
92 | + } |
|
93 | 93 | } |