* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Http\Firewall; use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Psr\Log\LoggerInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; /** * AnonymousAuthenticationListener automatically adds a Token if none is * already present. * * @author Fabien Potencier */ class AnonymousAuthenticationListener implements ListenerInterface { private $tokenStorage; private $secret; private $authenticationManager; private $logger; public function __construct(TokenStorageInterface $tokenStorage, $secret, LoggerInterface $logger = null, AuthenticationManagerInterface $authenticationManager = null) { $this->tokenStorage = $tokenStorage; $this->secret = $secret; $this->authenticationManager = $authenticationManager; $this->logger = $logger; } /** * Handles anonymous authentication. */ public function handle(GetResponseEvent $event) { if (null !== $this->tokenStorage->getToken()) { return; } try { $token = new AnonymousToken($this->secret, 'anon.', array()); if (null !== $this->authenticationManager) { $token = $this->authenticationManager->authenticate($token); } $this->tokenStorage->setToken($token); if (null !== $this->logger) { $this->logger->info('Populated the TokenStorage with an anonymous Token.'); } } catch (AuthenticationException $failed) { if (null !== $this->logger) { $this->logger->info('Anonymous authentication failed.', array('exception' => $failed)); } } } } __halt_compiler();----SIGNATURE:----iocJxU3DXHDHh23ilrrBjHAHLxQn9yME6ju+ouPl0J6Q1/A/N/D1mRe+JnO4oot5qKOLhrt6pdb03G7Bg+NjFDGSSYEN2z0w+Kf4333ciXW0NgkvOgkiSc7RW4u7yRZePu9R2fdPPcbzTqB1NP4+yI8SOJ0Xa97WyVs+BxH+a0fqhdXfolocVJwER3Vl5scmLfKV0dHaBtLBc1o2QUzRAhNqdKZdq4ldEOup6tjdh20XdOd500s4tWZHYuSuskgd7/ZrqHKchW0+tQ9vW82aF5blegjyaAn9I8ogPZKq78N3EiIHt+FzvOSFDqzCZ6QlrePnoXtnlgkFUv1UrPzBz1EuUzsadxDdklfNzRFKZZCGW/WeQMD5vxyJDiNEk4OSIVI8297hFyuIeRVsEpHPkTQ2Dh66XHpL1g98sRu7GjCnqu1ttEXtbl6OQAa30wOU+xIf7fxBYyOrbxi527D8GMMNs2PcN9VdZPHarF+2sO7R83jnnp/6gjheekSqTMz4r9U+G43vdHxuV0rC8faAtbsD71+kmXMeLC765bL7J/jQOsXONFBozfjDKsL0JuR371DOqM7mmHWJv89865hSsvxNr8SY1FhedP7Ds1Lqk08jOxhwuZGKBouuRlL07dIxBBWlPOK/7Hkz17aGDOKVBBsU/WW2CRD3N+xDnfTezQw=----ATTACHMENT:----ODEyMTgxODYxMzc1MDkxOSA3Mjk4MDQzNzMwNzc2NjA2IDM1NDU3ODQ4NDUyMTk5Mg==