|
| 1 | +#!/usr/bin/env php |
| 2 | +<?php |
| 3 | + |
| 4 | +declare(strict_types=1); |
| 5 | + |
| 6 | +require __DIR__.'/../vendor/autoload.php'; |
| 7 | + |
| 8 | +use Jose\Component\Console; |
| 9 | +use Symfony\Component\Console\Application; |
| 10 | +use Jose\Component\Core\Converter\StandardJsonConverter; |
| 11 | +use Jose\Component\KeyManagement\KeyAnalyzer; |
| 12 | +use Jose\Component\KeyManagement\X5UFactory; |
| 13 | +use Jose\Component\KeyManagement\JKUFactory; |
| 14 | +use Jose\Component\KeyManagement\KeyAnalyzer\JWKAnalyzerManager; |
| 15 | +use Http\Adapter\Guzzle6\Client; |
| 16 | +use GuzzleHttp\Psr7\Request; |
| 17 | +use GuzzleHttp\Psr7\Response; |
| 18 | +use Http\Message\MessageFactory as Psr7MessageFactory; |
| 19 | + |
| 20 | +/** |
| 21 | + * Class MessageFactory. |
| 22 | + */ |
| 23 | +final class MessageFactory implements Psr7MessageFactory |
| 24 | +{ |
| 25 | + /** |
| 26 | + * {@inheritdoc} |
| 27 | + */ |
| 28 | + public function createRequest($method, $uri, array $headers = [], $body = null, $protocolVersion = '1.1') |
| 29 | + { |
| 30 | + return new Request($method, $uri, $headers, $body, $protocolVersion); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * {@inheritdoc} |
| 35 | + */ |
| 36 | + public function createResponse($statusCode = 200, $reasonPhrase = null, array $headers = [], $body = null, $protocolVersion = '1.1') |
| 37 | + { |
| 38 | + return new Response($statusCode, $headers, $body, $protocolVersion, $reasonPhrase); |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +$jsonConverter = new StandardJsonConverter(); |
| 43 | +$httpClient = new Client(); |
| 44 | +$messageFactory = new MessageFactory(); |
| 45 | +$jwkAnalyzerManager = new JWKAnalyzerManager(); |
| 46 | +$jwkAnalyzerManager |
| 47 | + ->add(new KeyAnalyzer\AlgorithmAnalyzer()) |
| 48 | + ->add(new KeyAnalyzer\UsageAnalyzer()) |
| 49 | + ->add(new KeyAnalyzer\KeyIdentifierAnalyzer()) |
| 50 | + ->add(new KeyAnalyzer\NoneAnalyzer()) |
| 51 | + ->add(new KeyAnalyzer\OctAnalyzer()) |
| 52 | + ->add(new KeyAnalyzer\RsaAnalyzer()) |
| 53 | +; |
| 54 | + |
| 55 | +$application = new Application('Jose', '@package_version@'); |
| 56 | +$application->add(new Console\OctKeyGeneratorCommand($jsonConverter)); |
| 57 | +$application->add(new Console\RsaKeyGeneratorCommand($jsonConverter)); |
| 58 | +$application->add(new Console\EcKeyGeneratorCommand($jsonConverter)); |
| 59 | +$application->add(new Console\OkpKeyGeneratorCommand($jsonConverter)); |
| 60 | +$application->add(new Console\KeyFileLoaderCommand($jsonConverter)); |
| 61 | +$application->add(new Console\P12CertificateLoaderCommand($jsonConverter)); |
| 62 | +$application->add(new Console\X509CertificateLoaderCommand($jsonConverter)); |
| 63 | + |
| 64 | +$application->add(new Console\EcKeysetGeneratorCommand($jsonConverter)); |
| 65 | +$application->add(new Console\OkpKeysetGeneratorCommand($jsonConverter)); |
| 66 | +$application->add(new Console\OctKeysetGeneratorCommand($jsonConverter)); |
| 67 | +$application->add(new Console\RsaKeysetGeneratorCommand($jsonConverter)); |
| 68 | +$application->add(new Console\MergeKeysetCommand($jsonConverter)); |
| 69 | +$application->add(new Console\PublicKeysetCommand($jsonConverter)); |
| 70 | +$application->add(new Console\RotateKeysetCommand($jsonConverter)); |
| 71 | +$application->add(new Console\AddKeyIntoKeysetCommand($jsonConverter)); |
| 72 | + |
| 73 | +$application->add(new Console\OptimizeRsaKeyCommand($jsonConverter)); |
| 74 | +$application->add(new Console\KeyAnalyzerCommand($jwkAnalyzerManager, $jsonConverter)); |
| 75 | +$application->add(new Console\KeysetAnalyzerCommand($jwkAnalyzerManager, $jsonConverter)); |
| 76 | +$application->add(new Console\X5ULoaderCommand(new X5UFactory($jsonConverter, $httpClient, $messageFactory), $jsonConverter)); |
| 77 | +$application->add(new Console\JKULoaderCommand(new JKUFactory($jsonConverter, $httpClient, $messageFactory), $jsonConverter)); |
| 78 | + |
| 79 | +$application->add(new Console\PemConverterCommand($jsonConverter)); |
| 80 | + |
| 81 | +$application->add(new Console\GetThumbprintCommand($jsonConverter)); |
| 82 | + |
| 83 | +$application->add(new Console\UpdateCommand()); |
| 84 | +$application->add(new Console\RollbackCommand()); |
| 85 | + |
| 86 | +$application->run(); |
0 commit comments