CoreFiles by mySites.guru
SecTokenBindingHandler.php42 lines, 1,309 bytes, from Joomla_5.0.0-alpha1-Alpha-Full_Package.zip
Raw History Compare with 4.4.0-alpha4
md5
42fb9c2bbaa2078a68f480e1d9626fd8
sha1
ca4d12acb2a9a0632d291864e0fd84c595c8ac03
sha256
253dcfcbeac2c23845026e58881e847a40a0d662f679dfb6001c4e6b4c124c18
<?php

declare(strict_types=1);

namespace Webauthn\TokenBinding;

use function count;
use Psr\Http\Message\ServerRequestInterface;
use Webauthn\Exception\InvalidDataException;

/**
 * @deprecated Since 4.3.0 and will be removed in 5.0.0
 */
final class SecTokenBindingHandler implements TokenBindingHandler
{
    public static function create(): self
    {
        return new self();
    }

    public function check(TokenBinding $tokenBinding, ServerRequestInterface $request): void
    {
        if ($tokenBinding->getStatus() !== TokenBinding::TOKEN_BINDING_STATUS_PRESENT) {
            return;
        }

        $request->hasHeader('Sec-Token-Binding') || throw InvalidDataException::create(
            $tokenBinding,
            'The header parameter "Sec-Token-Binding" is missing.'
        );
        $tokenBindingIds = $request->getHeader('Sec-Token-Binding');
        count($tokenBindingIds) === 1 || throw InvalidDataException::create(
            $tokenBinding,
            'The header parameter "Sec-Token-Binding" is invalid.'
        );
        $tokenBindingId = reset($tokenBindingIds);
        $tokenBindingId === $tokenBinding->getId() || throw InvalidDataException::create(
            $tokenBinding,
            'The header parameter "Sec-Token-Binding" is invalid.'
        );
    }
}

The same content is in 155 releases, Joomla 5.0.0-alpha1 to 6.2.1-rc1. See them all, or every version of this file.