diff options
Diffstat (limited to '')
10 files changed, 424 insertions, 424 deletions
diff --git a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/AlgorithmAnalyzer.php b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/AlgorithmAnalyzer.php index a7ebcad..81a9566 100644 --- a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/AlgorithmAnalyzer.php +++ b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/AlgorithmAnalyzer.php @@ -1,26 +1,26 @@ -<?php - -declare(strict_types=1); - -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2018 Spomky-Labs - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -namespace Jose\Component\KeyManagement\KeyAnalyzer; - -use Jose\Component\Core\JWK; - -final class AlgorithmAnalyzer implements KeyAnalyzer -{ - public function analyze(JWK $jwk, MessageBag $bag) - { - if (!$jwk->has('alg')) { - $bag->add(Message::medium('The parameter "alg" should be added.')); - } - } -} +<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\KeyManagement\KeyAnalyzer;
+
+use Jose\Component\Core\JWK;
+
+final class AlgorithmAnalyzer implements KeyAnalyzer
+{
+ public function analyze(JWK $jwk, MessageBag $bag)
+ {
+ if (!$jwk->has('alg')) {
+ $bag->add(Message::medium('The parameter "alg" should be added.'));
+ }
+ }
+}
diff --git a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyAnalyzer.php b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyAnalyzer.php index 470b788..6bba0a0 100644 --- a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyAnalyzer.php +++ b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyAnalyzer.php @@ -1,24 +1,24 @@ -<?php - -declare(strict_types=1); - -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2018 Spomky-Labs - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -namespace Jose\Component\KeyManagement\KeyAnalyzer; - -use Jose\Component\Core\JWK; - -interface KeyAnalyzer -{ - /** - * This method will analyse the key and add messages to the message bag if needed. - */ - public function analyze(JWK $jwk, MessageBag $bag); -} +<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\KeyManagement\KeyAnalyzer;
+
+use Jose\Component\Core\JWK;
+
+interface KeyAnalyzer
+{
+ /**
+ * This method will analyse the key and add messages to the message bag if needed.
+ */
+ public function analyze(JWK $jwk, MessageBag $bag);
+}
diff --git a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyAnalyzerManager.php b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyAnalyzerManager.php index 2b8b4a9..e34f416 100644 --- a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyAnalyzerManager.php +++ b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyAnalyzerManager.php @@ -1,50 +1,50 @@ -<?php - -declare(strict_types=1); - -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2018 Spomky-Labs - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -namespace Jose\Component\KeyManagement\KeyAnalyzer; - -use Jose\Component\Core\JWK; - -class KeyAnalyzerManager -{ - /** - * @var KeyAnalyzer[] - */ - private $analyzers = []; - - /** - * Adds a Key Analyzer to the manager. - * - * @return KeyAnalyzerManager - */ - public function add(KeyAnalyzer $analyzer): self - { - $this->analyzers[] = $analyzer; - - return $this; - } - - /** - * This method will analyze the JWK object using all analyzers. - * It returns a message bag that may contains messages. - */ - public function analyze(JWK $jwk): MessageBag - { - $bag = new MessageBag(); - foreach ($this->analyzers as $analyzer) { - $analyzer->analyze($jwk, $bag); - } - - return $bag; - } -} +<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\KeyManagement\KeyAnalyzer;
+
+use Jose\Component\Core\JWK;
+
+class KeyAnalyzerManager
+{
+ /**
+ * @var KeyAnalyzer[]
+ */
+ private $analyzers = [];
+
+ /**
+ * Adds a Key Analyzer to the manager.
+ *
+ * @return KeyAnalyzerManager
+ */
+ public function add(KeyAnalyzer $analyzer): self
+ {
+ $this->analyzers[] = $analyzer;
+
+ return $this;
+ }
+
+ /**
+ * This method will analyze the JWK object using all analyzers.
+ * It returns a message bag that may contains messages.
+ */
+ public function analyze(JWK $jwk): MessageBag
+ {
+ $bag = new MessageBag();
+ foreach ($this->analyzers as $analyzer) {
+ $analyzer->analyze($jwk, $bag);
+ }
+
+ return $bag;
+ }
+}
diff --git a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyIdentifierAnalyzer.php b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyIdentifierAnalyzer.php index 71acb70..9b0ad06 100644 --- a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyIdentifierAnalyzer.php +++ b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/KeyIdentifierAnalyzer.php @@ -1,26 +1,26 @@ -<?php - -declare(strict_types=1); - -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2018 Spomky-Labs - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -namespace Jose\Component\KeyManagement\KeyAnalyzer; - -use Jose\Component\Core\JWK; - -final class KeyIdentifierAnalyzer implements KeyAnalyzer -{ - public function analyze(JWK $jwk, MessageBag $bag) - { - if (!$jwk->has('kid')) { - $bag->add(Message::medium('The parameter "kid" should be added.')); - } - } -} +<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\KeyManagement\KeyAnalyzer;
+
+use Jose\Component\Core\JWK;
+
+final class KeyIdentifierAnalyzer implements KeyAnalyzer
+{
+ public function analyze(JWK $jwk, MessageBag $bag)
+ {
+ if (!$jwk->has('kid')) {
+ $bag->add(Message::medium('The parameter "kid" should be added.'));
+ }
+ }
+}
diff --git a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/Message.php b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/Message.php index 4baf868..30e25cf 100644 --- a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/Message.php +++ b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/Message.php @@ -1,96 +1,96 @@ -<?php - -declare(strict_types=1); - -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2018 Spomky-Labs - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -namespace Jose\Component\KeyManagement\KeyAnalyzer; - -class Message implements \JsonSerializable -{ - /** - * @var string - */ - private $message; - - /** - * @var string - */ - private $severity; - - public const SEVERITY_LOW = 'low'; - - public const SEVERITY_MEDIUM = 'medium'; - - public const SEVERITY_HIGH = 'high'; - - /** - * Message constructor. - */ - private function __construct(string $message, string $severity) - { - $this->message = $message; - $this->severity = $severity; - } - - /** - * Creates a message with severity=low. - * - * @return Message - */ - public static function low(string $message): self - { - return new self($message, self::SEVERITY_LOW); - } - - /** - * Creates a message with severity=medium. - * - * @return Message - */ - public static function medium(string $message): self - { - return new self($message, self::SEVERITY_MEDIUM); - } - - /** - * Creates a message with severity=high. - * - * @return Message - */ - public static function high(string $message): self - { - return new self($message, self::SEVERITY_HIGH); - } - - /** - * Returns the message. - */ - public function getMessage(): string - { - return $this->message; - } - - /** - * Returns the severity of the message. - */ - public function getSeverity(): string - { - return $this->severity; - } - - public function jsonSerialize() - { - return [ - 'message' => $this->message, - 'severity' => $this->severity, - ]; - } -} +<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\KeyManagement\KeyAnalyzer;
+
+class Message implements \JsonSerializable
+{
+ /**
+ * @var string
+ */
+ private $message;
+
+ /**
+ * @var string
+ */
+ private $severity;
+
+ public const SEVERITY_LOW = 'low';
+
+ public const SEVERITY_MEDIUM = 'medium';
+
+ public const SEVERITY_HIGH = 'high';
+
+ /**
+ * Message constructor.
+ */
+ private function __construct(string $message, string $severity)
+ {
+ $this->message = $message;
+ $this->severity = $severity;
+ }
+
+ /**
+ * Creates a message with severity=low.
+ *
+ * @return Message
+ */
+ public static function low(string $message): self
+ {
+ return new self($message, self::SEVERITY_LOW);
+ }
+
+ /**
+ * Creates a message with severity=medium.
+ *
+ * @return Message
+ */
+ public static function medium(string $message): self
+ {
+ return new self($message, self::SEVERITY_MEDIUM);
+ }
+
+ /**
+ * Creates a message with severity=high.
+ *
+ * @return Message
+ */
+ public static function high(string $message): self
+ {
+ return new self($message, self::SEVERITY_HIGH);
+ }
+
+ /**
+ * Returns the message.
+ */
+ public function getMessage(): string
+ {
+ return $this->message;
+ }
+
+ /**
+ * Returns the severity of the message.
+ */
+ public function getSeverity(): string
+ {
+ return $this->severity;
+ }
+
+ public function jsonSerialize()
+ {
+ return [
+ 'message' => $this->message,
+ 'severity' => $this->severity,
+ ];
+ }
+}
diff --git a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/MessageBag.php b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/MessageBag.php index b41795f..5bb7566 100644 --- a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/MessageBag.php +++ b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/MessageBag.php @@ -1,59 +1,59 @@ -<?php - -declare(strict_types=1); - -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2018 Spomky-Labs - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -namespace Jose\Component\KeyManagement\KeyAnalyzer; - -class MessageBag implements \JsonSerializable, \IteratorAggregate, \Countable -{ - /** - * @var Message[] - */ - private $messages = []; - - /** - * Adds a message to the message bag. - * - * @return MessageBag - */ - public function add(Message $message): self - { - $this->messages[] = $message; - - return $this; - } - - /** - * Returns all messages. - * - * @return Message[] - */ - public function all(): array - { - return $this->messages; - } - - public function jsonSerialize() - { - return \array_values($this->messages); - } - - public function count() - { - return \count($this->messages); - } - - public function getIterator() - { - return new \ArrayIterator($this->messages); - } -} +<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\KeyManagement\KeyAnalyzer;
+
+class MessageBag implements \JsonSerializable, \IteratorAggregate, \Countable
+{
+ /**
+ * @var Message[]
+ */
+ private $messages = [];
+
+ /**
+ * Adds a message to the message bag.
+ *
+ * @return MessageBag
+ */
+ public function add(Message $message): self
+ {
+ $this->messages[] = $message;
+
+ return $this;
+ }
+
+ /**
+ * Returns all messages.
+ *
+ * @return Message[]
+ */
+ public function all(): array
+ {
+ return $this->messages;
+ }
+
+ public function jsonSerialize()
+ {
+ return \array_values($this->messages);
+ }
+
+ public function count()
+ {
+ return \count($this->messages);
+ }
+
+ public function getIterator()
+ {
+ return new \ArrayIterator($this->messages);
+ }
+}
diff --git a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/NoneAnalyzer.php b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/NoneAnalyzer.php index a293efd..ce3ee29 100644 --- a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/NoneAnalyzer.php +++ b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/NoneAnalyzer.php @@ -1,28 +1,28 @@ -<?php - -declare(strict_types=1); - -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2018 Spomky-Labs - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -namespace Jose\Component\KeyManagement\KeyAnalyzer; - -use Jose\Component\Core\JWK; - -final class NoneAnalyzer implements KeyAnalyzer -{ - public function analyze(JWK $jwk, MessageBag $bag) - { - if ('none' !== $jwk->get('kty')) { - return; - } - - $bag->add(Message::high('This key is a meant to be used with the algorithm "none". This algorithm is not secured and should be used with care.')); - } -} +<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\KeyManagement\KeyAnalyzer;
+
+use Jose\Component\Core\JWK;
+
+final class NoneAnalyzer implements KeyAnalyzer
+{
+ public function analyze(JWK $jwk, MessageBag $bag)
+ {
+ if ('none' !== $jwk->get('kty')) {
+ return;
+ }
+
+ $bag->add(Message::high('This key is a meant to be used with the algorithm "none". This algorithm is not secured and should be used with care.'));
+ }
+}
diff --git a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/OctAnalyzer.php b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/OctAnalyzer.php index 4c2d7c1..223b5e3 100644 --- a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/OctAnalyzer.php +++ b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/OctAnalyzer.php @@ -1,50 +1,50 @@ -<?php - -declare(strict_types=1); - -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2018 Spomky-Labs - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -namespace Jose\Component\KeyManagement\KeyAnalyzer; - -use Base64Url\Base64Url; -use Jose\Component\Core\JWK; -use ZxcvbnPhp\Zxcvbn; - -final class OctAnalyzer implements KeyAnalyzer -{ - public function analyze(JWK $jwk, MessageBag $bag) - { - if ('oct' !== $jwk->get('kty')) { - return; - } - $k = Base64Url::decode($jwk->get('k')); - $kLength = 8 * \mb_strlen($k, '8bit'); - if ($kLength < 128) { - $bag->add(Message::high('The key length is less than 128 bits.')); - } - - if (\class_exists(Zxcvbn::class)) { - $zxcvbn = new Zxcvbn(); - $strength = $zxcvbn->passwordStrength($k); - switch (true) { - case $strength['score'] < 3: - $bag->add(Message::high('The octet string is weak and easily guessable. Please change your key as soon as possible.')); - - break; - case 3 === $strength['score']: - $bag->add(Message::medium('The octet string is safe, but a longer key is preferable.')); - - break; - default: - break; - } - } - } -} +<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\KeyManagement\KeyAnalyzer;
+
+use Base64Url\Base64Url;
+use Jose\Component\Core\JWK;
+use ZxcvbnPhp\Zxcvbn;
+
+final class OctAnalyzer implements KeyAnalyzer
+{
+ public function analyze(JWK $jwk, MessageBag $bag)
+ {
+ if ('oct' !== $jwk->get('kty')) {
+ return;
+ }
+ $k = Base64Url::decode($jwk->get('k'));
+ $kLength = 8 * \mb_strlen($k, '8bit');
+ if ($kLength < 128) {
+ $bag->add(Message::high('The key length is less than 128 bits.'));
+ }
+
+ if (\class_exists(Zxcvbn::class)) {
+ $zxcvbn = new Zxcvbn();
+ $strength = $zxcvbn->passwordStrength($k);
+ switch (true) {
+ case $strength['score'] < 3:
+ $bag->add(Message::high('The octet string is weak and easily guessable. Please change your key as soon as possible.'));
+
+ break;
+ case 3 === $strength['score']:
+ $bag->add(Message::medium('The octet string is safe, but a longer key is preferable.'));
+
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
diff --git a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/RsaAnalyzer.php b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/RsaAnalyzer.php index 6274aa0..11a2b85 100644 --- a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/RsaAnalyzer.php +++ b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/RsaAnalyzer.php @@ -1,34 +1,34 @@ -<?php - -declare(strict_types=1); - -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2018 Spomky-Labs - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -namespace Jose\Component\KeyManagement\KeyAnalyzer; - -use Base64Url\Base64Url; -use Jose\Component\Core\JWK; - -final class RsaAnalyzer implements KeyAnalyzer -{ - public function analyze(JWK $jwk, MessageBag $bag) - { - if ('RSA' !== $jwk->get('kty')) { - return; - } - $n = 8 * \mb_strlen(Base64Url::decode($jwk->get('n')), '8bit'); - if ($n < 2048) { - $bag->add(Message::high('The key length is less than 2048 bits.')); - } - if ($jwk->has('d') && (!$jwk->has('p') || !$jwk->has('q') || !$jwk->has('dp') || !$jwk->has('dq') || !$jwk->has('p') || !$jwk->has('qi'))) { - $bag->add(Message::medium('The key is a private RSA key, but Chinese Remainder Theorem primes are missing. These primes are not mandatory, but signatures and decryption processes are faster when available.')); - } - } -} +<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\KeyManagement\KeyAnalyzer;
+
+use Base64Url\Base64Url;
+use Jose\Component\Core\JWK;
+
+final class RsaAnalyzer implements KeyAnalyzer
+{
+ public function analyze(JWK $jwk, MessageBag $bag)
+ {
+ if ('RSA' !== $jwk->get('kty')) {
+ return;
+ }
+ $n = 8 * \mb_strlen(Base64Url::decode($jwk->get('n')), '8bit');
+ if ($n < 2048) {
+ $bag->add(Message::high('The key length is less than 2048 bits.'));
+ }
+ if ($jwk->has('d') && (!$jwk->has('p') || !$jwk->has('q') || !$jwk->has('dp') || !$jwk->has('dq') || !$jwk->has('p') || !$jwk->has('qi'))) {
+ $bag->add(Message::medium('The key is a private RSA key, but Chinese Remainder Theorem primes are missing. These primes are not mandatory, but signatures and decryption processes are faster when available.'));
+ }
+ }
+}
diff --git a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/UsageAnalyzer.php b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/UsageAnalyzer.php index 8cdfaf6..6227458 100644 --- a/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/UsageAnalyzer.php +++ b/vendor/web-token/jwt-key-mgmt/KeyAnalyzer/UsageAnalyzer.php @@ -1,31 +1,31 @@ -<?php - -declare(strict_types=1); - -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2018 Spomky-Labs - * - * This software may be modified and distributed under the terms - * of the MIT license. See the LICENSE file for details. - */ - -namespace Jose\Component\KeyManagement\KeyAnalyzer; - -use Jose\Component\Core\JWK; - -final class UsageAnalyzer implements KeyAnalyzer -{ - public function analyze(JWK $jwk, MessageBag $bag) - { - if (!$jwk->has('use')) { - $bag->add(Message::medium('The parameter "use" should be added.')); - } elseif (!\in_array($jwk->get('use'), ['sig', 'enc'], true)) { - $bag->add(Message::high(\sprintf('The parameter "use" has an unsupported value "%s". Please use "sig" (signature) or "enc" (encryption).', $jwk->get('use')))); - } - if ($jwk->has('key_ops') && !\in_array($jwk->get('key_ops'), ['sign', 'verify', 'encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], true)) { - $bag->add(Message::high(\sprintf('The parameter "key_ops" has an unsupported value "%s". Please use one of the following values: %s.', $jwk->get('use'), \implode(', ', ['verify', 'sign', 'encryp', 'decrypt', 'wrapKey', 'unwrapKey'])))); - } - } -} +<?php
+
+declare(strict_types=1);
+
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2018 Spomky-Labs
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ */
+
+namespace Jose\Component\KeyManagement\KeyAnalyzer;
+
+use Jose\Component\Core\JWK;
+
+final class UsageAnalyzer implements KeyAnalyzer
+{
+ public function analyze(JWK $jwk, MessageBag $bag)
+ {
+ if (!$jwk->has('use')) {
+ $bag->add(Message::medium('The parameter "use" should be added.'));
+ } elseif (!\in_array($jwk->get('use'), ['sig', 'enc'], true)) {
+ $bag->add(Message::high(\sprintf('The parameter "use" has an unsupported value "%s". Please use "sig" (signature) or "enc" (encryption).', $jwk->get('use'))));
+ }
+ if ($jwk->has('key_ops') && !\in_array($jwk->get('key_ops'), ['sign', 'verify', 'encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], true)) {
+ $bag->add(Message::high(\sprintf('The parameter "key_ops" has an unsupported value "%s". Please use one of the following values: %s.', $jwk->get('use'), \implode(', ', ['verify', 'sign', 'encryp', 'decrypt', 'wrapKey', 'unwrapKey']))));
+ }
+ }
+}
|