PHP 8.3.31
Preview: AnonymousAuthenticationProvider.php Size: 1.42 KB
/opt/alt/php54/usr/share/pear/Symfony/Component/Security/Core/Authentication/Provider/AnonymousAuthenticationProvider.php

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Security\Core\Authentication\Provider;

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;

/**
 * AnonymousAuthenticationProvider validates AnonymousToken instances.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 */
class AnonymousAuthenticationProvider implements AuthenticationProviderInterface
{
    private $key;

    /**
     * Constructor.
     *
     * @param string $key The key shared with the authentication token
     */
    public function __construct($key)
    {
        $this->key = $key;
    }

    /**
     * {@inheritdoc}
     */
    public function authenticate(TokenInterface $token)
    {
        if (!$this->supports($token)) {
            return null;
        }

        if ($this->key !== $token->getKey()) {
            throw new BadCredentialsException('The Token does not contain the expected key.');
        }

        return $token;
    }

    /**
     * {@inheritdoc}
     */
    public function supports(TokenInterface $token)
    {
        return $token instanceof AnonymousToken;
    }
}

Directory Contents

Dirs: 0 × Files: 7

Name Size Perms Modified Actions
1.42 KB lrw-r--r-- 2019-12-18 11:22:57
Edit Download
1.03 KB lrw-r--r-- 2019-12-18 11:22:57
Edit Download
3.78 KB lrw-r--r-- 2019-12-18 11:22:57
Edit Download
2.74 KB lrw-r--r-- 2019-12-18 11:22:57
Edit Download
1.96 KB lrw-r--r-- 2019-12-18 11:22:57
Edit Download
1.62 KB lrw-r--r-- 2019-12-18 11:22:57
Edit Download
5.12 KB lrw-r--r-- 2019-12-18 11:22:57
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).