diff --git a/src/Component/Console/AddKeyIntoKeysetCommand.php b/src/Component/Console/AddKeyIntoKeysetCommand.php index 65f0643e..a1d3d70e 100644 --- a/src/Component/Console/AddKeyIntoKeysetCommand.php +++ b/src/Component/Console/AddKeyIntoKeysetCommand.php @@ -10,18 +10,18 @@ use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; use Jose\Component\Core\Util\JsonConverter; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[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 function configure(): void { parent::configure(); - $this->setDescription('Add a key into a key set.') + $this ->setHelp('This command adds a key at the end of a key set.') ->addArgument('jwkset', InputArgument::REQUIRED, 'The JWKSet object') ->addArgument('jwk', InputArgument::REQUIRED, 'The new JWK object'); diff --git a/src/Component/Console/EcKeyGeneratorCommand.php b/src/Component/Console/EcKeyGeneratorCommand.php index b2bf547e..5dd1f2fb 100644 --- a/src/Component/Console/EcKeyGeneratorCommand.php +++ b/src/Component/Console/EcKeyGeneratorCommand.php @@ -7,19 +7,20 @@ use InvalidArgumentException; use function is_string; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'key:generate:ec', description: 'Generate an EC key (JWK format)',)] final class EcKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:ec'; - protected function configure(): void { parent::configure(); $this->setDescription('Generate an EC key (JWK format)') - ->addArgument('curve', InputArgument::REQUIRED, 'Curve of the key.'); + ->addArgument('curve', InputArgument::REQUIRED, 'Curve of the key.') + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Component/Console/EcKeysetGeneratorCommand.php b/src/Component/Console/EcKeysetGeneratorCommand.php index e9ef502d..d5e2c652 100644 --- a/src/Component/Console/EcKeysetGeneratorCommand.php +++ b/src/Component/Console/EcKeysetGeneratorCommand.php @@ -8,18 +8,18 @@ use function is_string; use Jose\Component\Core\JWKSet; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[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 function configure(): void { parent::configure(); - $this->setDescription('Generate an EC key set (JWKSet format)') + $this ->addArgument('quantity', InputArgument::REQUIRED, 'Quantity of keys in the key set.') ->addArgument('curve', InputArgument::REQUIRED, 'Curve of the keys.'); } diff --git a/src/Component/Console/GetThumbprintCommand.php b/src/Component/Console/GetThumbprintCommand.php index 73be22a1..a9fce63f 100644 --- a/src/Component/Console/GetThumbprintCommand.php +++ b/src/Component/Console/GetThumbprintCommand.php @@ -9,19 +9,19 @@ use function is_string; use Jose\Component\Core\JWK; use Jose\Component\Core\Util\JsonConverter; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'key:thumbprint', description: 'Get the thumbprint of a JWK key.',)] final class GetThumbprintCommand extends ObjectOutputCommand { - protected static $defaultName = 'key:thumbprint'; - protected function configure(): void { parent::configure(); - $this->setDescription('Get the thumbprint of a JWK key.') + $this ->addArgument('jwk', InputArgument::REQUIRED, 'The JWK key.') ->addOption('hash', null, InputOption::VALUE_OPTIONAL, 'The hashing algorithm.', 'sha256'); } diff --git a/src/Component/Console/JKULoaderCommand.php b/src/Component/Console/JKULoaderCommand.php index e1d3f700..87ddf9c0 100644 --- a/src/Component/Console/JKULoaderCommand.php +++ b/src/Component/Console/JKULoaderCommand.php @@ -7,27 +7,27 @@ use InvalidArgumentException; use function is_string; use Jose\Component\KeyManagement\JKUFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'keyset:load:jku', description: 'Loads a key set from an url.',)] final class JKULoaderCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:load:jku'; - public function __construct( private readonly JKUFactory $jkuFactory, - ?string $name = null ) { - parent::__construct($name); + parent::__construct(); } protected function configure(): void { parent::configure(); - $this->setDescription('Loads a key set from an url.') + $this ->setHelp('This command will try to get a key set from an URL. The distant key set is a JWKSet.') - ->addArgument('url', InputArgument::REQUIRED, 'The URL'); + ->addArgument('url', InputArgument::REQUIRED, 'The URL') + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Component/Console/KeyAnalyzerCommand.php b/src/Component/Console/KeyAnalyzerCommand.php index 3cd1eafd..9408ea01 100644 --- a/src/Component/Console/KeyAnalyzerCommand.php +++ b/src/Component/Console/KeyAnalyzerCommand.php @@ -10,27 +10,26 @@ use Jose\Component\Core\JWK; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\KeyManagement\Analyzer\KeyAnalyzerManager; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'key:analyze', description: 'JWK quality analyzer.',)] final class KeyAnalyzerCommand extends Command { - protected static $defaultName = 'key:analyze'; - public function __construct( private readonly KeyAnalyzerManager $analyzerManager, - string $name = null ) { - parent::__construct($name); + parent::__construct(); } protected function configure(): void { parent::configure(); - $this->setDescription('JWK quality analyzer.') + $this ->setHelp('This command will analyze a JWK object and find security issues.') ->addArgument('jwk', InputArgument::REQUIRED, 'The JWK object'); } diff --git a/src/Component/Console/KeyFileLoaderCommand.php b/src/Component/Console/KeyFileLoaderCommand.php index 6306d861..4988c1fd 100644 --- a/src/Component/Console/KeyFileLoaderCommand.php +++ b/src/Component/Console/KeyFileLoaderCommand.php @@ -7,19 +7,19 @@ use InvalidArgumentException; use function is_string; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +#[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 function configure(): void { parent::configure(); - $this->setDescription('Loads a key from a key file (JWK format)') + $this ->addArgument('file', InputArgument::REQUIRED, 'Filename of the key.') ->addOption('secret', 's', InputOption::VALUE_OPTIONAL, 'Secret if the key is encrypted.', null); } diff --git a/src/Component/Console/KeysetAnalyzerCommand.php b/src/Component/Console/KeysetAnalyzerCommand.php index 0a09489f..dd4eddf1 100644 --- a/src/Component/Console/KeysetAnalyzerCommand.php +++ b/src/Component/Console/KeysetAnalyzerCommand.php @@ -12,28 +12,28 @@ use Jose\Component\KeyManagement\Analyzer\KeyAnalyzerManager; use Jose\Component\KeyManagement\Analyzer\KeysetAnalyzerManager; use Jose\Component\KeyManagement\Analyzer\MessageBag; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'keyset:analyze', description: 'JWKSet quality analyzer.',)] final class KeysetAnalyzerCommand extends Command { - protected static $defaultName = 'keyset:analyze'; - public function __construct( private readonly KeysetAnalyzerManager $keysetAnalyzerManager, private readonly KeyAnalyzerManager $keyAnalyzerManager, string $name = null ) { - parent::__construct($name); + parent::__construct(); } protected function configure(): void { parent::configure(); - $this->setDescription('JWKSet quality analyzer.') + $this ->setHelp('This command will analyze a JWKSet object and find security issues.') ->addArgument('jwkset', InputArgument::REQUIRED, 'The JWKSet object'); } diff --git a/src/Component/Console/MergeKeysetCommand.php b/src/Component/Console/MergeKeysetCommand.php index 032fe8aa..85b12127 100644 --- a/src/Component/Console/MergeKeysetCommand.php +++ b/src/Component/Console/MergeKeysetCommand.php @@ -8,18 +8,18 @@ use function is_array; use Jose\Component\Core\JWKSet; use Jose\Component\Core\Util\JsonConverter; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'keyset:merge', description: 'Merge several key sets into one.',)] final class MergeKeysetCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:merge'; - protected function configure(): void { parent::configure(); - $this->setDescription('Merge several key sets into one.') + $this ->setHelp( 'This command merges several key sets into one. It is very useful when you generate e.g. RSA, EC and OKP keys and you want only one key set to rule them all.' ) diff --git a/src/Component/Console/NoneKeyGeneratorCommand.php b/src/Component/Console/NoneKeyGeneratorCommand.php index 56531f7c..5f23c0b8 100644 --- a/src/Component/Console/NoneKeyGeneratorCommand.php +++ b/src/Component/Console/NoneKeyGeneratorCommand.php @@ -5,21 +5,16 @@ namespace Jose\Component\Console; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand( + name: 'key:generate:none', + description: 'Generate a none key (JWK format). This key type is only supposed to be used with the "none" algorithm.', +)] final class NoneKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:none'; - - protected function configure(): void - { - parent::configure(); - $this->setDescription( - 'Generate a none key (JWK format). This key type is only supposed to be used with the "none" algorithm.' - ); - } - protected function execute(InputInterface $input, OutputInterface $output): int { $args = $this->getOptions($input); diff --git a/src/Component/Console/OctKeyGeneratorCommand.php b/src/Component/Console/OctKeyGeneratorCommand.php index 67a7f49b..44fdb1d1 100644 --- a/src/Component/Console/OctKeyGeneratorCommand.php +++ b/src/Component/Console/OctKeyGeneratorCommand.php @@ -6,14 +6,14 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'key:generate:oct', description: 'Generate an octet key (JWK format)',)] final class OctKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:oct'; - protected function configure(): void { parent::configure(); diff --git a/src/Component/Console/OctKeysetGeneratorCommand.php b/src/Component/Console/OctKeysetGeneratorCommand.php index b73e8190..9259b65b 100644 --- a/src/Component/Console/OctKeysetGeneratorCommand.php +++ b/src/Component/Console/OctKeysetGeneratorCommand.php @@ -7,18 +7,18 @@ use InvalidArgumentException; use Jose\Component\Core\JWKSet; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[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 function configure(): void { parent::configure(); - $this->setDescription('Generate a key set with octet keys (JWK format)') + $this ->addArgument('quantity', InputArgument::REQUIRED, 'Quantity of keys in the key set.') ->addArgument('size', InputArgument::REQUIRED, 'Key size.'); } diff --git a/src/Component/Console/OkpKeyGeneratorCommand.php b/src/Component/Console/OkpKeyGeneratorCommand.php index bc120103..69dfa2da 100644 --- a/src/Component/Console/OkpKeyGeneratorCommand.php +++ b/src/Component/Console/OkpKeyGeneratorCommand.php @@ -7,14 +7,14 @@ use InvalidArgumentException; use function is_string; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[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 function configure(): void { parent::configure(); diff --git a/src/Component/Console/OkpKeysetGeneratorCommand.php b/src/Component/Console/OkpKeysetGeneratorCommand.php index d878c1db..b45b2658 100644 --- a/src/Component/Console/OkpKeysetGeneratorCommand.php +++ b/src/Component/Console/OkpKeysetGeneratorCommand.php @@ -8,18 +8,21 @@ use function is_string; use Jose\Component\Core\JWKSet; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand( + name: 'keyset:generate:okp', + description: 'Generate a key set with Octet Key Pairs keys (JWKSet format)', +)] final class OkpKeysetGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'keyset:generate:okp'; - protected function configure(): void { parent::configure(); - $this->setDescription('Generate a key set with Octet Key Pairs keys (JWKSet format)') + $this ->addArgument('quantity', InputArgument::REQUIRED, 'Quantity of keys in the key set.') ->addArgument('curve', InputArgument::REQUIRED, 'Curve of the keys.'); } diff --git a/src/Component/Console/OptimizeRsaKeyCommand.php b/src/Component/Console/OptimizeRsaKeyCommand.php index 1b085227..15322c8e 100644 --- a/src/Component/Console/OptimizeRsaKeyCommand.php +++ b/src/Component/Console/OptimizeRsaKeyCommand.php @@ -10,19 +10,20 @@ use Jose\Component\Core\JWK; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\KeyManagement\KeyConverter\RSAKey; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[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 function configure(): void { parent::configure(); - $this->setDescription('Optimize a RSA key by calculating additional primes (CRT).') - ->addArgument('jwk', InputArgument::REQUIRED, 'The RSA key.'); + $this + ->addArgument('jwk', InputArgument::REQUIRED, 'The RSA key.') + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Component/Console/P12CertificateLoaderCommand.php b/src/Component/Console/P12CertificateLoaderCommand.php index 9913e2fa..07f007cc 100644 --- a/src/Component/Console/P12CertificateLoaderCommand.php +++ b/src/Component/Console/P12CertificateLoaderCommand.php @@ -7,19 +7,19 @@ use InvalidArgumentException; use function is_string; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +#[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 function configure(): void { parent::configure(); - $this->setDescription('Load a key from a P12 certificate file.') + $this ->addArgument('file', InputArgument::REQUIRED, 'Filename of the P12 certificate.') ->addOption('secret', 's', InputOption::VALUE_OPTIONAL, 'Secret if the key is encrypted.', null); } diff --git a/src/Component/Console/PemConverterCommand.php b/src/Component/Console/PemConverterCommand.php index c682ed7c..8703d7e8 100644 --- a/src/Component/Console/PemConverterCommand.php +++ b/src/Component/Console/PemConverterCommand.php @@ -11,19 +11,20 @@ use Jose\Component\Core\Util\ECKey; use Jose\Component\Core\Util\JsonConverter; use Jose\Component\Core\Util\RSAKey; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[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 function configure(): void { parent::configure(); - $this->setDescription('Converts a RSA or EC key into PKCS#1 key.') - ->addArgument('jwk', InputArgument::REQUIRED, 'The key'); + $this + ->addArgument('jwk', InputArgument::REQUIRED, 'The key') + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Component/Console/PublicKeyCommand.php b/src/Component/Console/PublicKeyCommand.php index 318d0eb8..6d395f13 100644 --- a/src/Component/Console/PublicKeyCommand.php +++ b/src/Component/Console/PublicKeyCommand.php @@ -9,18 +9,21 @@ use function is_string; use Jose\Component\Core\JWK; use Jose\Component\Core\Util\JsonConverter; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand( + name: 'key:convert:public', + description: 'Convert a private key into public key. Symmetric keys (shared keys) are not changed.', +)] final class PublicKeyCommand extends ObjectOutputCommand { - protected static $defaultName = 'key:convert:public'; - protected function configure(): void { parent::configure(); - $this->setDescription('Convert a private key into public key. Symmetric keys (shared keys) are not changed.') + $this ->setHelp('This command converts a private key into a public key.') ->addArgument('jwk', InputArgument::REQUIRED, 'The JWK object'); } diff --git a/src/Component/Console/PublicKeysetCommand.php b/src/Component/Console/PublicKeysetCommand.php index b74187db..0c89a672 100644 --- a/src/Component/Console/PublicKeysetCommand.php +++ b/src/Component/Console/PublicKeysetCommand.php @@ -9,20 +9,21 @@ use function is_string; use Jose\Component\Core\JWKSet; use Jose\Component\Core\Util\JsonConverter; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand( + name: 'keyset:convert:public', + description: 'Convert private keys in a key set into public keys. Symmetric keys (shared keys) are not changed.', +)] final class PublicKeysetCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:convert:public'; - protected function configure(): void { parent::configure(); - $this->setDescription( - 'Convert private keys in a key set into public keys. Symmetric keys (shared keys) are not changed.' - ) + $this ->setHelp('This command converts private keys in a key set into public keys.') ->addArgument('jwkset', InputArgument::REQUIRED, 'The JWKSet object'); } diff --git a/src/Component/Console/RotateKeysetCommand.php b/src/Component/Console/RotateKeysetCommand.php index 323780e7..fd62855d 100644 --- a/src/Component/Console/RotateKeysetCommand.php +++ b/src/Component/Console/RotateKeysetCommand.php @@ -11,18 +11,18 @@ use Jose\Component\Core\JWK; use Jose\Component\Core\JWKSet; use Jose\Component\Core\Util\JsonConverter; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'keyset:rotate', description: 'Rotate a key set.',)] final class RotateKeysetCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:rotate'; - protected function configure(): void { parent::configure(); - $this->setDescription('Rotate a key set.') + $this ->setHelp('This command removes the last key in a key set a place a new one at the beginning.') ->addArgument('jwkset', InputArgument::REQUIRED, 'The JWKSet object') ->addArgument('jwk', InputArgument::REQUIRED, 'The new JWK object'); diff --git a/src/Component/Console/RsaKeyGeneratorCommand.php b/src/Component/Console/RsaKeyGeneratorCommand.php index 7a07c049..1148b63f 100644 --- a/src/Component/Console/RsaKeyGeneratorCommand.php +++ b/src/Component/Console/RsaKeyGeneratorCommand.php @@ -6,19 +6,20 @@ use InvalidArgumentException; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'key:generate:rsa', description: 'Generate a RSA key (JWK format)',)] final class RsaKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:rsa'; - protected function configure(): void { parent::configure(); - $this->setDescription('Generate a RSA key (JWK format)') - ->addArgument('size', InputArgument::REQUIRED, 'Key size.'); + $this + ->addArgument('size', InputArgument::REQUIRED, 'Key size.') + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Component/Console/RsaKeysetGeneratorCommand.php b/src/Component/Console/RsaKeysetGeneratorCommand.php index ed7225df..48794852 100644 --- a/src/Component/Console/RsaKeysetGeneratorCommand.php +++ b/src/Component/Console/RsaKeysetGeneratorCommand.php @@ -7,18 +7,18 @@ use InvalidArgumentException; use Jose\Component\Core\JWKSet; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[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 function configure(): void { parent::configure(); - $this->setDescription('Generate a key set with RSA keys (JWK format)') + $this ->addArgument('quantity', InputArgument::REQUIRED, 'Quantity of keys in the key set.') ->addArgument('size', InputArgument::REQUIRED, 'Key size.'); } diff --git a/src/Component/Console/SecretKeyGeneratorCommand.php b/src/Component/Console/SecretKeyGeneratorCommand.php index 4504f1bd..17d16c83 100644 --- a/src/Component/Console/SecretKeyGeneratorCommand.php +++ b/src/Component/Console/SecretKeyGeneratorCommand.php @@ -8,19 +8,22 @@ use function is_bool; use function is_string; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand( + name: 'key:generate:from_secret', + description: 'Generate an octet key (JWK format) using an existing secret', +)] final class SecretKeyGeneratorCommand extends GeneratorCommand { - protected static $defaultName = 'key:generate:from_secret'; - protected function configure(): void { parent::configure(); - $this->setDescription('Generate an octet key (JWK format) using an existing secret') + $this ->addArgument('secret', InputArgument::REQUIRED, 'The secret') ->addOption( 'is_b64', diff --git a/src/Component/Console/X509CertificateLoaderCommand.php b/src/Component/Console/X509CertificateLoaderCommand.php index 5640d16c..befe05a2 100644 --- a/src/Component/Console/X509CertificateLoaderCommand.php +++ b/src/Component/Console/X509CertificateLoaderCommand.php @@ -7,19 +7,20 @@ use InvalidArgumentException; use function is_string; use Jose\Component\KeyManagement\JWKFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[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 function configure(): void { parent::configure(); - $this->setDescription('Load a key from a X.509 certificate file.') - ->addArgument('file', InputArgument::REQUIRED, 'Filename of the X.509 certificate.'); + $this + ->addArgument('file', InputArgument::REQUIRED, 'Filename of the X.509 certificate.') + ; } protected function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Component/Console/X5ULoaderCommand.php b/src/Component/Console/X5ULoaderCommand.php index bed659e9..5e9a5fd6 100644 --- a/src/Component/Console/X5ULoaderCommand.php +++ b/src/Component/Console/X5ULoaderCommand.php @@ -7,25 +7,25 @@ use InvalidArgumentException; use function is_string; use Jose\Component\KeyManagement\X5UFactory; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'keyset:load:x5u', description: 'Loads a key set from an url.',)] final class X5ULoaderCommand extends ObjectOutputCommand { - protected static $defaultName = 'keyset:load:x5u'; - public function __construct( private readonly X5UFactory $x5uFactory, ?string $name = null ) { - parent::__construct($name); + parent::__construct(); } protected function configure(): void { parent::configure(); - $this->setDescription('Loads a key set from an url.') + $this ->setHelp( 'This command will try to get a key set from an URL. The distant key set is list of X.509 certificates.' )