summaryrefslogtreecommitdiffstats
path: root/vendor/web-token/jwt-signature/JWSTokenSupport.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/web-token/jwt-signature/JWSTokenSupport.php')
-rw-r--r--vendor/web-token/jwt-signature/JWSTokenSupport.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/web-token/jwt-signature/JWSTokenSupport.php b/vendor/web-token/jwt-signature/JWSTokenSupport.php
new file mode 100644
index 0000000..667f3fc
--- /dev/null
+++ b/vendor/web-token/jwt-signature/JWSTokenSupport.php
@@ -0,0 +1,38 @@
+<?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\Signature;
+
+use Jose\Component\Checker\TokenTypeSupport;
+use Jose\Component\Core\JWT;
+
+final class JWSTokenSupport implements TokenTypeSupport
+{
+ public function supports(JWT $jwt): bool
+ {
+ return $jwt instanceof JWS;
+ }
+
+ public function retrieveTokenHeaders(JWT $jwt, int $index, array &$protectedHeader, array &$unprotectedHeader): void
+ {
+ if (!$jwt instanceof JWS) {
+ return;
+ }
+
+ if ($index > $jwt->countSignatures()) {
+ throw new \InvalidArgumentException('Unknown signature index.');
+ }
+ $protectedHeader = $jwt->getSignature($index)->getProtectedHeader();
+ $unprotectedHeader = $jwt->getSignature($index)->getHeader();
+ }
+}