From 75160b12821f7f4299cce7f0b69c83c1502ae071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Mon, 27 May 2024 13:08:29 +0200 Subject: 2024-02-19 upstream --- vendor/web-token/jwt-key-mgmt/X5UFactory.php | 132 +++++++++++++-------------- 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'vendor/web-token/jwt-key-mgmt/X5UFactory.php') diff --git a/vendor/web-token/jwt-key-mgmt/X5UFactory.php b/vendor/web-token/jwt-key-mgmt/X5UFactory.php index 1163b59..c7e5394 100644 --- a/vendor/web-token/jwt-key-mgmt/X5UFactory.php +++ b/vendor/web-token/jwt-key-mgmt/X5UFactory.php @@ -1,66 +1,66 @@ -jsonConverter = $jsonConverter ?? new \Jose\Component\Core\Util\JsonConverter(); - parent::__construct($client, $requestFactory); - } - - /** - * This method will try to fetch the url a retrieve the key set. - * Throws an exception in case of failure. - * - * @throws \InvalidArgumentException - */ - public function loadFromUrl(string $url, array $header = []): JWKSet - { - $content = $this->getContent($url, $header); - $data = $this->jsonConverter->decode($content); - if (!\is_array($data)) { - throw new \RuntimeException('Invalid content.'); - } - - $keys = []; - foreach ($data as $kid => $cert) { - if (false === \mb_strpos($cert, '-----BEGIN CERTIFICATE-----')) { - $cert = '-----BEGIN CERTIFICATE-----'.PHP_EOL.$cert.PHP_EOL.'-----END CERTIFICATE-----'; - } - $jwk = KeyConverter::loadKeyFromCertificate($cert); - if (\is_string($kid)) { - $jwk['kid'] = $kid; - $keys[$kid] = new JWK($jwk); - } else { - $keys[] = new JWK($jwk); - } - } - - return new JWKSet($keys); - } -} +jsonConverter = $jsonConverter ?? new \Jose\Component\Core\Util\JsonConverter(); + parent::__construct($client, $requestFactory); + } + + /** + * This method will try to fetch the url a retrieve the key set. + * Throws an exception in case of failure. + * + * @throws \InvalidArgumentException + */ + public function loadFromUrl(string $url, array $header = []): JWKSet + { + $content = $this->getContent($url, $header); + $data = $this->jsonConverter->decode($content); + if (!\is_array($data)) { + throw new \RuntimeException('Invalid content.'); + } + + $keys = []; + foreach ($data as $kid => $cert) { + if (false === \mb_strpos($cert, '-----BEGIN CERTIFICATE-----')) { + $cert = '-----BEGIN CERTIFICATE-----'.PHP_EOL.$cert.PHP_EOL.'-----END CERTIFICATE-----'; + } + $jwk = KeyConverter::loadKeyFromCertificate($cert); + if (\is_string($kid)) { + $jwk['kid'] = $kid; + $keys[$kid] = new JWK($jwk); + } else { + $keys[] = new JWK($jwk); + } + } + + return new JWKSet($keys); + } +} -- cgit v1.2.3