CoreFiles by mySites.guru
JWSTokenSupport.php42 lines, 1,105 bytes, from Joomla_4.2.2-Stable-Full_Package.zip
Raw History Compare with 4.2.1
md5
feb2f930f5234dd4c4e91b31ba0e87dc
sha1
c90e8b76093b7487a9549ea3de2d3982b9da6cbe
sha256
2b9bc2abb56d9d81bf8616f3fdb3ff2179eacfd096d77a2eba1f4838085102fd
<?php

declare(strict_types=1);

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014-2020 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 InvalidArgumentException;
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;
    }

    /**
     * @throws InvalidArgumentException if the signature index does not exist
     */
    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();
    }
}

The same content is in 75 releases, Joomla 4.2.0-beta3 to 4.4.14. See them all, or every version of this file.