CoreFiles by mySites.guru
X5ULoaderCommand.php49 lines, 1,511 bytes, from Joomla_5.2.2-Stable-Full_Package.zip
Raw History Compare with 5.2.1
md5
c8bb6ca76b5f171088bcace057349afb
sha1
ea19ee2a8ecfcaa58c9b56a2137542b8d63bd29f
sha256
a2181ca8d2b3668824da5fb6aeb94fd89a590774781143de0b81fc1506bbe143
<?php

declare(strict_types=1);

namespace Jose\Component\Console;

use InvalidArgumentException;
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;
use function is_string;

#[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
    ) {
        parent::__construct($name);
    }

    protected function configure(): void
    {
        parent::configure();
        $this->setHelp(
            'This command will try to get a key set from an URL. The distant key set is list of X.509 certificates.'
        )
            ->addArgument('url', InputArgument::REQUIRED, 'The URL');
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $url = $input->getArgument('url');
        if (! is_string($url)) {
            throw new InvalidArgumentException('Invalid URL');
        }
        $result = $this->x5uFactory->loadFromUrl($url);
        $this->prepareJsonOutput($input, $output, $result);

        return self::SUCCESS;
    }
}

The same content is in 135 releases, Joomla 5.1.0-beta1 to 6.2.1. See them all, or every version of this file.