CoreFiles by mySites.guru
SignedWith.php34 lines, 871 bytes, from Joomla_4.4.14-Stable-Full_Package.zip
Raw History Compare with 4.4.13
md5
909106cc3b07ef2ff802bc398b6be554
sha1
de1418e26ca3df4e967bdc503e53b4dc03d38de5
sha256
ec924b1dbf2ac1f2367f3418641043d4912c64e2134b9f58cd1e5372a6ee6614
<?php

namespace Lcobucci\JWT\Validation\Constraint;

use Lcobucci\JWT\Signer;
use Lcobucci\JWT\Token;
use Lcobucci\JWT\Validation\Constraint;
use Lcobucci\JWT\Validation\ConstraintViolation;

final class SignedWith implements Constraint
{
    /** @var Signer */
    private $signer;

    /** @var Signer\Key */
    private $key;

    public function __construct(Signer $signer, Signer\Key $key)
    {
        $this->signer = $signer;
        $this->key    = $key;
    }

    public function assert(Token $token)
    {
        if ($token->headers()->get('alg') !== $this->signer->getAlgorithmId()) {
            throw new ConstraintViolation('Token signer mismatch');
        }

        if (! $this->signer->verify((string) $token->signature(), $token->getPayload(), $this->key)) {
            throw new ConstraintViolation('Token signature mismatch');
        }
    }
}

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.