Source of file AnonymousAuthenticationProvider.php
Size: 1,459 Bytes - Last Modified: 2013-07-17T08:22:21+02:00
/home/theseer/Downloads/Symfony/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/AnonymousAuthenticationProvider.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | <?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; } } |