diff --git a/CHANGELOG.md b/CHANGELOG.md index 1df01a1e..ef4a692f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ about writing changes to this log. ## [Unreleased] +## [1.5.3] - 2023-12-19 + +- [PR-377](https://github.com/itk-dev/naevnssekretariatet/pull/377) + Improved `tvist1:digital-post-envelope:list` command and added Digital post + debug command. + ## [1.5.2] - [PR-378](https://github.com/itk-dev/naevnssekretariatet/pull/378) @@ -292,7 +298,8 @@ Fixed error in unescaped characters in filename - [TVIST1-604](https://jira.itkdev.dk/browse/TVIST1-604): Resolved issue regarding time formats. -[Unreleased]: https://github.com/itk-dev/naevnssekretariatet/compare/1.5.2...HEAD +[Unreleased]: https://github.com/itk-dev/naevnssekretariatet/compare/1.5.3...HEAD +[1.5.3]: https://github.com/itk-dev/naevnssekretariatet/compare/1.5.2...1.5.3 [1.5.2]: https://github.com/itk-dev/naevnssekretariatet/compare/1.5.1...1.5.2 [1.5.1]: https://github.com/itk-dev/naevnssekretariatet/compare/1.5.0...1.5.1 [1.5.0]: https://github.com/itk-dev/naevnssekretariatet/compare/1.4.1...1.5.0 diff --git a/composer.json b/composer.json index 32aee845..4a484bd2 100644 --- a/composer.json +++ b/composer.json @@ -35,9 +35,9 @@ "gedmo/doctrine-extensions": "^3.0", "itk-dev/azure-key-vault-php": "^1.0", "itk-dev/beskedfordeler-symfony": "^1.0", - "itk-dev/datafordeler-php-client": "dev-develop", - "itk-dev/openid-connect-bundle": "dev-develop", - "itk-dev/serviceplatformen": "dev-feature/guzzle7-adapter", + "itk-dev/datafordeler-php-client": "^1.0", + "itk-dev/openid-connect-bundle": "^2.0", + "itk-dev/serviceplatformen": "dev-feature/tvist1", "knplabs/knp-paginator-bundle": "^5.6", "league/oauth2-client": "^2.6", "lexik/form-filter-bundle": "^7.0", diff --git a/composer.lock b/composer.lock index d25ff7dc..6177edad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "72ac2843bb623840a7f9d0d5f7322aea", + "content-hash": "67e38e62eefe8ad3301eff80be165aab", "packages": [ { "name": "behat/transliterator", @@ -2521,16 +2521,16 @@ }, { "name": "itk-dev/datafordeler-php-client", - "version": "dev-develop", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/itk-dev/datafordeler-php-client.git", - "reference": "619145e7ebe07a1c59084abfa481f9dd835984c5" + "reference": "7e7d31231320781a421dcc5ff8f36155f175c236" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/itk-dev/datafordeler-php-client/zipball/619145e7ebe07a1c59084abfa481f9dd835984c5", - "reference": "619145e7ebe07a1c59084abfa481f9dd835984c5", + "url": "https://api.github.com/repos/itk-dev/datafordeler-php-client/zipball/7e7d31231320781a421dcc5ff8f36155f175c236", + "reference": "7e7d31231320781a421dcc5ff8f36155f175c236", "shasum": "" }, "require": { @@ -2575,10 +2575,10 @@ ], "description": "PHP client for datafordeler.dk", "support": { - "source": "https://github.com/itk-dev/datafordeler-php-client/tree/develop", + "source": "https://github.com/itk-dev/datafordeler-php-client/tree/1.0.0", "issues": "https://github.com/itk-dev/datafordeler-php-client/issues" }, - "time": "2022-02-23T14:44:58+00:00" + "time": "2023-02-18T10:23:46+00:00" }, { "name": "itk-dev/openid-connect", @@ -2644,16 +2644,16 @@ }, { "name": "itk-dev/openid-connect-bundle", - "version": "dev-develop", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/itk-dev/openid-connect-bundle.git", - "reference": "5706f7ee285507952d116c757b9ec2fedd9e15dc" + "reference": "4dc2119ae6d8605eb647b09e80fac3f1ca8c24b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/itk-dev/openid-connect-bundle/zipball/5706f7ee285507952d116c757b9ec2fedd9e15dc", - "reference": "5706f7ee285507952d116c757b9ec2fedd9e15dc", + "url": "https://api.github.com/repos/itk-dev/openid-connect-bundle/zipball/4dc2119ae6d8605eb647b09e80fac3f1ca8c24b8", + "reference": "4dc2119ae6d8605eb647b09e80fac3f1ca8c24b8", "shasum": "" }, "require": { @@ -2674,7 +2674,6 @@ "phpunit/phpunit": "^9.5", "vimeo/psalm": "^4.7" }, - "default-branch": true, "type": "symfony-bundle", "autoload": { "psr-4": { @@ -2698,22 +2697,22 @@ "description": "Symfony bundle for openid-connect", "support": { "issues": "https://github.com/itk-dev/openid-connect-bundle/issues", - "source": "https://github.com/itk-dev/openid-connect-bundle/tree/develop" + "source": "https://github.com/itk-dev/openid-connect-bundle/tree/2.0.0" }, - "time": "2022-01-10T10:54:13+00:00" + "time": "2022-01-10T10:53:42+00:00" }, { "name": "itk-dev/serviceplatformen", - "version": "dev-feature/guzzle7-adapter", + "version": "dev-feature/tvist1", "source": { "type": "git", "url": "https://github.com/itk-dev/serviceplatformen.git", - "reference": "6fba39bed5eb60efd5169633520d128fdabcc557" + "reference": "64b46ba62547217758501a2af29de2230d6e4dae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/itk-dev/serviceplatformen/zipball/6fba39bed5eb60efd5169633520d128fdabcc557", - "reference": "6fba39bed5eb60efd5169633520d128fdabcc557", + "url": "https://api.github.com/repos/itk-dev/serviceplatformen/zipball/64b46ba62547217758501a2af29de2230d6e4dae", + "reference": "64b46ba62547217758501a2af29de2230d6e4dae", "shasum": "" }, "require": { @@ -2786,9 +2785,9 @@ ], "support": { "issues": "https://github.com/itk-dev/serviceplatformen/issues", - "source": "https://github.com/itk-dev/serviceplatformen/tree/feature/guzzle7-adapter" + "source": "https://github.com/itk-dev/serviceplatformen/tree/feature/tvist1" }, - "time": "2023-03-27T11:34:51+00:00" + "time": "2023-07-07T10:00:35+00:00" }, { "name": "jms/metadata", @@ -14836,8 +14835,6 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { - "itk-dev/datafordeler-php-client": 20, - "itk-dev/openid-connect-bundle": 20, "itk-dev/serviceplatformen": 20 }, "prefer-stable": true, @@ -14850,5 +14847,5 @@ "ext-soap": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/Command/DigitalPostDebugCommand.php b/src/Command/DigitalPostDebugCommand.php new file mode 100644 index 00000000..17d73bf3 --- /dev/null +++ b/src/Command/DigitalPostDebugCommand.php @@ -0,0 +1,56 @@ +addArgument('action', InputArgument::REQUIRED, 'The action'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $action = $input->getArgument('action'); + + switch ($action) { + case 'getSAMLToken': + case 'fetchSAMLToken': + $sf1601 = $this->invoke($this->digitalPoster, 'getSF1601'); + $entityId = 'http://entityid.kombit.dk/service/kombipostafsend/1'; + $samlToken = $this->invoke($sf1601, $action, [$entityId]); + + $output->write(json_encode($samlToken)); + + return Command::SUCCESS; + } + } + + /** + * Invoke method on an object. + */ + private function invoke(object $object, string $method, array $args = []): mixed + { + $method = new \ReflectionMethod($object, $method); + $method->setAccessible(true); + + return $method->invoke($object, ...$args); + } +} diff --git a/src/Command/DigitalPostEnvelopeListCommand.php b/src/Command/DigitalPostEnvelopeListCommand.php index 600183ef..e41dd8a9 100644 --- a/src/Command/DigitalPostEnvelopeListCommand.php +++ b/src/Command/DigitalPostEnvelopeListCommand.php @@ -37,7 +37,8 @@ protected function configure() { $this ->addOption('status', null, InputOption::VALUE_REQUIRED, 'Show only envelopes with this status') - ->addOption('digital-post-subject', null, InputOption::VALUE_REQUIRED, 'Show only envelopes with subject matching this LIKE expression') + ->addOption('digital-post-id', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Show only envelopes with the digital post id') + ->addOption('digital-post-subject', null, InputOption::VALUE_REQUIRED, 'Show only envelopes with digital post subjects matching this LIKE expression') ->addOption('max-results', null, InputOption::VALUE_REQUIRED, 'Show at most this many envelopes', 10) ->addOption('id', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Envelope id') ->addOption('message-uuid', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Messaged uuid') @@ -134,6 +135,14 @@ private function findEnvelopes(InputInterface $input): array ->setParameter('status', $status) ; } + if ($ids = $input->getOption('digital-post-id')) { + $ids = array_map(static fn (string $id) => Uuid::fromString($id)->toBinary(), $ids); + $qb + ->join('e.digitalPost', 'p') + ->andWhere('p.id IN (:digital_post_ids)') + ->setParameter('digital_post_ids', $ids) + ; + } if ($subject = $input->getOption('digital-post-subject')) { $qb ->join('e.digitalPost', 'p') diff --git a/src/Service/SF1601/DigitalPoster.php b/src/Service/SF1601/DigitalPoster.php index d1b0c974..36a49b3b 100644 --- a/src/Service/SF1601/DigitalPoster.php +++ b/src/Service/SF1601/DigitalPoster.php @@ -27,13 +27,7 @@ public function __construct(private CertificateLocatorHelper $certificateLocator public function canReceive(string $type, string $identifier): ?bool { - $options = $this->options['sf1601'] - + [ - 'certificate_locator' => $this->certificateLocatorHelper->getCertificateLocator(), - ]; - unset($options[ForsendelseHelper::FORSENDELSES_TYPE_IDENTIFIKATOR]); - $service = new SF1601($options); - + $service = $this->getSF1601(); $transactionId = Serializer::createUuid(); return $service->postForespoerg($transactionId, $type, $identifier); @@ -80,12 +74,7 @@ public function sendDigitalPost(DigitalPost $digitalPost, DigitalPost\Recipient ]; $forsendelse = $this->forsendelseHelper->createForsendelse($digitalPost, $recipient, $forsendelseOptions); - $options = $this->options['sf1601'] - + [ - 'certificate_locator' => $this->certificateLocatorHelper->getCertificateLocator(), - ]; - unset($options[ForsendelseHelper::FORSENDELSES_TYPE_IDENTIFIKATOR]); - $service = new SF1601($options); + $service = $this->getSF1601(); $transactionId = Serializer::createUuid(); $response = $service->kombiPostAfsend($transactionId, SF1601::TYPE_AUTOMATISK_VALG, $meMoMessage, $forsendelse); @@ -154,6 +143,20 @@ public function sendDigitalPost(DigitalPost $digitalPost, DigitalPost\Recipient } } + /** + * Get SF1601 instance. + */ + private function getSF1601(): SF1601 + { + $options = $this->options['sf1601'] + + [ + 'certificate_locator' => $this->certificateLocatorHelper->getCertificateLocator(), + ]; + unset($options[ForsendelseHelper::FORSENDELSES_TYPE_IDENTIFIKATOR]); + + return new SF1601($options); + } + private function resolveOptions(array $options): array { return (new OptionsResolver())