CoreFiles by mySites.guru
None.php41 lines, 825 bytes, from Joomla_5.0.3-Stable-Full_Package.zip
Raw History Compare with 5.0.2
md5
1482f85be339b2549e9ef823e3ff6fc8
sha1
332f1e1c0f940faa40ec01edcdff9e39f23a2149
sha256
94eee3473025c4c896d2b561f0d6a1a6cc3244dd1db6e1ac9bef6a0c40f08fae
<?php

declare(strict_types=1);

namespace Jose\Component\Signature\Algorithm;

use function in_array;
use InvalidArgumentException;
use Jose\Component\Core\JWK;

final class None implements SignatureAlgorithm
{
    public function allowedKeyTypes(): array
    {
        return ['none'];
    }

    public function sign(JWK $key, string $input): string
    {
        $this->checkKey($key);

        return '';
    }

    public function verify(JWK $key, string $input, string $signature): bool
    {
        return $signature === '';
    }

    public function name(): string
    {
        return 'none';
    }

    private function checkKey(JWK $key): void
    {
        if (! in_array($key->get('kty'), $this->allowedKeyTypes(), true)) {
            throw new InvalidArgumentException('Wrong key type.');
        }
    }
}

The same content is in 22 releases, Joomla 5.0.0-alpha1 to 5.1.0-alpha4. See them all, or every version of this file.