diff --git a/composer.json b/composer.json index 95022e0d8..26e789463 100644 --- a/composer.json +++ b/composer.json @@ -51,8 +51,6 @@ "ext-mbstring": "*", "ext-openssl": "*", "brick/math": "^0.12", - "paragonie/constant_time_encoding": "^2.6", - "paragonie/sodium_compat": "^1.20", "psr/clock": "^1.0", "psr/event-dispatcher": "^1.0", "spomky-labs/pki-framework": "^1.1", @@ -67,11 +65,11 @@ "ext-curl": "*", "ext-gmp": "*", "ext-sodium": "*", - "bjeavons/zxcvbn-php": "^1.3", "ekino/phpstan-banned-code": "^1.0", "infection/infection": "^0.27", "matthiasnoback/symfony-config-test": "^5.0", "nikic/php-parser": "^4.18", + "paragonie/sodium_compat": "^1.20", "php-parallel-lint/php-parallel-lint": "^1.3", "phpbench/phpbench": "^1.2", "phpstan/extension-installer": "^1.3", @@ -100,7 +98,6 @@ "web-token/jwt-experimental": "self.version" }, "suggest": { - "bjeavons/zxcvbn-php": "Adds key quality check for oct keys.", "symfony/serializer": "Use the Symfony serializer to serialize/unserialize JWS and JWE tokens.", "symfony/var-dumper": "Used to show data on the debug toolbar.", "spomky-labs/aes-key-wrap": "To enable AES Key Wrap algorithm." diff --git a/deptrac.yaml b/deptrac.yaml index b71e53d00..1cfa01515 100644 --- a/deptrac.yaml +++ b/deptrac.yaml @@ -15,7 +15,7 @@ parameters: collectors: - { type: className, regex: '^Symfony\\' } - { type: className, regex: '^SpomkyLabs\\Pki\\' } - - { type: className, regex: '^ParagonIE\\' } + - { type: className, regex: '^ParagonIE\\Sodium\\' } - { type: className, regex: '^Psr\\EventDispatcher\\' } - { type: className, regex: '^Psr\\Clock\\' } - { type: className, regex: '^Brick\\Math\\' } diff --git a/performance/JWE/A128GCMKWBench.php b/performance/JWE/A128GCMKWBench.php index ef8b72ac3..0394bfff0 100644 --- a/performance/JWE/A128GCMKWBench.php +++ b/performance/JWE/A128GCMKWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class A128GCMKWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -90,6 +92,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -102,6 +105,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/A128KWBench.php b/performance/JWE/A128KWBench.php index a864fde50..c7ae4a7e6 100644 --- a/performance/JWE/A128KWBench.php +++ b/performance/JWE/A128KWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class A128KWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -90,6 +92,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -102,6 +105,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/A192GCMKWBench.php b/performance/JWE/A192GCMKWBench.php index e83bf456e..0df88fe5d 100644 --- a/performance/JWE/A192GCMKWBench.php +++ b/performance/JWE/A192GCMKWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class A192GCMKWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -90,6 +92,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -102,6 +105,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/A192KWBench.php b/performance/JWE/A192KWBench.php index cd33f9837..a9be82c4e 100644 --- a/performance/JWE/A192KWBench.php +++ b/performance/JWE/A192KWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class A192KWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -90,6 +92,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -102,6 +105,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/A256GCMKWBench.php b/performance/JWE/A256GCMKWBench.php index a9880ef2e..aca5dfab7 100644 --- a/performance/JWE/A256GCMKWBench.php +++ b/performance/JWE/A256GCMKWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class A256GCMKWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -90,6 +92,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -102,6 +105,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/A256KWBench.php b/performance/JWE/A256KWBench.php index a77da73ee..205d1e925 100644 --- a/performance/JWE/A256KWBench.php +++ b/performance/JWE/A256KWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class A256KWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -90,6 +92,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -102,6 +105,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/ECDHESA128KWBench.php b/performance/JWE/ECDHESA128KWBench.php index 6c3199e79..e81c97f2e 100644 --- a/performance/JWE/ECDHESA128KWBench.php +++ b/performance/JWE/ECDHESA128KWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class ECDHESA128KWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -179,6 +181,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -216,6 +219,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/ECDHESA192KWBench.php b/performance/JWE/ECDHESA192KWBench.php index 6c6c450ad..2c59c10d7 100644 --- a/performance/JWE/ECDHESA192KWBench.php +++ b/performance/JWE/ECDHESA192KWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class ECDHESA192KWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -179,6 +181,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -216,6 +219,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/ECDHESA256KWBench.php b/performance/JWE/ECDHESA256KWBench.php index f436217c0..436095297 100644 --- a/performance/JWE/ECDHESA256KWBench.php +++ b/performance/JWE/ECDHESA256KWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class ECDHESA256KWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -179,6 +181,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -216,6 +219,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/ECDHESBench.php b/performance/JWE/ECDHESBench.php index 0846daea8..7559c1a31 100644 --- a/performance/JWE/ECDHESBench.php +++ b/performance/JWE/ECDHESBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class ECDHESBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -251,6 +253,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -288,6 +291,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/PBES2HS256A128KWBench.php b/performance/JWE/PBES2HS256A128KWBench.php index 49d0a98a8..ab94868a4 100644 --- a/performance/JWE/PBES2HS256A128KWBench.php +++ b/performance/JWE/PBES2HS256A128KWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class PBES2HS256A128KWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -90,6 +92,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -102,6 +105,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/PBES2HS384A192KWBench.php b/performance/JWE/PBES2HS384A192KWBench.php index 2b889b8eb..e4f85ec9c 100644 --- a/performance/JWE/PBES2HS384A192KWBench.php +++ b/performance/JWE/PBES2HS384A192KWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class PBES2HS384A192KWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -90,6 +92,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -102,6 +105,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/PBES2HS512A256KWBench.php b/performance/JWE/PBES2HS512A256KWBench.php index da086ab88..0d0eb8d96 100644 --- a/performance/JWE/PBES2HS512A256KWBench.php +++ b/performance/JWE/PBES2HS512A256KWBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class PBES2HS512A256KWBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -90,6 +92,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -102,6 +105,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/RSA1_5Bench.php b/performance/JWE/RSA1_5Bench.php index 3d6421578..5167e88bc 100644 --- a/performance/JWE/RSA1_5Bench.php +++ b/performance/JWE/RSA1_5Bench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class RSA1_5Bench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -168,6 +170,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -195,6 +198,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/RSAOAEP256Bench.php b/performance/JWE/RSAOAEP256Bench.php index b5376a06e..bf2af7aef 100644 --- a/performance/JWE/RSAOAEP256Bench.php +++ b/performance/JWE/RSAOAEP256Bench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class RSAOAEP256Bench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -168,6 +170,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -195,6 +198,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWE/RSAOAEPBench.php b/performance/JWE/RSAOAEPBench.php index c5c7b85da..8f30e6be7 100644 --- a/performance/JWE/RSAOAEPBench.php +++ b/performance/JWE/RSAOAEPBench.php @@ -4,6 +4,7 @@ namespace Jose\Performance\JWE; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -13,6 +14,7 @@ */ final class RSAOAEPBench extends EncryptionBench { + #[Override] public function dataHeadersAndAlgorithms(): array { return [ @@ -168,6 +170,7 @@ public function dataPrivateKeys(): array ]; } + #[Override] public function dataRecipientPublicKeys(): array { return [ @@ -195,6 +198,7 @@ public function dataRecipientPublicKeys(): array ]; } + #[Override] protected function getAAD(): ?string { return 'A,B,C,D'; diff --git a/performance/JWS/ES256Bench.php b/performance/JWS/ES256Bench.php index bd5f27382..257fc9753 100644 --- a/performance/JWS/ES256Bench.php +++ b/performance/JWS/ES256Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJFUzI1NiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -67,6 +71,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey() diff --git a/performance/JWS/ES384Bench.php b/performance/JWS/ES384Bench.php index 8c5239cf7..78f9ea0d0 100644 --- a/performance/JWS/ES384Bench.php +++ b/performance/JWS/ES384Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJFUzM4NCJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -67,6 +71,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey() diff --git a/performance/JWS/ES512Bench.php b/performance/JWS/ES512Bench.php index 12e51a73b..7c2fd71ba 100644 --- a/performance/JWS/ES512Bench.php +++ b/performance/JWS/ES512Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJFUzUxMiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -67,6 +71,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey() diff --git a/performance/JWS/EdDSABench.php b/performance/JWS/EdDSABench.php index 496e39068..7715473cb 100644 --- a/performance/JWS/EdDSABench.php +++ b/performance/JWS/EdDSABench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJFZERTQSJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -64,6 +68,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey() diff --git a/performance/JWS/HS256Bench.php b/performance/JWS/HS256Bench.php index 9654cfb09..528eec587 100644 --- a/performance/JWS/HS256Bench.php +++ b/performance/JWS/HS256Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJIUzI1NiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -64,6 +68,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey(); diff --git a/performance/JWS/HS384Bench.php b/performance/JWS/HS384Bench.php index 23b1bcb4f..290a147b0 100644 --- a/performance/JWS/HS384Bench.php +++ b/performance/JWS/HS384Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJIUzM4NCJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -64,6 +68,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey(); diff --git a/performance/JWS/HS512Bench.php b/performance/JWS/HS512Bench.php index f2930c5b5..a366652b3 100644 --- a/performance/JWS/HS512Bench.php +++ b/performance/JWS/HS512Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJIUzUxMiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -64,6 +68,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey(); diff --git a/performance/JWS/NoneBench.php b/performance/JWS/NoneBench.php index 2a4c562fb..2dccfb8b6 100644 --- a/performance/JWS/NoneBench.php +++ b/performance/JWS/NoneBench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJub25lIn0.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -61,6 +65,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey(); diff --git a/performance/JWS/PS256Bench.php b/performance/JWS/PS256Bench.php index 514430a84..05a62758d 100644 --- a/performance/JWS/PS256Bench.php +++ b/performance/JWS/PS256Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJQUzI1NiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -71,6 +75,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey() diff --git a/performance/JWS/PS384Bench.php b/performance/JWS/PS384Bench.php index 2c1f8cb6c..e7127469c 100644 --- a/performance/JWS/PS384Bench.php +++ b/performance/JWS/PS384Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJQUzM4NCJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -71,6 +75,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey() diff --git a/performance/JWS/PS512Bench.php b/performance/JWS/PS512Bench.php index 473864326..3bbec29f8 100644 --- a/performance/JWS/PS512Bench.php +++ b/performance/JWS/PS512Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJQUzUxMiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -71,6 +75,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey() diff --git a/performance/JWS/RS256Bench.php b/performance/JWS/RS256Bench.php index 1e27ea895..2b2c7840a 100644 --- a/performance/JWS/RS256Bench.php +++ b/performance/JWS/RS256Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJSUzI1NiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -71,6 +75,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey() diff --git a/performance/JWS/RS384Bench.php b/performance/JWS/RS384Bench.php index 32147b68b..6a9d848fe 100644 --- a/performance/JWS/RS384Bench.php +++ b/performance/JWS/RS384Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJSUzM4NCJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -71,6 +75,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey() diff --git a/performance/JWS/RS512Bench.php b/performance/JWS/RS512Bench.php index 33492aa4b..f1fac51cd 100644 --- a/performance/JWS/RS512Bench.php +++ b/performance/JWS/RS512Bench.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use PhpBench\Benchmark\Metadata\Annotations\Groups; use PhpBench\Benchmark\Metadata\Annotations\Revs; @@ -42,6 +43,7 @@ public function dataVerify(): array ]; } + #[Override] protected function getAlgorithm(): SignatureAlgorithm { return $this->getSignatureAlgorithmsManager() @@ -49,11 +51,13 @@ protected function getAlgorithm(): SignatureAlgorithm ; } + #[Override] protected function getInput(): string { return 'eyJhbGciOiJSUzUxMiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4'; } + #[Override] protected function getPrivateKey(): JWK { return new JWK([ @@ -71,6 +75,7 @@ protected function getPrivateKey(): JWK ]); } + #[Override] protected function getPublicKey(): JWK { return $this->getPrivateKey() diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3d10ea199..65ba8e594 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -885,11 +885,6 @@ parameters: count: 1 path: src/Bundle/Resources/config/Algorithms/signature_experimental.php - - - message: "#^Class Jose\\\\Bundle\\\\JoseFramework\\\\Routing\\\\JWKSetLoader has an uninitialized property \\$resolver\\. Give it default value or assign it in the constructor\\.$#" - count: 1 - path: src/Bundle/Routing/JWKSetLoader.php - - message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWEEncoder\\:\\:decode\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" count: 1 @@ -1175,86 +1170,16 @@ parameters: count: 1 path: src/Library/Checker/IssuerChecker.php - - - message: "#^Property Jose\\\\Component\\\\Console\\\\AddKeyIntoKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/AddKeyIntoKeysetCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\AddKeyIntoKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/AddKeyIntoKeysetCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/EcKeyGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/EcKeyGeneratorCommand.php - - message: "#^Cannot cast mixed to int\\.$#" count: 1 path: src/Library/Console/EcKeysetGeneratorCommand.php - - - message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/EcKeysetGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/EcKeysetGeneratorCommand.php - - message: "#^Method Jose\\\\Component\\\\Console\\\\GeneratorCommand\\:\\:getOptions\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/Library/Console/GeneratorCommand.php - - - message: "#^Property Jose\\\\Component\\\\Console\\\\GetThumbprintCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/GetThumbprintCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\GetThumbprintCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/GetThumbprintCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\JKULoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/JKULoaderCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\JKULoaderCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/JKULoaderCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\KeyAnalyzerCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/KeyAnalyzerCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\KeyAnalyzerCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/KeyAnalyzerCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\KeyFileLoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/KeyFileLoaderCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\KeyFileLoaderCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/KeyFileLoaderCommand.php - - message: "#^Parameter \\#1 \\$jwk of method Jose\\\\Component\\\\KeyManagement\\\\Analyzer\\\\KeyAnalyzerManager\\:\\:analyze\\(\\) expects Jose\\\\Component\\\\Core\\\\JWK, mixed given\\.$#" count: 1 @@ -1265,226 +1190,31 @@ parameters: count: 1 path: src/Library/Console/KeysetAnalyzerCommand.php - - - message: "#^Property Jose\\\\Component\\\\Console\\\\KeysetAnalyzerCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/KeysetAnalyzerCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\KeysetAnalyzerCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/KeysetAnalyzerCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\MergeKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/MergeKeysetCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\MergeKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/MergeKeysetCommand.php - - - - message: "#^Attribute class Jose\\\\Component\\\\Console\\\\AsCommand does not exist\\.$#" - count: 1 - path: src/Library/Console/NoneKeyGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\NoneKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/NoneKeyGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\NoneKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/NoneKeyGeneratorCommand.php - - message: "#^Cannot cast mixed to int\\.$#" count: 1 path: src/Library/Console/OctKeyGeneratorCommand.php - - - message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/OctKeyGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/OctKeyGeneratorCommand.php - - message: "#^Cannot cast mixed to int\\.$#" count: 2 path: src/Library/Console/OctKeysetGeneratorCommand.php - - - message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/OctKeysetGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/OctKeysetGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/OkpKeyGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/OkpKeyGeneratorCommand.php - - message: "#^Cannot cast mixed to int\\.$#" count: 1 path: src/Library/Console/OkpKeysetGeneratorCommand.php - - - message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/OkpKeysetGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/OkpKeysetGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\OptimizeRsaKeyCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/OptimizeRsaKeyCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\OptimizeRsaKeyCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/OptimizeRsaKeyCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\P12CertificateLoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/P12CertificateLoaderCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\P12CertificateLoaderCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/P12CertificateLoaderCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\PemConverterCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/PemConverterCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\PemConverterCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/PemConverterCommand.php - - - - message: "#^Attribute class Jose\\\\Component\\\\Console\\\\AsCommand does not exist\\.$#" - count: 1 - path: src/Library/Console/PublicKeyCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeyCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/PublicKeyCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeyCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/PublicKeyCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/PublicKeysetCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/PublicKeysetCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\RotateKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/RotateKeysetCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\RotateKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/RotateKeysetCommand.php - - message: "#^Cannot cast mixed to int\\.$#" count: 1 path: src/Library/Console/RsaKeyGeneratorCommand.php - - - message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/RsaKeyGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/RsaKeyGeneratorCommand.php - - message: "#^Cannot cast mixed to int\\.$#" count: 2 path: src/Library/Console/RsaKeysetGeneratorCommand.php - - - message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/RsaKeysetGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/RsaKeysetGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\SecretKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/SecretKeyGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\SecretKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/SecretKeyGeneratorCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\X509CertificateLoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/X509CertificateLoaderCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\X509CertificateLoaderCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/X509CertificateLoaderCommand.php - - - - message: "#^Attribute class Jose\\\\Component\\\\Console\\\\AsCommand does not exist\\.$#" - count: 1 - path: src/Library/Console/X5ULoaderCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\X5ULoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#" - count: 1 - path: src/Library/Console/X5ULoaderCommand.php - - - - message: "#^Property Jose\\\\Component\\\\Console\\\\X5ULoaderCommand\\:\\:\\$defaultName has no type specified\\.$#" - count: 1 - path: src/Library/Console/X5ULoaderCommand.php - - message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#" count: 1 @@ -1570,6 +1300,41 @@ parameters: count: 1 path: src/Library/Core/JWKSet.php + - + message: "#^Comparison operation \"\\>\" between 0 and 1 is always false\\.$#" + count: 1 + path: src/Library/Core/Util/Base64UrlSafe.php + + - + message: "#^Instantiated class Jose\\\\Component\\\\Core\\\\Util\\\\InvalidArgumentException not found\\.$#" + count: 2 + path: src/Library/Core/Util/Base64UrlSafe.php + + - + message: "#^Instantiated class Jose\\\\Component\\\\Core\\\\Util\\\\RangeException not found\\.$#" + count: 3 + path: src/Library/Core/Util/Base64UrlSafe.php + + - + message: "#^Method Jose\\\\Component\\\\Core\\\\Util\\\\Base64UrlSafe\\:\\:safeSubstr\\(\\) has parameter \\$length with no type specified\\.$#" + count: 1 + path: src/Library/Core/Util/Base64UrlSafe.php + + - + message: "#^Throwing object of an unknown class Jose\\\\Component\\\\Core\\\\Util\\\\InvalidArgumentException\\.$#" + count: 2 + path: src/Library/Core/Util/Base64UrlSafe.php + + - + message: "#^Throwing object of an unknown class Jose\\\\Component\\\\Core\\\\Util\\\\RangeException\\.$#" + count: 3 + path: src/Library/Core/Util/Base64UrlSafe.php + + - + message: "#^Variable \\$i might not be defined\\.$#" + count: 2 + path: src/Library/Core/Util/Base64UrlSafe.php + - message: "#^Method Jose\\\\Component\\\\Core\\\\Util\\\\ECKey\\:\\:createECKey\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#" count: 1 @@ -1590,6 +1355,46 @@ parameters: count: 2 path: src/Library/Core/Util/Ecc/Curve.php + - + message: "#^Parameter \\#1 \\$a is passed by reference so it does not accept readonly property Jose\\\\Component\\\\Core\\\\Util\\\\Ecc\\\\Point\\:\\:\\$infinity\\.$#" + count: 1 + path: src/Library/Core/Util/Ecc/Point.php + + - + message: "#^Parameter \\#1 \\$sa is passed by reference so it does not accept readonly property Jose\\\\Component\\\\Core\\\\Util\\\\Ecc\\\\Point\\:\\:\\$order\\.$#" + count: 1 + path: src/Library/Core/Util/Ecc/Point.php + + - + message: "#^Parameter \\#1 \\$sa is passed by reference so it does not accept readonly property Jose\\\\Component\\\\Core\\\\Util\\\\Ecc\\\\Point\\:\\:\\$x\\.$#" + count: 1 + path: src/Library/Core/Util/Ecc/Point.php + + - + message: "#^Parameter \\#1 \\$sa is passed by reference so it does not accept readonly property Jose\\\\Component\\\\Core\\\\Util\\\\Ecc\\\\Point\\:\\:\\$y\\.$#" + count: 1 + path: src/Library/Core/Util/Ecc/Point.php + + - + message: "#^Parameter \\#2 \\$b is passed by reference so it does not accept readonly property Jose\\\\Component\\\\Core\\\\Util\\\\Ecc\\\\Point\\:\\:\\$infinity\\.$#" + count: 1 + path: src/Library/Core/Util/Ecc/Point.php + + - + message: "#^Parameter \\#2 \\$sb is passed by reference so it does not accept readonly property Jose\\\\Component\\\\Core\\\\Util\\\\Ecc\\\\Point\\:\\:\\$order\\.$#" + count: 1 + path: src/Library/Core/Util/Ecc/Point.php + + - + message: "#^Parameter \\#2 \\$sb is passed by reference so it does not accept readonly property Jose\\\\Component\\\\Core\\\\Util\\\\Ecc\\\\Point\\:\\:\\$x\\.$#" + count: 1 + path: src/Library/Core/Util/Ecc/Point.php + + - + message: "#^Parameter \\#2 \\$sb is passed by reference so it does not accept readonly property Jose\\\\Component\\\\Core\\\\Util\\\\Ecc\\\\Point\\:\\:\\$y\\.$#" + count: 1 + path: src/Library/Core/Util/Ecc/Point.php + - message: "#^Method Jose\\\\Component\\\\Core\\\\Util\\\\RSAKey\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -1622,7 +1427,7 @@ parameters: - message: "#^Parameter \\#1 \\$length of function random_bytes expects int\\<1, max\\>, int given\\.$#" - count: 2 + count: 1 path: src/Library/Encryption/Algorithm/KeyEncryption/Util/RSACrypt.php - @@ -1881,7 +1686,7 @@ parameters: path: src/Library/Encryption/Serializer/JSONFlattenedSerializer.php - - message: "#^Parameter \\#1 \\$encodedString of static method ParagonIE\\\\ConstantTime\\\\Base64\\:\\:decodeNoPadding\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#1 \\$encodedString of static method Jose\\\\Component\\\\Core\\\\Util\\\\Base64UrlSafe\\:\\:decodeNoPadding\\(\\) expects string, mixed given\\.$#" count: 3 path: src/Library/Encryption/Serializer/JSONFlattenedSerializer.php @@ -1911,7 +1716,7 @@ parameters: path: src/Library/Encryption/Serializer/JSONGeneralSerializer.php - - message: "#^Parameter \\#1 \\$encodedString of static method ParagonIE\\\\ConstantTime\\\\Base64\\:\\:decodeNoPadding\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#1 \\$encodedString of static method Jose\\\\Component\\\\Core\\\\Util\\\\Base64UrlSafe\\:\\:decodeNoPadding\\(\\) expects string, mixed given\\.$#" count: 3 path: src/Library/Encryption/Serializer/JSONGeneralSerializer.php @@ -1950,6 +1755,21 @@ parameters: count: 2 path: src/Library/KeyManagement/Analyzer/UsageAnalyzer.php + - + message: "#^Argument of an invalid type array\\\\|string supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: src/Library/KeyManagement/Analyzer/ZxcvbnKeyAnalyzer.php + + - + message: "#^Only booleans are allowed in a negated boolean, int\\<0, max\\> given\\.$#" + count: 1 + path: src/Library/KeyManagement/Analyzer/ZxcvbnKeyAnalyzer.php + + - + message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, array\\\\|string given\\.$#" + count: 1 + path: src/Library/KeyManagement/Analyzer/ZxcvbnKeyAnalyzer.php + - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\JKUFactory\\:\\:loadFromUrl\\(\\) has parameter \\$header with no value type specified in iterable type array\\.$#" count: 1 @@ -2050,146 +1870,6 @@ parameters: count: 1 path: src/Library/KeyManagement/KeyConverter/ECKey.php - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:loadFromKey\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:loadFromKeyFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:loadFromX5C\\(\\) has parameter \\$x5c with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:loadFromX5C\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:loadKeyFromCertificate\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:loadKeyFromCertificateFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:loadKeyFromDER\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:loadKeyFromPEM\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:loadKeyFromX509Resource\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:tryToLoadECKey\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:tryToLoadOtherKeyTypes\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/KeyConverter.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\RSAKey\\:\\:__construct\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/RSAKey.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\RSAKey\\:\\:createFromKeyDetails\\(\\) has parameter \\$details with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/RSAKey.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\RSAKey\\:\\:loadJWK\\(\\) has parameter \\$jwk with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/RSAKey.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\RSAKey\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/RSAKey.php - - - - message: "#^Parameter \\#1 \\$details of static method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\RSAKey\\:\\:createFromKeyDetails\\(\\) expects array, mixed given\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/RSAKey.php - - - - message: "#^Property Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\RSAKey\\:\\:\\$values type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/KeyConverter/RSAKey.php - - - - message: "#^Cannot cast mixed to string\\.$#" - count: 1 - path: src/Library/KeyManagement/X5UFactory.php - - - - message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\X5UFactory\\:\\:loadFromUrl\\(\\) has parameter \\$header with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Library/KeyManagement/X5UFactory.php - - - - message: "#^Parameter \\#1 \\$certificate of static method Jose\\\\Component\\\\KeyManagement\\\\KeyConverter\\\\KeyConverter\\:\\:loadKeyFromCertificate\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Library/KeyManagement/X5UFactory.php - - - - message: "#^Call to function array_key_exists\\(\\) with 'key' and array\\{key\\: Jose\\\\Component\\\\Core\\\\JWK, header\\?\\: array\\\\} will always evaluate to true\\.$#" - count: 1 - path: src/Library/NestedToken/NestedTokenBuilder.php - - - - message: "#^Call to function array_key_exists\\(\\) with 'key' and array\\{key\\: Jose\\\\Component\\\\Core\\\\JWK, protected_header\\?\\: array\\, header\\?\\: array\\\\} will always evaluate to true\\.$#" - count: 1 - path: src/Library/NestedToken/NestedTokenBuilder.php - - - - message: "#^Call to function is_array\\(\\) with array\\{key\\: Jose\\\\Component\\\\Core\\\\JWK, header\\?\\: array\\\\} will always evaluate to true\\.$#" - count: 1 - path: src/Library/NestedToken/NestedTokenBuilder.php - - - - message: "#^Call to function is_array\\(\\) with array\\{key\\: Jose\\\\Component\\\\Core\\\\JWK, protected_header\\?\\: array\\, header\\?\\: array\\\\} will always evaluate to true\\.$#" - count: 1 - path: src/Library/NestedToken/NestedTokenBuilder.php - - - - message: "#^Result of \\|\\| is always false\\.$#" - count: 2 - path: src/Library/NestedToken/NestedTokenBuilder.php - - - - message: "#^Strict comparison using \\=\\=\\= between non\\-empty\\-string and '' will always evaluate to false\\.$#" - count: 1 - path: src/Library/Signature/Algorithm/None.php - - - - message: "#^Parameter \\#1 \\$length of function random_bytes expects int\\<1, max\\>, int given\\.$#" - count: 1 - path: src/Library/Signature/Algorithm/Util/RSA.php - - - - message: "#^Variable static method call on Jose\\\\Component\\\\Core\\\\Util\\\\Hash\\.$#" - count: 2 - path: src/Library/Signature/Algorithm/Util/RSA.php - - message: "#^Parameter \\#2 \\$protectedHeader of method Jose\\\\Component\\\\Signature\\\\JWS\\:\\:addSignature\\(\\) expects array\\{alg\\?\\: string, string\\?\\: mixed\\}, array\\ given\\.$#" count: 1 @@ -2231,7 +1911,7 @@ parameters: path: src/Library/Signature/Serializer/CompactSerializer.php - - message: "#^Parameter \\#1 \\$encodedString of static method ParagonIE\\\\ConstantTime\\\\Base64\\:\\:decodeNoPadding\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#1 \\$encodedString of static method Jose\\\\Component\\\\Core\\\\Util\\\\Base64UrlSafe\\:\\:decodeNoPadding\\(\\) expects string, mixed given\\.$#" count: 1 path: src/Library/Signature/Serializer/JSONFlattenedSerializer.php @@ -2261,7 +1941,7 @@ parameters: path: src/Library/Signature/Serializer/JSONGeneralSerializer.php - - message: "#^Parameter \\#1 \\$encodedString of static method ParagonIE\\\\ConstantTime\\\\Base64\\:\\:decodeNoPadding\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#1 \\$encodedString of static method Jose\\\\Component\\\\Core\\\\Util\\\\Base64UrlSafe\\:\\:decodeNoPadding\\(\\) expects string, mixed given\\.$#" count: 1 path: src/Library/Signature/Serializer/JSONGeneralSerializer.php diff --git a/rector.php b/rector.php index b3c24ab79..0f5ae450a 100644 --- a/rector.php +++ b/rector.php @@ -42,7 +42,7 @@ __DIR__ . '/src/Bundle/JoseFramework/DependencyInjection/Source/KeyManagement/JWKSource.php', __DIR__ . '/src/Bundle/JoseFramework/DependencyInjection/Source/KeyManagement/JWKSetSource.php', ]); - $config->phpVersion(PhpVersion::PHP_81); + $config->phpVersion(PhpVersion::PHP_83); $config->parallel(); $config->importNames(); $config->importShortClasses(); diff --git a/src/Bundle/Controller/JWKSetController.php b/src/Bundle/Controller/JWKSetController.php index 34a4a32be..c6296f52a 100644 --- a/src/Bundle/Controller/JWKSetController.php +++ b/src/Bundle/Controller/JWKSetController.php @@ -6,10 +6,10 @@ use Symfony\Component\HttpFoundation\Response; -class JWKSetController +final readonly class JWKSetController { public function __construct( - private readonly string $jwkset + private string $jwkset ) { } diff --git a/src/Bundle/Controller/JWKSetControllerFactory.php b/src/Bundle/Controller/JWKSetControllerFactory.php index 36bff63fc..a1d0f0520 100644 --- a/src/Bundle/Controller/JWKSetControllerFactory.php +++ b/src/Bundle/Controller/JWKSetControllerFactory.php @@ -7,7 +7,7 @@ use Jose\Component\Core\JWKSet; use Jose\Component\Core\Util\JsonConverter; -class JWKSetControllerFactory +final readonly class JWKSetControllerFactory { public function create(JWKSet $jwkset): JWKSetController { diff --git a/src/Bundle/DataCollector/AlgorithmCollector.php b/src/Bundle/DataCollector/AlgorithmCollector.php index ebb47e3b7..eb5081d48 100644 --- a/src/Bundle/DataCollector/AlgorithmCollector.php +++ b/src/Bundle/DataCollector/AlgorithmCollector.php @@ -10,21 +10,23 @@ use Jose\Component\Encryption\Algorithm\KeyEncryptionAlgorithm; use Jose\Component\Signature\Algorithm\MacAlgorithm; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; +use Override; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Throwable; use function array_key_exists; -final class AlgorithmCollector implements Collector +final readonly class AlgorithmCollector implements Collector { public function __construct( - private readonly AlgorithmManagerFactory $algorithmManagerFactory + private AlgorithmManagerFactory $algorithmManagerFactory ) { } /** * @param array $data */ + #[Override] public function collect(array &$data, Request $request, Response $response, ?Throwable $exception = null): void { $algorithms = $this->algorithmManagerFactory->all(); diff --git a/src/Bundle/DataCollector/CheckerCollector.php b/src/Bundle/DataCollector/CheckerCollector.php index 09f778314..2e64145c5 100644 --- a/src/Bundle/DataCollector/CheckerCollector.php +++ b/src/Bundle/DataCollector/CheckerCollector.php @@ -12,6 +12,7 @@ use Jose\Bundle\JoseFramework\Services\ClaimCheckerManagerFactory; use Jose\Bundle\JoseFramework\Services\HeaderCheckerManager; use Jose\Bundle\JoseFramework\Services\HeaderCheckerManagerFactory; +use Override; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -19,7 +20,7 @@ use Symfony\Component\VarDumper\Cloner\VarCloner; use Throwable; -class CheckerCollector implements Collector, EventSubscriberInterface +final class CheckerCollector implements Collector, EventSubscriberInterface { /** * @var array @@ -60,6 +61,7 @@ public function __construct( /** * @param array $data */ + #[Override] public function collect(array &$data, Request $request, Response $response, ?Throwable $exception = null): void { $this->collectHeaderCheckerManagers($data); @@ -79,6 +81,7 @@ public function addClaimCheckerManager(string $id, ClaimCheckerManager $claimChe $this->claimCheckerManagers[$id] = $claimCheckerManager; } + #[Override] public static function getSubscribedEvents(): array { return [ diff --git a/src/Bundle/DataCollector/JWECollector.php b/src/Bundle/DataCollector/JWECollector.php index c7869d74e..caa13ee90 100644 --- a/src/Bundle/DataCollector/JWECollector.php +++ b/src/Bundle/DataCollector/JWECollector.php @@ -13,6 +13,7 @@ use Jose\Component\Encryption\JWEDecrypter; use Jose\Component\Encryption\JWELoader; use Jose\Component\Encryption\Serializer\JWESerializerManagerFactory; +use Override; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -20,7 +21,7 @@ use Symfony\Component\VarDumper\Cloner\VarCloner; use Throwable; -class JWECollector implements Collector, EventSubscriberInterface +final class JWECollector implements Collector, EventSubscriberInterface { /** * @var array @@ -66,6 +67,7 @@ public function __construct( /** * @param array $data */ + #[Override] public function collect(array &$data, Request $request, Response $response, ?Throwable $exception = null): void { $this->collectSupportedCompressionMethods($data); @@ -91,6 +93,7 @@ public function addJWELoader(string $id, JWELoader $jweLoader): void $this->jweLoaders[$id] = $jweLoader; } + #[Override] public static function getSubscribedEvents(): array { return [ diff --git a/src/Bundle/DataCollector/JWSCollector.php b/src/Bundle/DataCollector/JWSCollector.php index e6e63b4bf..ad9ffd90a 100644 --- a/src/Bundle/DataCollector/JWSCollector.php +++ b/src/Bundle/DataCollector/JWSCollector.php @@ -12,6 +12,7 @@ use Jose\Component\Signature\JWSLoader; use Jose\Component\Signature\JWSVerifier; use Jose\Component\Signature\Serializer\JWSSerializerManagerFactory; +use Override; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -19,7 +20,7 @@ use Symfony\Component\VarDumper\Cloner\VarCloner; use Throwable; -class JWSCollector implements Collector, EventSubscriberInterface +final class JWSCollector implements Collector, EventSubscriberInterface { /** * @var array @@ -64,6 +65,7 @@ public function __construct( /** * @param array $data */ + #[Override] public function collect(array &$data, Request $request, Response $response, ?Throwable $exception = null): void { $this->collectSupportedJWSSerializations($data); @@ -88,6 +90,7 @@ public function addJWSLoader(string $id, JWSLoader $jwsLoader): void $this->jwsLoaders[$id] = $jwsLoader; } + #[Override] public static function getSubscribedEvents(): array { return [ diff --git a/src/Bundle/DataCollector/JoseCollector.php b/src/Bundle/DataCollector/JoseCollector.php index 64873d167..3fd079a9e 100644 --- a/src/Bundle/DataCollector/JoseCollector.php +++ b/src/Bundle/DataCollector/JoseCollector.php @@ -4,19 +4,21 @@ namespace Jose\Bundle\JoseFramework\DataCollector; +use Override; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\VarDumper\Cloner\Data; use Throwable; -class JoseCollector extends DataCollector +final class JoseCollector extends DataCollector { /** * @var Collector[] */ private array $collectors = []; + #[Override] public function collect(Request $request, Response $response, ?Throwable $exception = null): void { foreach ($this->collectors as $collector) { @@ -29,6 +31,7 @@ public function add(Collector $collector): void $this->collectors[] = $collector; } + #[Override] public function getName(): string { return 'jose_collector'; @@ -42,6 +45,7 @@ public function getData(): array|Data return $this->data; } + #[Override] public function reset(): void { $this->data = []; diff --git a/src/Bundle/DataCollector/KeyCollector.php b/src/Bundle/DataCollector/KeyCollector.php index c27d1d85b..df7166658 100644 --- a/src/Bundle/DataCollector/KeyCollector.php +++ b/src/Bundle/DataCollector/KeyCollector.php @@ -9,12 +9,13 @@ use Jose\Component\KeyManagement\Analyzer\KeyAnalyzerManager; use Jose\Component\KeyManagement\Analyzer\KeysetAnalyzerManager; use Jose\Component\KeyManagement\Analyzer\MessageBag; +use Override; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\VarDumper\Cloner\VarCloner; use Throwable; -class KeyCollector implements Collector +final class KeyCollector implements Collector { /** * @var array @@ -35,6 +36,7 @@ public function __construct( /** * @param array $data */ + #[Override] public function collect(array &$data, Request $request, Response $response, ?Throwable $exception = null): void { $this->collectJWK($data); diff --git a/src/Bundle/DependencyInjection/Compiler/AlgorithmCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/AlgorithmCompilerPass.php index 23079b712..9d569d8c6 100644 --- a/src/Bundle/DependencyInjection/Compiler/AlgorithmCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/AlgorithmCompilerPass.php @@ -6,12 +6,14 @@ use InvalidArgumentException; use Jose\Component\Core\AlgorithmManagerFactory; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -final class AlgorithmCompilerPass implements CompilerPassInterface +final readonly class AlgorithmCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(AlgorithmManagerFactory::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/CheckerCollectorCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/CheckerCollectorCompilerPass.php index f5b252d63..f1375902f 100644 --- a/src/Bundle/DependencyInjection/Compiler/CheckerCollectorCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/CheckerCollectorCompilerPass.php @@ -5,13 +5,15 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler; use Jose\Bundle\JoseFramework\DataCollector\CheckerCollector; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -final class CheckerCollectorCompilerPass implements CompilerPassInterface +final readonly class CheckerCollectorCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(CheckerCollector::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/ClaimCheckerCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/ClaimCheckerCompilerPass.php index 176c28af6..50495cf62 100644 --- a/src/Bundle/DependencyInjection/Compiler/ClaimCheckerCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/ClaimCheckerCompilerPass.php @@ -6,12 +6,14 @@ use InvalidArgumentException; use Jose\Bundle\JoseFramework\Services\ClaimCheckerManagerFactory; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -final class ClaimCheckerCompilerPass implements CompilerPassInterface +final readonly class ClaimCheckerCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(ClaimCheckerManagerFactory::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/CompressionMethodCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/CompressionMethodCompilerPass.php index dfcbf369f..67b4b2c31 100644 --- a/src/Bundle/DependencyInjection/Compiler/CompressionMethodCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/CompressionMethodCompilerPass.php @@ -6,12 +6,14 @@ use InvalidArgumentException; use Jose\Component\Encryption\Compression\CompressionMethodManagerFactory; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -final class CompressionMethodCompilerPass implements CompilerPassInterface +final readonly class CompressionMethodCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(CompressionMethodManagerFactory::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/DataCollectorCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/DataCollectorCompilerPass.php index a2660d70b..4ac4b0074 100644 --- a/src/Bundle/DependencyInjection/Compiler/DataCollectorCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/DataCollectorCompilerPass.php @@ -5,12 +5,14 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler; use Jose\Bundle\JoseFramework\DataCollector\JoseCollector; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -final class DataCollectorCompilerPass implements CompilerPassInterface +final readonly class DataCollectorCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(JoseCollector::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/EncryptionSerializerCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/EncryptionSerializerCompilerPass.php index bed7d5f86..f3d3cb61e 100644 --- a/src/Bundle/DependencyInjection/Compiler/EncryptionSerializerCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/EncryptionSerializerCompilerPass.php @@ -5,12 +5,14 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler; use Jose\Component\Encryption\Serializer\JWESerializerManagerFactory; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -final class EncryptionSerializerCompilerPass implements CompilerPassInterface +final readonly class EncryptionSerializerCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(JWESerializerManagerFactory::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/EventDispatcherAliasCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/EventDispatcherAliasCompilerPass.php index 647c5ea33..b26e88e09 100644 --- a/src/Bundle/DependencyInjection/Compiler/EventDispatcherAliasCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/EventDispatcherAliasCompilerPass.php @@ -4,12 +4,14 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -final class EventDispatcherAliasCompilerPass implements CompilerPassInterface +final readonly class EventDispatcherAliasCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition('event_dispatcher') || $container->hasAlias(EventDispatcherInterface::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/HeaderCheckerCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/HeaderCheckerCompilerPass.php index 8e67c341f..fcd5b665f 100644 --- a/src/Bundle/DependencyInjection/Compiler/HeaderCheckerCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/HeaderCheckerCompilerPass.php @@ -6,13 +6,15 @@ use InvalidArgumentException; use Jose\Bundle\JoseFramework\Services\HeaderCheckerManagerFactory; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -final class HeaderCheckerCompilerPass implements CompilerPassInterface +final readonly class HeaderCheckerCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(HeaderCheckerManagerFactory::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/JWECollectorCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/JWECollectorCompilerPass.php index 6296489ba..3297e777f 100644 --- a/src/Bundle/DependencyInjection/Compiler/JWECollectorCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/JWECollectorCompilerPass.php @@ -5,13 +5,15 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler; use Jose\Bundle\JoseFramework\DataCollector\JWECollector; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -final class JWECollectorCompilerPass implements CompilerPassInterface +final readonly class JWECollectorCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(JWECollector::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/JWSCollectorCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/JWSCollectorCompilerPass.php index 8689c7094..5177b231b 100644 --- a/src/Bundle/DependencyInjection/Compiler/JWSCollectorCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/JWSCollectorCompilerPass.php @@ -5,13 +5,15 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler; use Jose\Bundle\JoseFramework\DataCollector\JWSCollector; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -final class JWSCollectorCompilerPass implements CompilerPassInterface +final readonly class JWSCollectorCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(JWSCollector::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/KeyAnalyzerCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/KeyAnalyzerCompilerPass.php index a0228635e..daee882f6 100644 --- a/src/Bundle/DependencyInjection/Compiler/KeyAnalyzerCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/KeyAnalyzerCompilerPass.php @@ -5,12 +5,14 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler; use Jose\Component\KeyManagement\Analyzer\KeyAnalyzerManager; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -final class KeyAnalyzerCompilerPass implements CompilerPassInterface +final readonly class KeyAnalyzerCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(KeyAnalyzerManager::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/KeyCollectorCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/KeyCollectorCompilerPass.php index 95a4b33f8..c5c4e81db 100644 --- a/src/Bundle/DependencyInjection/Compiler/KeyCollectorCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/KeyCollectorCompilerPass.php @@ -5,13 +5,15 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler; use Jose\Bundle\JoseFramework\DataCollector\KeyCollector; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -final class KeyCollectorCompilerPass implements CompilerPassInterface +final readonly class KeyCollectorCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(KeyCollector::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/KeySetControllerCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/KeySetControllerCompilerPass.php index 3beaf4d99..c0c4abad7 100644 --- a/src/Bundle/DependencyInjection/Compiler/KeySetControllerCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/KeySetControllerCompilerPass.php @@ -6,11 +6,13 @@ use InvalidArgumentException; use Jose\Bundle\JoseFramework\Routing\JWKSetLoader; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -final class KeySetControllerCompilerPass implements CompilerPassInterface +final readonly class KeySetControllerCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(JWKSetLoader::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/KeysetAnalyzerCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/KeysetAnalyzerCompilerPass.php index 41a096522..7e4af9142 100644 --- a/src/Bundle/DependencyInjection/Compiler/KeysetAnalyzerCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/KeysetAnalyzerCompilerPass.php @@ -5,12 +5,14 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler; use Jose\Component\KeyManagement\Analyzer\KeysetAnalyzerManager; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -final class KeysetAnalyzerCompilerPass implements CompilerPassInterface +final readonly class KeysetAnalyzerCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(KeysetAnalyzerManager::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/SignatureSerializerCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/SignatureSerializerCompilerPass.php index 255686f08..ec912effe 100644 --- a/src/Bundle/DependencyInjection/Compiler/SignatureSerializerCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/SignatureSerializerCompilerPass.php @@ -5,12 +5,14 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler; use Jose\Component\Signature\Serializer\JWSSerializerManagerFactory; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -final class SignatureSerializerCompilerPass implements CompilerPassInterface +final readonly class SignatureSerializerCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! $container->hasDefinition(JWSSerializerManagerFactory::class)) { diff --git a/src/Bundle/DependencyInjection/Compiler/SymfonySerializerCompilerPass.php b/src/Bundle/DependencyInjection/Compiler/SymfonySerializerCompilerPass.php index c57c53ffb..cd2941deb 100644 --- a/src/Bundle/DependencyInjection/Compiler/SymfonySerializerCompilerPass.php +++ b/src/Bundle/DependencyInjection/Compiler/SymfonySerializerCompilerPass.php @@ -10,12 +10,14 @@ use Jose\Bundle\JoseFramework\Serializer\JWSSerializer; use Jose\Component\Encryption\Serializer\JWESerializerManagerFactory; use Jose\Component\Signature\Serializer\JWSSerializerManagerFactory; +use Override; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Serializer\Serializer; -class SymfonySerializerCompilerPass implements CompilerPassInterface +final readonly class SymfonySerializerCompilerPass implements CompilerPassInterface { + #[Override] public function process(ContainerBuilder $container): void { if (! class_exists(Serializer::class)) { diff --git a/src/Bundle/DependencyInjection/Configuration.php b/src/Bundle/DependencyInjection/Configuration.php index cfa26cff9..e5c055980 100644 --- a/src/Bundle/DependencyInjection/Configuration.php +++ b/src/Bundle/DependencyInjection/Configuration.php @@ -5,10 +5,11 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; +use Override; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; -final class Configuration implements ConfigurationInterface +final readonly class Configuration implements ConfigurationInterface { /** * @param Source[] $sources @@ -19,6 +20,7 @@ public function __construct( ) { } + #[Override] public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder($this->alias); diff --git a/src/Bundle/DependencyInjection/JoseFrameworkExtension.php b/src/Bundle/DependencyInjection/JoseFrameworkExtension.php index d27456666..a0d8f6b82 100644 --- a/src/Bundle/DependencyInjection/JoseFrameworkExtension.php +++ b/src/Bundle/DependencyInjection/JoseFrameworkExtension.php @@ -5,6 +5,7 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; +use Override; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; @@ -22,6 +23,7 @@ public function __construct( ) { } + #[Override] public function getAlias(): string { return $this->alias; @@ -30,6 +32,7 @@ public function getAlias(): string /** * @param array $configs */ + #[Override] public function load(array $configs, ContainerBuilder $container): void { $processor = new Processor(); @@ -40,11 +43,13 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getConfiguration(array $configs, ContainerBuilder $container): Configuration { return new Configuration($this->getAlias(), $this->sources); } + #[Override] public function prepend(ContainerBuilder $container): void { $configs = $container->getExtensionConfig($this->getAlias()); diff --git a/src/Bundle/DependencyInjection/Source/AbstractSource.php b/src/Bundle/DependencyInjection/Source/AbstractSource.php index aaa3b7823..8c5c25348 100644 --- a/src/Bundle/DependencyInjection/Source/AbstractSource.php +++ b/src/Bundle/DependencyInjection/Source/AbstractSource.php @@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; -abstract class AbstractSource +abstract readonly class AbstractSource { /** * @param array{is_public: bool, tags: array, string?: mixed} $config diff --git a/src/Bundle/DependencyInjection/Source/Checker/CheckerSource.php b/src/Bundle/DependencyInjection/Source/Checker/CheckerSource.php index c504c892d..645517d26 100644 --- a/src/Bundle/DependencyInjection/Source/Checker/CheckerSource.php +++ b/src/Bundle/DependencyInjection/Source/Checker/CheckerSource.php @@ -9,6 +9,7 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use Jose\Bundle\JoseFramework\DependencyInjection\Source\SourceWithCompilerPasses; use Jose\Component\Checker\TokenTypeSupport; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -17,7 +18,7 @@ use function array_key_exists; use function count; -class CheckerSource implements SourceWithCompilerPasses +final readonly class CheckerSource implements SourceWithCompilerPasses { /** * @var Source[] @@ -29,11 +30,13 @@ public function __construct() $this->sources = [new ClaimChecker(), new HeaderChecker()]; } + #[Override] public function name(): string { return 'checkers'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { $container->registerForAutoconfiguration(TokenTypeSupport::class)->addTag('jose.checker.token_type'); @@ -48,6 +51,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node->children() @@ -69,6 +73,7 @@ public function getNodeDefinition(NodeDefinition $node): void } } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { $result = []; @@ -85,6 +90,7 @@ public function prepend(ContainerBuilder $container, array $config): array /** * @return CompilerPassInterface[] */ + #[Override] public function getCompilerPasses(): array { return [new ClaimCheckerCompilerPass(), new HeaderCheckerCompilerPass()]; diff --git a/src/Bundle/DependencyInjection/Source/Checker/ClaimChecker.php b/src/Bundle/DependencyInjection/Source/Checker/ClaimChecker.php index 2ae572129..01608d220 100644 --- a/src/Bundle/DependencyInjection/Source/Checker/ClaimChecker.php +++ b/src/Bundle/DependencyInjection/Source/Checker/ClaimChecker.php @@ -7,18 +7,21 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use Jose\Bundle\JoseFramework\Services\ClaimCheckerManager; use Jose\Bundle\JoseFramework\Services\ClaimCheckerManagerFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class ClaimChecker implements Source +final readonly class ClaimChecker implements Source { + #[Override] public function name(): string { return 'claims'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { @@ -41,6 +44,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node @@ -76,6 +80,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/Checker/HeaderChecker.php b/src/Bundle/DependencyInjection/Source/Checker/HeaderChecker.php index 111d1ab65..d6c1144c5 100644 --- a/src/Bundle/DependencyInjection/Source/Checker/HeaderChecker.php +++ b/src/Bundle/DependencyInjection/Source/Checker/HeaderChecker.php @@ -7,18 +7,21 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use Jose\Bundle\JoseFramework\Services\HeaderCheckerManager; use Jose\Bundle\JoseFramework\Services\HeaderCheckerManagerFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class HeaderChecker implements Source +final readonly class HeaderChecker implements Source { + #[Override] public function name(): string { return 'headers'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { @@ -41,6 +44,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node @@ -76,6 +80,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/Console/ConsoleSource.php b/src/Bundle/DependencyInjection/Source/Console/ConsoleSource.php index b18e87262..a155938f2 100644 --- a/src/Bundle/DependencyInjection/Source/Console/ConsoleSource.php +++ b/src/Bundle/DependencyInjection/Source/Console/ConsoleSource.php @@ -5,28 +5,34 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Source\Console; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -class ConsoleSource implements Source +final readonly class ConsoleSource implements Source { + #[Override] public function name(): string { return 'console'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config')); $loader->load('commands.php'); } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { + // No configuration needed } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/Core/CoreSource.php b/src/Bundle/DependencyInjection/Source/Core/CoreSource.php index c1705e8c7..aaf33de96 100644 --- a/src/Bundle/DependencyInjection/Source/Core/CoreSource.php +++ b/src/Bundle/DependencyInjection/Source/Core/CoreSource.php @@ -12,6 +12,7 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Compiler\JWSCollectorCompilerPass; use Jose\Bundle\JoseFramework\DependencyInjection\Compiler\KeyCollectorCompilerPass; use Jose\Bundle\JoseFramework\DependencyInjection\Source\SourceWithCompilerPasses; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -19,13 +20,15 @@ use Symfony\Component\DependencyInjection\EnvVarProcessorInterface; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -class CoreSource implements SourceWithCompilerPasses +final readonly class CoreSource implements SourceWithCompilerPasses { + #[Override] public function name(): string { return 'core'; } + #[Override] public function load(array $config, ContainerBuilder $container): void { $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config')); @@ -41,10 +44,13 @@ public function load(array $config, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { + // No configuration needed } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; @@ -53,6 +59,7 @@ public function prepend(ContainerBuilder $container, array $config): array /** * @return CompilerPassInterface[] */ + #[Override] public function getCompilerPasses(): array { return [ diff --git a/src/Bundle/DependencyInjection/Source/Encryption/AbstractEncryptionSource.php b/src/Bundle/DependencyInjection/Source/Encryption/AbstractEncryptionSource.php index a162eb891..fb5623ce6 100644 --- a/src/Bundle/DependencyInjection/Source/Encryption/AbstractEncryptionSource.php +++ b/src/Bundle/DependencyInjection/Source/Encryption/AbstractEncryptionSource.php @@ -5,11 +5,13 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Source\Encryption; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; -abstract class AbstractEncryptionSource implements Source +abstract readonly class AbstractEncryptionSource implements Source { + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node @@ -59,6 +61,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/Encryption/EncryptionSource.php b/src/Bundle/DependencyInjection/Source/Encryption/EncryptionSource.php index 913968f7d..9a21bb583 100644 --- a/src/Bundle/DependencyInjection/Source/Encryption/EncryptionSource.php +++ b/src/Bundle/DependencyInjection/Source/Encryption/EncryptionSource.php @@ -19,6 +19,7 @@ use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2AESKW; use Jose\Component\Encryption\Algorithm\KeyEncryption\RSA; use Jose\Component\Encryption\Serializer\JWESerializer as JWESerializerAlias; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -28,7 +29,7 @@ use function count; use function in_array; -class EncryptionSource implements SourceWithCompilerPasses +final readonly class EncryptionSource implements SourceWithCompilerPasses { /** * @var Source[] @@ -40,11 +41,13 @@ public function __construct() $this->sources = [new JWEBuilder(), new JWEDecrypter(), new JWESerializer(), new JWELoader()]; } + #[Override] public function name(): string { return 'jwe'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { $container->registerForAutoconfiguration(JWESerializerAlias::class)->addTag('jose.jwe.serializer'); @@ -67,6 +70,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $childNode = $node->children() @@ -80,6 +84,7 @@ public function getNodeDefinition(NodeDefinition $node): void } } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { $result = []; @@ -96,6 +101,7 @@ public function prepend(ContainerBuilder $container, array $config): array /** * @return CompilerPassInterface[] */ + #[Override] public function getCompilerPasses(): array { return [new EncryptionSerializerCompilerPass(), new CompressionMethodCompilerPass()]; diff --git a/src/Bundle/DependencyInjection/Source/Encryption/JWEBuilder.php b/src/Bundle/DependencyInjection/Source/Encryption/JWEBuilder.php index 8a586c4af..62b4796de 100644 --- a/src/Bundle/DependencyInjection/Source/Encryption/JWEBuilder.php +++ b/src/Bundle/DependencyInjection/Source/Encryption/JWEBuilder.php @@ -6,17 +6,20 @@ use Jose\Bundle\JoseFramework\Services\JWEBuilderFactory; use Jose\Component\Encryption\JWEBuilder as JWEBuilderService; +use Override; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWEBuilder extends AbstractEncryptionSource +final readonly class JWEBuilder extends AbstractEncryptionSource { + #[Override] public function name(): string { return 'builders'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { diff --git a/src/Bundle/DependencyInjection/Source/Encryption/JWEDecrypter.php b/src/Bundle/DependencyInjection/Source/Encryption/JWEDecrypter.php index 212240ccb..7a3ab8167 100644 --- a/src/Bundle/DependencyInjection/Source/Encryption/JWEDecrypter.php +++ b/src/Bundle/DependencyInjection/Source/Encryption/JWEDecrypter.php @@ -6,17 +6,20 @@ use Jose\Bundle\JoseFramework\Services\JWEDecrypterFactory; use Jose\Component\Encryption\JWEDecrypter as JWEDecrypterService; +use Override; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWEDecrypter extends AbstractEncryptionSource +final readonly class JWEDecrypter extends AbstractEncryptionSource { + #[Override] public function name(): string { return 'decrypters'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { diff --git a/src/Bundle/DependencyInjection/Source/Encryption/JWELoader.php b/src/Bundle/DependencyInjection/Source/Encryption/JWELoader.php index bf1ec4fb8..0d1d3073b 100644 --- a/src/Bundle/DependencyInjection/Source/Encryption/JWELoader.php +++ b/src/Bundle/DependencyInjection/Source/Encryption/JWELoader.php @@ -7,18 +7,21 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use Jose\Bundle\JoseFramework\Services\JWELoaderFactory; use Jose\Component\Encryption\JWELoader as JWELoaderService; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWELoader implements Source +final readonly class JWELoader implements Source { + #[Override] public function name(): string { return 'loaders'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { @@ -44,6 +47,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node @@ -107,6 +111,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/Encryption/JWESerializer.php b/src/Bundle/DependencyInjection/Source/Encryption/JWESerializer.php index eaa9d0487..cf07e3cab 100644 --- a/src/Bundle/DependencyInjection/Source/Encryption/JWESerializer.php +++ b/src/Bundle/DependencyInjection/Source/Encryption/JWESerializer.php @@ -7,18 +7,21 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use Jose\Component\Encryption\Serializer\JWESerializerManager; use Jose\Component\Encryption\Serializer\JWESerializerManagerFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWESerializer implements Source +final readonly class JWESerializer implements Source { + #[Override] public function name(): string { return 'serializers'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { @@ -37,6 +40,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node->children() @@ -73,6 +77,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JKUSource.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JKUSource.php index a497b891e..72fdbfc83 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JKUSource.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JKUSource.php @@ -5,18 +5,21 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Source\KeyManagement; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -class JKUSource implements Source +final readonly class JKUSource implements Source { + #[Override] public function name(): string { return 'jku_factory'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { if ($configs[$this->name()]['enabled'] === true) { @@ -30,26 +33,28 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { - $node - ->children() + $node->children() ->arrayNode('jku_factory') ->canBeEnabled() ->children() ->scalarNode('client') ->info('HTTP Client used to retrieve key sets.') ->isRequired() - ->defaultNull() ->end() ->scalarNode('request_factory') ->info('The request factory service.') + //->setDeprecated('The "%node%" option is deprecated and will be removed in 4.0.') + ->defaultNull() ->end() ->end() ->end() ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource.php index 2e324f463..69a78b330 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource.php @@ -8,6 +8,7 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\KeyManagement\JWKSetSource\JWKSetSource as JWKSetSourceInterface; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use LogicException; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -15,18 +16,20 @@ use function array_key_exists; use function count; -class JWKSetSource implements Source +final class JWKSetSource implements Source { /** * @var JWKSetSourceInterface[] */ private ?array $jwkset_sources = null; + #[Override] public function name(): string { return 'key_sets'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { $sources = $this->getJWKSetSources(); @@ -42,6 +45,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $sourceNodeBuilder = $node @@ -63,6 +67,7 @@ public function getNodeDefinition(NodeDefinition $node): void } } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/JKU.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/JKU.php index 903eb9504..4905de1a5 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/JKU.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/JKU.php @@ -7,16 +7,18 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\Core\JWKSet; use Jose\Component\KeyManagement\JKUFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JKU extends AbstractSource implements JWKSetSource +final readonly class JKU extends AbstractSource implements JWKSetSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(JWKSet::class); @@ -27,11 +29,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKeySet(): string { return 'jku'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/JWKSet.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/JWKSet.php index 70ed43dc7..852ad690d 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/JWKSet.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/JWKSet.php @@ -7,16 +7,18 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\Core\JWKSet as JWKSetAlias; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWKSet extends AbstractSource implements JWKSetSource +final readonly class JWKSet extends AbstractSource implements JWKSetSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(JWKSetAlias::class); @@ -27,11 +29,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKeySet(): string { return 'jwkset'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/X5U.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/X5U.php index 8d6cd2cba..cf84a74f3 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/X5U.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSetSource/X5U.php @@ -7,16 +7,18 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\Core\JWKSet; use Jose\Component\KeyManagement\X5UFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class X5U extends AbstractSource implements JWKSetSource +final readonly class X5U extends AbstractSource implements JWKSetSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(JWKSet::class); @@ -27,11 +29,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKeySet(): string { return 'x5u'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource.php index f3d083789..8ed536d91 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource.php @@ -8,6 +8,7 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\KeyManagement\JWKSource\JWKSource as JWKSourceInterface; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use LogicException; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -15,18 +16,20 @@ use function array_key_exists; use function count; -class JWKSource implements Source +final class JWKSource implements Source { /** * @var JWKSourceInterface[]|null */ private ?array $jwkSources = null; + #[Override] public function name(): string { return 'keys'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { $sources = $this->getJWKSources(); @@ -42,6 +45,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $sourceNodeBuilder = $node @@ -63,6 +67,7 @@ public function getNodeDefinition(NodeDefinition $node): void } } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/CertificateFile.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/CertificateFile.php index 2c55663b4..0890b112e 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/CertificateFile.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/CertificateFile.php @@ -7,16 +7,18 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\Core\JWK; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class CertificateFile extends AbstractSource implements JWKSource +final readonly class CertificateFile extends AbstractSource implements JWKSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(JWK::class); @@ -27,11 +29,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKey(): string { return 'certificate'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/JWK.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/JWK.php index bd71bd2d0..6e1fba5c9 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/JWK.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/JWK.php @@ -6,16 +6,18 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWK extends AbstractSource implements JWKSource +final readonly class JWK extends AbstractSource implements JWKSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(\Jose\Component\Core\JWK::class); @@ -26,11 +28,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKey(): string { return 'jwk'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/JWKSet.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/JWKSet.php index 4d2a8843b..5e73d3ecd 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/JWKSet.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/JWKSet.php @@ -7,6 +7,7 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\Core\JWK; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -14,11 +15,12 @@ use function is_int; use function is_string; -class JWKSet extends AbstractSource implements JWKSource +final readonly class JWKSet extends AbstractSource implements JWKSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(JWK::class); @@ -29,11 +31,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKey(): string { return 'jwkset'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/KeyFile.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/KeyFile.php index 1411f8645..b3d4fe1c7 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/KeyFile.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/KeyFile.php @@ -7,16 +7,18 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\Core\JWK; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class KeyFile extends AbstractSource implements JWKSource +final readonly class KeyFile extends AbstractSource implements JWKSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(JWK::class); @@ -27,11 +29,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKey(): string { return 'file'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/P12.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/P12.php index a3caefdc2..98f7310bc 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/P12.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/P12.php @@ -7,16 +7,18 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\Core\JWK; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class P12 extends AbstractSource implements JWKSource +final readonly class P12 extends AbstractSource implements JWKSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(JWK::class); @@ -27,11 +29,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKey(): string { return 'p12'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/Secret.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/Secret.php index a936405fa..af6caea64 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/Secret.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/Secret.php @@ -7,16 +7,18 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\Core\JWK; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class Secret extends AbstractSource implements JWKSource +final readonly class Secret extends AbstractSource implements JWKSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(JWK::class); @@ -27,11 +29,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKey(): string { return 'secret'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/Values.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/Values.php index 5c756d4b9..ba41a202d 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/Values.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/Values.php @@ -7,16 +7,18 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\Core\JWK; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class Values extends AbstractSource implements JWKSource +final readonly class Values extends AbstractSource implements JWKSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(JWK::class); @@ -27,11 +29,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKey(): string { return 'values'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/X5C.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/X5C.php index d2129d30c..b10f9e6ab 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/X5C.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKSource/X5C.php @@ -7,16 +7,18 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\AbstractSource; use Jose\Component\Core\JWK; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class X5C extends AbstractSource implements JWKSource +final readonly class X5C extends AbstractSource implements JWKSource { /** * @param array $config */ + #[Override] public function createDefinition(ContainerBuilder $container, array $config): Definition { $definition = new Definition(JWK::class); @@ -27,11 +29,13 @@ public function createDefinition(ContainerBuilder $container, array $config): De return $definition; } + #[Override] public function getKey(): string { return 'x5c'; } + #[Override] public function addConfiguration(NodeDefinition $node): void { parent::addConfiguration($node); diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKUriSource.php b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKUriSource.php index ed67cf3e9..9899369ee 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/JWKUriSource.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/JWKUriSource.php @@ -7,18 +7,21 @@ use Jose\Bundle\JoseFramework\Controller\JWKSetController; use Jose\Bundle\JoseFramework\Controller\JWKSetControllerFactory; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWKUriSource implements Source +final readonly class JWKUriSource implements Source { + #[Override] public function name(): string { return 'jwk_uris'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { @@ -39,6 +42,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node->children() @@ -74,6 +78,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/KeyManagement/KeyManagementSource.php b/src/Bundle/DependencyInjection/Source/KeyManagement/KeyManagementSource.php index 94c3c6081..bd458adbc 100644 --- a/src/Bundle/DependencyInjection/Source/KeyManagement/KeyManagementSource.php +++ b/src/Bundle/DependencyInjection/Source/KeyManagement/KeyManagementSource.php @@ -11,6 +11,7 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\SourceWithCompilerPasses; use Jose\Component\KeyManagement\Analyzer\KeyAnalyzer; use Jose\Component\KeyManagement\Analyzer\KeysetAnalyzer; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -18,7 +19,7 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use function count; -class KeyManagementSource implements SourceWithCompilerPasses +final readonly class KeyManagementSource implements SourceWithCompilerPasses { /** * @var Source[] @@ -30,11 +31,13 @@ public function __construct() $this->sources = [new JWKSetSource(), new JWKSource(), new JWKUriSource(), new JKUSource()]; } + #[Override] public function name(): string { return 'key_mgmt'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { $container->registerForAutoconfiguration(KeyAnalyzer::class)->addTag('jose.key_analyzer'); @@ -49,6 +52,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { foreach ($this->sources as $source) { @@ -56,6 +60,7 @@ public function getNodeDefinition(NodeDefinition $node): void } } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { $result = []; @@ -72,6 +77,7 @@ public function prepend(ContainerBuilder $container, array $config): array /** * @return CompilerPassInterface[] */ + #[Override] public function getCompilerPasses(): array { return [ diff --git a/src/Bundle/DependencyInjection/Source/NestedToken/NestedToken.php b/src/Bundle/DependencyInjection/Source/NestedToken/NestedToken.php index 2068977cf..76256b1ab 100644 --- a/src/Bundle/DependencyInjection/Source/NestedToken/NestedToken.php +++ b/src/Bundle/DependencyInjection/Source/NestedToken/NestedToken.php @@ -5,6 +5,7 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Source\NestedToken; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -12,7 +13,7 @@ use function array_key_exists; use function count; -class NestedToken implements Source +final readonly class NestedToken implements Source { /** * @var Source[] @@ -24,11 +25,13 @@ public function __construct() $this->sources = [new NestedTokenLoader(), new NestedTokenBuilder()]; } + #[Override] public function name(): string { return 'nested_token'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config')); @@ -41,6 +44,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $childNode = $node->children() @@ -53,6 +57,7 @@ public function getNodeDefinition(NodeDefinition $node): void } } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { $result = []; diff --git a/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenBuilder.php b/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenBuilder.php index cd08c901d..59d9faf6d 100644 --- a/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenBuilder.php +++ b/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenBuilder.php @@ -7,18 +7,21 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use Jose\Bundle\JoseFramework\Services\NestedTokenBuilderFactory; use Jose\Component\NestedToken\NestedTokenBuilder as NestedTokenBuilderService; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class NestedTokenBuilder implements Source +final readonly class NestedTokenBuilder implements Source { + #[Override] public function name(): string { return 'builders'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { @@ -44,6 +47,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node->children() @@ -118,6 +122,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenLoader.php b/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenLoader.php index 85957aa01..91ed4b7b5 100644 --- a/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenLoader.php +++ b/src/Bundle/DependencyInjection/Source/NestedToken/NestedTokenLoader.php @@ -7,18 +7,21 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use Jose\Bundle\JoseFramework\Services\NestedTokenLoaderFactory; use Jose\Component\NestedToken\NestedTokenLoader as NestedTokenLoaderService; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class NestedTokenLoader implements Source +final readonly class NestedTokenLoader implements Source { + #[Override] public function name(): string { return 'loaders'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { @@ -46,6 +49,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node->children() @@ -136,6 +140,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/Signature/AbstractSignatureSource.php b/src/Bundle/DependencyInjection/Source/Signature/AbstractSignatureSource.php index e810d6b04..47311a9e0 100644 --- a/src/Bundle/DependencyInjection/Source/Signature/AbstractSignatureSource.php +++ b/src/Bundle/DependencyInjection/Source/Signature/AbstractSignatureSource.php @@ -5,11 +5,13 @@ namespace Jose\Bundle\JoseFramework\DependencyInjection\Source\Signature; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; -abstract class AbstractSignatureSource implements Source +abstract readonly class AbstractSignatureSource implements Source { + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node @@ -44,6 +46,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/Signature/JWSBuilder.php b/src/Bundle/DependencyInjection/Source/Signature/JWSBuilder.php index 86c7cf6e9..18c769573 100644 --- a/src/Bundle/DependencyInjection/Source/Signature/JWSBuilder.php +++ b/src/Bundle/DependencyInjection/Source/Signature/JWSBuilder.php @@ -6,17 +6,20 @@ use Jose\Bundle\JoseFramework\Services\JWSBuilderFactory; use Jose\Component\Signature\JWSBuilder as JWSBuilderService; +use Override; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWSBuilder extends AbstractSignatureSource +final readonly class JWSBuilder extends AbstractSignatureSource { + #[Override] public function name(): string { return 'builders'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { diff --git a/src/Bundle/DependencyInjection/Source/Signature/JWSLoader.php b/src/Bundle/DependencyInjection/Source/Signature/JWSLoader.php index 2884a3360..ea184ad25 100644 --- a/src/Bundle/DependencyInjection/Source/Signature/JWSLoader.php +++ b/src/Bundle/DependencyInjection/Source/Signature/JWSLoader.php @@ -7,18 +7,21 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use Jose\Bundle\JoseFramework\Services\JWSLoaderFactory; use Jose\Component\Signature\JWSLoader as JWSLoaderService; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWSLoader implements Source +final readonly class JWSLoader implements Source { + #[Override] public function name(): string { return 'loaders'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { @@ -42,6 +45,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node @@ -91,6 +95,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/Signature/JWSSerializer.php b/src/Bundle/DependencyInjection/Source/Signature/JWSSerializer.php index fae7f8b54..c083f7ee6 100644 --- a/src/Bundle/DependencyInjection/Source/Signature/JWSSerializer.php +++ b/src/Bundle/DependencyInjection/Source/Signature/JWSSerializer.php @@ -7,18 +7,21 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; use Jose\Component\Signature\Serializer\JWSSerializerManager; use Jose\Component\Signature\Serializer\JWSSerializerManagerFactory; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWSSerializer implements Source +final readonly class JWSSerializer implements Source { + #[Override] public function name(): string { return 'serializers'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { @@ -37,6 +40,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $node->children() @@ -73,6 +77,7 @@ public function getNodeDefinition(NodeDefinition $node): void ->end(); } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { return []; diff --git a/src/Bundle/DependencyInjection/Source/Signature/JWSVerifier.php b/src/Bundle/DependencyInjection/Source/Signature/JWSVerifier.php index 5b97788c8..a4b41079c 100644 --- a/src/Bundle/DependencyInjection/Source/Signature/JWSVerifier.php +++ b/src/Bundle/DependencyInjection/Source/Signature/JWSVerifier.php @@ -6,17 +6,20 @@ use Jose\Bundle\JoseFramework\Services\JWSVerifierFactory; use Jose\Component\Signature\JWSVerifier as JWSVerifierService; +use Override; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -class JWSVerifier extends AbstractSignatureSource +final readonly class JWSVerifier extends AbstractSignatureSource { + #[Override] public function name(): string { return 'verifiers'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { foreach ($configs[$this->name()] as $name => $itemConfig) { diff --git a/src/Bundle/DependencyInjection/Source/Signature/SignatureSource.php b/src/Bundle/DependencyInjection/Source/Signature/SignatureSource.php index d71aaa5ea..75af9b88e 100644 --- a/src/Bundle/DependencyInjection/Source/Signature/SignatureSource.php +++ b/src/Bundle/DependencyInjection/Source/Signature/SignatureSource.php @@ -13,6 +13,7 @@ use Jose\Component\Signature\Algorithm\HS1; use Jose\Component\Signature\Algorithm\None; use Jose\Component\Signature\Algorithm\RSAPSS; +use Override; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; @@ -22,7 +23,7 @@ use function count; use function extension_loaded; -class SignatureSource implements SourceWithCompilerPasses +final readonly class SignatureSource implements SourceWithCompilerPasses { /** * @var Source[] @@ -34,11 +35,13 @@ public function __construct() $this->sources = [new JWSBuilder(), new JWSVerifier(), new JWSSerializer(), new JWSLoader()]; } + #[Override] public function name(): string { return 'jws'; } + #[Override] public function load(array $configs, ContainerBuilder $container): void { $container->registerForAutoconfiguration(\Jose\Component\Signature\Serializer\JWSSerializer::class)->addTag( @@ -62,6 +65,7 @@ public function load(array $configs, ContainerBuilder $container): void } } + #[Override] public function getNodeDefinition(NodeDefinition $node): void { $childNode = $node->children() @@ -75,6 +79,7 @@ public function getNodeDefinition(NodeDefinition $node): void } } + #[Override] public function prepend(ContainerBuilder $container, array $config): array { $result = []; @@ -91,6 +96,7 @@ public function prepend(ContainerBuilder $container, array $config): array /** * @return CompilerPassInterface[] */ + #[Override] public function getCompilerPasses(): array { return [new SignatureSerializerCompilerPass()]; diff --git a/src/Bundle/EnvVarProcessor/KeyEnvVarProcessor.php b/src/Bundle/EnvVarProcessor/KeyEnvVarProcessor.php index 6cb50ff24..3a0c86696 100644 --- a/src/Bundle/EnvVarProcessor/KeyEnvVarProcessor.php +++ b/src/Bundle/EnvVarProcessor/KeyEnvVarProcessor.php @@ -7,11 +7,13 @@ use Closure; use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; +use Override; use RuntimeException; use Symfony\Component\DependencyInjection\EnvVarProcessorInterface; -final class KeyEnvVarProcessor implements EnvVarProcessorInterface +final readonly class KeyEnvVarProcessor implements EnvVarProcessorInterface { + #[Override] public function getEnv(string $prefix, string $name, Closure $getEnv): mixed { $env = $getEnv($name); @@ -23,6 +25,7 @@ public function getEnv(string $prefix, string $name, Closure $getEnv): mixed }; } + #[Override] public static function getProvidedTypes(): array { return [ diff --git a/src/Bundle/Helper/ConfigurationHelper.php b/src/Bundle/Helper/ConfigurationHelper.php index e7c9140bc..8360d645b 100644 --- a/src/Bundle/Helper/ConfigurationHelper.php +++ b/src/Bundle/Helper/ConfigurationHelper.php @@ -7,7 +7,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use function is_array; -class ConfigurationHelper +final readonly class ConfigurationHelper { final public const string BUNDLE_ALIAS = 'jose'; diff --git a/src/Bundle/JoseFrameworkBundle.php b/src/Bundle/JoseFrameworkBundle.php index b600be9b9..e774785b5 100644 --- a/src/Bundle/JoseFrameworkBundle.php +++ b/src/Bundle/JoseFrameworkBundle.php @@ -16,6 +16,7 @@ use Jose\Bundle\JoseFramework\DependencyInjection\Source\NestedToken\NestedToken; use Jose\Bundle\JoseFramework\DependencyInjection\Source\Signature\SignatureSource; use Jose\Bundle\JoseFramework\DependencyInjection\Source\SourceWithCompilerPasses; +use Override; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; @@ -35,11 +36,13 @@ public function __construct() } } + #[Override] public function getContainerExtension(): ExtensionInterface { return new JoseFrameworkExtension('jose', $this->sources); } + #[Override] public function build(ContainerBuilder $container): void { parent::build($container); diff --git a/src/Bundle/Resources/config/analyzers.php b/src/Bundle/Resources/config/analyzers.php index 2f2cdec37..38f351967 100644 --- a/src/Bundle/Resources/config/analyzers.php +++ b/src/Bundle/Resources/config/analyzers.php @@ -20,7 +20,6 @@ use Jose\Component\KeyManagement\Analyzer\UsageAnalyzer; use Jose\Component\KeyManagement\Analyzer\ZxcvbnKeyAnalyzer; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use ZxcvbnPhp\Zxcvbn; return function (ContainerConfigurator $container): void { $container = $container->services() @@ -52,7 +51,5 @@ $container->set(ES512KeyAnalyzer::class); } - if (class_exists(Zxcvbn::class)) { - $container->set(ZxcvbnKeyAnalyzer::class); - } + $container->set(ZxcvbnKeyAnalyzer::class); }; diff --git a/src/Bundle/Resources/config/jku_source.php b/src/Bundle/Resources/config/jku_source.php index 889693029..fc227010a 100644 --- a/src/Bundle/Resources/config/jku_source.php +++ b/src/Bundle/Resources/config/jku_source.php @@ -5,6 +5,7 @@ use Jose\Component\KeyManagement\JKUFactory; use Jose\Component\KeyManagement\X5UFactory; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symfony\Contracts\HttpClient\HttpClientInterface; use function Symfony\Component\DependencyInjection\Loader\Configurator\service; return function (ContainerConfigurator $container): void { @@ -14,11 +15,13 @@ ->autoconfigure() ->autowire(); - $container->set(JKUFactory::class) - ->public() - ->args([service('jose.http_client'), service('jose.request_factory') ->nullOnInvalid()]); + if (interface_exists(HttpClientInterface::class)) { + $container->set(JKUFactory::class) + ->public() + ->args([service('jose.http_client')]); - $container->set(X5UFactory::class) - ->public() - ->args([service('jose.http_client'), service('jose.request_factory') ->nullOnInvalid()]); + $container->set(X5UFactory::class) + ->public() + ->args([service('jose.http_client')]); + } }; diff --git a/src/Bundle/Routing/JWKSetLoader.php b/src/Bundle/Routing/JWKSetLoader.php index 68ee2ea19..672bfc8e6 100644 --- a/src/Bundle/Routing/JWKSetLoader.php +++ b/src/Bundle/Routing/JWKSetLoader.php @@ -4,16 +4,18 @@ namespace Jose\Bundle\JoseFramework\Routing; +use Override; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Loader\LoaderResolverInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; +use function assert; final class JWKSetLoader implements LoaderInterface { private readonly RouteCollection $routes; - private LoaderResolverInterface $resolver; + private null|LoaderResolverInterface $resolver = null; public function __construct() { @@ -29,21 +31,26 @@ public function add(string $pattern, string $name): void $this->routes->add(sprintf('jwkset_%s', $name), $route); } + #[Override] public function load(mixed $resource, string $type = null): RouteCollection { return $this->routes; } + #[Override] public function supports(mixed $resource, string $type = null): bool { return $type === 'jwkset'; } + #[Override] public function getResolver(): LoaderResolverInterface { + assert($this->resolver !== null, 'Resolver is not set.'); return $this->resolver; } + #[Override] public function setResolver(LoaderResolverInterface $resolver): void { $this->resolver = $resolver; diff --git a/src/Bundle/Serializer/JWEEncoder.php b/src/Bundle/Serializer/JWEEncoder.php index 642a757fa..e18e5f7c8 100644 --- a/src/Bundle/Serializer/JWEEncoder.php +++ b/src/Bundle/Serializer/JWEEncoder.php @@ -9,6 +9,7 @@ use Jose\Component\Encryption\Serializer\JWESerializerManager; use Jose\Component\Encryption\Serializer\JWESerializerManagerFactory; use LogicException; +use Override; use Symfony\Component\Serializer\Encoder\DecoderInterface; use Symfony\Component\Serializer\Encoder\EncoderInterface; use Symfony\Component\Serializer\Encoder\NormalizationAwareInterface; @@ -18,7 +19,7 @@ use function is_int; use function mb_strtolower; -final class JWEEncoder implements EncoderInterface, DecoderInterface, NormalizationAwareInterface +final readonly class JWEEncoder implements EncoderInterface, DecoderInterface, NormalizationAwareInterface { private readonly JWESerializerManager $serializerManager; @@ -32,16 +33,19 @@ public function __construct( $this->serializerManager = $serializerManager; } + #[Override] public function supportsEncoding(string $format, array $context = []): bool { return class_exists(JWESerializerManager::class) && $this->formatSupported($format); } + #[Override] public function supportsDecoding(string $format, array $context = []): bool { return class_exists(JWESerializerManager::class) && $this->formatSupported($format); } + #[Override] public function encode(mixed $data, string $format, array $context = []): string { if ($data instanceof JWE === false) { @@ -59,6 +63,7 @@ public function encode(mixed $data, string $format, array $context = []): string } } + #[Override] public function decode(string $data, string $format, array $context = []): JWE { try { diff --git a/src/Bundle/Serializer/JWESerializer.php b/src/Bundle/Serializer/JWESerializer.php index d5c9d7503..1d244c089 100644 --- a/src/Bundle/Serializer/JWESerializer.php +++ b/src/Bundle/Serializer/JWESerializer.php @@ -8,11 +8,12 @@ use Jose\Component\Encryption\Serializer\JWESerializerManager; use Jose\Component\Encryption\Serializer\JWESerializerManagerFactory; use LogicException; +use Override; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use function in_array; use function mb_strtolower; -final class JWESerializer implements DenormalizerInterface +final readonly class JWESerializer implements DenormalizerInterface { private readonly JWESerializerManager $serializerManager; @@ -26,6 +27,7 @@ public function __construct( $this->serializerManager = $serializerManager; } + #[Override] public function getSupportedTypes(?string $format): array { return [ @@ -33,6 +35,7 @@ public function getSupportedTypes(?string $format): array ]; } + #[Override] public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool { return $type === JWE::class @@ -40,6 +43,7 @@ public function supportsDenormalization(mixed $data, string $type, string $forma && $this->formatSupported($format); } + #[Override] public function denormalize(mixed $data, string $type, string $format = null, array $context = []): JWE { if ($data instanceof JWE === false) { diff --git a/src/Bundle/Serializer/JWSEncoder.php b/src/Bundle/Serializer/JWSEncoder.php index 5c3dfbbf1..bf97c4126 100644 --- a/src/Bundle/Serializer/JWSEncoder.php +++ b/src/Bundle/Serializer/JWSEncoder.php @@ -9,6 +9,7 @@ use Jose\Component\Signature\Serializer\JWSSerializerManager; use Jose\Component\Signature\Serializer\JWSSerializerManagerFactory; use LogicException; +use Override; use Symfony\Component\Serializer\Encoder\DecoderInterface; use Symfony\Component\Serializer\Encoder\EncoderInterface; use Symfony\Component\Serializer\Encoder\NormalizationAwareInterface; @@ -17,7 +18,7 @@ use function is_int; use function mb_strtolower; -final class JWSEncoder implements EncoderInterface, DecoderInterface, NormalizationAwareInterface +final readonly class JWSEncoder implements EncoderInterface, DecoderInterface, NormalizationAwareInterface { private readonly JWSSerializerManager $serializerManager; @@ -31,16 +32,19 @@ public function __construct( $this->serializerManager = $serializerManager; } + #[Override] public function supportsEncoding(string $format, array $context = []): bool { return class_exists(JWSSerializerManager::class) && $this->formatSupported($format); } + #[Override] public function supportsDecoding(string $format, array $context = []): bool { return class_exists(JWSSerializerManager::class) && $this->formatSupported($format); } + #[Override] public function encode($data, $format, array $context = []): string { if ($data instanceof JWS === false) { @@ -58,6 +62,7 @@ public function encode($data, $format, array $context = []): string } } + #[Override] public function decode($data, $format, array $context = []): JWS { try { diff --git a/src/Bundle/Serializer/JWSSerializer.php b/src/Bundle/Serializer/JWSSerializer.php index d6a224240..283c1ac16 100644 --- a/src/Bundle/Serializer/JWSSerializer.php +++ b/src/Bundle/Serializer/JWSSerializer.php @@ -8,11 +8,12 @@ use Jose\Component\Signature\Serializer\JWSSerializerManager; use Jose\Component\Signature\Serializer\JWSSerializerManagerFactory; use LogicException; +use Override; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use function in_array; use function mb_strtolower; -final class JWSSerializer implements DenormalizerInterface +final readonly class JWSSerializer implements DenormalizerInterface { private readonly JWSSerializerManager $serializerManager; @@ -26,6 +27,7 @@ public function __construct( $this->serializerManager = $serializerManager; } + #[Override] public function getSupportedTypes(?string $format): array { return [ @@ -33,6 +35,7 @@ public function getSupportedTypes(?string $format): array ]; } + #[Override] public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool { return $type === JWS::class @@ -40,6 +43,7 @@ public function supportsDenormalization(mixed $data, string $type, string $forma && $this->formatSupported($format); } + #[Override] public function denormalize(mixed $data, string $type, string $format = null, array $context = []): JWS { if ($data instanceof JWS === false) { diff --git a/src/Bundle/Services/ClaimCheckerManager.php b/src/Bundle/Services/ClaimCheckerManager.php index bb6271528..6479aea43 100644 --- a/src/Bundle/Services/ClaimCheckerManager.php +++ b/src/Bundle/Services/ClaimCheckerManager.php @@ -7,6 +7,7 @@ use Jose\Bundle\JoseFramework\Event\ClaimCheckedFailureEvent; use Jose\Bundle\JoseFramework\Event\ClaimCheckedSuccessEvent; use Jose\Component\Checker\ClaimCheckerManager as BaseClaimCheckerManager; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; use Throwable; @@ -19,6 +20,7 @@ public function __construct( parent::__construct($checkers); } + #[Override] public function check(array $claims, array $mandatoryClaims = []): array { try { diff --git a/src/Bundle/Services/HeaderCheckerManager.php b/src/Bundle/Services/HeaderCheckerManager.php index 02a404868..61a392338 100644 --- a/src/Bundle/Services/HeaderCheckerManager.php +++ b/src/Bundle/Services/HeaderCheckerManager.php @@ -8,6 +8,7 @@ use Jose\Bundle\JoseFramework\Event\HeaderCheckedSuccessEvent; use Jose\Component\Checker\HeaderCheckerManager as BaseHeaderCheckerManager; use Jose\Component\Core\JWT; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; use Throwable; @@ -21,6 +22,7 @@ public function __construct( parent::__construct($checkers, $tokenTypes); } + #[Override] public function check(JWT $jwt, int $index, array $mandatoryHeaderParameters = []): void { try { diff --git a/src/Bundle/Services/JWEBuilder.php b/src/Bundle/Services/JWEBuilder.php index 015d3e3aa..29dbbaebf 100644 --- a/src/Bundle/Services/JWEBuilder.php +++ b/src/Bundle/Services/JWEBuilder.php @@ -10,6 +10,7 @@ use Jose\Component\Encryption\Compression\CompressionMethodManager; use Jose\Component\Encryption\JWE; use Jose\Component\Encryption\JWEBuilder as BaseJWEBuilder; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; use Throwable; @@ -23,6 +24,7 @@ public function __construct( parent::__construct($algorithmManager, $compressionManager); } + #[Override] public function build(): JWE { try { diff --git a/src/Bundle/Services/JWEBuilderFactory.php b/src/Bundle/Services/JWEBuilderFactory.php index 7c8816868..897541afb 100644 --- a/src/Bundle/Services/JWEBuilderFactory.php +++ b/src/Bundle/Services/JWEBuilderFactory.php @@ -8,7 +8,7 @@ use Jose\Component\Encryption\Compression\CompressionMethodManagerFactory; use Psr\EventDispatcher\EventDispatcherInterface; -final class JWEBuilderFactory +final readonly class JWEBuilderFactory { public function __construct( private readonly AlgorithmManagerFactory $algorithmManagerFactory, diff --git a/src/Bundle/Services/JWEDecrypter.php b/src/Bundle/Services/JWEDecrypter.php index 514f3997d..882270daf 100644 --- a/src/Bundle/Services/JWEDecrypter.php +++ b/src/Bundle/Services/JWEDecrypter.php @@ -12,6 +12,7 @@ use Jose\Component\Encryption\Compression\CompressionMethodManager; use Jose\Component\Encryption\JWE; use Jose\Component\Encryption\JWEDecrypter as BaseJWEDecrypter; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; final class JWEDecrypter extends BaseJWEDecrypter @@ -24,6 +25,7 @@ public function __construct( parent::__construct($algorithmManager, $compressionMethodManager); } + #[Override] public function decryptUsingKeySet( JWE &$jwe, JWKSet $jwkset, diff --git a/src/Bundle/Services/JWEDecrypterFactory.php b/src/Bundle/Services/JWEDecrypterFactory.php index 44cfff9b7..9fb7b78ad 100644 --- a/src/Bundle/Services/JWEDecrypterFactory.php +++ b/src/Bundle/Services/JWEDecrypterFactory.php @@ -8,7 +8,7 @@ use Jose\Component\Encryption\Compression\CompressionMethodManagerFactory; use Psr\EventDispatcher\EventDispatcherInterface; -final class JWEDecrypterFactory +final readonly class JWEDecrypterFactory { public function __construct( private readonly AlgorithmManagerFactory $algorithmManagerFactory, diff --git a/src/Bundle/Services/JWELoader.php b/src/Bundle/Services/JWELoader.php index f14518560..4dbe07853 100644 --- a/src/Bundle/Services/JWELoader.php +++ b/src/Bundle/Services/JWELoader.php @@ -12,6 +12,7 @@ use Jose\Component\Encryption\JWEDecrypter; use Jose\Component\Encryption\JWELoader as BaseJWELoader; use Jose\Component\Encryption\Serializer\JWESerializerManager; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; use Throwable; @@ -26,6 +27,7 @@ public function __construct( parent::__construct($serializerManager, $jweDecrypter, $headerCheckerManager); } + #[Override] public function loadAndDecryptWithKeySet(string $token, JWKSet $keyset, ?int &$recipient): JWE { try { diff --git a/src/Bundle/Services/JWELoaderFactory.php b/src/Bundle/Services/JWELoaderFactory.php index 0cdc33ac2..236e177d5 100644 --- a/src/Bundle/Services/JWELoaderFactory.php +++ b/src/Bundle/Services/JWELoaderFactory.php @@ -7,7 +7,7 @@ use Jose\Component\Encryption\Serializer\JWESerializerManagerFactory; use Psr\EventDispatcher\EventDispatcherInterface; -final class JWELoaderFactory +final readonly class JWELoaderFactory { public function __construct( private readonly JWESerializerManagerFactory $jweSerializerManagerFactory, diff --git a/src/Bundle/Services/JWSBuilder.php b/src/Bundle/Services/JWSBuilder.php index ce428791d..ea9b8210f 100644 --- a/src/Bundle/Services/JWSBuilder.php +++ b/src/Bundle/Services/JWSBuilder.php @@ -9,6 +9,7 @@ use Jose\Component\Core\AlgorithmManager; use Jose\Component\Signature\JWS; use Jose\Component\Signature\JWSBuilder as BaseJWSBuilder; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; use Throwable; @@ -21,6 +22,7 @@ public function __construct( parent::__construct($signatureAlgorithmManager); } + #[Override] public function build(): JWS { try { diff --git a/src/Bundle/Services/JWSBuilderFactory.php b/src/Bundle/Services/JWSBuilderFactory.php index 710cac951..0304d11a3 100644 --- a/src/Bundle/Services/JWSBuilderFactory.php +++ b/src/Bundle/Services/JWSBuilderFactory.php @@ -7,7 +7,7 @@ use Jose\Component\Core\AlgorithmManagerFactory; use Psr\EventDispatcher\EventDispatcherInterface; -final class JWSBuilderFactory +final readonly class JWSBuilderFactory { public function __construct( private readonly AlgorithmManagerFactory $signatureAlgorithmManagerFactory, diff --git a/src/Bundle/Services/JWSLoader.php b/src/Bundle/Services/JWSLoader.php index 5f6c3ffd7..65b4ca22a 100644 --- a/src/Bundle/Services/JWSLoader.php +++ b/src/Bundle/Services/JWSLoader.php @@ -12,6 +12,7 @@ use Jose\Component\Signature\JWSLoader as BaseJWSLoader; use Jose\Component\Signature\JWSVerifier; use Jose\Component\Signature\Serializer\JWSSerializerManager; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; use Throwable; @@ -26,6 +27,7 @@ public function __construct( parent::__construct($serializerManager, $jwsVerifier, $headerCheckerManager); } + #[Override] public function loadAndVerifyWithKeySet( string $token, JWKSet $keyset, diff --git a/src/Bundle/Services/JWSLoaderFactory.php b/src/Bundle/Services/JWSLoaderFactory.php index f8ecdc9cf..04cbf84c1 100644 --- a/src/Bundle/Services/JWSLoaderFactory.php +++ b/src/Bundle/Services/JWSLoaderFactory.php @@ -7,7 +7,7 @@ use Jose\Component\Signature\Serializer\JWSSerializerManagerFactory; use Psr\EventDispatcher\EventDispatcherInterface; -final class JWSLoaderFactory +final readonly class JWSLoaderFactory { public function __construct( private readonly JWSSerializerManagerFactory $jwsSerializerManagerFactory, diff --git a/src/Bundle/Services/JWSVerifier.php b/src/Bundle/Services/JWSVerifier.php index f5c058445..b68ded865 100644 --- a/src/Bundle/Services/JWSVerifier.php +++ b/src/Bundle/Services/JWSVerifier.php @@ -11,6 +11,7 @@ use Jose\Component\Core\JWKSet; use Jose\Component\Signature\JWS; use Jose\Component\Signature\JWSVerifier as BaseJWSVerifier; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; final class JWSVerifier extends BaseJWSVerifier @@ -22,6 +23,7 @@ public function __construct( parent::__construct($signatureAlgorithmManager); } + #[Override] public function verifyWithKeySet( JWS $jws, JWKSet $jwkset, diff --git a/src/Bundle/Services/JWSVerifierFactory.php b/src/Bundle/Services/JWSVerifierFactory.php index 87be4d03b..cd31ce4ab 100644 --- a/src/Bundle/Services/JWSVerifierFactory.php +++ b/src/Bundle/Services/JWSVerifierFactory.php @@ -7,7 +7,7 @@ use Jose\Component\Core\AlgorithmManagerFactory; use Psr\EventDispatcher\EventDispatcherInterface; -final class JWSVerifierFactory +final readonly class JWSVerifierFactory { public function __construct( private readonly AlgorithmManagerFactory $algorithmManagerFactory, diff --git a/src/Bundle/Services/NestedTokenBuilder.php b/src/Bundle/Services/NestedTokenBuilder.php index d226d1670..b10c47f94 100644 --- a/src/Bundle/Services/NestedTokenBuilder.php +++ b/src/Bundle/Services/NestedTokenBuilder.php @@ -10,6 +10,7 @@ use Jose\Component\NestedToken\NestedTokenBuilder as BaseNestedTokenBuilder; use Jose\Component\Signature\JWSBuilder; use Jose\Component\Signature\Serializer\JWSSerializerManager; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; final class NestedTokenBuilder extends BaseNestedTokenBuilder @@ -24,6 +25,7 @@ public function __construct( parent::__construct($jweBuilder, $jweSerializerManager, $jwsBuilder, $jwsSerializerManager); } + #[Override] public function create( string $payload, array $signatures, diff --git a/src/Bundle/Services/NestedTokenBuilderFactory.php b/src/Bundle/Services/NestedTokenBuilderFactory.php index 0635a0417..f5126eaee 100644 --- a/src/Bundle/Services/NestedTokenBuilderFactory.php +++ b/src/Bundle/Services/NestedTokenBuilderFactory.php @@ -8,7 +8,7 @@ use Jose\Component\Signature\Serializer\JWSSerializerManagerFactory; use Psr\EventDispatcher\EventDispatcherInterface; -final class NestedTokenBuilderFactory +final readonly class NestedTokenBuilderFactory { public function __construct( private readonly JWEBuilderFactory $jweBuilderFactory, diff --git a/src/Bundle/Services/NestedTokenLoader.php b/src/Bundle/Services/NestedTokenLoader.php index 9ce79501d..a58ff547c 100644 --- a/src/Bundle/Services/NestedTokenLoader.php +++ b/src/Bundle/Services/NestedTokenLoader.php @@ -11,6 +11,7 @@ use Jose\Component\NestedToken\NestedTokenLoader as BaseNestedTokenLoader; use Jose\Component\Signature\JWS; use Jose\Component\Signature\JWSLoader; +use Override; use Psr\EventDispatcher\EventDispatcherInterface; use Throwable; @@ -24,6 +25,7 @@ public function __construct( parent::__construct($jweLoader, $jwsLoader); } + #[Override] public function load(string $token, JWKSet $encryptionKeySet, JWKSet $signatureKeySet, ?int &$signature = null): JWS { try { diff --git a/src/Bundle/Services/NestedTokenLoaderFactory.php b/src/Bundle/Services/NestedTokenLoaderFactory.php index 5496b2638..8e5dcbbe6 100644 --- a/src/Bundle/Services/NestedTokenLoaderFactory.php +++ b/src/Bundle/Services/NestedTokenLoaderFactory.php @@ -6,7 +6,7 @@ use Psr\EventDispatcher\EventDispatcherInterface; -final class NestedTokenLoaderFactory +final readonly class NestedTokenLoaderFactory { public function __construct( private readonly JWELoaderFactory $jweLoaderFactory, diff --git a/src/Bundle/composer.json b/src/Bundle/composer.json index e279a6184..cdfcd3f1f 100644 --- a/src/Bundle/composer.json +++ b/src/Bundle/composer.json @@ -41,8 +41,10 @@ "php": ">=8.3", "psr/event-dispatcher": "^1.0", "symfony/config": "^7.0", + "symfony/console": "^7.0", "symfony/dependency-injection": "^7.0", "symfony/event-dispatcher": "^7.0", + "symfony/http-client": "^7.0", "symfony/http-kernel": "^7.0", "web-token/jwt-library": "^4.0" }, diff --git a/src/Experimental/ContentEncryption/A128CCM_16_128.php b/src/Experimental/ContentEncryption/A128CCM_16_128.php index 484ca59c8..e1ba203c9 100644 --- a/src/Experimental/ContentEncryption/A128CCM_16_128.php +++ b/src/Experimental/ContentEncryption/A128CCM_16_128.php @@ -4,28 +4,35 @@ namespace Jose\Experimental\ContentEncryption; -final class A128CCM_16_128 extends AESCCM +use Override; + +final readonly class A128CCM_16_128 extends AESCCM { + #[Override] public function getCEKSize(): int { return 128; } + #[Override] public function name(): string { return 'A128CCM-16-128'; } + #[Override] public function getIVSize(): int { return 13 * 8; } + #[Override] protected function getMode(): string { return 'aes-128-ccm'; } + #[Override] protected function getTagLength(): int { return 16; diff --git a/src/Experimental/ContentEncryption/A128CCM_16_64.php b/src/Experimental/ContentEncryption/A128CCM_16_64.php index 561cda321..8408034ba 100644 --- a/src/Experimental/ContentEncryption/A128CCM_16_64.php +++ b/src/Experimental/ContentEncryption/A128CCM_16_64.php @@ -4,28 +4,35 @@ namespace Jose\Experimental\ContentEncryption; -final class A128CCM_16_64 extends AESCCM +use Override; + +final readonly class A128CCM_16_64 extends AESCCM { + #[Override] public function getCEKSize(): int { return 128; } + #[Override] public function name(): string { return 'A128CCM-16-64'; } + #[Override] public function getIVSize(): int { return 13 * 8; } + #[Override] protected function getMode(): string { return 'aes-128-ccm'; } + #[Override] protected function getTagLength(): int { return 8; diff --git a/src/Experimental/ContentEncryption/A128CCM_64_128.php b/src/Experimental/ContentEncryption/A128CCM_64_128.php index 14399f4dc..0b51013e7 100644 --- a/src/Experimental/ContentEncryption/A128CCM_64_128.php +++ b/src/Experimental/ContentEncryption/A128CCM_64_128.php @@ -4,28 +4,35 @@ namespace Jose\Experimental\ContentEncryption; -final class A128CCM_64_128 extends AESCCM +use Override; + +final readonly class A128CCM_64_128 extends AESCCM { + #[Override] public function getCEKSize(): int { return 128; } + #[Override] public function name(): string { return 'A128CCM-64-128'; } + #[Override] public function getIVSize(): int { return 7 * 8; } + #[Override] protected function getMode(): string { return 'aes-128-ccm'; } + #[Override] protected function getTagLength(): int { return 16; diff --git a/src/Experimental/ContentEncryption/A128CCM_64_64.php b/src/Experimental/ContentEncryption/A128CCM_64_64.php index 40bc3d01d..174f62ef1 100644 --- a/src/Experimental/ContentEncryption/A128CCM_64_64.php +++ b/src/Experimental/ContentEncryption/A128CCM_64_64.php @@ -4,28 +4,35 @@ namespace Jose\Experimental\ContentEncryption; -final class A128CCM_64_64 extends AESCCM +use Override; + +final readonly class A128CCM_64_64 extends AESCCM { + #[Override] public function getCEKSize(): int { return 128; } + #[Override] public function name(): string { return 'A128CCM-64-64'; } + #[Override] public function getIVSize(): int { return 7 * 8; } + #[Override] protected function getMode(): string { return 'aes-128-ccm'; } + #[Override] protected function getTagLength(): int { return 8; diff --git a/src/Experimental/ContentEncryption/A256CCM_16_128.php b/src/Experimental/ContentEncryption/A256CCM_16_128.php index 766007889..226b7cc59 100644 --- a/src/Experimental/ContentEncryption/A256CCM_16_128.php +++ b/src/Experimental/ContentEncryption/A256CCM_16_128.php @@ -4,28 +4,35 @@ namespace Jose\Experimental\ContentEncryption; -final class A256CCM_16_128 extends AESCCM +use Override; + +final readonly class A256CCM_16_128 extends AESCCM { + #[Override] public function getCEKSize(): int { return 256; } + #[Override] public function name(): string { return 'A256CCM-16-128'; } + #[Override] public function getIVSize(): int { return 13 * 8; } + #[Override] protected function getMode(): string { return 'aes-256-ccm'; } + #[Override] protected function getTagLength(): int { return 8; diff --git a/src/Experimental/ContentEncryption/A256CCM_16_64.php b/src/Experimental/ContentEncryption/A256CCM_16_64.php index e5efca0d3..0a4d0179c 100644 --- a/src/Experimental/ContentEncryption/A256CCM_16_64.php +++ b/src/Experimental/ContentEncryption/A256CCM_16_64.php @@ -4,28 +4,35 @@ namespace Jose\Experimental\ContentEncryption; -final class A256CCM_16_64 extends AESCCM +use Override; + +final readonly class A256CCM_16_64 extends AESCCM { + #[Override] public function getCEKSize(): int { return 256; } + #[Override] public function name(): string { return 'A256CCM-16-64'; } + #[Override] public function getIVSize(): int { return 13 * 8; } + #[Override] protected function getMode(): string { return 'aes-256-ccm'; } + #[Override] protected function getTagLength(): int { return 8; diff --git a/src/Experimental/ContentEncryption/A256CCM_64_128.php b/src/Experimental/ContentEncryption/A256CCM_64_128.php index d83c3f51c..fb4944c93 100644 --- a/src/Experimental/ContentEncryption/A256CCM_64_128.php +++ b/src/Experimental/ContentEncryption/A256CCM_64_128.php @@ -4,28 +4,35 @@ namespace Jose\Experimental\ContentEncryption; -final class A256CCM_64_128 extends AESCCM +use Override; + +final readonly class A256CCM_64_128 extends AESCCM { + #[Override] public function getCEKSize(): int { return 256; } + #[Override] public function name(): string { return 'A256CCM-16-128'; } + #[Override] public function getIVSize(): int { return 7 * 8; } + #[Override] protected function getMode(): string { return 'aes-256-ccm'; } + #[Override] protected function getTagLength(): int { return 16; diff --git a/src/Experimental/ContentEncryption/A256CCM_64_64.php b/src/Experimental/ContentEncryption/A256CCM_64_64.php index 13aa1f076..c1124cf4e 100644 --- a/src/Experimental/ContentEncryption/A256CCM_64_64.php +++ b/src/Experimental/ContentEncryption/A256CCM_64_64.php @@ -4,28 +4,35 @@ namespace Jose\Experimental\ContentEncryption; -final class A256CCM_64_64 extends AESCCM +use Override; + +final readonly class A256CCM_64_64 extends AESCCM { + #[Override] public function getCEKSize(): int { return 256; } + #[Override] public function name(): string { return 'A256CCM-16-64'; } + #[Override] public function getIVSize(): int { return 7 * 8; } + #[Override] protected function getMode(): string { return 'aes-256-ccm'; } + #[Override] protected function getTagLength(): int { return 8; diff --git a/src/Experimental/ContentEncryption/AESCCM.php b/src/Experimental/ContentEncryption/AESCCM.php index 5c2c31d33..34afa5f6b 100644 --- a/src/Experimental/ContentEncryption/AESCCM.php +++ b/src/Experimental/ContentEncryption/AESCCM.php @@ -5,16 +5,19 @@ namespace Jose\Experimental\ContentEncryption; use Jose\Component\Encryption\Algorithm\ContentEncryptionAlgorithm; +use Override; use RuntimeException; use const OPENSSL_RAW_DATA; -abstract class AESCCM implements ContentEncryptionAlgorithm +abstract readonly class AESCCM implements ContentEncryptionAlgorithm { + #[Override] public function allowedKeyTypes(): array { return []; //Irrelevant } + #[Override] public function encryptContent( string $data, string $cek, @@ -45,6 +48,7 @@ public function encryptContent( return $result; } + #[Override] public function decryptContent( string $data, string $cek, diff --git a/src/Experimental/KeyEncryption/A128CTR.php b/src/Experimental/KeyEncryption/A128CTR.php index 27dc8366a..e0df8a91d 100644 --- a/src/Experimental/KeyEncryption/A128CTR.php +++ b/src/Experimental/KeyEncryption/A128CTR.php @@ -4,13 +4,17 @@ namespace Jose\Experimental\KeyEncryption; -final class A128CTR extends AESCTR +use Override; + +final readonly class A128CTR extends AESCTR { + #[Override] public function name(): string { return 'A128CTR'; } + #[Override] protected function getMode(): string { return 'aes-128-ctr'; diff --git a/src/Experimental/KeyEncryption/A192CTR.php b/src/Experimental/KeyEncryption/A192CTR.php index d8e8bd191..92b17e7c7 100644 --- a/src/Experimental/KeyEncryption/A192CTR.php +++ b/src/Experimental/KeyEncryption/A192CTR.php @@ -4,13 +4,17 @@ namespace Jose\Experimental\KeyEncryption; -final class A192CTR extends AESCTR +use Override; + +final readonly class A192CTR extends AESCTR { + #[Override] public function name(): string { return 'A192CTR'; } + #[Override] protected function getMode(): string { return 'aes-192-ctr'; diff --git a/src/Experimental/KeyEncryption/A256CTR.php b/src/Experimental/KeyEncryption/A256CTR.php index b020f0c27..a8e770251 100644 --- a/src/Experimental/KeyEncryption/A256CTR.php +++ b/src/Experimental/KeyEncryption/A256CTR.php @@ -4,13 +4,17 @@ namespace Jose\Experimental\KeyEncryption; -final class A256CTR extends AESCTR +use Override; + +final readonly class A256CTR extends AESCTR { + #[Override] public function name(): string { return 'A256CTR'; } + #[Override] protected function getMode(): string { return 'aes-256-ctr'; diff --git a/src/Experimental/KeyEncryption/AESCTR.php b/src/Experimental/KeyEncryption/AESCTR.php index 76fd00f07..14cbd5c8b 100644 --- a/src/Experimental/KeyEncryption/AESCTR.php +++ b/src/Experimental/KeyEncryption/AESCTR.php @@ -6,15 +6,17 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\KeyEncryption\KeyEncryption; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use RuntimeException; use function in_array; use function is_string; use const OPENSSL_RAW_DATA; -abstract class AESCTR implements KeyEncryption +abstract readonly class AESCTR implements KeyEncryption { + #[Override] public function allowedKeyTypes(): array { return ['oct']; @@ -24,6 +26,7 @@ public function allowedKeyTypes(): array * @param array $completeHeader * @param array $additionalHeader */ + #[Override] public function encryptKey(JWK $key, string $cek, array $completeHeader, array &$additionalHeader): string { $k = $this->getKey($key); @@ -43,6 +46,7 @@ public function encryptKey(JWK $key, string $cek, array $completeHeader, array & /** * @param array $header */ + #[Override] public function decryptKey(JWK $key, string $encrypted_cek, array $header): string { $k = $this->getKey($key); @@ -58,6 +62,7 @@ public function decryptKey(JWK $key, string $encrypted_cek, array $header): stri return $result; } + #[Override] public function getKeyManagementMode(): string { return self::MODE_ENCRYPT; diff --git a/src/Experimental/KeyEncryption/Chacha20Poly1305.php b/src/Experimental/KeyEncryption/Chacha20Poly1305.php index 947a7c834..b52cfa21e 100644 --- a/src/Experimental/KeyEncryption/Chacha20Poly1305.php +++ b/src/Experimental/KeyEncryption/Chacha20Poly1305.php @@ -6,15 +6,16 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\KeyEncryption\KeyEncryption; use LogicException; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use RuntimeException; use function in_array; use function is_string; use const OPENSSL_RAW_DATA; -final class Chacha20Poly1305 implements KeyEncryption +final readonly class Chacha20Poly1305 implements KeyEncryption { public function __construct() { @@ -23,11 +24,13 @@ public function __construct() } } + #[Override] public function allowedKeyTypes(): array { return ['oct']; } + #[Override] public function name(): string { return 'chacha20-poly1305'; @@ -37,6 +40,7 @@ public function name(): string * @param array $completeHeader * @param array $additionalHeader */ + #[Override] public function encryptKey(JWK $key, string $cek, array $completeHeader, array &$additionalHeader): string { $k = $this->getKey($key); @@ -57,6 +61,7 @@ public function encryptKey(JWK $key, string $cek, array $completeHeader, array & /** * @param array $header */ + #[Override] public function decryptKey(JWK $key, string $encrypted_cek, array $header): string { $k = $this->getKey($key); @@ -75,6 +80,7 @@ public function decryptKey(JWK $key, string $encrypted_cek, array $header): stri return $result; } + #[Override] public function getKeyManagementMode(): string { return self::MODE_ENCRYPT; diff --git a/src/Experimental/KeyEncryption/RSAOAEP384.php b/src/Experimental/KeyEncryption/RSAOAEP384.php index 03863fb50..e18e68ebe 100644 --- a/src/Experimental/KeyEncryption/RSAOAEP384.php +++ b/src/Experimental/KeyEncryption/RSAOAEP384.php @@ -6,19 +6,23 @@ use Jose\Component\Encryption\Algorithm\KeyEncryption\RSA; use Jose\Component\Encryption\Algorithm\KeyEncryption\Util\RSACrypt; +use Override; -final class RSAOAEP384 extends RSA +final readonly class RSAOAEP384 extends RSA { + #[Override] public function getEncryptionMode(): int { return RSACrypt::ENCRYPTION_OAEP; } + #[Override] public function getHashAlgorithm(): string { return 'sha384'; } + #[Override] public function name(): string { return 'RSA-OAEP-384'; diff --git a/src/Experimental/KeyEncryption/RSAOAEP512.php b/src/Experimental/KeyEncryption/RSAOAEP512.php index 3c6b6e8a3..4b7cf321a 100644 --- a/src/Experimental/KeyEncryption/RSAOAEP512.php +++ b/src/Experimental/KeyEncryption/RSAOAEP512.php @@ -6,19 +6,23 @@ use Jose\Component\Encryption\Algorithm\KeyEncryption\RSA; use Jose\Component\Encryption\Algorithm\KeyEncryption\Util\RSACrypt; +use Override; -final class RSAOAEP512 extends RSA +final readonly class RSAOAEP512 extends RSA { + #[Override] public function getEncryptionMode(): int { return RSACrypt::ENCRYPTION_OAEP; } + #[Override] public function getHashAlgorithm(): string { return 'sha512'; } + #[Override] public function name(): string { return 'RSA-OAEP-512'; diff --git a/src/Experimental/Signature/Blake2b.php b/src/Experimental/Signature/Blake2b.php index 73cd75792..6dfba333c 100644 --- a/src/Experimental/Signature/Blake2b.php +++ b/src/Experimental/Signature/Blake2b.php @@ -6,8 +6,9 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Signature\Algorithm\MacAlgorithm; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use RuntimeException; use function extension_loaded; use function in_array; @@ -16,9 +17,9 @@ /** * @see \Jose\Tests\Component\Signature\Algorithm\Blake2bTest */ -final class Blake2b implements MacAlgorithm +final readonly class Blake2b implements MacAlgorithm { - private const MINIMUM_KEY_LENGTH = 32; + private const int MINIMUM_KEY_LENGTH = 32; public function __construct() { @@ -27,21 +28,25 @@ public function __construct() } } + #[Override] public function allowedKeyTypes(): array { return ['oct']; } + #[Override] public function name(): string { return 'BLAKE2B'; } + #[Override] public function verify(JWK $key, string $input, string $signature): bool { return hash_equals($this->hash($key, $input), $signature); } + #[Override] public function hash(JWK $key, string $input): string { $k = $this->getKey($key); diff --git a/src/Experimental/Signature/ES256K.php b/src/Experimental/Signature/ES256K.php index d365356b6..f15cf8660 100644 --- a/src/Experimental/Signature/ES256K.php +++ b/src/Experimental/Signature/ES256K.php @@ -5,19 +5,23 @@ namespace Jose\Experimental\Signature; use Jose\Component\Signature\Algorithm\ECDSA; +use Override; -final class ES256K extends ECDSA +final readonly class ES256K extends ECDSA { + #[Override] public function name(): string { return 'ES256K'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha256'; } + #[Override] protected function getSignaturePartLength(): int { return 64; diff --git a/src/Experimental/Signature/HS1.php b/src/Experimental/Signature/HS1.php index 56bb95457..544ebb521 100644 --- a/src/Experimental/Signature/HS1.php +++ b/src/Experimental/Signature/HS1.php @@ -5,14 +5,17 @@ namespace Jose\Experimental\Signature; use Jose\Component\Signature\Algorithm\HMAC; +use Override; -final class HS1 extends HMAC +final readonly class HS1 extends HMAC { + #[Override] public function name(): string { return 'HS1'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha1'; diff --git a/src/Experimental/Signature/HS256_64.php b/src/Experimental/Signature/HS256_64.php index fee13591f..41ac8ee77 100644 --- a/src/Experimental/Signature/HS256_64.php +++ b/src/Experimental/Signature/HS256_64.php @@ -6,9 +6,11 @@ use Jose\Component\Core\JWK; use Jose\Component\Signature\Algorithm\HMAC; +use Override; -final class HS256_64 extends HMAC +final readonly class HS256_64 extends HMAC { + #[Override] public function hash(JWK $key, string $input): string { $signature = parent::hash($key, $input); @@ -16,11 +18,13 @@ public function hash(JWK $key, string $input): string return mb_substr($signature, 0, 8, '8bit'); } + #[Override] public function name(): string { return 'HS256/64'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha256'; diff --git a/src/Experimental/Signature/RS1.php b/src/Experimental/Signature/RS1.php index a8cc7b916..6413c3149 100644 --- a/src/Experimental/Signature/RS1.php +++ b/src/Experimental/Signature/RS1.php @@ -5,14 +5,17 @@ namespace Jose\Experimental\Signature; use Jose\Component\Signature\Algorithm\RSAPKCS1; +use Override; -final class RS1 extends RSAPKCS1 +final readonly class RS1 extends RSAPKCS1 { + #[Override] public function name(): string { return 'RS1'; } + #[Override] protected function getAlgorithm(): string { return 'sha1'; diff --git a/src/Library/Checker/AlgorithmChecker.php b/src/Library/Checker/AlgorithmChecker.php index c2d7d0319..20afadeec 100644 --- a/src/Library/Checker/AlgorithmChecker.php +++ b/src/Library/Checker/AlgorithmChecker.php @@ -4,6 +4,7 @@ namespace Jose\Component\Checker; +use Override; use function in_array; use function is_string; @@ -11,19 +12,20 @@ * This class is a header parameter checker. When the "alg" header parameter is present, it will check if the value is * within the allowed ones. */ -final class AlgorithmChecker implements HeaderChecker +final readonly class AlgorithmChecker implements HeaderChecker { - private const HEADER_NAME = 'alg'; + private const string HEADER_NAME = 'alg'; /** * @param string[] $supportedAlgorithms */ public function __construct( - private readonly array $supportedAlgorithms, - private readonly bool $protectedHeader = false + private array $supportedAlgorithms, + private bool $protectedHeader = false ) { } + #[Override] public function checkHeader(mixed $value): void { if (! is_string($value)) { @@ -34,11 +36,13 @@ public function checkHeader(mixed $value): void } } + #[Override] public function supportedHeader(): string { return self::HEADER_NAME; } + #[Override] public function protectedHeaderOnly(): bool { return $this->protectedHeader; diff --git a/src/Library/Checker/AudienceChecker.php b/src/Library/Checker/AudienceChecker.php index 995a94c9d..3d6085009 100644 --- a/src/Library/Checker/AudienceChecker.php +++ b/src/Library/Checker/AudienceChecker.php @@ -4,6 +4,7 @@ namespace Jose\Component\Checker; +use Override; use function in_array; use function is_array; use function is_string; @@ -12,36 +13,41 @@ * This class is a header parameter and claim checker. When the "aud" header parameter or claim is present, it will * check if the value is within the allowed ones. */ -final class AudienceChecker implements ClaimChecker, HeaderChecker +final readonly class AudienceChecker implements ClaimChecker, HeaderChecker { - private const CLAIM_NAME = 'aud'; + private const string CLAIM_NAME = 'aud'; public function __construct( - private readonly string $audience, - private readonly bool $protectedHeader = false + private string $audience, + private bool $protectedHeader = false ) { } + #[Override] public function checkClaim(mixed $value): void { $this->checkValue($value, InvalidClaimException::class); } + #[Override] public function checkHeader(mixed $value): void { $this->checkValue($value, InvalidHeaderException::class); } + #[Override] public function supportedClaim(): string { return self::CLAIM_NAME; } + #[Override] public function supportedHeader(): string { return self::CLAIM_NAME; } + #[Override] public function protectedHeaderOnly(): bool { return $this->protectedHeader; diff --git a/src/Library/Checker/CallableChecker.php b/src/Library/Checker/CallableChecker.php index 9f51b8c14..ceb0020ff 100644 --- a/src/Library/Checker/CallableChecker.php +++ b/src/Library/Checker/CallableChecker.php @@ -5,6 +5,7 @@ namespace Jose\Component\Checker; use InvalidArgumentException; +use Override; use function call_user_func; use function is_callable; @@ -27,6 +28,7 @@ public function __construct( } } + #[Override] public function checkClaim(mixed $value): void { if (call_user_func($this->callable, $value) !== true) { @@ -34,11 +36,13 @@ public function checkClaim(mixed $value): void } } + #[Override] public function supportedClaim(): string { return $this->key; } + #[Override] public function checkHeader(mixed $value): void { if (call_user_func($this->callable, $value) !== true) { @@ -46,11 +50,13 @@ public function checkHeader(mixed $value): void } } + #[Override] public function supportedHeader(): string { return $this->key; } + #[Override] public function protectedHeaderOnly(): bool { return $this->protectedHeaderOnly; diff --git a/src/Library/Checker/ExpirationTimeChecker.php b/src/Library/Checker/ExpirationTimeChecker.php index 9541be76b..da2b192f6 100644 --- a/src/Library/Checker/ExpirationTimeChecker.php +++ b/src/Library/Checker/ExpirationTimeChecker.php @@ -4,6 +4,7 @@ namespace Jose\Component\Checker; +use Override; use Psr\Clock\ClockInterface; use function is_float; use function is_int; @@ -11,17 +12,18 @@ /** * This class is a claim checker. When the "exp" is present, it will compare the value with the current timestamp. */ -final class ExpirationTimeChecker implements ClaimChecker, HeaderChecker +final readonly class ExpirationTimeChecker implements ClaimChecker, HeaderChecker { private const string NAME = 'exp'; public function __construct( - private readonly ClockInterface $clock, - private readonly int $allowedTimeDrift = 0, - private readonly bool $protectedHeaderOnly = false, + private ClockInterface $clock, + private int $allowedTimeDrift = 0, + private bool $protectedHeaderOnly = false, ) { } + #[Override] public function checkClaim(mixed $value): void { if (! is_float($value) && ! is_int($value)) { @@ -35,11 +37,13 @@ public function checkClaim(mixed $value): void } } + #[Override] public function supportedClaim(): string { return self::NAME; } + #[Override] public function checkHeader(mixed $value): void { if (! is_float($value) && ! is_int($value)) { @@ -53,11 +57,13 @@ public function checkHeader(mixed $value): void } } + #[Override] public function supportedHeader(): string { return self::NAME; } + #[Override] public function protectedHeaderOnly(): bool { return $this->protectedHeaderOnly; diff --git a/src/Library/Checker/InternalClock.php b/src/Library/Checker/InternalClock.php deleted file mode 100644 index eace993fa..000000000 --- a/src/Library/Checker/InternalClock.php +++ /dev/null @@ -1,19 +0,0 @@ -value) { @@ -29,11 +32,13 @@ public function checkClaim(mixed $value): void } } + #[Override] public function supportedClaim(): string { return $this->key; } + #[Override] public function checkHeader(mixed $value): void { if ($value !== $this->value) { @@ -41,11 +46,13 @@ public function checkHeader(mixed $value): void } } + #[Override] public function supportedHeader(): string { return $this->key; } + #[Override] public function protectedHeaderOnly(): bool { return $this->protectedHeaderOnly; diff --git a/src/Library/Checker/IssuedAtChecker.php b/src/Library/Checker/IssuedAtChecker.php index ed02cf568..281c791a4 100644 --- a/src/Library/Checker/IssuedAtChecker.php +++ b/src/Library/Checker/IssuedAtChecker.php @@ -4,6 +4,7 @@ namespace Jose\Component\Checker; +use Override; use Psr\Clock\ClockInterface; use function is_float; use function is_int; @@ -11,17 +12,18 @@ /** * This class is a claim checker. When the "iat" is present, it will compare the value with the current timestamp. */ -final class IssuedAtChecker implements ClaimChecker, HeaderChecker +final readonly class IssuedAtChecker implements ClaimChecker, HeaderChecker { private const string NAME = 'iat'; public function __construct( - private readonly ClockInterface $clock, - private readonly int $allowedTimeDrift = 0, - private readonly bool $protectedHeaderOnly = false, + private ClockInterface $clock, + private int $allowedTimeDrift = 0, + private bool $protectedHeaderOnly = false, ) { } + #[Override] public function checkClaim(mixed $value): void { if (! is_float($value) && ! is_int($value)) { @@ -35,11 +37,13 @@ public function checkClaim(mixed $value): void } } + #[Override] public function supportedClaim(): string { return self::NAME; } + #[Override] public function checkHeader(mixed $value): void { if (! is_float($value) && ! is_int($value)) { @@ -53,11 +57,13 @@ public function checkHeader(mixed $value): void } } + #[Override] public function supportedHeader(): string { return self::NAME; } + #[Override] public function protectedHeaderOnly(): bool { return $this->protectedHeaderOnly; diff --git a/src/Library/Checker/IssuerChecker.php b/src/Library/Checker/IssuerChecker.php index 6c5a9b0f5..e4651b4c1 100644 --- a/src/Library/Checker/IssuerChecker.php +++ b/src/Library/Checker/IssuerChecker.php @@ -4,6 +4,7 @@ namespace Jose\Component\Checker; +use Override; use function in_array; use function is_string; @@ -11,36 +12,41 @@ * This class is a header parameter and claim checker. When the "iss" header parameter or claim is present, it will * check if the value is within the allowed ones. */ -final class IssuerChecker implements ClaimChecker, HeaderChecker +final readonly class IssuerChecker implements ClaimChecker, HeaderChecker { - private const CLAIM_NAME = 'iss'; + private const string CLAIM_NAME = 'iss'; public function __construct( - private readonly array $issuers, - private readonly bool $protectedHeader = false + private array $issuers, + private bool $protectedHeader = false ) { } + #[Override] public function checkClaim(mixed $value): void { $this->checkValue($value, InvalidClaimException::class); } + #[Override] public function checkHeader(mixed $value): void { $this->checkValue($value, InvalidHeaderException::class); } + #[Override] public function supportedClaim(): string { return self::CLAIM_NAME; } + #[Override] public function supportedHeader(): string { return self::CLAIM_NAME; } + #[Override] public function protectedHeaderOnly(): bool { return $this->protectedHeader; diff --git a/src/Library/Checker/NotBeforeChecker.php b/src/Library/Checker/NotBeforeChecker.php index 35585ae94..cf9daa066 100644 --- a/src/Library/Checker/NotBeforeChecker.php +++ b/src/Library/Checker/NotBeforeChecker.php @@ -4,6 +4,7 @@ namespace Jose\Component\Checker; +use Override; use Psr\Clock\ClockInterface; use function is_float; use function is_int; @@ -11,17 +12,18 @@ /** * This class is a claim checker. When the "nbf" is present, it will compare the value with the current timestamp. */ -final class NotBeforeChecker implements ClaimChecker, HeaderChecker +final readonly class NotBeforeChecker implements ClaimChecker, HeaderChecker { private const string NAME = 'nbf'; public function __construct( - private readonly ClockInterface $clock, - private readonly int $allowedTimeDrift = 0, - private readonly bool $protectedHeaderOnly = false, + private ClockInterface $clock, + private int $allowedTimeDrift = 0, + private bool $protectedHeaderOnly = false, ) { } + #[Override] public function checkClaim(mixed $value): void { if (! is_float($value) && ! is_int($value)) { @@ -35,11 +37,13 @@ public function checkClaim(mixed $value): void } } + #[Override] public function supportedClaim(): string { return self::NAME; } + #[Override] public function checkHeader(mixed $value): void { if (! is_float($value) && ! is_int($value)) { @@ -53,11 +57,13 @@ public function checkHeader(mixed $value): void } } + #[Override] public function supportedHeader(): string { return self::NAME; } + #[Override] public function protectedHeaderOnly(): bool { return $this->protectedHeaderOnly; diff --git a/src/Library/Checker/UnencodedPayloadChecker.php b/src/Library/Checker/UnencodedPayloadChecker.php index 91f79a224..b74429e27 100644 --- a/src/Library/Checker/UnencodedPayloadChecker.php +++ b/src/Library/Checker/UnencodedPayloadChecker.php @@ -4,6 +4,7 @@ namespace Jose\Component\Checker; +use Override; use function is_bool; /** @@ -13,8 +14,9 @@ */ final class UnencodedPayloadChecker implements HeaderChecker { - private const HEADER_NAME = 'b64'; + private const string HEADER_NAME = 'b64'; + #[Override] public function checkHeader(mixed $value): void { if (! is_bool($value)) { @@ -22,11 +24,13 @@ public function checkHeader(mixed $value): void } } + #[Override] public function supportedHeader(): string { return self::HEADER_NAME; } + #[Override] public function protectedHeaderOnly(): bool { return true; diff --git a/src/Library/Console/AddKeyIntoKeysetCommand.php b/src/Library/Console/AddKeyIntoKeysetCommand.php index 0748bc685..10794ccab 100644 --- a/src/Library/Console/AddKeyIntoKeysetCommand.php +++ b/src/Library/Console/AddKeyIntoKeysetCommand.php @@ -8,6 +8,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; use Jose\Component\Core\Util\JsonConverter; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -18,10 +19,7 @@ #[AsCommand(name: 'keyset:add:key', description: 'Add a key into a key set.',)] final class AddKeyIntoKeysetCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:add:key'; - - protected static $defaultDescription = 'Add a key into a key set.'; - + #[Override] protected function configure(): void { parent::configure(); @@ -30,6 +28,7 @@ protected function configure(): void ->addArgument('jwk', InputArgument::REQUIRED, 'The new JWK object'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $jwkset = $this->getKeyset($input); diff --git a/src/Library/Console/EcKeyGeneratorCommand.php b/src/Library/Console/EcKeyGeneratorCommand.php index 42ff88a74..f334d8cd1 100644 --- a/src/Library/Console/EcKeyGeneratorCommand.php +++ b/src/Library/Console/EcKeyGeneratorCommand.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -15,16 +16,14 @@ #[AsCommand(name: 'key:generate:ec', description: 'Generate an EC key (JWK format)',)] final class EcKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:ec'; - - protected static $defaultDescription = 'Generate an EC key (JWK format)'; - + #[Override] protected function configure(): void { parent::configure(); $this->addArgument('curve', InputArgument::REQUIRED, 'Curve of the key.'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $curve = $input->getArgument('curve'); diff --git a/src/Library/Console/EcKeysetGeneratorCommand.php b/src/Library/Console/EcKeysetGeneratorCommand.php index 5dfab7c32..78b3cb0e6 100644 --- a/src/Library/Console/EcKeysetGeneratorCommand.php +++ b/src/Library/Console/EcKeysetGeneratorCommand.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Jose\Component\Core\JWKSet; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -16,10 +17,7 @@ #[AsCommand(name: 'keyset:generate:ec', description: 'Generate an EC key set (JWKSet format)',)] final class EcKeysetGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'keyset:generate:ec'; - - protected static $defaultDescription = 'Generate an EC key set (JWKSet format)'; - + #[Override] protected function configure(): void { parent::configure(); @@ -27,6 +25,7 @@ protected function configure(): void ->addArgument('curve', InputArgument::REQUIRED, 'Curve of the keys.'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $quantity = (int) $input->getArgument('quantity'); diff --git a/src/Library/Console/GeneratorCommand.php b/src/Library/Console/GeneratorCommand.php index 8f4f58cb4..da3cc7039 100644 --- a/src/Library/Console/GeneratorCommand.php +++ b/src/Library/Console/GeneratorCommand.php @@ -5,19 +5,22 @@ namespace Jose\Component\Console; use InvalidArgumentException; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\KeyManagement\JWKFactory; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use function is_bool; abstract class GeneratorCommand extends ObjectOutputCommand { + #[Override] public function isEnabled(): bool { return class_exists(JWKFactory::class); } + #[Override] protected function configure(): void { parent::configure(); diff --git a/src/Library/Console/GetThumbprintCommand.php b/src/Library/Console/GetThumbprintCommand.php index 31e0cdf53..a98a12587 100644 --- a/src/Library/Console/GetThumbprintCommand.php +++ b/src/Library/Console/GetThumbprintCommand.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; use Jose\Component\Core\Util\JsonConverter; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -18,10 +19,7 @@ #[AsCommand(name: 'key:thumbprint', description: 'Get the thumbprint of a JWK key.',)] final class GetThumbprintCommand extends ObjectOutputCommand { - protected static $defaultName = 'key:thumbprint'; - - protected static $defaultDescription = 'Get the thumbprint of a JWK key.'; - + #[Override] protected function configure(): void { parent::configure(); @@ -29,6 +27,7 @@ protected function configure(): void ->addOption('hash', null, InputOption::VALUE_OPTIONAL, 'The hashing algorithm.', 'sha256'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $jwk = $input->getArgument('jwk'); diff --git a/src/Library/Console/JKULoaderCommand.php b/src/Library/Console/JKULoaderCommand.php index 94d2f2ef9..243dc0d61 100644 --- a/src/Library/Console/JKULoaderCommand.php +++ b/src/Library/Console/JKULoaderCommand.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JKUFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -15,10 +16,6 @@ #[AsCommand(name: 'keyset:load:jku', description: 'Loads a key set from an url.',)] final class JKULoaderCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:load:jku'; - - protected static $defaultDescription = 'Loads a key set from an url.'; - public function __construct( private readonly JKUFactory $jkuFactory, ?string $name = null @@ -26,6 +23,7 @@ public function __construct( parent::__construct($name); } + #[Override] protected function configure(): void { parent::configure(); @@ -33,6 +31,7 @@ protected function configure(): void ->addArgument('url', InputArgument::REQUIRED, 'The URL'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $url = $input->getArgument('url'); diff --git a/src/Library/Console/KeyAnalyzerCommand.php b/src/Library/Console/KeyAnalyzerCommand.php index 368fdfa65..faf7fbb2b 100644 --- a/src/Library/Console/KeyAnalyzerCommand.php +++ b/src/Library/Console/KeyAnalyzerCommand.php @@ -8,6 +8,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\KeyManagement\Analyzer\KeyAnalyzerManager; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Formatter\OutputFormatterStyle; @@ -20,10 +21,6 @@ #[AsCommand(name: 'key:analyze', description: 'JWK quality analyzer.',)] final class KeyAnalyzerCommand extends Command { - protected static $defaultName = 'key:analyze'; - - protected static $defaultDescription = 'JWK quality analyzer.'; - public function __construct( private readonly KeyAnalyzerManager $analyzerManager, string $name = null @@ -31,6 +28,7 @@ public function __construct( parent::__construct($name); } + #[Override] protected function configure(): void { parent::configure(); @@ -38,6 +36,7 @@ protected function configure(): void ->addArgument('jwk', InputArgument::REQUIRED, 'The JWK object'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $output->getFormatter() diff --git a/src/Library/Console/KeyFileLoaderCommand.php b/src/Library/Console/KeyFileLoaderCommand.php index 6ed746762..763ed29df 100644 --- a/src/Library/Console/KeyFileLoaderCommand.php +++ b/src/Library/Console/KeyFileLoaderCommand.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -16,10 +17,7 @@ #[AsCommand(name: 'key:load:key', description: 'Loads a key from a key file (JWK format)',)] final class KeyFileLoaderCommand extends GeneratorCommand { - protected static $defaultName = 'key:load:key'; - - protected static $defaultDescription = 'Loads a key from a key file (JWK format)'; - + #[Override] protected function configure(): void { parent::configure(); @@ -27,6 +25,7 @@ protected function configure(): void ->addOption('secret', 's', InputOption::VALUE_OPTIONAL, 'Secret if the key is encrypted.', null); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $file = $input->getArgument('file'); diff --git a/src/Library/Console/KeysetAnalyzerCommand.php b/src/Library/Console/KeysetAnalyzerCommand.php index 826afa0c3..22cd56f3a 100644 --- a/src/Library/Console/KeysetAnalyzerCommand.php +++ b/src/Library/Console/KeysetAnalyzerCommand.php @@ -10,6 +10,7 @@ use Jose\Component\KeyManagement\Analyzer\KeyAnalyzerManager; use Jose\Component\KeyManagement\Analyzer\KeysetAnalyzerManager; use Jose\Component\KeyManagement\Analyzer\MessageBag; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Formatter\OutputFormatterStyle; @@ -22,10 +23,6 @@ #[AsCommand(name: 'keyset:analyze', description: 'JWKSet quality analyzer.',)] final class KeysetAnalyzerCommand extends Command { - protected static $defaultName = 'keyset:analyze'; - - protected static $defaultDescription = 'JWKSet quality analyzer.'; - public function __construct( private readonly KeysetAnalyzerManager $keysetAnalyzerManager, private readonly KeyAnalyzerManager $keyAnalyzerManager, @@ -34,6 +31,7 @@ public function __construct( parent::__construct($name); } + #[Override] protected function configure(): void { parent::configure(); @@ -41,6 +39,7 @@ protected function configure(): void ->addArgument('jwkset', InputArgument::REQUIRED, 'The JWKSet object'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $output->getFormatter() diff --git a/src/Library/Console/MergeKeysetCommand.php b/src/Library/Console/MergeKeysetCommand.php index a558ba694..5b0735747 100644 --- a/src/Library/Console/MergeKeysetCommand.php +++ b/src/Library/Console/MergeKeysetCommand.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Jose\Component\Core\JWKSet; use Jose\Component\Core\Util\JsonConverter; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -16,10 +17,7 @@ #[AsCommand(name: 'keyset:merge', description: 'Merge several key sets into one.',)] final class MergeKeysetCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:merge'; - - protected static $defaultDescription = 'Merge several key sets into one.'; - + #[Override] protected function configure(): void { parent::configure(); @@ -29,6 +27,7 @@ protected function configure(): void ->addArgument('jwksets', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'The JWKSet objects'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { /** @var string[] $keySets */ diff --git a/src/Library/Console/NoneKeyGeneratorCommand.php b/src/Library/Console/NoneKeyGeneratorCommand.php index 86dd6cf91..2becd1789 100644 --- a/src/Library/Console/NoneKeyGeneratorCommand.php +++ b/src/Library/Console/NoneKeyGeneratorCommand.php @@ -5,6 +5,8 @@ namespace Jose\Component\Console; use Jose\Component\KeyManagement\JWKFactory; +use Override; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -14,15 +16,7 @@ )] final class NoneKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:none'; - - protected static $defaultDescription = 'Generate a none key (JWK format). This key type is only supposed to be used with the "none" algorithm.'; - - protected function configure(): void - { - parent::configure(); - } - + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $args = $this->getOptions($input); diff --git a/src/Library/Console/OctKeyGeneratorCommand.php b/src/Library/Console/OctKeyGeneratorCommand.php index 2601ebf9b..83c07935e 100644 --- a/src/Library/Console/OctKeyGeneratorCommand.php +++ b/src/Library/Console/OctKeyGeneratorCommand.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -14,16 +15,14 @@ #[AsCommand(name: 'key:generate:oct', description: 'Generate an octet key (JWK format)',)] final class OctKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:oct'; - - protected static $defaultDescription = 'Generate an octet key (JWK format)'; - + #[Override] protected function configure(): void { parent::configure(); $this->addArgument('size', InputArgument::REQUIRED, 'Key size.'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $size = (int) $input->getArgument('size'); diff --git a/src/Library/Console/OctKeysetGeneratorCommand.php b/src/Library/Console/OctKeysetGeneratorCommand.php index e7dd92fae..9e3615ae5 100644 --- a/src/Library/Console/OctKeysetGeneratorCommand.php +++ b/src/Library/Console/OctKeysetGeneratorCommand.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Jose\Component\Core\JWKSet; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -15,10 +16,7 @@ #[AsCommand(name: 'keyset:generate:oct', description: 'Generate a key set with octet keys (JWK format)',)] final class OctKeysetGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'keyset:generate:oct'; - - protected static $defaultDescription = 'Generate a key set with octet keys (JWK format)'; - + #[Override] protected function configure(): void { parent::configure(); @@ -26,6 +24,7 @@ protected function configure(): void ->addArgument('size', InputArgument::REQUIRED, 'Key size.'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $quantity = (int) $input->getArgument('quantity'); diff --git a/src/Library/Console/OkpKeyGeneratorCommand.php b/src/Library/Console/OkpKeyGeneratorCommand.php index 195efb7df..f79d2a9f5 100644 --- a/src/Library/Console/OkpKeyGeneratorCommand.php +++ b/src/Library/Console/OkpKeyGeneratorCommand.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -15,16 +16,14 @@ #[AsCommand(name: 'key:generate:okp', description: 'Generate an Octet Key Pair key (JWK format)',)] final class OkpKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:okp'; - - protected static $defaultDescription = 'Generate an Octet Key Pair key (JWK format)'; - + #[Override] protected function configure(): void { parent::configure(); $this->addArgument('curve', InputArgument::REQUIRED, 'Curve of the key.'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $curve = $input->getArgument('curve'); diff --git a/src/Library/Console/OkpKeysetGeneratorCommand.php b/src/Library/Console/OkpKeysetGeneratorCommand.php index a98dfd382..78b578a28 100644 --- a/src/Library/Console/OkpKeysetGeneratorCommand.php +++ b/src/Library/Console/OkpKeysetGeneratorCommand.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Jose\Component\Core\JWKSet; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -19,10 +20,7 @@ )] final class OkpKeysetGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'keyset:generate:okp'; - - protected static $defaultDescription = 'Generate a key set with Octet Key Pairs keys (JWKSet format)'; - + #[Override] protected function configure(): void { parent::configure(); @@ -30,6 +28,7 @@ protected function configure(): void ->addArgument('curve', InputArgument::REQUIRED, 'Curve of the keys.'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $quantity = (int) $input->getArgument('quantity'); diff --git a/src/Library/Console/OptimizeRsaKeyCommand.php b/src/Library/Console/OptimizeRsaKeyCommand.php index 693bc41d2..d8a8a900e 100644 --- a/src/Library/Console/OptimizeRsaKeyCommand.php +++ b/src/Library/Console/OptimizeRsaKeyCommand.php @@ -8,6 +8,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\KeyManagement\KeyConverter\RSAKey; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -18,16 +19,14 @@ #[AsCommand(name: 'key:optimize', description: 'Optimize a RSA key by calculating additional primes (CRT).',)] final class OptimizeRsaKeyCommand extends ObjectOutputCommand { - protected static $defaultName = 'key:optimize'; - - protected static $defaultDescription = 'Optimize a RSA key by calculating additional primes (CRT).'; - + #[Override] protected function configure(): void { parent::configure(); $this->addArgument('jwk', InputArgument::REQUIRED, 'The RSA key.'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $jwk = $input->getArgument('jwk'); diff --git a/src/Library/Console/P12CertificateLoaderCommand.php b/src/Library/Console/P12CertificateLoaderCommand.php index 92cfccddb..ec6f14b69 100644 --- a/src/Library/Console/P12CertificateLoaderCommand.php +++ b/src/Library/Console/P12CertificateLoaderCommand.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -16,10 +17,7 @@ #[AsCommand(name: 'key:load:p12', description: 'Load a key from a P12 certificate file.',)] final class P12CertificateLoaderCommand extends GeneratorCommand { - protected static $defaultName = 'key:load:p12'; - - protected static $defaultDescription = 'Load a key from a P12 certificate file.'; - + #[Override] protected function configure(): void { parent::configure(); @@ -27,6 +25,7 @@ protected function configure(): void ->addOption('secret', 's', InputOption::VALUE_OPTIONAL, 'Secret if the key is encrypted.', null); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $file = $input->getArgument('file'); diff --git a/src/Library/Console/PemConverterCommand.php b/src/Library/Console/PemConverterCommand.php index 1fcb957bd..daa2dbc04 100644 --- a/src/Library/Console/PemConverterCommand.php +++ b/src/Library/Console/PemConverterCommand.php @@ -9,6 +9,7 @@ use Jose\Component\Core\Util\ECKey; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\Core\Util\RSAKey; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -19,16 +20,14 @@ #[AsCommand(name: 'key:convert:pkcs1', description: 'Converts a RSA or EC key into PKCS#1 key.',)] final class PemConverterCommand extends ObjectOutputCommand { - protected static $defaultName = 'key:convert:pkcs1'; - - protected static $defaultDescription = 'Converts a RSA or EC key into PKCS#1 key.'; - + #[Override] protected function configure(): void { parent::configure(); $this->addArgument('jwk', InputArgument::REQUIRED, 'The key'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $jwk = $input->getArgument('jwk'); diff --git a/src/Library/Console/PublicKeyCommand.php b/src/Library/Console/PublicKeyCommand.php index 81bd93fb9..9f953aea6 100644 --- a/src/Library/Console/PublicKeyCommand.php +++ b/src/Library/Console/PublicKeyCommand.php @@ -7,6 +7,8 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; use Jose\Component\Core\Util\JsonConverter; +use Override; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -19,10 +21,7 @@ )] final class PublicKeyCommand extends ObjectOutputCommand { - protected static $defaultName = 'key:convert:public'; - - protected static $defaultDescription = 'Convert a private key into public key. Symmetric keys (shared keys) are not changed.'; - + #[Override] protected function configure(): void { parent::configure(); @@ -30,6 +29,7 @@ protected function configure(): void ->addArgument('jwk', InputArgument::REQUIRED, 'The JWK object'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $jwk = $this->getKey($input); diff --git a/src/Library/Console/PublicKeysetCommand.php b/src/Library/Console/PublicKeysetCommand.php index 474ebb0ac..b0a61c20d 100644 --- a/src/Library/Console/PublicKeysetCommand.php +++ b/src/Library/Console/PublicKeysetCommand.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Jose\Component\Core\JWKSet; use Jose\Component\Core\Util\JsonConverter; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -20,10 +21,7 @@ )] final class PublicKeysetCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:convert:public'; - - protected static $defaultDescription = 'Convert private keys in a key set into public keys. Symmetric keys (shared keys) are not changed.'; - + #[Override] protected function configure(): void { parent::configure(); @@ -31,6 +29,7 @@ protected function configure(): void ->addArgument('jwkset', InputArgument::REQUIRED, 'The JWKSet object'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $jwkset = $this->getKeyset($input); diff --git a/src/Library/Console/RotateKeysetCommand.php b/src/Library/Console/RotateKeysetCommand.php index d2451f6a8..b363eea7a 100644 --- a/src/Library/Console/RotateKeysetCommand.php +++ b/src/Library/Console/RotateKeysetCommand.php @@ -8,6 +8,7 @@ use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; use Jose\Component\Core\Util\JsonConverter; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -19,10 +20,7 @@ #[AsCommand(name: 'keyset:rotate', description: 'Rotate a key set.',)] final class RotateKeysetCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:rotate'; - - protected static $defaultDescription = 'Rotate a key set.'; - + #[Override] protected function configure(): void { parent::configure(); @@ -31,6 +29,7 @@ protected function configure(): void ->addArgument('jwk', InputArgument::REQUIRED, 'The new JWK object'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $jwkset = $this->getKeyset($input) diff --git a/src/Library/Console/RsaKeyGeneratorCommand.php b/src/Library/Console/RsaKeyGeneratorCommand.php index 409158c47..afa7fbef7 100644 --- a/src/Library/Console/RsaKeyGeneratorCommand.php +++ b/src/Library/Console/RsaKeyGeneratorCommand.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -14,16 +15,14 @@ #[AsCommand(name: 'key:generate:rsa', description: 'Generate a RSA key (JWK format)',)] final class RsaKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:rsa'; - - protected static $defaultDescription = 'Generate a RSA key (JWK format)'; - + #[Override] protected function configure(): void { parent::configure(); $this->addArgument('size', InputArgument::REQUIRED, 'Key size.'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $size = (int) $input->getArgument('size'); diff --git a/src/Library/Console/RsaKeysetGeneratorCommand.php b/src/Library/Console/RsaKeysetGeneratorCommand.php index adf309e0e..bb2383141 100644 --- a/src/Library/Console/RsaKeysetGeneratorCommand.php +++ b/src/Library/Console/RsaKeysetGeneratorCommand.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Jose\Component\Core\JWKSet; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -15,10 +16,7 @@ #[AsCommand(name: 'keyset:generate:rsa', description: 'Generate a key set with RSA keys (JWK format)',)] final class RsaKeysetGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'keyset:generate:rsa'; - - protected static $defaultDescription = 'Generate a key set with RSA keys (JWK format)'; - + #[Override] protected function configure(): void { parent::configure(); @@ -26,6 +24,7 @@ protected function configure(): void ->addArgument('size', InputArgument::REQUIRED, 'Key size.'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $quantity = (int) $input->getArgument('quantity'); diff --git a/src/Library/Console/SecretKeyGeneratorCommand.php b/src/Library/Console/SecretKeyGeneratorCommand.php index 9db7a74a4..79ce599af 100644 --- a/src/Library/Console/SecretKeyGeneratorCommand.php +++ b/src/Library/Console/SecretKeyGeneratorCommand.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -20,10 +21,7 @@ )] final class SecretKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:from_secret'; - - protected static $defaultDescription = 'Generate an octet key (JWK format) using an existing secret'; - + #[Override] protected function configure(): void { parent::configure(); @@ -36,6 +34,7 @@ protected function configure(): void ); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $secret = $input->getArgument('secret'); diff --git a/src/Library/Console/X509CertificateLoaderCommand.php b/src/Library/Console/X509CertificateLoaderCommand.php index d26e2d2ff..7e8f7a65d 100644 --- a/src/Library/Console/X509CertificateLoaderCommand.php +++ b/src/Library/Console/X509CertificateLoaderCommand.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JWKFactory; +use Override; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -15,16 +16,14 @@ #[AsCommand(name: 'key:load:x509', description: 'Load a key from a X.509 certificate file.',)] final class X509CertificateLoaderCommand extends GeneratorCommand { - protected static $defaultName = 'key:load:x509'; - - protected static $defaultDescription = 'Load a key from a X.509 certificate file.'; - + #[Override] protected function configure(): void { parent::configure(); $this->addArgument('file', InputArgument::REQUIRED, 'Filename of the X.509 certificate.'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $file = $input->getArgument('file'); diff --git a/src/Library/Console/X5ULoaderCommand.php b/src/Library/Console/X5ULoaderCommand.php index 2592c5ba2..7d613a641 100644 --- a/src/Library/Console/X5ULoaderCommand.php +++ b/src/Library/Console/X5ULoaderCommand.php @@ -6,6 +6,8 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\X5UFactory; +use Override; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -14,10 +16,6 @@ #[AsCommand(name: 'keyset:load:x5u', description: 'Loads a key set from an url.',)] final class X5ULoaderCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:load:x5u'; - - protected static $defaultDescription = 'Loads a key set from an url.'; - public function __construct( private readonly X5UFactory $x5uFactory, ?string $name = null @@ -25,6 +23,7 @@ public function __construct( parent::__construct($name); } + #[Override] protected function configure(): void { parent::configure(); @@ -34,6 +33,7 @@ protected function configure(): void ->addArgument('url', InputArgument::REQUIRED, 'The URL'); } + #[Override] protected function execute(InputInterface $input, OutputInterface $output): int { $url = $input->getArgument('url'); diff --git a/src/Library/Core/AlgorithmManager.php b/src/Library/Core/AlgorithmManager.php index 147921b5e..65d006143 100644 --- a/src/Library/Core/AlgorithmManager.php +++ b/src/Library/Core/AlgorithmManager.php @@ -7,7 +7,7 @@ use InvalidArgumentException; use function array_key_exists; -class AlgorithmManager +final class AlgorithmManager { /** * @var array diff --git a/src/Library/Core/AlgorithmManagerFactory.php b/src/Library/Core/AlgorithmManagerFactory.php index 3854e668f..df9a0cad1 100644 --- a/src/Library/Core/AlgorithmManagerFactory.php +++ b/src/Library/Core/AlgorithmManagerFactory.php @@ -10,7 +10,7 @@ /** * @see \Jose\Tests\Component\Core\AlgorithmManagerFactoryTest */ -class AlgorithmManagerFactory +final class AlgorithmManagerFactory { private array $algorithms = []; diff --git a/src/Library/Core/JWK.php b/src/Library/Core/JWK.php index 9685becf5..42a863811 100644 --- a/src/Library/Core/JWK.php +++ b/src/Library/Core/JWK.php @@ -5,8 +5,9 @@ namespace Jose\Component\Core; use InvalidArgumentException; +use Jose\Component\Core\Util\Base64UrlSafe; use JsonSerializable; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use function array_key_exists; use function in_array; use function is_array; @@ -48,6 +49,7 @@ public static function createFromJson(string $json): self /** * Returns the values to be serialized. */ + #[Override] public function jsonSerialize(): array { return $this->values; diff --git a/src/Library/Core/Util/Base64UrlSafe.php b/src/Library/Core/Util/Base64UrlSafe.php new file mode 100644 index 000000000..c3f44d652 --- /dev/null +++ b/src/Library/Core/Util/Base64UrlSafe.php @@ -0,0 +1,215 @@ + $chunk */ + $chunk = unpack('C*', self::safeSubstr($encodedString, $i, 4)); + $c0 = static::decode6Bits($chunk[1]); + $c1 = static::decode6Bits($chunk[2]); + $c2 = static::decode6Bits($chunk[3]); + $c3 = static::decode6Bits($chunk[4]); + + $dest .= pack( + 'CCC', + ((($c0 << 2) | ($c1 >> 4)) & 0xff), + ((($c1 << 4) | ($c2 >> 2)) & 0xff), + ((($c2 << 6) | $c3) & 0xff) + ); + $err |= ($c0 | $c1 | $c2 | $c3) >> 8; + } + + if ($i < $srcLen) { + /** @var array $chunk */ + $chunk = unpack('C*', self::safeSubstr($encodedString, $i, $srcLen - $i)); + $c0 = static::decode6Bits($chunk[1]); + + if ($i + 2 < $srcLen) { + $c1 = static::decode6Bits($chunk[2]); + $c2 = static::decode6Bits($chunk[3]); + $dest .= pack('CC', ((($c0 << 2) | ($c1 >> 4)) & 0xff), ((($c1 << 4) | ($c2 >> 2)) & 0xff)); + $err |= ($c0 | $c1 | $c2) >> 8; + if ($strictPadding) { + $err |= ($c2 << 6) & 0xff; + } + } elseif ($i + 1 < $srcLen) { + $c1 = static::decode6Bits($chunk[2]); + $dest .= pack('C', ((($c0 << 2) | ($c1 >> 4)) & 0xff)); + $err |= ($c0 | $c1) >> 8; + if ($strictPadding) { + $err |= ($c1 << 4) & 0xff; + } + } elseif ($strictPadding) { + $err |= 1; + } + } + $check = ($err === 0); + if (! $check) { + throw new RangeException('Base64::decode() only expects characters in the correct base64 alphabet'); + } + return $dest; + } + + public static function decodeNoPadding(string $encodedString): string + { + $srcLen = self::safeStrlen($encodedString); + if ($srcLen === 0) { + return ''; + } + if (($srcLen & 3) === 0) { + if ($encodedString[$srcLen - 1] === '=') { + throw new InvalidArgumentException("decodeNoPadding() doesn't tolerate padding"); + } + if (($srcLen & 3) > 1) { + if ($encodedString[$srcLen - 2] === '=') { + throw new InvalidArgumentException("decodeNoPadding() doesn't tolerate padding"); + } + } + } + return static::decode($encodedString, true); + } + + private static function doEncode(string $src, bool $pad = true): string + { + $dest = ''; + $srcLen = self::safeStrlen($src); + for ($i = 0; $i + 3 <= $srcLen; $i += 3) { + /** @var array $chunk */ + $chunk = unpack('C*', self::safeSubstr($src, $i, 3)); + $b0 = $chunk[1]; + $b1 = $chunk[2]; + $b2 = $chunk[3]; + + $dest .= + static::encode6Bits($b0 >> 2) . + static::encode6Bits((($b0 << 4) | ($b1 >> 4)) & 63) . + static::encode6Bits((($b1 << 2) | ($b2 >> 6)) & 63) . + static::encode6Bits($b2 & 63); + } + + if ($i < $srcLen) { + /** @var array $chunk */ + $chunk = unpack('C*', self::safeSubstr($src, $i, $srcLen - $i)); + $b0 = $chunk[1]; + if ($i + 1 < $srcLen) { + $b1 = $chunk[2]; + $dest .= + static::encode6Bits($b0 >> 2) . + static::encode6Bits((($b0 << 4) | ($b1 >> 4)) & 63) . + static::encode6Bits(($b1 << 2) & 63); + if ($pad) { + $dest .= '='; + } + } else { + $dest .= + static::encode6Bits($b0 >> 2) . + static::encode6Bits(($b0 << 4) & 63); + if ($pad) { + $dest .= '=='; + } + } + } + return $dest; + } + + private static function decode6Bits(int $src): int + { + $ret = -1; + $ret += (((0x40 - $src) & ($src - 0x5b)) >> 8) & ($src - 64); + $ret += (((0x60 - $src) & ($src - 0x7b)) >> 8) & ($src - 70); + $ret += (((0x2f - $src) & ($src - 0x3a)) >> 8) & ($src + 5); + $ret += (((0x2c - $src) & ($src - 0x2e)) >> 8) & 63; + + return $ret + ((((0x5e - $src) & ($src - 0x60)) >> 8) & 64); + } + + private static function encode6Bits(int $src): string + { + $diff = 0x41; + $diff += ((25 - $src) >> 8) & 6; + $diff -= ((51 - $src) >> 8) & 75; + $diff -= ((61 - $src) >> 8) & 13; + $diff += ((62 - $src) >> 8) & 49; + + return pack('C', $src + $diff); + } + + private static function safeStrlen(string $str): int + { + return mb_strlen($str, '8bit'); + } + + private static function safeSubstr(string $str, int $start = 0, $length = null): string + { + if ($length === 0) { + return ''; + } + return mb_substr($str, $start, $length, '8bit'); + } +} diff --git a/src/Library/Core/Util/BigInteger.php b/src/Library/Core/Util/BigInteger.php index 5bbea7c2a..3735155e6 100644 --- a/src/Library/Core/Util/BigInteger.php +++ b/src/Library/Core/Util/BigInteger.php @@ -11,10 +11,10 @@ /** * @internal */ -final class BigInteger +final readonly class BigInteger { private function __construct( - private readonly BrickBigInteger $value + private BrickBigInteger $value ) { } diff --git a/src/Library/Core/Util/ECKey.php b/src/Library/Core/Util/ECKey.php index 9bd92186b..8f50b48ef 100644 --- a/src/Library/Core/Util/ECKey.php +++ b/src/Library/Core/Util/ECKey.php @@ -6,7 +6,6 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; use RuntimeException; use function extension_loaded; use function is_array; @@ -18,7 +17,7 @@ /** * @internal */ -final class ECKey +final readonly class ECKey { public static function convertToPEM(JWK $jwk): string { diff --git a/src/Library/Core/Util/ECSignature.php b/src/Library/Core/Util/ECSignature.php index 689150914..29dc907d9 100644 --- a/src/Library/Core/Util/ECSignature.php +++ b/src/Library/Core/Util/ECSignature.php @@ -11,21 +11,21 @@ /** * @internal */ -final class ECSignature +final readonly class ECSignature { - private const ASN1_SEQUENCE = '30'; + private const string ASN1_SEQUENCE = '30'; - private const ASN1_INTEGER = '02'; + private const string ASN1_INTEGER = '02'; - private const ASN1_MAX_SINGLE_BYTE = 128; + private const int ASN1_MAX_SINGLE_BYTE = 128; - private const ASN1_LENGTH_2BYTES = '81'; + private const string ASN1_LENGTH_2BYTES = '81'; - private const ASN1_BIG_INTEGER_LIMIT = '7f'; + private const string ASN1_BIG_INTEGER_LIMIT = '7f'; - private const ASN1_NEGATIVE_INTEGER = '00'; + private const string ASN1_NEGATIVE_INTEGER = '00'; - private const BYTE_SIZE = 2; + private const int BYTE_SIZE = 2; public static function toAsn1(string $signature, int $length): string { diff --git a/src/Library/Core/Util/Ecc/Curve.php b/src/Library/Core/Util/Ecc/Curve.php index b8b53a524..2674d7dad 100644 --- a/src/Library/Core/Util/Ecc/Curve.php +++ b/src/Library/Core/Util/Ecc/Curve.php @@ -5,6 +5,7 @@ namespace Jose\Component\Core\Util\Ecc; use Brick\Math\BigInteger; +use Override; use RuntimeException; use Stringable; use const STR_PAD_LEFT; @@ -12,17 +13,18 @@ /** * @internal */ -final class Curve implements Stringable +final readonly class Curve implements Stringable { public function __construct( - private readonly int $size, - private readonly BigInteger $prime, - private readonly BigInteger $a, - private readonly BigInteger $b, - private readonly Point $generator + private int $size, + private BigInteger $prime, + private BigInteger $a, + private BigInteger $b, + private Point $generator ) { } + #[Override] public function __toString(): string { return 'curve(' . Math::toString($this->getA()) . ', ' . Math::toString($this->getB()) . ', ' . Math::toString( diff --git a/src/Library/Core/Util/Ecc/EcDH.php b/src/Library/Core/Util/Ecc/EcDH.php index c44d803f7..63f7b5954 100644 --- a/src/Library/Core/Util/Ecc/EcDH.php +++ b/src/Library/Core/Util/Ecc/EcDH.php @@ -33,7 +33,7 @@ /** * @internal */ -final class EcDH +final readonly class EcDH { public static function computeSharedKey(Curve $curve, PublicKey $publicKey, PrivateKey $privateKey): BigInteger { diff --git a/src/Library/Core/Util/Ecc/Math.php b/src/Library/Core/Util/Ecc/Math.php index 645bba54c..ec4b56838 100644 --- a/src/Library/Core/Util/Ecc/Math.php +++ b/src/Library/Core/Util/Ecc/Math.php @@ -10,7 +10,7 @@ /** * @internal */ -final class Math +final readonly class Math { public static function equals(BigInteger $first, BigInteger $other): bool { diff --git a/src/Library/Core/Util/Ecc/ModularArithmetic.php b/src/Library/Core/Util/Ecc/ModularArithmetic.php index 3d801ff83..06992139c 100644 --- a/src/Library/Core/Util/Ecc/ModularArithmetic.php +++ b/src/Library/Core/Util/Ecc/ModularArithmetic.php @@ -9,7 +9,7 @@ /** * @internal */ -final class ModularArithmetic +final readonly class ModularArithmetic { public static function sub(BigInteger $minuend, BigInteger $subtrahend, BigInteger $modulus): BigInteger { diff --git a/src/Library/Core/Util/Ecc/NistCurve.php b/src/Library/Core/Util/Ecc/NistCurve.php index 190fbcff9..8df1b32fd 100644 --- a/src/Library/Core/Util/Ecc/NistCurve.php +++ b/src/Library/Core/Util/Ecc/NistCurve.php @@ -26,7 +26,7 @@ /** * @internal */ -final class NistCurve +final readonly class NistCurve { /** * Returns an NIST P-256 curve. diff --git a/src/Library/Core/Util/Ecc/Point.php b/src/Library/Core/Util/Ecc/Point.php index e88127400..a5bdd05e7 100644 --- a/src/Library/Core/Util/Ecc/Point.php +++ b/src/Library/Core/Util/Ecc/Point.php @@ -27,7 +27,7 @@ /** * @internal */ -final class Point +final readonly class Point { private function __construct( private BigInteger $x, diff --git a/src/Library/Core/Util/Ecc/PrivateKey.php b/src/Library/Core/Util/Ecc/PrivateKey.php index 1f73ef229..341068ed4 100644 --- a/src/Library/Core/Util/Ecc/PrivateKey.php +++ b/src/Library/Core/Util/Ecc/PrivateKey.php @@ -26,10 +26,10 @@ /** * @internal */ -final class PrivateKey +final readonly class PrivateKey { private function __construct( - private readonly BigInteger $secret + private BigInteger $secret ) { } diff --git a/src/Library/Core/Util/Ecc/PublicKey.php b/src/Library/Core/Util/Ecc/PublicKey.php index 1f5507107..90d99af7d 100644 --- a/src/Library/Core/Util/Ecc/PublicKey.php +++ b/src/Library/Core/Util/Ecc/PublicKey.php @@ -24,10 +24,10 @@ /** * @internal */ -final class PublicKey +final readonly class PublicKey { public function __construct( - private readonly Point $point + private Point $point ) { } diff --git a/src/Library/Core/Util/Hash.php b/src/Library/Core/Util/Hash.php index cdc00032a..2641224e1 100644 --- a/src/Library/Core/Util/Hash.php +++ b/src/Library/Core/Util/Hash.php @@ -4,18 +4,34 @@ namespace Jose\Component\Core\Util; +use InvalidArgumentException; + /** * @internal */ -final class Hash +final readonly class Hash { + /** + * @param positive-int $length + */ private function __construct( - private readonly string $hash, - private readonly int $length, - private readonly string $t + private string $hash, + private int $length, + private string $t ) { } + public static function get(string $function): self + { + return match ($function) { + 'sha1' => self::sha1(), + 'sha256' => self::sha256(), + 'sha384' => self::sha384(), + 'sha512' => self::sha512(), + default => throw new InvalidArgumentException('Unsupported hash function'), + }; + } + public static function sha1(): self { return new self('sha1', 20, "\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14"); @@ -36,6 +52,9 @@ public static function sha512(): self return new self('sha512', 64, "\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40"); } + /** + * @return positive-int + */ public function getLength(): int { return $this->length; diff --git a/src/Library/Core/Util/JsonConverter.php b/src/Library/Core/Util/JsonConverter.php index d51c9777c..8f575cebc 100644 --- a/src/Library/Core/Util/JsonConverter.php +++ b/src/Library/Core/Util/JsonConverter.php @@ -10,7 +10,7 @@ use const JSON_UNESCAPED_SLASHES; use const JSON_UNESCAPED_UNICODE; -final class JsonConverter +final readonly class JsonConverter { public static function encode(mixed $payload): string { diff --git a/src/Library/Core/Util/KeyChecker.php b/src/Library/Core/Util/KeyChecker.php index 8e902e650..fbb50b379 100644 --- a/src/Library/Core/Util/KeyChecker.php +++ b/src/Library/Core/Util/KeyChecker.php @@ -13,7 +13,7 @@ /** * @internal */ -final class KeyChecker +final readonly class KeyChecker { public static function checkKeyUsage(JWK $key, string $usage): void { diff --git a/src/Library/Core/Util/RSAKey.php b/src/Library/Core/Util/RSAKey.php index 7b47d5cc5..39c45e1ad 100644 --- a/src/Library/Core/Util/RSAKey.php +++ b/src/Library/Core/Util/RSAKey.php @@ -6,7 +6,6 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; use RuntimeException; use SpomkyLabs\Pki\ASN1\Type\Constructed\Sequence; use SpomkyLabs\Pki\ASN1\Type\Primitive\BitString; @@ -31,11 +30,11 @@ final class RSAKey private BigInteger $modulus; - private int $modulus_length; + private int $modulusLength; - private BigInteger $public_exponent; + private BigInteger $publicExponent; - private ?BigInteger $private_exponent = null; + private ?BigInteger $privateExponent = null; /** * @var BigInteger[] @@ -67,7 +66,7 @@ public function getModulus(): BigInteger public function getModulusLength(): int { - return $this->modulus_length; + return $this->modulusLength; } public function getExponent(): BigInteger @@ -82,12 +81,12 @@ public function getExponent(): BigInteger public function getPublicExponent(): BigInteger { - return $this->public_exponent; + return $this->publicExponent; } public function getPrivateExponent(): ?BigInteger { - return $this->private_exponent; + return $this->privateExponent; } /** @@ -202,11 +201,11 @@ public static function exponentiate(self $key, BigInteger $c): BigInteger private function populateBigIntegers(): void { $this->modulus = $this->convertBase64StringToBigInteger($this->values['n']); - $this->modulus_length = mb_strlen($this->getModulus()->toBytes(), '8bit'); - $this->public_exponent = $this->convertBase64StringToBigInteger($this->values['e']); + $this->modulusLength = mb_strlen($this->getModulus()->toBytes(), '8bit'); + $this->publicExponent = $this->convertBase64StringToBigInteger($this->values['e']); if (! $this->isPublic()) { - $this->private_exponent = $this->convertBase64StringToBigInteger($this->values['d']); + $this->privateExponent = $this->convertBase64StringToBigInteger($this->values['d']); if (array_key_exists('p', $this->values) && array_key_exists('q', $this->values)) { $this->primes = [ diff --git a/src/Library/Encryption/Algorithm/ContentEncryption/A128CBCHS256.php b/src/Library/Encryption/Algorithm/ContentEncryption/A128CBCHS256.php index 0554a52b9..c602ffed9 100644 --- a/src/Library/Encryption/Algorithm/ContentEncryption/A128CBCHS256.php +++ b/src/Library/Encryption/Algorithm/ContentEncryption/A128CBCHS256.php @@ -4,23 +4,29 @@ namespace Jose\Component\Encryption\Algorithm\ContentEncryption; -final class A128CBCHS256 extends AESCBCHS +use Override; + +final readonly class A128CBCHS256 extends AESCBCHS { + #[Override] public function getCEKSize(): int { return 256; } + #[Override] public function name(): string { return 'A128CBC-HS256'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha256'; } + #[Override] protected function getMode(): string { return 'aes-128-cbc'; diff --git a/src/Library/Encryption/Algorithm/ContentEncryption/A128GCM.php b/src/Library/Encryption/Algorithm/ContentEncryption/A128GCM.php index 03f3b990f..82c285182 100644 --- a/src/Library/Encryption/Algorithm/ContentEncryption/A128GCM.php +++ b/src/Library/Encryption/Algorithm/ContentEncryption/A128GCM.php @@ -4,18 +4,23 @@ namespace Jose\Component\Encryption\Algorithm\ContentEncryption; -final class A128GCM extends AESGCM +use Override; + +final readonly class A128GCM extends AESGCM { + #[Override] public function getCEKSize(): int { return 128; } + #[Override] public function name(): string { return 'A128GCM'; } + #[Override] protected function getMode(): string { return 'aes-128-gcm'; diff --git a/src/Library/Encryption/Algorithm/ContentEncryption/A192CBCHS384.php b/src/Library/Encryption/Algorithm/ContentEncryption/A192CBCHS384.php index c45e1694c..1019483be 100644 --- a/src/Library/Encryption/Algorithm/ContentEncryption/A192CBCHS384.php +++ b/src/Library/Encryption/Algorithm/ContentEncryption/A192CBCHS384.php @@ -4,23 +4,29 @@ namespace Jose\Component\Encryption\Algorithm\ContentEncryption; -final class A192CBCHS384 extends AESCBCHS +use Override; + +final readonly class A192CBCHS384 extends AESCBCHS { + #[Override] public function getCEKSize(): int { return 384; } + #[Override] public function name(): string { return 'A192CBC-HS384'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha384'; } + #[Override] protected function getMode(): string { return 'aes-192-cbc'; diff --git a/src/Library/Encryption/Algorithm/ContentEncryption/A192GCM.php b/src/Library/Encryption/Algorithm/ContentEncryption/A192GCM.php index 74ba68e15..a0facafe6 100644 --- a/src/Library/Encryption/Algorithm/ContentEncryption/A192GCM.php +++ b/src/Library/Encryption/Algorithm/ContentEncryption/A192GCM.php @@ -4,18 +4,23 @@ namespace Jose\Component\Encryption\Algorithm\ContentEncryption; -final class A192GCM extends AESGCM +use Override; + +final readonly class A192GCM extends AESGCM { + #[Override] public function getCEKSize(): int { return 192; } + #[Override] public function name(): string { return 'A192GCM'; } + #[Override] protected function getMode(): string { return 'aes-192-gcm'; diff --git a/src/Library/Encryption/Algorithm/ContentEncryption/A256CBCHS512.php b/src/Library/Encryption/Algorithm/ContentEncryption/A256CBCHS512.php index 1eb0541d1..b298fa721 100644 --- a/src/Library/Encryption/Algorithm/ContentEncryption/A256CBCHS512.php +++ b/src/Library/Encryption/Algorithm/ContentEncryption/A256CBCHS512.php @@ -4,23 +4,29 @@ namespace Jose\Component\Encryption\Algorithm\ContentEncryption; -final class A256CBCHS512 extends AESCBCHS +use Override; + +final readonly class A256CBCHS512 extends AESCBCHS { + #[Override] public function getCEKSize(): int { return 512; } + #[Override] public function name(): string { return 'A256CBC-HS512'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha512'; } + #[Override] protected function getMode(): string { return 'aes-256-cbc'; diff --git a/src/Library/Encryption/Algorithm/ContentEncryption/A256GCM.php b/src/Library/Encryption/Algorithm/ContentEncryption/A256GCM.php index 6c9e9d238..937cbbf74 100644 --- a/src/Library/Encryption/Algorithm/ContentEncryption/A256GCM.php +++ b/src/Library/Encryption/Algorithm/ContentEncryption/A256GCM.php @@ -4,18 +4,23 @@ namespace Jose\Component\Encryption\Algorithm\ContentEncryption; -final class A256GCM extends AESGCM +use Override; + +final readonly class A256GCM extends AESGCM { + #[Override] public function getCEKSize(): int { return 256; } + #[Override] public function name(): string { return 'A256GCM'; } + #[Override] protected function getMode(): string { return 'aes-256-gcm'; diff --git a/src/Library/Encryption/Algorithm/ContentEncryption/AESCBCHS.php b/src/Library/Encryption/Algorithm/ContentEncryption/AESCBCHS.php index 8395db17e..82458ccc9 100644 --- a/src/Library/Encryption/Algorithm/ContentEncryption/AESCBCHS.php +++ b/src/Library/Encryption/Algorithm/ContentEncryption/AESCBCHS.php @@ -4,13 +4,14 @@ namespace Jose\Component\Encryption\Algorithm\ContentEncryption; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\ContentEncryptionAlgorithm; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use RuntimeException; use function extension_loaded; use const OPENSSL_RAW_DATA; -abstract class AESCBCHS implements ContentEncryptionAlgorithm +abstract readonly class AESCBCHS implements ContentEncryptionAlgorithm { public function __construct() { @@ -19,11 +20,13 @@ public function __construct() } } + #[Override] public function allowedKeyTypes(): array { return []; //Irrelevant } + #[Override] public function encryptContent( string $data, string $cek, @@ -43,6 +46,7 @@ public function encryptContent( return $result; } + #[Override] public function decryptContent( string $data, string $cek, @@ -64,6 +68,7 @@ public function decryptContent( return $result; } + #[Override] public function getIVSize(): int { return 128; diff --git a/src/Library/Encryption/Algorithm/ContentEncryption/AESGCM.php b/src/Library/Encryption/Algorithm/ContentEncryption/AESGCM.php index c939df464..e1a3ecde1 100644 --- a/src/Library/Encryption/Algorithm/ContentEncryption/AESGCM.php +++ b/src/Library/Encryption/Algorithm/ContentEncryption/AESGCM.php @@ -4,13 +4,14 @@ namespace Jose\Component\Encryption\Algorithm\ContentEncryption; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\ContentEncryptionAlgorithm; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use RuntimeException; use function extension_loaded; use const OPENSSL_RAW_DATA; -abstract class AESGCM implements ContentEncryptionAlgorithm +abstract readonly class AESGCM implements ContentEncryptionAlgorithm { public function __construct() { @@ -19,11 +20,13 @@ public function __construct() } } + #[Override] public function allowedKeyTypes(): array { return []; //Irrelevant } + #[Override] public function encryptContent( string $data, string $cek, @@ -45,6 +48,7 @@ public function encryptContent( return $result; } + #[Override] public function decryptContent( string $data, string $cek, @@ -66,6 +70,7 @@ public function decryptContent( return $result; } + #[Override] public function getIVSize(): int { return 96; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/A128GCMKW.php b/src/Library/Encryption/Algorithm/KeyEncryption/A128GCMKW.php index a21630829..229c4ef22 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/A128GCMKW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/A128GCMKW.php @@ -4,13 +4,17 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; -final class A128GCMKW extends AESGCMKW +use Override; + +final readonly class A128GCMKW extends AESGCMKW { + #[Override] public function name(): string { return 'A128GCMKW'; } + #[Override] protected function getKeySize(): int { return 128; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/A128KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/A128KW.php index 635b9aca3..3c71dd64e 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/A128KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/A128KW.php @@ -6,14 +6,17 @@ use AESKW\A128KW as Wrapper; use AESKW\Wrapper as WrapperInterface; +use Override; -final class A128KW extends AESKW +final readonly class A128KW extends AESKW { + #[Override] public function name(): string { return 'A128KW'; } + #[Override] protected function getWrapper(): WrapperInterface { return new Wrapper(); diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/A192GCMKW.php b/src/Library/Encryption/Algorithm/KeyEncryption/A192GCMKW.php index 5f54d3fbb..67e5b3592 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/A192GCMKW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/A192GCMKW.php @@ -4,13 +4,17 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; -final class A192GCMKW extends AESGCMKW +use Override; + +final readonly class A192GCMKW extends AESGCMKW { + #[Override] public function name(): string { return 'A192GCMKW'; } + #[Override] protected function getKeySize(): int { return 192; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/A192KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/A192KW.php index 8960ca40a..02b6181cc 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/A192KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/A192KW.php @@ -6,14 +6,17 @@ use AESKW\A192KW as Wrapper; use AESKW\Wrapper as WrapperInterface; +use Override; -final class A192KW extends AESKW +final readonly class A192KW extends AESKW { + #[Override] public function name(): string { return 'A192KW'; } + #[Override] protected function getWrapper(): WrapperInterface { return new Wrapper(); diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/A256GCMKW.php b/src/Library/Encryption/Algorithm/KeyEncryption/A256GCMKW.php index a93caa4f3..d54661a5f 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/A256GCMKW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/A256GCMKW.php @@ -4,13 +4,17 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; -final class A256GCMKW extends AESGCMKW +use Override; + +final readonly class A256GCMKW extends AESGCMKW { + #[Override] public function name(): string { return 'A256GCMKW'; } + #[Override] protected function getKeySize(): int { return 256; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/A256KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/A256KW.php index 52cbf2049..c03227575 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/A256KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/A256KW.php @@ -6,14 +6,17 @@ use AESKW\A256KW as Wrapper; use AESKW\Wrapper as WrapperInterface; +use Override; -final class A256KW extends AESKW +final readonly class A256KW extends AESKW { + #[Override] public function name(): string { return 'A256KW'; } + #[Override] protected function getWrapper(): WrapperInterface { return new Wrapper(); diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/AESGCMKW.php b/src/Library/Encryption/Algorithm/KeyEncryption/AESGCMKW.php index 82db172ca..b46fd1999 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/AESGCMKW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/AESGCMKW.php @@ -7,14 +7,15 @@ use AESKW\Wrapper as WrapperInterface; use InvalidArgumentException; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; +use Override; use RuntimeException; use function extension_loaded; use function in_array; use function is_string; use const OPENSSL_RAW_DATA; -abstract class AESGCMKW implements KeyWrapping +abstract readonly class AESGCMKW implements KeyWrapping { public function __construct() { @@ -26,6 +27,7 @@ public function __construct() } } + #[Override] public function allowedKeyTypes(): array { return ['oct']; @@ -35,6 +37,7 @@ public function allowedKeyTypes(): array * @param array $completeHeader * @param array $additionalHeader */ + #[Override] public function wrapKey(JWK $key, string $cek, array $completeHeader, array &$additionalHeader): string { $kek = $this->getKey($key); @@ -55,6 +58,7 @@ public function wrapKey(JWK $key, string $cek, array $completeHeader, array &$ad /** * @param array $completeHeader */ + #[Override] public function unwrapKey(JWK $key, string $encrypted_cek, array $completeHeader): string { $kek = $this->getKey($key); @@ -77,6 +81,7 @@ public function unwrapKey(JWK $key, string $encrypted_cek, array $completeHeader return $cek; } + #[Override] public function getKeyManagementMode(): string { return self::MODE_WRAP; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/AESKW.php b/src/Library/Encryption/Algorithm/KeyEncryption/AESKW.php index 909f2a1e1..a6c3aa12b 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/AESKW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/AESKW.php @@ -7,12 +7,13 @@ use AESKW\Wrapper as WrapperInterface; use InvalidArgumentException; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; +use Override; use RuntimeException; use function in_array; use function is_string; -abstract class AESKW implements KeyWrapping +abstract readonly class AESKW implements KeyWrapping { public function __construct() { @@ -21,6 +22,7 @@ public function __construct() } } + #[Override] public function allowedKeyTypes(): array { return ['oct']; @@ -30,6 +32,7 @@ public function allowedKeyTypes(): array * @param array $completeHeader * @param array $additionalHeader */ + #[Override] public function wrapKey(JWK $key, string $cek, array $completeHeader, array &$additionalHeader): string { $k = $this->getKey($key); @@ -41,6 +44,7 @@ public function wrapKey(JWK $key, string $cek, array $completeHeader, array &$ad /** * @param array $completeHeader */ + #[Override] public function unwrapKey(JWK $key, string $encrypted_cek, array $completeHeader): string { $k = $this->getKey($key); @@ -49,6 +53,7 @@ public function unwrapKey(JWK $key, string $encrypted_cek, array $completeHeader return $wrapper::unwrap($k, $encrypted_cek); } + #[Override] public function getKeyManagementMode(): string { return self::MODE_WRAP; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php b/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php index 9027a8e74..b705b3624 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php @@ -7,13 +7,14 @@ use Brick\Math\BigInteger; use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\Ecc\Curve; use Jose\Component\Core\Util\Ecc\EcDH; use Jose\Component\Core\Util\Ecc\NistCurve; use Jose\Component\Core\Util\Ecc\PrivateKey; use Jose\Component\Core\Util\ECKey; use Jose\Component\Encryption\Algorithm\KeyEncryption\Util\ConcatKDF; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use RuntimeException; use Throwable; use function array_key_exists; @@ -23,8 +24,9 @@ use function is_array; use function is_string; -abstract class AbstractECDH implements KeyAgreement +abstract readonly class AbstractECDH implements KeyAgreement { + #[Override] public function allowedKeyTypes(): array { return ['EC', 'OKP']; @@ -34,6 +36,7 @@ public function allowedKeyTypes(): array * @param array $complete_header * @param array $additional_header_values */ + #[Override] public function getAgreementKey( int $encryptionKeyLength, string $algorithm, @@ -62,6 +65,7 @@ public function getAgreementKey( return ConcatKDF::generate($agreed_key, $algorithm, $encryptionKeyLength, $apu, $apv); } + #[Override] public function getKeyManagementMode(): string { return self::MODE_AGREEMENT; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDHAESKW.php b/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDHAESKW.php index 4aa6f0f7d..396c2bb82 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDHAESKW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDHAESKW.php @@ -5,9 +5,10 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use AESKW\Wrapper as WrapperInterface; +use Override; use RuntimeException; -abstract class AbstractECDHAESKW implements KeyAgreementWithKeyWrapping +abstract readonly class AbstractECDHAESKW implements KeyAgreementWithKeyWrapping { public function __construct() { @@ -16,11 +17,13 @@ public function __construct() } } + #[Override] public function allowedKeyTypes(): array { return ['EC', 'OKP']; } + #[Override] public function getKeyManagementMode(): string { return self::MODE_WRAP; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/Dir.php b/src/Library/Encryption/Algorithm/KeyEncryption/Dir.php index d01ec4921..86b5ec4ce 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/Dir.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/Dir.php @@ -6,12 +6,14 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; +use Override; use function in_array; use function is_string; -final class Dir implements DirectEncryption +final readonly class Dir implements DirectEncryption { + #[Override] public function getCEK(JWK $key): string { if (! in_array($key->get('kty'), $this->allowedKeyTypes(), true)) { @@ -28,16 +30,19 @@ public function getCEK(JWK $key): string return Base64UrlSafe::decodeNoPadding($k); } + #[Override] public function name(): string { return 'dir'; } + #[Override] public function allowedKeyTypes(): array { return ['oct']; } + #[Override] public function getKeyManagementMode(): string { return self::MODE_DIRECT; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHES.php b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHES.php index f83a300c0..e83071d58 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHES.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHES.php @@ -4,8 +4,11 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; -final class ECDHES extends AbstractECDH +use Override; + +final readonly class ECDHES extends AbstractECDH { + #[Override] public function name(): string { return 'ECDH-ES'; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA128KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA128KW.php index 8fbacc110..345182591 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA128KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA128KW.php @@ -5,19 +5,23 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use AESKW\A128KW as Wrapper; +use Override; -final class ECDHESA128KW extends ECDHESAESKW +final readonly class ECDHESA128KW extends ECDHESAESKW { + #[Override] public function name(): string { return 'ECDH-ES+A128KW'; } + #[Override] protected function getWrapper(): Wrapper { return new Wrapper(); } + #[Override] protected function getKeyLength(): int { return 128; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA192KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA192KW.php index 948c38391..78b7c04ac 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA192KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA192KW.php @@ -5,19 +5,23 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use AESKW\A192KW as Wrapper; +use Override; -final class ECDHESA192KW extends ECDHESAESKW +final readonly class ECDHESA192KW extends ECDHESAESKW { + #[Override] public function name(): string { return 'ECDH-ES+A192KW'; } + #[Override] protected function getWrapper(): Wrapper { return new Wrapper(); } + #[Override] protected function getKeyLength(): int { return 192; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA256KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA256KW.php index 367cf4489..b127128a4 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA256KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESA256KW.php @@ -5,19 +5,23 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use AESKW\A256KW as Wrapper; +use Override; -final class ECDHESA256KW extends ECDHESAESKW +final readonly class ECDHESA256KW extends ECDHESAESKW { + #[Override] public function name(): string { return 'ECDH-ES+A256KW'; } + #[Override] protected function getWrapper(): Wrapper { return new Wrapper(); } + #[Override] protected function getKeyLength(): int { return 256; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESAESKW.php b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESAESKW.php index 1a40ca295..c082f682c 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESAESKW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHESAESKW.php @@ -5,13 +5,15 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use Jose\Component\Core\JWK; +use Override; -abstract class ECDHESAESKW extends AbstractECDHAESKW +abstract readonly class ECDHESAESKW extends AbstractECDHAESKW { /** * @param array $complete_header * @param array $additional_header_values */ + #[Override] public function wrapAgreementKey( JWK $recipientKey, ?JWK $senderKey, @@ -37,6 +39,7 @@ public function wrapAgreementKey( /** * @param array $complete_header */ + #[Override] public function unwrapAgreementKey( JWK $recipientKey, ?JWK $senderKey, diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSS.php b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSS.php index 50b832a81..8dcfc412e 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSS.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSS.php @@ -6,9 +6,11 @@ use Jose\Component\Core\JWK; use LogicException; +use Override; -final class ECDHSS extends AbstractECDH +final readonly class ECDHSS extends AbstractECDH { + #[Override] public function name(): string { return 'ECDH-SS'; @@ -18,6 +20,7 @@ public function name(): string * @param array $complete_header * @param array $additional_header_values */ + #[Override] public function getAgreementKey( int $encryptionKeyLength, string $algorithm, diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA128KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA128KW.php index 1d5f2eb9e..4f6270e09 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA128KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA128KW.php @@ -5,19 +5,23 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use AESKW\A128KW as Wrapper; +use Override; -final class ECDHSSA128KW extends ECDHSSAESKW +final readonly class ECDHSSA128KW extends ECDHSSAESKW { + #[Override] public function name(): string { return 'ECDH-SS+A128KW'; } + #[Override] protected function getWrapper(): Wrapper { return new Wrapper(); } + #[Override] protected function getKeyLength(): int { return 128; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA192KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA192KW.php index 4adb17ab3..c2f6416b7 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA192KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA192KW.php @@ -5,19 +5,23 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use AESKW\A192KW as Wrapper; +use Override; -final class ECDHSSA192KW extends ECDHSSAESKW +final readonly class ECDHSSA192KW extends ECDHSSAESKW { + #[Override] public function name(): string { return 'ECDH-SS+A192KW'; } + #[Override] protected function getWrapper(): Wrapper { return new Wrapper(); } + #[Override] protected function getKeyLength(): int { return 192; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA256KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA256KW.php index 3be555d3a..262b72574 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA256KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSA256KW.php @@ -5,22 +5,26 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use AESKW\A256KW as Wrapper; +use Override; -final class ECDHSSA256KW extends ECDHSSAESKW +final readonly class ECDHSSA256KW extends ECDHSSAESKW { /** * NOTE: the return name was modified */ + #[Override] public function name(): string { return 'ECDH-SS+A256KW'; } + #[Override] protected function getWrapper(): Wrapper { return new Wrapper(); } + #[Override] protected function getKeyLength(): int { return 256; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSAESKW.php b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSAESKW.php index 2cdb56176..45b4469a4 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSAESKW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/ECDHSSAESKW.php @@ -5,13 +5,15 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use Jose\Component\Core\JWK; +use Override; -abstract class ECDHSSAESKW extends AbstractECDHAESKW +abstract readonly class ECDHSSAESKW extends AbstractECDHAESKW { /** * @param array $complete_header * @param array $additional_header_values */ + #[Override] public function wrapAgreementKey( JWK $recipientKey, ?JWK $senderKey, @@ -37,6 +39,7 @@ public function wrapAgreementKey( /** * @param array $complete_header */ + #[Override] public function unwrapAgreementKey( JWK $recipientKey, ?JWK $senderKey, diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/PBES2AESKW.php b/src/Library/Encryption/Algorithm/KeyEncryption/PBES2AESKW.php index a8222fc65..eb9c0ad32 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/PBES2AESKW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/PBES2AESKW.php @@ -10,13 +10,14 @@ use AESKW\Wrapper as WrapperInterface; use InvalidArgumentException; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; +use Override; use RuntimeException; use function in_array; use function is_int; use function is_string; -abstract class PBES2AESKW implements KeyWrapping +abstract readonly class PBES2AESKW implements KeyWrapping { public function __construct( private readonly int $salt_size = 64, @@ -27,6 +28,7 @@ public function __construct( } } + #[Override] public function allowedKeyTypes(): array { return ['oct']; @@ -36,6 +38,7 @@ public function allowedKeyTypes(): array * @param array $completeHeader * @param array $additionalHeader */ + #[Override] public function wrapKey(JWK $key, string $cek, array $completeHeader, array &$additionalHeader): string { $password = $this->getKey($key); @@ -64,6 +67,7 @@ public function wrapKey(JWK $key, string $cek, array $completeHeader, array &$ad /** * @param array $completeHeader */ + #[Override] public function unwrapKey(JWK $key, string $encrypted_cek, array $completeHeader): string { $password = $this->getKey($key); @@ -83,6 +87,7 @@ public function unwrapKey(JWK $key, string $encrypted_cek, array $completeHeader return $wrapper::unwrap($derived_key, $encrypted_cek); } + #[Override] public function getKeyManagementMode(): string { return self::MODE_WRAP; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS256A128KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS256A128KW.php index 645ac0f23..cb3126b41 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS256A128KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS256A128KW.php @@ -5,24 +5,29 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use AESKW\A128KW as Wrapper; +use Override; -final class PBES2HS256A128KW extends PBES2AESKW +final readonly class PBES2HS256A128KW extends PBES2AESKW { + #[Override] public function name(): string { return 'PBES2-HS256+A128KW'; } + #[Override] protected function getWrapper(): Wrapper { return new Wrapper(); } + #[Override] protected function getHashAlgorithm(): string { return 'sha256'; } + #[Override] protected function getKeySize(): int { return 16; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS384A192KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS384A192KW.php index 018218eaf..fe352b634 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS384A192KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS384A192KW.php @@ -5,24 +5,29 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use AESKW\A192KW as Wrapper; +use Override; -final class PBES2HS384A192KW extends PBES2AESKW +final readonly class PBES2HS384A192KW extends PBES2AESKW { + #[Override] public function name(): string { return 'PBES2-HS384+A192KW'; } + #[Override] protected function getWrapper(): Wrapper { return new Wrapper(); } + #[Override] protected function getHashAlgorithm(): string { return 'sha384'; } + #[Override] protected function getKeySize(): int { return 24; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS512A256KW.php b/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS512A256KW.php index adf30c152..9ec8883c0 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS512A256KW.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/PBES2HS512A256KW.php @@ -5,24 +5,29 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use AESKW\A256KW as Wrapper; +use Override; -final class PBES2HS512A256KW extends PBES2AESKW +final readonly class PBES2HS512A256KW extends PBES2AESKW { + #[Override] public function name(): string { return 'PBES2-HS512+A256KW'; } + #[Override] protected function getWrapper(): Wrapper { return new Wrapper(); } + #[Override] protected function getHashAlgorithm(): string { return 'sha512'; } + #[Override] protected function getKeySize(): int { return 32; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/RSA.php b/src/Library/Encryption/Algorithm/KeyEncryption/RSA.php index 1d5de916a..190fba76d 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/RSA.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/RSA.php @@ -8,10 +8,12 @@ use Jose\Component\Core\JWK; use Jose\Component\Core\Util\RSAKey; use Jose\Component\Encryption\Algorithm\KeyEncryption\Util\RSACrypt; +use Override; use function in_array; -abstract class RSA implements KeyEncryption +abstract readonly class RSA implements KeyEncryption { + #[Override] public function allowedKeyTypes(): array { return ['RSA']; @@ -21,6 +23,7 @@ public function allowedKeyTypes(): array * @param array $completeHeader * @param array $additionalHeader */ + #[Override] public function encryptKey(JWK $key, string $cek, array $completeHeader, array &$additionalHeader): string { $this->checkKey($key); @@ -32,6 +35,7 @@ public function encryptKey(JWK $key, string $cek, array $completeHeader, array & /** * @param array $header */ + #[Override] public function decryptKey(JWK $key, string $encrypted_cek, array $header): string { $this->checkKey($key); @@ -43,6 +47,7 @@ public function decryptKey(JWK $key, string $encrypted_cek, array $header): stri return RSACrypt::decrypt($priv, $encrypted_cek, $this->getEncryptionMode(), $this->getHashAlgorithm()); } + #[Override] public function getKeyManagementMode(): string { return self::MODE_ENCRYPT; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/RSA15.php b/src/Library/Encryption/Algorithm/KeyEncryption/RSA15.php index 0480e2148..8e7ad55c4 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/RSA15.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/RSA15.php @@ -5,19 +5,23 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use Jose\Component\Encryption\Algorithm\KeyEncryption\Util\RSACrypt; +use Override; -final class RSA15 extends RSA +final readonly class RSA15 extends RSA { + #[Override] public function name(): string { return 'RSA1_5'; } + #[Override] protected function getEncryptionMode(): int { return RSACrypt::ENCRYPTION_PKCS1; } + #[Override] protected function getHashAlgorithm(): ?string { return null; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/RSAOAEP.php b/src/Library/Encryption/Algorithm/KeyEncryption/RSAOAEP.php index 6c7ea2507..ee7cb219f 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/RSAOAEP.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/RSAOAEP.php @@ -5,19 +5,23 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use Jose\Component\Encryption\Algorithm\KeyEncryption\Util\RSACrypt; +use Override; -final class RSAOAEP extends RSA +final readonly class RSAOAEP extends RSA { + #[Override] public function name(): string { return 'RSA-OAEP'; } + #[Override] protected function getEncryptionMode(): int { return RSACrypt::ENCRYPTION_OAEP; } + #[Override] protected function getHashAlgorithm(): string { return 'sha1'; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/RSAOAEP256.php b/src/Library/Encryption/Algorithm/KeyEncryption/RSAOAEP256.php index 3169b0227..02fcd4527 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/RSAOAEP256.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/RSAOAEP256.php @@ -5,19 +5,23 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption; use Jose\Component\Encryption\Algorithm\KeyEncryption\Util\RSACrypt; +use Override; -final class RSAOAEP256 extends RSA +final readonly class RSAOAEP256 extends RSA { + #[Override] public function getEncryptionMode(): int { return RSACrypt::ENCRYPTION_OAEP; } + #[Override] public function getHashAlgorithm(): string { return 'sha256'; } + #[Override] public function name(): string { return 'RSA-OAEP-256'; diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/Util/ConcatKDF.php b/src/Library/Encryption/Algorithm/KeyEncryption/Util/ConcatKDF.php index 3084efe35..92c9d2647 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/Util/ConcatKDF.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/Util/ConcatKDF.php @@ -5,7 +5,7 @@ namespace Jose\Component\Encryption\Algorithm\KeyEncryption\Util; use InvalidArgumentException; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; use const STR_PAD_LEFT; /** @@ -13,7 +13,7 @@ * * @see https://tools.ietf.org/html/rfc7518#section-4.6.2 */ -final class ConcatKDF +final readonly class ConcatKDF { /** * Key Derivation Function. diff --git a/src/Library/Encryption/Algorithm/KeyEncryption/Util/RSACrypt.php b/src/Library/Encryption/Algorithm/KeyEncryption/Util/RSACrypt.php index 596a0d09f..ac035318b 100644 --- a/src/Library/Encryption/Algorithm/KeyEncryption/Util/RSACrypt.php +++ b/src/Library/Encryption/Algorithm/KeyEncryption/Util/RSACrypt.php @@ -18,7 +18,7 @@ /** * @internal */ -final class RSACrypt +final readonly class RSACrypt { /** * Optimal Asymmetric Encryption Padding (OAEP). diff --git a/src/Library/Encryption/Compression/CompressionMethodManager.php b/src/Library/Encryption/Compression/CompressionMethodManager.php index 8a51e6a6b..5ff46251a 100644 --- a/src/Library/Encryption/Compression/CompressionMethodManager.php +++ b/src/Library/Encryption/Compression/CompressionMethodManager.php @@ -7,7 +7,7 @@ use InvalidArgumentException; use function array_key_exists; -class CompressionMethodManager +final class CompressionMethodManager { /** * @var CompressionMethod[] @@ -57,7 +57,7 @@ public function list(): array /** * Add the given compression method to the manager. */ - protected function add(CompressionMethod $compressionMethod): void + private function add(CompressionMethod $compressionMethod): void { $name = $compressionMethod->name(); $this->compressionMethods[$name] = $compressionMethod; diff --git a/src/Library/Encryption/Compression/CompressionMethodManagerFactory.php b/src/Library/Encryption/Compression/CompressionMethodManagerFactory.php index 806424ef9..0377b802f 100644 --- a/src/Library/Encryption/Compression/CompressionMethodManagerFactory.php +++ b/src/Library/Encryption/Compression/CompressionMethodManagerFactory.php @@ -6,7 +6,7 @@ use InvalidArgumentException; -class CompressionMethodManagerFactory +final class CompressionMethodManagerFactory { /** * @var CompressionMethod[] diff --git a/src/Library/Encryption/Compression/Deflate.php b/src/Library/Encryption/Compression/Deflate.php index 3f8796851..81062a7b0 100644 --- a/src/Library/Encryption/Compression/Deflate.php +++ b/src/Library/Encryption/Compression/Deflate.php @@ -5,28 +5,29 @@ namespace Jose\Component\Encryption\Compression; use InvalidArgumentException; +use Override; use Throwable; use function is_string; -final class Deflate implements CompressionMethod +final readonly class Deflate implements CompressionMethod { - private int $compressionLevel = -1; - - public function __construct(int $compressionLevel = -1) - { + public function __construct( + private int $compressionLevel = -1 + ) { if ($compressionLevel < -1 || $compressionLevel > 9) { throw new InvalidArgumentException( 'The compression level can be given as 0 for no compression up to 9 for maximum compression. If -1 given, the default compression level will be the default compression level of the zlib library.' ); } - $this->compressionLevel = $compressionLevel; } + #[Override] public function name(): string { return 'DEF'; } + #[Override] public function compress(string $data): string { try { @@ -41,6 +42,7 @@ public function compress(string $data): string } } + #[Override] public function uncompress(string $data): string { try { diff --git a/src/Library/Encryption/JWE.php b/src/Library/Encryption/JWE.php index 199085cd9..d9a1a5651 100644 --- a/src/Library/Encryption/JWE.php +++ b/src/Library/Encryption/JWE.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\Core\JWT; +use Override; use function array_key_exists; use function count; @@ -25,6 +26,7 @@ public function __construct( ) { } + #[Override] public function getPayload(): ?string { return $this->payload; diff --git a/src/Library/Encryption/JWEBuilder.php b/src/Library/Encryption/JWEBuilder.php index c3f1b5e84..5c502b11e 100644 --- a/src/Library/Encryption/JWEBuilder.php +++ b/src/Library/Encryption/JWEBuilder.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Jose\Component\Core\AlgorithmManager; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\Core\Util\KeyChecker; use Jose\Component\Encryption\Algorithm\ContentEncryptionAlgorithm; @@ -19,7 +20,6 @@ use Jose\Component\Encryption\Compression\CompressionMethod; use Jose\Component\Encryption\Compression\CompressionMethodManager; use LogicException; -use ParagonIE\ConstantTime\Base64UrlSafe; use RuntimeException; use function array_key_exists; use function count; diff --git a/src/Library/Encryption/JWETokenSupport.php b/src/Library/Encryption/JWETokenSupport.php index 2b5568aeb..5c24b0f08 100644 --- a/src/Library/Encryption/JWETokenSupport.php +++ b/src/Library/Encryption/JWETokenSupport.php @@ -6,9 +6,11 @@ use Jose\Component\Checker\TokenTypeSupport; use Jose\Component\Core\JWT; +use Override; final class JWETokenSupport implements TokenTypeSupport { + #[Override] public function supports(JWT $jwt): bool { return $jwt instanceof JWE; @@ -18,6 +20,7 @@ public function supports(JWT $jwt): bool * @param array $protectedHeader * @param array $unprotectedHeader */ + #[Override] public function retrieveTokenHeaders(JWT $jwt, int $index, array &$protectedHeader, array &$unprotectedHeader): void { if (! $jwt instanceof JWE) { diff --git a/src/Library/Encryption/Recipient.php b/src/Library/Encryption/Recipient.php index 37502e130..4fadd867f 100644 --- a/src/Library/Encryption/Recipient.php +++ b/src/Library/Encryption/Recipient.php @@ -10,11 +10,11 @@ /** * @internal */ -final class Recipient +final readonly class Recipient { public function __construct( - private readonly array $header, - private readonly ?string $encryptedKey + private array $header, + private ?string $encryptedKey ) { } diff --git a/src/Library/Encryption/Serializer/CompactSerializer.php b/src/Library/Encryption/Serializer/CompactSerializer.php index cb2fae595..cfbc6b4be 100644 --- a/src/Library/Encryption/Serializer/CompactSerializer.php +++ b/src/Library/Encryption/Serializer/CompactSerializer.php @@ -5,29 +5,33 @@ namespace Jose\Component\Encryption\Serializer; use InvalidArgumentException; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\Encryption\JWE; use Jose\Component\Encryption\Recipient; use LogicException; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use Throwable; use function count; use function is_array; -final class CompactSerializer implements JWESerializer +final readonly class CompactSerializer implements JWESerializer { public const string NAME = 'jwe_compact'; + #[Override] public function displayName(): string { return 'JWE Compact'; } + #[Override] public function name(): string { return self::NAME; } + #[Override] public function serialize(JWE $jwe, ?int $recipientIndex = null): string { if ($recipientIndex === null) { @@ -49,6 +53,7 @@ public function serialize(JWE $jwe, ?int $recipientIndex = null): string ); } + #[Override] public function unserialize(string $input): JWE { $parts = explode('.', $input); diff --git a/src/Library/Encryption/Serializer/JSONFlattenedSerializer.php b/src/Library/Encryption/Serializer/JSONFlattenedSerializer.php index 5d52db8ff..52c2936ec 100644 --- a/src/Library/Encryption/Serializer/JSONFlattenedSerializer.php +++ b/src/Library/Encryption/Serializer/JSONFlattenedSerializer.php @@ -5,28 +5,32 @@ namespace Jose\Component\Encryption\Serializer; use InvalidArgumentException; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\Encryption\JWE; use Jose\Component\Encryption\Recipient; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use function array_key_exists; use function count; use function is_array; -final class JSONFlattenedSerializer implements JWESerializer +final readonly class JSONFlattenedSerializer implements JWESerializer { public const string NAME = 'jwe_json_flattened'; + #[Override] public function displayName(): string { return 'JWE JSON Flattened'; } + #[Override] public function name(): string { return self::NAME; } + #[Override] public function serialize(JWE $jwe, ?int $recipientIndex = null): string { if ($recipientIndex === null) { @@ -57,6 +61,7 @@ public function serialize(JWE $jwe, ?int $recipientIndex = null): string return JsonConverter::encode($data); } + #[Override] public function unserialize(string $input): JWE { $data = JsonConverter::decode($input); diff --git a/src/Library/Encryption/Serializer/JSONGeneralSerializer.php b/src/Library/Encryption/Serializer/JSONGeneralSerializer.php index c456e0ba8..768fb17c6 100644 --- a/src/Library/Encryption/Serializer/JSONGeneralSerializer.php +++ b/src/Library/Encryption/Serializer/JSONGeneralSerializer.php @@ -5,29 +5,33 @@ namespace Jose\Component\Encryption\Serializer; use InvalidArgumentException; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\Encryption\JWE; use Jose\Component\Encryption\Recipient; use LogicException; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use function array_key_exists; use function count; use function is_array; -final class JSONGeneralSerializer implements JWESerializer +final readonly class JSONGeneralSerializer implements JWESerializer { public const string NAME = 'jwe_json_general'; + #[Override] public function displayName(): string { return 'JWE JSON General'; } + #[Override] public function name(): string { return self::NAME; } + #[Override] public function serialize(JWE $jwe, ?int $recipientIndex = null): string { if ($jwe->countRecipients() === 0) { @@ -63,6 +67,7 @@ public function serialize(JWE $jwe, ?int $recipientIndex = null): string return JsonConverter::encode($data); } + #[Override] public function unserialize(string $input): JWE { $data = JsonConverter::decode($input); diff --git a/src/Library/Encryption/Serializer/JWESerializerManager.php b/src/Library/Encryption/Serializer/JWESerializerManager.php index 14641bbaa..fd2a172a1 100644 --- a/src/Library/Encryption/Serializer/JWESerializerManager.php +++ b/src/Library/Encryption/Serializer/JWESerializerManager.php @@ -7,7 +7,7 @@ use InvalidArgumentException; use Jose\Component\Encryption\JWE; -class JWESerializerManager +final class JWESerializerManager { /** * @var JWESerializer[] diff --git a/src/Library/Encryption/Serializer/JWESerializerManagerFactory.php b/src/Library/Encryption/Serializer/JWESerializerManagerFactory.php index d62f26d71..f62d94e6e 100644 --- a/src/Library/Encryption/Serializer/JWESerializerManagerFactory.php +++ b/src/Library/Encryption/Serializer/JWESerializerManagerFactory.php @@ -6,7 +6,7 @@ use InvalidArgumentException; -class JWESerializerManagerFactory +final class JWESerializerManagerFactory { /** * @var JWESerializer[] diff --git a/src/Library/KeyManagement/Analyzer/AlgorithmAnalyzer.php b/src/Library/KeyManagement/Analyzer/AlgorithmAnalyzer.php index a1db8d3ed..85dafaf2f 100644 --- a/src/Library/KeyManagement/Analyzer/AlgorithmAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/AlgorithmAnalyzer.php @@ -5,9 +5,11 @@ namespace Jose\Component\KeyManagement\Analyzer; use Jose\Component\Core\JWK; +use Override; -final class AlgorithmAnalyzer implements KeyAnalyzer +final readonly class AlgorithmAnalyzer implements KeyAnalyzer { + #[Override] public function analyze(JWK $jwk, MessageBag $bag): void { if (! $jwk->has('alg')) { diff --git a/src/Library/KeyManagement/Analyzer/ES256KeyAnalyzer.php b/src/Library/KeyManagement/Analyzer/ES256KeyAnalyzer.php index fbf802068..f927b6b70 100644 --- a/src/Library/KeyManagement/Analyzer/ES256KeyAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/ES256KeyAnalyzer.php @@ -6,24 +6,29 @@ use Jose\Component\Core\Util\Ecc\Curve; use Jose\Component\Core\Util\Ecc\NistCurve; +use Override; -final class ES256KeyAnalyzer extends ESKeyAnalyzer +final readonly class ES256KeyAnalyzer extends ESKeyAnalyzer { + #[Override] protected function getAlgorithmName(): string { return 'ES256'; } + #[Override] protected function getCurveName(): string { return 'P-256'; } + #[Override] protected function getCurve(): Curve { return NistCurve::curve256(); } + #[Override] protected function getKeySize(): int { return 256; diff --git a/src/Library/KeyManagement/Analyzer/ES384KeyAnalyzer.php b/src/Library/KeyManagement/Analyzer/ES384KeyAnalyzer.php index 01075b5d9..7c2fcdbc2 100644 --- a/src/Library/KeyManagement/Analyzer/ES384KeyAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/ES384KeyAnalyzer.php @@ -6,24 +6,29 @@ use Jose\Component\Core\Util\Ecc\Curve; use Jose\Component\Core\Util\Ecc\NistCurve; +use Override; -final class ES384KeyAnalyzer extends ESKeyAnalyzer +final readonly class ES384KeyAnalyzer extends ESKeyAnalyzer { + #[Override] protected function getAlgorithmName(): string { return 'ES384'; } + #[Override] protected function getCurveName(): string { return 'P-384'; } + #[Override] protected function getCurve(): Curve { return NistCurve::curve384(); } + #[Override] protected function getKeySize(): int { return 384; diff --git a/src/Library/KeyManagement/Analyzer/ES512KeyAnalyzer.php b/src/Library/KeyManagement/Analyzer/ES512KeyAnalyzer.php index b146deecb..f0a83cf77 100644 --- a/src/Library/KeyManagement/Analyzer/ES512KeyAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/ES512KeyAnalyzer.php @@ -6,24 +6,29 @@ use Jose\Component\Core\Util\Ecc\Curve; use Jose\Component\Core\Util\Ecc\NistCurve; +use Override; -final class ES512KeyAnalyzer extends ESKeyAnalyzer +final readonly class ES512KeyAnalyzer extends ESKeyAnalyzer { + #[Override] protected function getAlgorithmName(): string { return 'ES512'; } + #[Override] protected function getCurveName(): string { return 'P-521'; } + #[Override] protected function getCurve(): Curve { return NistCurve::curve521(); } + #[Override] protected function getKeySize(): int { return 528; diff --git a/src/Library/KeyManagement/Analyzer/ESKeyAnalyzer.php b/src/Library/KeyManagement/Analyzer/ESKeyAnalyzer.php index 2c0038618..1720047c7 100644 --- a/src/Library/KeyManagement/Analyzer/ESKeyAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/ESKeyAnalyzer.php @@ -6,12 +6,14 @@ use Brick\Math\BigInteger; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\Ecc\Curve; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use function is_string; -abstract class ESKeyAnalyzer implements KeyAnalyzer +abstract readonly class ESKeyAnalyzer implements KeyAnalyzer { + #[Override] public function analyze(JWK $jwk, MessageBag $bag): void { if ($jwk->get('kty') !== 'EC') { diff --git a/src/Library/KeyManagement/Analyzer/HS256KeyAnalyzer.php b/src/Library/KeyManagement/Analyzer/HS256KeyAnalyzer.php index c83ac6d1f..fbff1708c 100644 --- a/src/Library/KeyManagement/Analyzer/HS256KeyAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/HS256KeyAnalyzer.php @@ -4,13 +4,17 @@ namespace Jose\Component\KeyManagement\Analyzer; -final class HS256KeyAnalyzer extends HSKeyAnalyzer +use Override; + +final readonly class HS256KeyAnalyzer extends HSKeyAnalyzer { + #[Override] protected function getAlgorithmName(): string { return 'HS256'; } + #[Override] protected function getMinimumKeySize(): int { return 256; diff --git a/src/Library/KeyManagement/Analyzer/HS384KeyAnalyzer.php b/src/Library/KeyManagement/Analyzer/HS384KeyAnalyzer.php index 908a226e0..74075b6f4 100644 --- a/src/Library/KeyManagement/Analyzer/HS384KeyAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/HS384KeyAnalyzer.php @@ -4,13 +4,17 @@ namespace Jose\Component\KeyManagement\Analyzer; -final class HS384KeyAnalyzer extends HSKeyAnalyzer +use Override; + +final readonly class HS384KeyAnalyzer extends HSKeyAnalyzer { + #[Override] protected function getAlgorithmName(): string { return 'HS384'; } + #[Override] protected function getMinimumKeySize(): int { return 384; diff --git a/src/Library/KeyManagement/Analyzer/HS512KeyAnalyzer.php b/src/Library/KeyManagement/Analyzer/HS512KeyAnalyzer.php index ba52b5174..5013a7389 100644 --- a/src/Library/KeyManagement/Analyzer/HS512KeyAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/HS512KeyAnalyzer.php @@ -4,13 +4,17 @@ namespace Jose\Component\KeyManagement\Analyzer; -final class HS512KeyAnalyzer extends HSKeyAnalyzer +use Override; + +final readonly class HS512KeyAnalyzer extends HSKeyAnalyzer { + #[Override] protected function getAlgorithmName(): string { return 'HS512'; } + #[Override] protected function getMinimumKeySize(): int { return 512; diff --git a/src/Library/KeyManagement/Analyzer/HSKeyAnalyzer.php b/src/Library/KeyManagement/Analyzer/HSKeyAnalyzer.php index 0e283a5a0..004a9f169 100644 --- a/src/Library/KeyManagement/Analyzer/HSKeyAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/HSKeyAnalyzer.php @@ -5,11 +5,13 @@ namespace Jose\Component\KeyManagement\Analyzer; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; +use Override; use function is_string; -abstract class HSKeyAnalyzer implements KeyAnalyzer +abstract readonly class HSKeyAnalyzer implements KeyAnalyzer { + #[Override] public function analyze(JWK $jwk, MessageBag $bag): void { if ($jwk->get('kty') !== 'oct') { diff --git a/src/Library/KeyManagement/Analyzer/KeyAnalyzerManager.php b/src/Library/KeyManagement/Analyzer/KeyAnalyzerManager.php index 378ce6df9..acbbdfad0 100644 --- a/src/Library/KeyManagement/Analyzer/KeyAnalyzerManager.php +++ b/src/Library/KeyManagement/Analyzer/KeyAnalyzerManager.php @@ -6,7 +6,7 @@ use Jose\Component\Core\JWK; -class KeyAnalyzerManager +final class KeyAnalyzerManager { /** * @var KeyAnalyzer[] diff --git a/src/Library/KeyManagement/Analyzer/KeyIdentifierAnalyzer.php b/src/Library/KeyManagement/Analyzer/KeyIdentifierAnalyzer.php index 2f21105f7..1dbd1260a 100644 --- a/src/Library/KeyManagement/Analyzer/KeyIdentifierAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/KeyIdentifierAnalyzer.php @@ -5,9 +5,11 @@ namespace Jose\Component\KeyManagement\Analyzer; use Jose\Component\Core\JWK; +use Override; -final class KeyIdentifierAnalyzer implements KeyAnalyzer +final readonly class KeyIdentifierAnalyzer implements KeyAnalyzer { + #[Override] public function analyze(JWK $jwk, MessageBag $bag): void { if (! $jwk->has('kid')) { diff --git a/src/Library/KeyManagement/Analyzer/KeysetAnalyzerManager.php b/src/Library/KeyManagement/Analyzer/KeysetAnalyzerManager.php index 7c9ec9b46..cd28ffbf6 100644 --- a/src/Library/KeyManagement/Analyzer/KeysetAnalyzerManager.php +++ b/src/Library/KeyManagement/Analyzer/KeysetAnalyzerManager.php @@ -6,7 +6,7 @@ use Jose\Component\Core\JWKSet; -class KeysetAnalyzerManager +final class KeysetAnalyzerManager { /** * @var KeysetAnalyzer[] diff --git a/src/Library/KeyManagement/Analyzer/Message.php b/src/Library/KeyManagement/Analyzer/Message.php index 65933574d..2c800b16b 100644 --- a/src/Library/KeyManagement/Analyzer/Message.php +++ b/src/Library/KeyManagement/Analyzer/Message.php @@ -5,8 +5,9 @@ namespace Jose\Component\KeyManagement\Analyzer; use JsonSerializable; +use Override; -class Message implements JsonSerializable +final readonly class Message implements JsonSerializable { final public const string SEVERITY_LOW = 'low'; @@ -15,8 +16,8 @@ class Message implements JsonSerializable final public const string SEVERITY_HIGH = 'high'; private function __construct( - private readonly string $message, - private readonly string $severity + private string $message, + private string $severity ) { } @@ -60,6 +61,7 @@ public function getSeverity(): string return $this->severity; } + #[Override] public function jsonSerialize(): array { return [ diff --git a/src/Library/KeyManagement/Analyzer/MessageBag.php b/src/Library/KeyManagement/Analyzer/MessageBag.php index 453fcd285..20699a3c9 100644 --- a/src/Library/KeyManagement/Analyzer/MessageBag.php +++ b/src/Library/KeyManagement/Analyzer/MessageBag.php @@ -8,10 +8,11 @@ use Countable; use IteratorAggregate; use JsonSerializable; +use Override; use Traversable; use function count; -class MessageBag implements JsonSerializable, IteratorAggregate, Countable +final class MessageBag implements JsonSerializable, IteratorAggregate, Countable { /** * @var Message[] @@ -36,16 +37,19 @@ public function all(): array return $this->messages; } + #[Override] public function jsonSerialize(): array { return array_values($this->messages); } + #[Override] public function count(): int { return count($this->messages); } + #[Override] public function getIterator(): Traversable { return new ArrayIterator($this->messages); diff --git a/src/Library/KeyManagement/Analyzer/MixedKeyTypes.php b/src/Library/KeyManagement/Analyzer/MixedKeyTypes.php index 5c473348b..bb9d1d7f8 100644 --- a/src/Library/KeyManagement/Analyzer/MixedKeyTypes.php +++ b/src/Library/KeyManagement/Analyzer/MixedKeyTypes.php @@ -5,9 +5,11 @@ namespace Jose\Component\KeyManagement\Analyzer; use Jose\Component\Core\JWKSet; +use Override; final class MixedKeyTypes implements KeysetAnalyzer { + #[Override] public function analyze(JWKSet $jwkset, MessageBag $bag): void { if ($jwkset->count() === 0) { diff --git a/src/Library/KeyManagement/Analyzer/MixedPublicAndPrivateKeys.php b/src/Library/KeyManagement/Analyzer/MixedPublicAndPrivateKeys.php index aa957a00b..83bee5f15 100644 --- a/src/Library/KeyManagement/Analyzer/MixedPublicAndPrivateKeys.php +++ b/src/Library/KeyManagement/Analyzer/MixedPublicAndPrivateKeys.php @@ -5,9 +5,11 @@ namespace Jose\Component\KeyManagement\Analyzer; use Jose\Component\Core\JWKSet; +use Override; -final class MixedPublicAndPrivateKeys implements KeysetAnalyzer +final readonly class MixedPublicAndPrivateKeys implements KeysetAnalyzer { + #[Override] public function analyze(JWKSet $jwkset, MessageBag $bag): void { if ($jwkset->count() === 0) { diff --git a/src/Library/KeyManagement/Analyzer/NoneAnalyzer.php b/src/Library/KeyManagement/Analyzer/NoneAnalyzer.php index 57488a891..d82fbeaec 100644 --- a/src/Library/KeyManagement/Analyzer/NoneAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/NoneAnalyzer.php @@ -5,9 +5,11 @@ namespace Jose\Component\KeyManagement\Analyzer; use Jose\Component\Core\JWK; +use Override; -final class NoneAnalyzer implements KeyAnalyzer +final readonly class NoneAnalyzer implements KeyAnalyzer { + #[Override] public function analyze(JWK $jwk, MessageBag $bag): void { if ($jwk->get('kty') !== 'none') { diff --git a/src/Library/KeyManagement/Analyzer/OctAnalyzer.php b/src/Library/KeyManagement/Analyzer/OctAnalyzer.php index 240517933..fe603f5f3 100644 --- a/src/Library/KeyManagement/Analyzer/OctAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/OctAnalyzer.php @@ -5,11 +5,13 @@ namespace Jose\Component\KeyManagement\Analyzer; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; +use Override; use function is_string; -final class OctAnalyzer implements KeyAnalyzer +final readonly class OctAnalyzer implements KeyAnalyzer { + #[Override] public function analyze(JWK $jwk, MessageBag $bag): void { if ($jwk->get('kty') !== 'oct') { diff --git a/src/Library/KeyManagement/Analyzer/RsaAnalyzer.php b/src/Library/KeyManagement/Analyzer/RsaAnalyzer.php index 84885e2b9..c4ca05cca 100644 --- a/src/Library/KeyManagement/Analyzer/RsaAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/RsaAnalyzer.php @@ -6,13 +6,15 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; +use Override; use function is_array; use function is_string; use const STR_PAD_RIGHT; -final class RsaAnalyzer implements KeyAnalyzer +final readonly class RsaAnalyzer implements KeyAnalyzer { + #[Override] public function analyze(JWK $jwk, MessageBag $bag): void { if ($jwk->get('kty') !== 'RSA') { diff --git a/src/Library/KeyManagement/Analyzer/UsageAnalyzer.php b/src/Library/KeyManagement/Analyzer/UsageAnalyzer.php index e30ae9638..c58169d64 100644 --- a/src/Library/KeyManagement/Analyzer/UsageAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/UsageAnalyzer.php @@ -5,10 +5,12 @@ namespace Jose\Component\KeyManagement\Analyzer; use Jose\Component\Core\JWK; +use Override; use function in_array; -final class UsageAnalyzer implements KeyAnalyzer +final readonly class UsageAnalyzer implements KeyAnalyzer { + #[Override] public function analyze(JWK $jwk, MessageBag $bag): void { if (! $jwk->has('use')) { diff --git a/src/Library/KeyManagement/Analyzer/ZxcvbnKeyAnalyzer.php b/src/Library/KeyManagement/Analyzer/ZxcvbnKeyAnalyzer.php index 2f5ccb9ab..3bc366130 100644 --- a/src/Library/KeyManagement/Analyzer/ZxcvbnKeyAnalyzer.php +++ b/src/Library/KeyManagement/Analyzer/ZxcvbnKeyAnalyzer.php @@ -5,13 +5,26 @@ namespace Jose\Component\KeyManagement\Analyzer; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; -use Throwable; -use ZxcvbnPhp\Zxcvbn; +use Jose\Component\Core\Util\Base64UrlSafe; +use Override; +use SensitiveParameter; +use function count; use function is_string; +use function mb_strlen; -final class ZxcvbnKeyAnalyzer implements KeyAnalyzer +final readonly class ZxcvbnKeyAnalyzer implements KeyAnalyzer { + public const int STRENGTH_VERY_WEAK = 0; + + public const int STRENGTH_WEAK = 1; + + public const int STRENGTH_MEDIUM = 2; + + public const int STRENGTH_STRONG = 3; + + public const int STRENGTH_VERY_STRONG = 4; + + #[Override] public function analyze(JWK $jwk, MessageBag $bag): void { if ($jwk->get('kty') !== 'oct') { @@ -24,32 +37,63 @@ public function analyze(JWK $jwk, MessageBag $bag): void return; } $k = Base64UrlSafe::decodeNoPadding($k); - if (! class_exists(Zxcvbn::class)) { - return; + $strength = self::estimateStrength($k); + switch (true) { + case $strength < 3: + $bag->add( + Message::high( + 'The octet string is weak and easily guessable. Please change your key as soon as possible.' + ) + ); + + break; + + case $strength === 3: + $bag->add(Message::medium('The octet string is safe, but a longer key is preferable.')); + + break; + + default: + break; + } + } + + /** + * Returns the estimated strength of a password. + * + * The higher the value, the stronger the password. + * + * @return self::STRENGTH_* + */ + private static function estimateStrength(#[SensitiveParameter] string $password): int + { + if (! $length = mb_strlen($password)) { + return self::STRENGTH_VERY_WEAK; } - $zxcvbn = new Zxcvbn(); - try { - $strength = $zxcvbn->passwordStrength($k); - switch (true) { - case $strength['score'] < 3: - $bag->add( - Message::high( - 'The octet string is weak and easily guessable. Please change your key as soon as possible.' - ) - ); - - break; - - case $strength['score'] === 3: - $bag->add(Message::medium('The octet string is safe, but a longer key is preferable.')); - - break; - - default: - break; - } - } catch (Throwable) { - $bag->add(Message::medium('The test of the weakness cannot be performed.')); + $password = count_chars($password, 1); + $chars = count($password); + + $control = $digit = $upper = $lower = $symbol = $other = 0; + foreach ($password as $chr => $count) { + match (true) { + $chr < 32 || $chr === 127 => $control = 33, + $chr >= 48 && $chr <= 57 => $digit = 10, + $chr >= 65 && $chr <= 90 => $upper = 26, + $chr >= 97 && $chr <= 122 => $lower = 26, + $chr >= 128 => $other = 128, + default => $symbol = 33, + }; } + + $pool = $lower + $upper + $digit + $symbol + $control + $other; + $entropy = $chars * log($pool, 2) + ($length - $chars) * log($chars, 2); + + return match (true) { + $entropy >= 120 => self::STRENGTH_VERY_STRONG, + $entropy >= 100 => self::STRENGTH_STRONG, + $entropy >= 80 => self::STRENGTH_MEDIUM, + $entropy >= 60 => self::STRENGTH_WEAK, + default => self::STRENGTH_VERY_WEAK, + }; } } diff --git a/src/Library/KeyManagement/JWKFactory.php b/src/Library/KeyManagement/JWKFactory.php index bf42b0277..1bf4ac45c 100644 --- a/src/Library/KeyManagement/JWKFactory.php +++ b/src/Library/KeyManagement/JWKFactory.php @@ -7,11 +7,11 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\ECKey; use Jose\Component\KeyManagement\KeyConverter\KeyConverter; use Jose\Component\KeyManagement\KeyConverter\RSAKey; use OpenSSLCertificate; -use ParagonIE\ConstantTime\Base64UrlSafe; use RuntimeException; use Throwable; use function array_key_exists; diff --git a/src/Library/KeyManagement/KeyConverter/ECKey.php b/src/Library/KeyManagement/KeyConverter/ECKey.php index 8ee1bfad4..6c3f61a73 100644 --- a/src/Library/KeyManagement/KeyConverter/ECKey.php +++ b/src/Library/KeyManagement/KeyConverter/ECKey.php @@ -5,7 +5,7 @@ namespace Jose\Component\KeyManagement\KeyConverter; use InvalidArgumentException; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; use SpomkyLabs\Pki\CryptoEncoding\PEM; use SpomkyLabs\Pki\CryptoTypes\Asymmetric\EC\ECPrivateKey; use SpomkyLabs\Pki\CryptoTypes\Asymmetric\EC\ECPublicKey; diff --git a/src/Library/KeyManagement/KeyConverter/KeyConverter.php b/src/Library/KeyManagement/KeyConverter/KeyConverter.php index 82442bb7d..029f015a6 100644 --- a/src/Library/KeyManagement/KeyConverter/KeyConverter.php +++ b/src/Library/KeyManagement/KeyConverter/KeyConverter.php @@ -5,8 +5,8 @@ namespace Jose\Component\KeyManagement\KeyConverter; use InvalidArgumentException; +use Jose\Component\Core\Util\Base64UrlSafe; use OpenSSLCertificate; -use ParagonIE\ConstantTime\Base64UrlSafe; use ParagonIE\Sodium\Core\Ed25519; use RuntimeException; use SpomkyLabs\Pki\CryptoEncoding\PEM; @@ -31,8 +31,11 @@ /** * @internal */ -final class KeyConverter +final readonly class KeyConverter { + /** + * @return array + */ public static function loadKeyFromCertificateFile(string $file): array { if (! file_exists($file)) { @@ -46,6 +49,9 @@ public static function loadKeyFromCertificateFile(string $file): array return self::loadKeyFromCertificate($content); } + /** + * @return array + */ public static function loadKeyFromCertificate(string $certificate): array { if (! extension_loaded('openssl')) { @@ -71,6 +77,9 @@ public static function loadKeyFromCertificate(string $certificate): array return self::loadKeyFromX509Resource($res); } + /** + * @return array + */ public static function loadKeyFromX509Resource(OpenSSLCertificate $res): array { if (! extension_loaded('openssl')) { @@ -110,6 +119,9 @@ public static function loadKeyFromX509Resource(OpenSSLCertificate $res): array throw new InvalidArgumentException('Unable to load the certificate'); } + /** + * @return array + */ public static function loadFromKeyFile(string $file, ?string $password = null): array { $content = file_get_contents($file); @@ -120,6 +132,9 @@ public static function loadFromKeyFile(string $file, ?string $password = null): return self::loadFromKey($content, $password); } + /** + * @return array + */ public static function loadFromKey(string $key, ?string $password = null): array { try { @@ -132,6 +147,9 @@ public static function loadFromKey(string $key, ?string $password = null): array /** * Be careful! The certificate chain is loaded, but it is NOT VERIFIED by any mean! It is mandatory to verify the * root CA or intermediate CA are trusted. If not done, it may lead to potential security issues. + * + * @param array $x5c + * @return array */ public static function loadFromX5C(array $x5c): array { @@ -142,8 +160,9 @@ public static function loadFromX5C(array $x5c): array throw new InvalidArgumentException('The certificate chain is empty'); } foreach ($x5c as $id => $cert) { + assert(is_string($cert), 'Invalid certificate'); $x5c[$id] = '-----BEGIN CERTIFICATE-----' . PHP_EOL . chunk_split( - (string) $cert, + $cert, 64, PHP_EOL ) . '-----END CERTIFICATE-----'; @@ -160,6 +179,9 @@ public static function loadFromX5C(array $x5c): array return self::loadKeyFromCertificate(reset($x5c)); } + /** + * @return array + */ private static function loadKeyFromDER(string $der, ?string $password = null): array { $pem = self::convertDerToPem($der); @@ -167,6 +189,9 @@ private static function loadKeyFromDER(string $der, ?string $password = null): a return self::loadKeyFromPEM($pem, $password); } + /** + * @return array + */ private static function loadKeyFromPEM(string $pem, ?string $password = null): array { if (! extension_loaded('openssl')) { @@ -209,22 +234,28 @@ private static function loadKeyFromPEM(string $pem, ?string $password = null): a /** * This method tries to load Ed448, X488, Ed25519 and X25519 keys. + * + * @return array */ private static function tryToLoadECKey(string $input): array { try { return ECKey::createFromPEM($input)->toArray(); } catch (Throwable) { + // no break } try { return self::tryToLoadOtherKeyTypes($input); } catch (Throwable) { + // no break } throw new InvalidArgumentException('Unable to load the key.'); } /** * This method tries to load Ed448, X488, Ed25519 and X25519 keys. + * + * @return array */ private static function tryToLoadOtherKeyTypes(string $input): array { @@ -239,6 +270,7 @@ private static function tryToLoadOtherKeyTypes(string $input): array ]; return self::populatePoints($key, $values); } catch (Throwable) { + // no break } try { $key = PublicKey::fromPEM($pem); @@ -250,6 +282,7 @@ private static function tryToLoadOtherKeyTypes(string $input): array 'x' => Base64UrlSafe::encodeUnpadded((string) $key->subjectPublicKey()), ]; } catch (Throwable) { + // no break } throw new InvalidArgumentException('Unsupported key type'); } diff --git a/src/Library/KeyManagement/KeyConverter/RSAKey.php b/src/Library/KeyManagement/KeyConverter/RSAKey.php index ff98ea376..66661dac7 100644 --- a/src/Library/KeyManagement/KeyConverter/RSAKey.php +++ b/src/Library/KeyManagement/KeyConverter/RSAKey.php @@ -6,26 +6,37 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\BigInteger; -use ParagonIE\ConstantTime\Base64UrlSafe; use RuntimeException; use function array_key_exists; +use function assert; use function extension_loaded; use function in_array; use function is_array; +use function is_string; /** * @internal */ final class RSAKey { + /** + * @var array + */ private array $values = []; + /** + * @param array $data + */ private function __construct(array $data) { $this->loadJWK($data); } + /** + * @param array $details + */ public static function createFromKeyDetails(array $details): self { $values = [ @@ -43,6 +54,7 @@ public static function createFromKeyDetails(array $details): self ]; foreach ($details as $key => $value) { if (in_array($key, $keys, true)) { + assert(is_string($value), 'Invalid key.'); $value = Base64UrlSafe::encodeUnpadded($value); $values[array_search($key, $keys, true)] = $value; } @@ -68,8 +80,12 @@ public static function createFromPEM(string $pem): self if (! is_array($details) || ! isset($details['rsa'])) { throw new InvalidArgumentException('Unable to load the key.'); } + $data = $details['rsa']; + if (! is_array($data)) { + throw new InvalidArgumentException('Unable to load the key.'); + } - return self::createFromKeyDetails($details['rsa']); + return self::createFromKeyDetails($data); } public static function createFromJWK(JWK $jwk): self @@ -95,6 +111,9 @@ public static function toPublic(self $private): self return new self($data); } + /** + * @return array + */ public function toArray(): array { return $this->values; @@ -116,6 +135,9 @@ public function optimize(): void } } + /** + * @param array $jwk + */ private function loadJWK(array $jwk): void { if (! array_key_exists('kty', $jwk)) { diff --git a/src/Library/KeyManagement/X5UFactory.php b/src/Library/KeyManagement/X5UFactory.php index 1eaf9bf52..495e79a55 100644 --- a/src/Library/KeyManagement/X5UFactory.php +++ b/src/Library/KeyManagement/X5UFactory.php @@ -9,6 +9,7 @@ use Jose\Component\Core\Util\JsonConverter; use Jose\Component\KeyManagement\KeyConverter\KeyConverter; use RuntimeException; +use function assert; use function is_array; use function is_string; use const PHP_EOL; @@ -17,6 +18,8 @@ class X5UFactory extends UrlKeySetFactory { /** * This method will try to fetch the url a retrieve the key set. Throws an exception in case of failure. + * + * @param array $header */ public function loadFromUrl(string $url, array $header = []): JWKSet { @@ -28,7 +31,8 @@ public function loadFromUrl(string $url, array $header = []): JWKSet $keys = []; foreach ($data as $kid => $cert) { - if (mb_strpos((string) $cert, '-----BEGIN CERTIFICATE-----') === false) { + assert(is_string($cert), 'Invalid content.'); + if (mb_strpos($cert, '-----BEGIN CERTIFICATE-----') === false) { $cert = '-----BEGIN CERTIFICATE-----' . PHP_EOL . $cert . PHP_EOL . '-----END CERTIFICATE-----'; } $jwk = KeyConverter::loadKeyFromCertificate($cert); diff --git a/src/Library/NestedToken/NestedTokenBuilder.php b/src/Library/NestedToken/NestedTokenBuilder.php index a187d0407..1ddd42347 100644 --- a/src/Library/NestedToken/NestedTokenBuilder.php +++ b/src/Library/NestedToken/NestedTokenBuilder.php @@ -4,14 +4,12 @@ namespace Jose\Component\NestedToken; -use InvalidArgumentException; use Jose\Component\Core\JWK; use Jose\Component\Encryption\JWEBuilder; use Jose\Component\Encryption\Serializer\JWESerializerManager; use Jose\Component\Signature\JWSBuilder; use Jose\Component\Signature\Serializer\JWSSerializerManager; use function array_key_exists; -use function is_array; class NestedTokenBuilder { @@ -44,11 +42,6 @@ public function create( $jws = $this->jwsBuilder->create() ->withPayload($payload); foreach ($signatures as $signature) { - if (! is_array($signature) || ! array_key_exists('key', $signature)) { - throw new InvalidArgumentException( - 'The signatures must be an array of arrays containing a key, a protected header and a header' - ); - } $signature['protected_header'] = array_key_exists( 'protected_header', $signature @@ -68,11 +61,6 @@ public function create( ->withSharedHeader($jweSharedHeader) ->withAAD($aad); foreach ($recipients as $recipient) { - if (! is_array($recipient) || ! array_key_exists('key', $recipient)) { - throw new InvalidArgumentException( - 'The recipients must be an array of arrays containing a key and a header' - ); - } $recipient['header'] = array_key_exists('header', $recipient) ? $recipient['header'] : []; $jwe = $jwe->addRecipient($recipient['key'], $recipient['header']); } diff --git a/src/Library/Signature/Algorithm/ECDSA.php b/src/Library/Signature/Algorithm/ECDSA.php index 3c1f2a7e2..6383da979 100644 --- a/src/Library/Signature/Algorithm/ECDSA.php +++ b/src/Library/Signature/Algorithm/ECDSA.php @@ -9,13 +9,14 @@ use Jose\Component\Core\Util\ECKey; use Jose\Component\Core\Util\ECSignature; use LogicException; +use Override; use RuntimeException; use Throwable; use function defined; use function extension_loaded; use function in_array; -abstract class ECDSA implements SignatureAlgorithm +abstract readonly class ECDSA implements SignatureAlgorithm { public function __construct() { @@ -27,11 +28,13 @@ public function __construct() } } + #[Override] public function allowedKeyTypes(): array { return ['EC']; } + #[Override] public function sign(JWK $key, string $input): string { $this->checkKey($key); @@ -44,6 +47,7 @@ public function sign(JWK $key, string $input): string return ECSignature::fromAsn1($signature, $this->getSignaturePartLength()); } + #[Override] public function verify(JWK $key, string $input, string $signature): bool { $this->checkKey($key); diff --git a/src/Library/Signature/Algorithm/ES256.php b/src/Library/Signature/Algorithm/ES256.php index 926cde026..28b32d895 100644 --- a/src/Library/Signature/Algorithm/ES256.php +++ b/src/Library/Signature/Algorithm/ES256.php @@ -4,18 +4,23 @@ namespace Jose\Component\Signature\Algorithm; -final class ES256 extends ECDSA +use Override; + +final readonly class ES256 extends ECDSA { + #[Override] public function name(): string { return 'ES256'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha256'; } + #[Override] protected function getSignaturePartLength(): int { return 64; diff --git a/src/Library/Signature/Algorithm/ES384.php b/src/Library/Signature/Algorithm/ES384.php index 764a6aed5..a9c3a62db 100644 --- a/src/Library/Signature/Algorithm/ES384.php +++ b/src/Library/Signature/Algorithm/ES384.php @@ -4,18 +4,23 @@ namespace Jose\Component\Signature\Algorithm; -final class ES384 extends ECDSA +use Override; + +final readonly class ES384 extends ECDSA { + #[Override] public function name(): string { return 'ES384'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha384'; } + #[Override] protected function getSignaturePartLength(): int { return 96; diff --git a/src/Library/Signature/Algorithm/ES512.php b/src/Library/Signature/Algorithm/ES512.php index 70cfee7d9..21a7666ed 100644 --- a/src/Library/Signature/Algorithm/ES512.php +++ b/src/Library/Signature/Algorithm/ES512.php @@ -4,18 +4,23 @@ namespace Jose\Component\Signature\Algorithm; -final class ES512 extends ECDSA +use Override; + +final readonly class ES512 extends ECDSA { + #[Override] public function name(): string { return 'ES512'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha512'; } + #[Override] protected function getSignaturePartLength(): int { return 132; diff --git a/src/Library/Signature/Algorithm/EdDSA.php b/src/Library/Signature/Algorithm/EdDSA.php index 6d59ce4d4..16ca48e47 100644 --- a/src/Library/Signature/Algorithm/EdDSA.php +++ b/src/Library/Signature/Algorithm/EdDSA.php @@ -6,7 +6,8 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; +use Override; use ParagonIE\Sodium\Core\Ed25519; use RuntimeException; use function assert; @@ -14,7 +15,7 @@ use function in_array; use function is_string; -final class EdDSA implements SignatureAlgorithm +final readonly class EdDSA implements SignatureAlgorithm { public function __construct() { @@ -23,6 +24,7 @@ public function __construct() } } + #[Override] public function allowedKeyTypes(): array { return ['OKP']; @@ -31,6 +33,7 @@ public function allowedKeyTypes(): array /** * @return non-empty-string */ + #[Override] public function sign(JWK $key, string $input): string { $this->checkKey($key); @@ -61,11 +64,12 @@ public function sign(JWK $key, string $input): string }; } - /** - * @param non-empty-string $signature - */ + #[Override] public function verify(JWK $key, string $input, string $signature): bool { + if ($signature === '') { + return false; + } $this->checkKey($key); $x = $key->get('x'); if (! is_string($x)) { @@ -81,6 +85,7 @@ public function verify(JWK $key, string $input, string $signature): bool }; } + #[Override] public function name(): string { return 'EdDSA'; diff --git a/src/Library/Signature/Algorithm/HMAC.php b/src/Library/Signature/Algorithm/HMAC.php index badda9871..f55a757b8 100644 --- a/src/Library/Signature/Algorithm/HMAC.php +++ b/src/Library/Signature/Algorithm/HMAC.php @@ -6,22 +6,26 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; +use Override; use function in_array; use function is_string; -abstract class HMAC implements MacAlgorithm +abstract readonly class HMAC implements MacAlgorithm { + #[Override] public function allowedKeyTypes(): array { return ['oct']; } + #[Override] public function verify(JWK $key, string $input, string $signature): bool { return hash_equals($this->hash($key, $input), $signature); } + #[Override] public function hash(JWK $key, string $input): string { $k = $this->getKey($key); diff --git a/src/Library/Signature/Algorithm/HS256.php b/src/Library/Signature/Algorithm/HS256.php index a27f67eb5..ba1dc83c7 100644 --- a/src/Library/Signature/Algorithm/HS256.php +++ b/src/Library/Signature/Algorithm/HS256.php @@ -6,19 +6,23 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Override; -final class HS256 extends HMAC +final readonly class HS256 extends HMAC { + #[Override] public function name(): string { return 'HS256'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha256'; } + #[Override] protected function getKey(JWK $key): string { $k = parent::getKey($key); diff --git a/src/Library/Signature/Algorithm/HS384.php b/src/Library/Signature/Algorithm/HS384.php index 17fc5c9ab..7dd18b327 100644 --- a/src/Library/Signature/Algorithm/HS384.php +++ b/src/Library/Signature/Algorithm/HS384.php @@ -6,19 +6,23 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Override; -final class HS384 extends HMAC +final readonly class HS384 extends HMAC { + #[Override] public function name(): string { return 'HS384'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha384'; } + #[Override] protected function getKey(JWK $key): string { $k = parent::getKey($key); diff --git a/src/Library/Signature/Algorithm/HS512.php b/src/Library/Signature/Algorithm/HS512.php index 4bbbd24b4..7db4b176b 100644 --- a/src/Library/Signature/Algorithm/HS512.php +++ b/src/Library/Signature/Algorithm/HS512.php @@ -6,19 +6,23 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Override; -final class HS512 extends HMAC +final readonly class HS512 extends HMAC { + #[Override] public function name(): string { return 'HS512'; } + #[Override] protected function getHashAlgorithm(): string { return 'sha512'; } + #[Override] protected function getKey(JWK $key): string { $k = parent::getKey($key); diff --git a/src/Library/Signature/Algorithm/None.php b/src/Library/Signature/Algorithm/None.php index be9e48731..417a337fd 100644 --- a/src/Library/Signature/Algorithm/None.php +++ b/src/Library/Signature/Algorithm/None.php @@ -6,15 +6,18 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Override; use function in_array; -final class None implements SignatureAlgorithm +final readonly class None implements SignatureAlgorithm { + #[Override] public function allowedKeyTypes(): array { return ['none']; } + #[Override] public function sign(JWK $key, string $input): string { $this->checkKey($key); @@ -22,11 +25,13 @@ public function sign(JWK $key, string $input): string return ''; } + #[Override] public function verify(JWK $key, string $input, string $signature): bool { return $signature === ''; } + #[Override] public function name(): string { return 'none'; diff --git a/src/Library/Signature/Algorithm/PS256.php b/src/Library/Signature/Algorithm/PS256.php index 8b4ea3167..3a7e550c7 100644 --- a/src/Library/Signature/Algorithm/PS256.php +++ b/src/Library/Signature/Algorithm/PS256.php @@ -4,13 +4,17 @@ namespace Jose\Component\Signature\Algorithm; -final class PS256 extends RSAPSS +use Override; + +final readonly class PS256 extends RSAPSS { + #[Override] public function name(): string { return 'PS256'; } + #[Override] protected function getAlgorithm(): string { return 'sha256'; diff --git a/src/Library/Signature/Algorithm/PS384.php b/src/Library/Signature/Algorithm/PS384.php index 36f37df26..f55cc4885 100644 --- a/src/Library/Signature/Algorithm/PS384.php +++ b/src/Library/Signature/Algorithm/PS384.php @@ -4,13 +4,17 @@ namespace Jose\Component\Signature\Algorithm; -final class PS384 extends RSAPSS +use Override; + +final readonly class PS384 extends RSAPSS { + #[Override] public function name(): string { return 'PS384'; } + #[Override] protected function getAlgorithm(): string { return 'sha384'; diff --git a/src/Library/Signature/Algorithm/PS512.php b/src/Library/Signature/Algorithm/PS512.php index 929b989e6..912efb3f7 100644 --- a/src/Library/Signature/Algorithm/PS512.php +++ b/src/Library/Signature/Algorithm/PS512.php @@ -4,13 +4,17 @@ namespace Jose\Component\Signature\Algorithm; -final class PS512 extends RSAPSS +use Override; + +final readonly class PS512 extends RSAPSS { + #[Override] public function name(): string { return 'PS512'; } + #[Override] protected function getAlgorithm(): string { return 'sha512'; diff --git a/src/Library/Signature/Algorithm/RS256.php b/src/Library/Signature/Algorithm/RS256.php index 02f6bd7f0..edff7a2ce 100644 --- a/src/Library/Signature/Algorithm/RS256.php +++ b/src/Library/Signature/Algorithm/RS256.php @@ -4,13 +4,17 @@ namespace Jose\Component\Signature\Algorithm; -final class RS256 extends RSAPKCS1 +use Override; + +final readonly class RS256 extends RSAPKCS1 { + #[Override] public function name(): string { return 'RS256'; } + #[Override] protected function getAlgorithm(): string { return 'sha256'; diff --git a/src/Library/Signature/Algorithm/RS384.php b/src/Library/Signature/Algorithm/RS384.php index 13d6893ae..c104df4c2 100644 --- a/src/Library/Signature/Algorithm/RS384.php +++ b/src/Library/Signature/Algorithm/RS384.php @@ -4,13 +4,17 @@ namespace Jose\Component\Signature\Algorithm; -final class RS384 extends RSAPKCS1 +use Override; + +final readonly class RS384 extends RSAPKCS1 { + #[Override] public function name(): string { return 'RS384'; } + #[Override] protected function getAlgorithm(): string { return 'sha384'; diff --git a/src/Library/Signature/Algorithm/RS512.php b/src/Library/Signature/Algorithm/RS512.php index cb9f3f00c..2a45f4851 100644 --- a/src/Library/Signature/Algorithm/RS512.php +++ b/src/Library/Signature/Algorithm/RS512.php @@ -4,13 +4,17 @@ namespace Jose\Component\Signature\Algorithm; -final class RS512 extends RSAPKCS1 +use Override; + +final readonly class RS512 extends RSAPKCS1 { + #[Override] public function name(): string { return 'RS512'; } + #[Override] protected function getAlgorithm(): string { return 'sha512'; diff --git a/src/Library/Signature/Algorithm/RSAPKCS1.php b/src/Library/Signature/Algorithm/RSAPKCS1.php index 8e135f73b..54ce2fdfa 100644 --- a/src/Library/Signature/Algorithm/RSAPKCS1.php +++ b/src/Library/Signature/Algorithm/RSAPKCS1.php @@ -7,11 +7,12 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; use Jose\Component\Core\Util\RSAKey; +use Override; use RuntimeException; use function extension_loaded; use function in_array; -abstract class RSAPKCS1 implements SignatureAlgorithm +abstract readonly class RSAPKCS1 implements SignatureAlgorithm { public function __construct() { @@ -20,11 +21,13 @@ public function __construct() } } + #[Override] public function allowedKeyTypes(): array { return ['RSA']; } + #[Override] public function verify(JWK $key, string $input, string $signature): bool { $this->checkKey($key); @@ -33,6 +36,7 @@ public function verify(JWK $key, string $input, string $signature): bool return openssl_verify($input, $signature, $pub->toPEM(), $this->getAlgorithm()) === 1; } + #[Override] public function sign(JWK $key, string $input): string { $this->checkKey($key); diff --git a/src/Library/Signature/Algorithm/RSAPSS.php b/src/Library/Signature/Algorithm/RSAPSS.php index 46dafec01..8d5511e27 100644 --- a/src/Library/Signature/Algorithm/RSAPSS.php +++ b/src/Library/Signature/Algorithm/RSAPSS.php @@ -8,15 +8,18 @@ use Jose\Component\Core\JWK; use Jose\Component\Core\Util\RSAKey; use Jose\Component\Signature\Algorithm\Util\RSA as JoseRSA; +use Override; use function in_array; -abstract class RSAPSS implements SignatureAlgorithm +abstract readonly class RSAPSS implements SignatureAlgorithm { + #[Override] public function allowedKeyTypes(): array { return ['RSA']; } + #[Override] public function verify(JWK $key, string $input, string $signature): bool { $this->checkKey($key); @@ -28,6 +31,7 @@ public function verify(JWK $key, string $input, string $signature): bool /** * @return non-empty-string */ + #[Override] public function sign(JWK $key, string $input): string { $this->checkKey($key); diff --git a/src/Library/Signature/Algorithm/SignatureAlgorithm.php b/src/Library/Signature/Algorithm/SignatureAlgorithm.php index a283d1dd7..3dd0b1cd9 100644 --- a/src/Library/Signature/Algorithm/SignatureAlgorithm.php +++ b/src/Library/Signature/Algorithm/SignatureAlgorithm.php @@ -21,8 +21,8 @@ public function sign(JWK $key, string $input): string; * Verify the signature of data. * * @param JWK $key The private key used to sign the data - * @param non-empty-string $input The input - * @param non-empty-string $signature The signature to verify + * @param string $input The input + * @param string $signature The signature to verify */ public function verify(JWK $key, string $input, string $signature): bool; } diff --git a/src/Library/Signature/Algorithm/Util/RSA.php b/src/Library/Signature/Algorithm/Util/RSA.php index 75e0e2ce9..9f6d015df 100644 --- a/src/Library/Signature/Algorithm/Util/RSA.php +++ b/src/Library/Signature/Algorithm/Util/RSA.php @@ -17,7 +17,7 @@ /** * @internal */ -final class RSA +final readonly class RSA { /** * Probabilistic Signature Scheme. @@ -61,7 +61,7 @@ public static function sign(RSAKey $key, string $message, string $hash, int $mod */ public static function signWithPSS(RSAKey $key, string $message, string $hash): string { - $em = self::encodeEMSAPSS($message, 8 * $key->getModulusLength() - 1, Hash::$hash()); + $em = self::encodeEMSAPSS($message, 8 * $key->getModulusLength() - 1, Hash::get($hash)); $message = BigInteger::createFromBinaryString($em); $signature = RSAKey::exponentiate($key, $message); $result = self::convertIntegerToOctetString($signature, $key->getModulusLength()); @@ -100,7 +100,7 @@ public static function verifyWithPSS(RSAKey $key, string $message, string $signa $em = self::convertIntegerToOctetString($m2, $key->getModulusLength()); $modBits = 8 * $key->getModulusLength(); - return self::verifyEMSAPSS($message, $em, $modBits - 1, Hash::$hash()); + return self::verifyEMSAPSS($message, $em, $modBits - 1, Hash::get($hash)); } private static function convertIntegerToOctetString(BigInteger $x, int $xLen): string diff --git a/src/Library/Signature/JWS.php b/src/Library/Signature/JWS.php index 715ddcc11..27bb832d1 100644 --- a/src/Library/Signature/JWS.php +++ b/src/Library/Signature/JWS.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Jose\Component\Core\JWT; +use Override; use function count; /** @@ -25,6 +26,7 @@ public function __construct( ) { } + #[Override] public function getPayload(): ?string { return $this->payload; diff --git a/src/Library/Signature/JWSBuilder.php b/src/Library/Signature/JWSBuilder.php index 84201cc6c..3c1a1661d 100644 --- a/src/Library/Signature/JWSBuilder.php +++ b/src/Library/Signature/JWSBuilder.php @@ -8,12 +8,12 @@ use Jose\Component\Core\Algorithm; use Jose\Component\Core\AlgorithmManager; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\Core\Util\KeyChecker; use Jose\Component\Signature\Algorithm\MacAlgorithm; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; use LogicException; -use ParagonIE\ConstantTime\Base64UrlSafe; use RuntimeException; use function array_key_exists; use function count; diff --git a/src/Library/Signature/JWSTokenSupport.php b/src/Library/Signature/JWSTokenSupport.php index 607d66245..31116e62a 100644 --- a/src/Library/Signature/JWSTokenSupport.php +++ b/src/Library/Signature/JWSTokenSupport.php @@ -7,9 +7,11 @@ use InvalidArgumentException; use Jose\Component\Checker\TokenTypeSupport; use Jose\Component\Core\JWT; +use Override; final class JWSTokenSupport implements TokenTypeSupport { + #[Override] public function supports(JWT $jwt): bool { return $jwt instanceof JWS; @@ -19,6 +21,7 @@ public function supports(JWT $jwt): bool * @param array $protectedHeader * @param array $unprotectedHeader */ + #[Override] public function retrieveTokenHeaders(JWT $jwt, int $index, array &$protectedHeader, array &$unprotectedHeader): void { if (! $jwt instanceof JWS) { diff --git a/src/Library/Signature/JWSVerifier.php b/src/Library/Signature/JWSVerifier.php index d750a507d..545436727 100644 --- a/src/Library/Signature/JWSVerifier.php +++ b/src/Library/Signature/JWSVerifier.php @@ -9,10 +9,10 @@ use Jose\Component\Core\AlgorithmManager; use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\KeyChecker; use Jose\Component\Signature\Algorithm\MacAlgorithm; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; -use ParagonIE\ConstantTime\Base64UrlSafe; use Throwable; class JWSVerifier diff --git a/src/Library/Signature/Serializer/CompactSerializer.php b/src/Library/Signature/Serializer/CompactSerializer.php index 55b5a0f7e..191973c3e 100644 --- a/src/Library/Signature/Serializer/CompactSerializer.php +++ b/src/Library/Signature/Serializer/CompactSerializer.php @@ -5,28 +5,32 @@ namespace Jose\Component\Signature\Serializer; use InvalidArgumentException; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\Signature\JWS; use LogicException; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use Throwable; use function count; use function is_array; -final class CompactSerializer extends Serializer +final readonly class CompactSerializer extends Serializer { public const string NAME = 'jws_compact'; + #[Override] public function displayName(): string { return 'JWS Compact'; } + #[Override] public function name(): string { return self::NAME; } + #[Override] public function serialize(JWS $jws, ?int $signatureIndex = null): string { if ($signatureIndex === null) { @@ -53,6 +57,7 @@ public function serialize(JWS $jws, ?int $signatureIndex = null): string ); } + #[Override] public function unserialize(string $input): JWS { $parts = explode('.', $input); diff --git a/src/Library/Signature/Serializer/JSONFlattenedSerializer.php b/src/Library/Signature/Serializer/JSONFlattenedSerializer.php index 342d910b4..aa94d51ed 100644 --- a/src/Library/Signature/Serializer/JSONFlattenedSerializer.php +++ b/src/Library/Signature/Serializer/JSONFlattenedSerializer.php @@ -5,26 +5,30 @@ namespace Jose\Component\Signature\Serializer; use InvalidArgumentException; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\Signature\JWS; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use function count; use function is_array; -final class JSONFlattenedSerializer extends Serializer +final readonly class JSONFlattenedSerializer extends Serializer { public const string NAME = 'jws_json_flattened'; + #[Override] public function displayName(): string { return 'JWS JSON Flattened'; } + #[Override] public function name(): string { return self::NAME; } + #[Override] public function serialize(JWS $jws, ?int $signatureIndex = null): string { if ($signatureIndex === null) { @@ -50,6 +54,7 @@ public function serialize(JWS $jws, ?int $signatureIndex = null): string return JsonConverter::encode($data); } + #[Override] public function unserialize(string $input): JWS { $data = JsonConverter::decode($input); diff --git a/src/Library/Signature/Serializer/JSONGeneralSerializer.php b/src/Library/Signature/Serializer/JSONGeneralSerializer.php index 4329b0e3f..4f7d88664 100644 --- a/src/Library/Signature/Serializer/JSONGeneralSerializer.php +++ b/src/Library/Signature/Serializer/JSONGeneralSerializer.php @@ -5,29 +5,33 @@ namespace Jose\Component\Signature\Serializer; use InvalidArgumentException; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\Signature\JWS; use LogicException; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Override; use function array_key_exists; use function count; use function is_array; use function is_string; -final class JSONGeneralSerializer extends Serializer +final readonly class JSONGeneralSerializer extends Serializer { public const string NAME = 'jws_json_general'; + #[Override] public function displayName(): string { return 'JWS JSON General'; } + #[Override] public function name(): string { return self::NAME; } + #[Override] public function serialize(JWS $jws, ?int $signatureIndex = null): string { if ($jws->countSignatures() === 0) { @@ -62,6 +66,7 @@ public function serialize(JWS $jws, ?int $signatureIndex = null): string return JsonConverter::encode($data); } + #[Override] public function unserialize(string $input): JWS { $data = JsonConverter::decode($input); diff --git a/src/Library/Signature/Serializer/JWSSerializerManager.php b/src/Library/Signature/Serializer/JWSSerializerManager.php index fdf5b481c..74339c8e3 100644 --- a/src/Library/Signature/Serializer/JWSSerializerManager.php +++ b/src/Library/Signature/Serializer/JWSSerializerManager.php @@ -7,7 +7,7 @@ use InvalidArgumentException; use Jose\Component\Signature\JWS; -class JWSSerializerManager +final class JWSSerializerManager { /** * @var JWSSerializer[] diff --git a/src/Library/Signature/Serializer/JWSSerializerManagerFactory.php b/src/Library/Signature/Serializer/JWSSerializerManagerFactory.php index 361fb9fec..dd2b3c3a7 100644 --- a/src/Library/Signature/Serializer/JWSSerializerManagerFactory.php +++ b/src/Library/Signature/Serializer/JWSSerializerManagerFactory.php @@ -6,7 +6,7 @@ use InvalidArgumentException; -class JWSSerializerManagerFactory +final class JWSSerializerManagerFactory { /** * @var JWSSerializer[] diff --git a/src/Library/Signature/Serializer/Serializer.php b/src/Library/Signature/Serializer/Serializer.php index 541d3e2ec..0e2663db3 100644 --- a/src/Library/Signature/Serializer/Serializer.php +++ b/src/Library/Signature/Serializer/Serializer.php @@ -6,7 +6,7 @@ use function array_key_exists; -abstract class Serializer implements JWSSerializer +abstract readonly class Serializer implements JWSSerializer { /** * @param array $protectedHeader diff --git a/src/Library/composer.json b/src/Library/composer.json index e21514079..0fa473ea1 100644 --- a/src/Library/composer.json +++ b/src/Library/composer.json @@ -42,12 +42,8 @@ "ext-json": "*", "ext-mbstring": "*", "brick/math": "^0.12", - "paragonie/constant_time_encoding": "^2.6", - "paragonie/sodium_compat": "^1.20", "psr/clock": "^1.0", - "spomky-labs/pki-framework": "^1.1", - "symfony/console": "^7.0", - "symfony/http-client": "^7.0" + "spomky-labs/pki-framework": "^1.1" }, "conflict": { "spomky-labs/jose": "*" @@ -58,7 +54,8 @@ "ext-bcmath": "GMP or BCMath is highly recommended to improve the library performance", "ext-sodium": "Sodium is required for OKP key creation, EdDSA signature algorithm and ECDH-ES key encryption with OKP keys", "paragonie/sodium_compat": "Sodium is required for OKP key creation, EdDSA signature algorithm and ECDH-ES key encryption with OKP keys", + "symfony/console": "Needed to use console commands", "symfony/http-client": "To enable JKU/X5U support.", - "spomky-labs/aes-key-wrap": "For all Key Wrapping algorithms (A128KW, A192KW, A256KW, A128GCMKW, A192GCMKW, A256GCMKW, PBES2-HS256+A128KW, PBES2-HS384+A192KW, PBES2-HS512+A256KW...)" + "spomky-labs/aes-key-wrap": "For all Key Wrapping algorithms (AxxxKW, AxxxGCMKW, PBES2-HSxxx+AyyyKW...)" } } diff --git a/tests/Bundle/JoseFramework/AppKernel.php b/tests/Bundle/JoseFramework/AppKernel.php index 6e5db505b..d9b79276e 100644 --- a/tests/Bundle/JoseFramework/AppKernel.php +++ b/tests/Bundle/JoseFramework/AppKernel.php @@ -12,9 +12,9 @@ * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ - use Jose\Bundle\JoseFramework\JoseFrameworkBundle; use Jose\Tests\Bundle\JoseFramework\TestBundle\TestBundle; +use Override; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\HttpKernel\Bundle\BundleInterface; @@ -30,11 +30,13 @@ public function __construct(string $environment) /** * @return BundleInterface[] */ + #[Override] public function registerBundles(): array { return [new FrameworkBundle(), new JoseFrameworkBundle(), new TestBundle()]; } + #[Override] public function registerContainerConfiguration(LoaderInterface $loader): void { $loader->load(__DIR__ . '/config/config_' . $this->getEnvironment() . '.yml'); diff --git a/tests/Bundle/JoseFramework/Functional/KeyManagement/JWKLoaderTest.php b/tests/Bundle/JoseFramework/Functional/KeyManagement/JWKLoaderTest.php index a5e81b93b..098794111 100644 --- a/tests/Bundle/JoseFramework/Functional/KeyManagement/JWKLoaderTest.php +++ b/tests/Bundle/JoseFramework/Functional/KeyManagement/JWKLoaderTest.php @@ -5,7 +5,7 @@ namespace Jose\Tests\Bundle\JoseFramework\Functional\KeyManagement; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; diff --git a/tests/Bundle/JoseFramework/TestBundle/Checker/CustomChecker.php b/tests/Bundle/JoseFramework/TestBundle/Checker/CustomChecker.php index c38483788..da9edbb23 100644 --- a/tests/Bundle/JoseFramework/TestBundle/Checker/CustomChecker.php +++ b/tests/Bundle/JoseFramework/TestBundle/Checker/CustomChecker.php @@ -7,9 +7,11 @@ use InvalidArgumentException; use Jose\Component\Checker\ClaimChecker; use Jose\Component\Checker\HeaderChecker; +use Override; class CustomChecker implements ClaimChecker, HeaderChecker { + #[Override] public function checkClaim($value): void { if ($value === true) { @@ -17,11 +19,13 @@ public function checkClaim($value): void } } + #[Override] public function supportedClaim(): string { return 'custom'; } + #[Override] public function checkHeader($value): void { if ($value === true) { @@ -29,11 +33,13 @@ public function checkHeader($value): void } } + #[Override] public function supportedHeader(): string { return 'custom'; } + #[Override] public function protectedHeaderOnly(): bool { return true; diff --git a/tests/Bundle/JoseFramework/TestBundle/DependencyInjection/TestExtension.php b/tests/Bundle/JoseFramework/TestBundle/DependencyInjection/TestExtension.php index 605b08661..b4a5aa698 100644 --- a/tests/Bundle/JoseFramework/TestBundle/DependencyInjection/TestExtension.php +++ b/tests/Bundle/JoseFramework/TestBundle/DependencyInjection/TestExtension.php @@ -5,20 +5,23 @@ namespace Jose\Tests\Bundle\JoseFramework\TestBundle\DependencyInjection; use Jose\Bundle\JoseFramework\Helper\ConfigurationHelper; +use Override; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -class TestExtension extends Extension implements PrependExtensionInterface +final class TestExtension extends Extension implements PrependExtensionInterface { + #[Override] public function load(array $configs, ContainerBuilder $container): void { $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.php'); } + #[Override] public function prepend(ContainerBuilder $container): void { ConfigurationHelper::addKey($container, 'jwk2', 'jwk', [ diff --git a/tests/Component/Checker/Stub/MockClock.php b/tests/Component/Checker/Stub/MockClock.php index d0524a8e4..35fe03a53 100644 --- a/tests/Component/Checker/Stub/MockClock.php +++ b/tests/Component/Checker/Stub/MockClock.php @@ -5,15 +5,17 @@ namespace Jose\Tests\Component\Checker\Stub; use DateTimeImmutable; +use Override; use Psr\Clock\ClockInterface; -final class MockClock implements ClockInterface +final readonly class MockClock implements ClockInterface { public function __construct( - private readonly DateTimeImmutable $now = new DateTimeImmutable(), + private DateTimeImmutable $now = new DateTimeImmutable(), ) { } + #[Override] public function now(): DateTimeImmutable { return $this->now; diff --git a/tests/Component/Checker/Stub/OtherToken.php b/tests/Component/Checker/Stub/OtherToken.php index 5bec6d976..5a4f03bdc 100644 --- a/tests/Component/Checker/Stub/OtherToken.php +++ b/tests/Component/Checker/Stub/OtherToken.php @@ -5,6 +5,7 @@ namespace Jose\Tests\Component\Checker\Stub; use Jose\Component\Core\JWT; +use Override; class OtherToken implements JWT { @@ -15,6 +16,7 @@ public function __construct( ) { } + #[Override] public function getPayload(): ?string { return $this->payload; diff --git a/tests/Component/Checker/Stub/Token.php b/tests/Component/Checker/Stub/Token.php index 0cb9f7d7e..5b1691895 100644 --- a/tests/Component/Checker/Stub/Token.php +++ b/tests/Component/Checker/Stub/Token.php @@ -5,8 +5,9 @@ namespace Jose\Tests\Component\Checker\Stub; use Jose\Component\Core\JWT; +use Override; -class Token implements JWT +final readonly class Token implements JWT { public function __construct( private readonly ?string $payload, @@ -15,6 +16,7 @@ public function __construct( ) { } + #[Override] public function getPayload(): ?string { return $this->payload; diff --git a/tests/Component/Checker/Stub/TokenSupport.php b/tests/Component/Checker/Stub/TokenSupport.php index ad0fd80e3..d2af99933 100644 --- a/tests/Component/Checker/Stub/TokenSupport.php +++ b/tests/Component/Checker/Stub/TokenSupport.php @@ -7,13 +7,15 @@ use InvalidArgumentException; use Jose\Component\Checker\TokenTypeSupport; use Jose\Component\Core\JWT; +use Override; -class TokenSupport implements TokenTypeSupport +final readonly class TokenSupport implements TokenTypeSupport { /** * @param array $protectedHeader * @param array $unprotectedHeader */ + #[Override] public function retrieveTokenHeaders(JWT $jwt, int $index, array &$protectedHeader, array &$unprotectedHeader): void { if (! $jwt instanceof Token) { @@ -23,6 +25,7 @@ public function retrieveTokenHeaders(JWT $jwt, int $index, array &$protectedHead $unprotectedHeader = $jwt->getUnprotectedHeader(); } + #[Override] public function supports(JWT $jwt): bool { return $jwt instanceof Token; diff --git a/tests/Component/Console/KeyCreationCommandTest.php b/tests/Component/Console/KeyCreationCommandTest.php index 3dc3b4251..fb6ecfc1f 100644 --- a/tests/Component/Console/KeyCreationCommandTest.php +++ b/tests/Component/Console/KeyCreationCommandTest.php @@ -12,7 +12,7 @@ use Jose\Component\Console\RsaKeyGeneratorCommand; use Jose\Component\Console\SecretKeyGeneratorCommand; use Jose\Component\Core\JWK; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/Component/Core/FooAlgorithm.php b/tests/Component/Core/FooAlgorithm.php index b01154685..dcb02d518 100644 --- a/tests/Component/Core/FooAlgorithm.php +++ b/tests/Component/Core/FooAlgorithm.php @@ -5,14 +5,17 @@ namespace Jose\Tests\Component\Core; use Jose\Component\Core\Algorithm; +use Override; class FooAlgorithm implements Algorithm { + #[Override] public function name(): string { return 'foo'; } + #[Override] public function allowedKeyTypes(): array { return ['FOO']; diff --git a/tests/Component/Encryption/EncrypterTest.php b/tests/Component/Encryption/EncrypterTest.php index 02cd957d9..ced636dac 100644 --- a/tests/Component/Encryption/EncrypterTest.php +++ b/tests/Component/Encryption/EncrypterTest.php @@ -7,7 +7,7 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use const JSON_THROW_ON_ERROR; diff --git a/tests/Component/Encryption/JWEFlattenedTest.php b/tests/Component/Encryption/JWEFlattenedTest.php index fd4e21a3e..efe9afcbe 100644 --- a/tests/Component/Encryption/JWEFlattenedTest.php +++ b/tests/Component/Encryption/JWEFlattenedTest.php @@ -5,7 +5,7 @@ namespace Jose\Tests\Component\Encryption; use Jose\Component\Core\JWKSet; -use ParagonIE\ConstantTime\Base64UrlSafe; +use Jose\Component\Core\Util\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php index fae1ff622..f02edbf22 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionProtectedContentOnlyTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php index 5a42d8e81..fa5882300 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php index e0dbc1766..7fa678b2b 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithAdditionalAuthenticatedDataTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php index 5311b9fe9..6ed875fd6 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php index e62dd5494..da8dadf7d 100644 --- a/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php +++ b/tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithSpecificProtectedHeaderValuesTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php b/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php index 8858445e1..2a2afec60 100644 --- a/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/A256GCMKWAndA128CBC_HS256EncryptionTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php b/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php index 9c98d0118..8dde1fe07 100644 --- a/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/DirAndA128GCMEncryptionTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php b/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php index 0ac5faf70..93fe1d1f3 100644 --- a/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/ECDH_ES_A128KWAndA128GCMEncryptionTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php b/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php index 045db225e..cd0bf4d3f 100644 --- a/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/ECDH_ES_AndA128CBC_HS256EncryptionTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php b/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php index eae257f36..88c43e0b2 100644 --- a/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/MultipleRecipientEncryptionTest.php @@ -6,8 +6,8 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php b/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php index fe8c16a2b..74f654a8d 100644 --- a/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/PBES2_HS512_A256KWAndA128CBC_HS256EncryptionTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use const JSON_THROW_ON_ERROR; diff --git a/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php b/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php index 8c8796809..01b3b2dfe 100644 --- a/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/RSA1_5AndA128CBC_HS256EncryptionTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php b/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php index 1a8491304..5e58170f9 100644 --- a/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php +++ b/tests/Component/Encryption/RFC7520/RSA_OAEPAndA256GCMEncryptionTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\Component\Encryption\RFC7520; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Tests\Component\Encryption\EncryptionTestCase; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; /** diff --git a/tests/Component/Encryption/RSAKeyEncryptionTest.php b/tests/Component/Encryption/RSAKeyEncryptionTest.php index de91fd445..daefc60f1 100644 --- a/tests/Component/Encryption/RSAKeyEncryptionTest.php +++ b/tests/Component/Encryption/RSAKeyEncryptionTest.php @@ -7,10 +7,10 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\KeyEncryption\RSA15; use Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP; use Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP256; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use const STR_PAD_LEFT; diff --git a/tests/Component/KeyManagement/FooAlgorithm.php b/tests/Component/KeyManagement/FooAlgorithm.php index 88aac35ef..1d0cd18be 100644 --- a/tests/Component/KeyManagement/FooAlgorithm.php +++ b/tests/Component/KeyManagement/FooAlgorithm.php @@ -5,14 +5,17 @@ namespace Jose\Tests\Component\KeyManagement; use Jose\Component\Core\Algorithm; +use Override; class FooAlgorithm implements Algorithm { + #[Override] public function name(): string { return 'foo'; } + #[Override] public function allowedKeyTypes(): array { return ['FOO']; diff --git a/tests/Component/KeyManagement/JWKFactoryTest.php b/tests/Component/KeyManagement/JWKFactoryTest.php index c777b5034..0ca4f796a 100644 --- a/tests/Component/KeyManagement/JWKFactoryTest.php +++ b/tests/Component/KeyManagement/JWKFactoryTest.php @@ -4,9 +4,9 @@ namespace Jose\Tests\Component\KeyManagement; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\ECKey; use Jose\Component\KeyManagement\JWKFactory; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/Component/KeyManagement/JWKTest.php b/tests/Component/KeyManagement/JWKTest.php index f76e9d917..2d37dbf42 100644 --- a/tests/Component/KeyManagement/JWKTest.php +++ b/tests/Component/KeyManagement/JWKTest.php @@ -7,9 +7,9 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Core\Util\RSAKey; use Jose\Component\KeyManagement\JWKFactory; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use const JSON_THROW_ON_ERROR; diff --git a/tests/Component/Signature/JWSTest.php b/tests/Component/Signature/JWSTest.php index f2c0c409a..31ff5869c 100644 --- a/tests/Component/Signature/JWSTest.php +++ b/tests/Component/Signature/JWSTest.php @@ -5,9 +5,9 @@ namespace Jose\Tests\Component\Signature; use InvalidArgumentException; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Signature\JWS; use LogicException; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use const JSON_THROW_ON_ERROR; diff --git a/tests/Component/Signature/SignerTest.php b/tests/Component/Signature/SignerTest.php index 80a66d07c..e24e7a38b 100644 --- a/tests/Component/Signature/SignerTest.php +++ b/tests/Component/Signature/SignerTest.php @@ -7,9 +7,9 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Signature\Serializer\CompactSerializer; use LogicException; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use const JSON_THROW_ON_ERROR; diff --git a/tests/ComposerJsonTest.php b/tests/ComposerJsonTest.php index de4a287cc..c66619416 100644 --- a/tests/ComposerJsonTest.php +++ b/tests/ComposerJsonTest.php @@ -18,7 +18,7 @@ */ final class ComposerJsonTest extends TestCase { - private const SRC_DIR = __DIR__ . '/../src'; + private const string SRC_DIR = __DIR__ . '/../src'; #[Test] public function packageDependenciesEqualRootDependencies(): void diff --git a/tests/EncryptionAlgorithm/ContentEncryption/AESCBC/AESCBC_HSContentEncryptionTest.php b/tests/EncryptionAlgorithm/ContentEncryption/AESCBC/AESCBC_HSContentEncryptionTest.php index f45cf3868..2f3bad203 100644 --- a/tests/EncryptionAlgorithm/ContentEncryption/AESCBC/AESCBC_HSContentEncryptionTest.php +++ b/tests/EncryptionAlgorithm/ContentEncryption/AESCBC/AESCBC_HSContentEncryptionTest.php @@ -4,10 +4,10 @@ namespace Jose\Tests\EncryptionAlgorithm\ContentEncryption\AESCBC; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\ContentEncryption\A128CBCHS256; use Jose\Component\Encryption\Algorithm\ContentEncryption\A192CBCHS384; use Jose\Component\Encryption\Algorithm\ContentEncryption\A256CBCHS512; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use ReflectionClass; diff --git a/tests/EncryptionAlgorithm/ContentEncryption/AESGCM/AESGCMContentEncryptionTest.php b/tests/EncryptionAlgorithm/ContentEncryption/AESGCM/AESGCMContentEncryptionTest.php index d3cd7f12d..11a15e1b8 100644 --- a/tests/EncryptionAlgorithm/ContentEncryption/AESGCM/AESGCMContentEncryptionTest.php +++ b/tests/EncryptionAlgorithm/ContentEncryption/AESGCM/AESGCMContentEncryptionTest.php @@ -4,10 +4,10 @@ namespace Jose\Tests\EncryptionAlgorithm\ContentEncryption\AESGCM; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\ContentEncryption\A128GCM; use Jose\Component\Encryption\Algorithm\ContentEncryption\A192GCM; use Jose\Component\Encryption\Algorithm\ContentEncryption\A256GCM; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use const STR_PAD_LEFT; diff --git a/tests/EncryptionAlgorithm/Experimental/Chacha20Poly1305ContentEncryptionTest.php b/tests/EncryptionAlgorithm/Experimental/Chacha20Poly1305ContentEncryptionTest.php index e09abb4d4..5e112b053 100644 --- a/tests/EncryptionAlgorithm/Experimental/Chacha20Poly1305ContentEncryptionTest.php +++ b/tests/EncryptionAlgorithm/Experimental/Chacha20Poly1305ContentEncryptionTest.php @@ -6,6 +6,7 @@ use Jose\Component\Core\JWK; use Jose\Experimental\KeyEncryption\Chacha20Poly1305; +use Override; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Throwable; @@ -16,6 +17,7 @@ */ final class Chacha20Poly1305ContentEncryptionTest extends TestCase { + #[Override] protected function setUp(): void { if (! in_array('chacha20-poly1305', openssl_get_cipher_methods(), true)) { diff --git a/tests/EncryptionAlgorithm/KeyEncryption/AESGCMKW/AESGCMKWKeyEncryptionTest.php b/tests/EncryptionAlgorithm/KeyEncryption/AESGCMKW/AESGCMKWKeyEncryptionTest.php index 409033898..e97a450da 100644 --- a/tests/EncryptionAlgorithm/KeyEncryption/AESGCMKW/AESGCMKWKeyEncryptionTest.php +++ b/tests/EncryptionAlgorithm/KeyEncryption/AESGCMKW/AESGCMKWKeyEncryptionTest.php @@ -6,10 +6,10 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\KeyEncryption\A128GCMKW; use Jose\Component\Encryption\Algorithm\KeyEncryption\A192GCMKW; use Jose\Component\Encryption\Algorithm\KeyEncryption\A256GCMKW; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/EncryptionAlgorithm/KeyEncryption/AESKW/AESKWKeyEncryptionTest.php b/tests/EncryptionAlgorithm/KeyEncryption/AESKW/AESKWKeyEncryptionTest.php index 3f7117e90..9013745a6 100644 --- a/tests/EncryptionAlgorithm/KeyEncryption/AESKW/AESKWKeyEncryptionTest.php +++ b/tests/EncryptionAlgorithm/KeyEncryption/AESKW/AESKWKeyEncryptionTest.php @@ -6,10 +6,10 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\KeyEncryption\A128KW; use Jose\Component\Encryption\Algorithm\KeyEncryption\A192KW; use Jose\Component\Encryption\Algorithm\KeyEncryption\A256KW; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/EncryptionAlgorithm/KeyEncryption/Direct/DirAlgorithmTest.php b/tests/EncryptionAlgorithm/KeyEncryption/Direct/DirAlgorithmTest.php index 6f249c9c6..5ba32c12a 100644 --- a/tests/EncryptionAlgorithm/KeyEncryption/Direct/DirAlgorithmTest.php +++ b/tests/EncryptionAlgorithm/KeyEncryption/Direct/DirAlgorithmTest.php @@ -6,8 +6,8 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\KeyEncryption\Dir; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/EncryptionAlgorithm/KeyEncryption/ECDHES/ECDHESKeyAgreementTest.php b/tests/EncryptionAlgorithm/KeyEncryption/ECDHES/ECDHESKeyAgreementTest.php index 922b329c9..79bf42a7e 100644 --- a/tests/EncryptionAlgorithm/KeyEncryption/ECDHES/ECDHESKeyAgreementTest.php +++ b/tests/EncryptionAlgorithm/KeyEncryption/ECDHES/ECDHESKeyAgreementTest.php @@ -6,11 +6,11 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHES; use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA128KW; use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA192KW; use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA256KW; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use const STR_PAD_LEFT; diff --git a/tests/EncryptionAlgorithm/KeyEncryption/PBES2/PBES2_HS_AESKWKeyEncryptionTest.php b/tests/EncryptionAlgorithm/KeyEncryption/PBES2/PBES2_HS_AESKWKeyEncryptionTest.php index d033c3cb6..07b61db29 100644 --- a/tests/EncryptionAlgorithm/KeyEncryption/PBES2/PBES2_HS_AESKWKeyEncryptionTest.php +++ b/tests/EncryptionAlgorithm/KeyEncryption/PBES2/PBES2_HS_AESKWKeyEncryptionTest.php @@ -6,10 +6,10 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS256A128KW; use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS384A192KW; use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS512A256KW; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use const STR_PAD_LEFT; diff --git a/tests/SignatureAlgorithm/ECDSA/ECDSAFromRFC6979Test.php b/tests/SignatureAlgorithm/ECDSA/ECDSAFromRFC6979Test.php index 40d53ed7a..eeaeb47b9 100644 --- a/tests/SignatureAlgorithm/ECDSA/ECDSAFromRFC6979Test.php +++ b/tests/SignatureAlgorithm/ECDSA/ECDSAFromRFC6979Test.php @@ -5,11 +5,11 @@ namespace Jose\Tests\SignatureAlgorithm\ECDSA; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Signature\Algorithm\ES256; use Jose\Component\Signature\Algorithm\ES384; use Jose\Component\Signature\Algorithm\ES512; use Jose\Component\Signature\Algorithm\SignatureAlgorithm; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/SignatureAlgorithm/ECDSA/ECDSASignatureTest.php b/tests/SignatureAlgorithm/ECDSA/ECDSASignatureTest.php index a6f97b2d6..fe138502a 100644 --- a/tests/SignatureAlgorithm/ECDSA/ECDSASignatureTest.php +++ b/tests/SignatureAlgorithm/ECDSA/ECDSASignatureTest.php @@ -6,10 +6,10 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Signature\Algorithm\ES256; use Jose\Component\Signature\Algorithm\ES384; use Jose\Component\Signature\Algorithm\ES512; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/SignatureAlgorithm/EdDSA/EdDSASignatureTest.php b/tests/SignatureAlgorithm/EdDSA/EdDSASignatureTest.php index 77ee9baad..b866df5b3 100644 --- a/tests/SignatureAlgorithm/EdDSA/EdDSASignatureTest.php +++ b/tests/SignatureAlgorithm/EdDSA/EdDSASignatureTest.php @@ -6,10 +6,10 @@ use Jose\Component\Core\AlgorithmManager; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Signature\Algorithm\EdDSA; use Jose\Component\Signature\JWSBuilder; use Jose\Component\Signature\JWSVerifier; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/SignatureAlgorithm/Experimental/Blake2bTest.php b/tests/SignatureAlgorithm/Experimental/Blake2bTest.php index bcc9c455d..6ad2ba597 100644 --- a/tests/SignatureAlgorithm/Experimental/Blake2bTest.php +++ b/tests/SignatureAlgorithm/Experimental/Blake2bTest.php @@ -6,8 +6,8 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Experimental\Signature\Blake2b; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Before; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -17,15 +17,15 @@ */ final class Blake2bTest extends TestCase { - private const KEY_ONE = 'GOu4rLyVCBxmxP-sbniU68ojAja5PkRdvv7vNvBCqDQ'; + private const string KEY_ONE = 'GOu4rLyVCBxmxP-sbniU68ojAja5PkRdvv7vNvBCqDQ'; - private const KEY_TWO = 'Pu7gywseH-R5HLIWnMll4rEg1ltjUPq_P9WwEzAsAb8'; + private const string KEY_TWO = 'Pu7gywseH-R5HLIWnMll4rEg1ltjUPq_P9WwEzAsAb8'; - private const CONTENTS = 'test'; + private const string CONTENTS = 'test'; - private const EXPECTED_HASH_WITH_KEY_ONE = '_TG5kmkav_YGl3I9uQiv4cm1VN6Q0zPCom4G7-p74JU'; + private const string EXPECTED_HASH_WITH_KEY_ONE = '_TG5kmkav_YGl3I9uQiv4cm1VN6Q0zPCom4G7-p74JU'; - private const SHORT_KEY = 'PIBQuM5PopdMxtmTWmyvNA'; + private const string SHORT_KEY = 'PIBQuM5PopdMxtmTWmyvNA'; private JWK $keyOne; diff --git a/tests/SignatureAlgorithm/Experimental/P256KSignatureTest.php b/tests/SignatureAlgorithm/Experimental/P256KSignatureTest.php index bcece1422..4964d81e7 100644 --- a/tests/SignatureAlgorithm/Experimental/P256KSignatureTest.php +++ b/tests/SignatureAlgorithm/Experimental/P256KSignatureTest.php @@ -5,8 +5,8 @@ namespace Jose\Tests\SignatureAlgorithm\Experimental; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Experimental\Signature\ES256K; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/SignatureAlgorithm/HMAC/HMACSignatureTest.php b/tests/SignatureAlgorithm/HMAC/HMACSignatureTest.php index 80856a43e..92b0e6c0f 100644 --- a/tests/SignatureAlgorithm/HMAC/HMACSignatureTest.php +++ b/tests/SignatureAlgorithm/HMAC/HMACSignatureTest.php @@ -6,10 +6,10 @@ use InvalidArgumentException; use Jose\Component\Core\JWK; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Signature\Algorithm\HS256; use Jose\Component\Signature\Algorithm\HS384; use Jose\Component\Signature\Algorithm\HS512; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/SignatureAlgorithm/RSA/RSASignatureTest.php b/tests/SignatureAlgorithm/RSA/RSASignatureTest.php index da510cd90..b68b27eeb 100644 --- a/tests/SignatureAlgorithm/RSA/RSASignatureTest.php +++ b/tests/SignatureAlgorithm/RSA/RSASignatureTest.php @@ -8,6 +8,7 @@ use Jose\Component\Core\AlgorithmManager; use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; +use Jose\Component\Core\Util\Base64UrlSafe; use Jose\Component\Signature\Algorithm\PS256; use Jose\Component\Signature\Algorithm\PS384; use Jose\Component\Signature\Algorithm\PS512; @@ -18,7 +19,6 @@ use Jose\Component\Signature\JWSVerifier; use Jose\Component\Signature\Serializer\CompactSerializer; use Jose\Component\Signature\Serializer\JSONGeneralSerializer; -use ParagonIE\ConstantTime\Base64UrlSafe; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use const JSON_THROW_ON_ERROR;