* * 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:----uu5+5n1piDCzIXb861qtjnKU2NhrY2GcbbW99Q94ZVt9It0lH9eDVWqQr2QYtzWnQ+n0tCcUfVlL36MsTnvxbJ8dQDCXDnUtQTbNOWYZes3sCgXQdovRzMCFjn+6H27oh+kyb8GBxSALyLcHtPwvwY9i24UZJznQa6mNp4cv6CLe8qmrJwVivgnRnR/CxtMtsyT2Xre7QU/cL41L+++4SBNiZsXfLHlBpSCO2CbhkU6Wcwh+582BDMHlpXoTpBKlTsh++ORgKr90kxPjnmrvbkO+KLivTxuhVNn6MWr/dQ4UM3gsWZPDb5LMNTHnzqyNmixlAUdFfdwMtj3ERPuQ2NPS2vjBqDjYPCh/It0A67wbVjB+Ne3FEbTn02AMjjWdP1GBeyJyT5xxrsVjeqSrlrG3ecVcRfRjZcORd/+1qVk1PXYST75blgqg3MXOY4xp7qeEybiQOddOVxALR7oECHI3zjyZRHTAgyKenQE9uTthAKefJ2md7Xh7Fpg++knEJKRGJAvDKSy2e9ZQtO8MOQOdoOxxScwtzHedUAVpmGCYgBhAwRtgBOx6Nwejb0QsM7JOYq0/Aw+twaxoIvNWqxQPLEMSyu5zibw0I9mNmaK9wTrz4ZfOKq9fuDrbP4UgtKRN00lqSAojjNeSL3RRHu+o7k+KDdD3Q1nX8wCNJvI=----ATTACHMENT:----ODkxODc0ODY3NTU2ODMxNiA5NjA5MzA4MTU4NjU3Njg3IDcyNjgzNjA1Njk0NDgzODQ=