* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Http; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Firewall uses a FirewallMap to register security listeners for the given * request. * * It allows for different security strategies within the same application * (a Basic authentication for the /api, and a web based authentication for * everything else for instance). * * @author Fabien Potencier */ class Firewall implements EventSubscriberInterface { private $map; private $dispatcher; private $exceptionListeners; public function __construct(FirewallMapInterface $map, EventDispatcherInterface $dispatcher) { $this->map = $map; $this->dispatcher = $dispatcher; $this->exceptionListeners = new \SplObjectStorage(); } public function onKernelRequest(GetResponseEvent $event) { if (!$event->isMasterRequest()) { return; } // register listeners for this firewall $listeners = $this->map->getListeners($event->getRequest()); $authenticationListeners = $listeners[0]; $exceptionListener = $listeners[1]; $logoutListener = isset($listeners[2]) ? $listeners[2] : null; if (null !== $exceptionListener) { $this->exceptionListeners[$event->getRequest()] = $exceptionListener; $exceptionListener->register($this->dispatcher); } $this->handleRequest($event, $authenticationListeners); if (null !== $logoutListener) { $logoutListener->handle($event); } } public function onKernelFinishRequest(FinishRequestEvent $event) { $request = $event->getRequest(); if (isset($this->exceptionListeners[$request])) { $this->exceptionListeners[$request]->unregister($this->dispatcher); unset($this->exceptionListeners[$request]); } } /** * {@inheritdoc} */ public static function getSubscribedEvents() { return array( KernelEvents::REQUEST => array('onKernelRequest', 8), KernelEvents::FINISH_REQUEST => 'onKernelFinishRequest', ); } protected function handleRequest(GetResponseEvent $event, $listeners) { foreach ($listeners as $listener) { $listener->handle($event); if ($event->hasResponse()) { break; } } } } __halt_compiler();----SIGNATURE:----bYuCyGnaVFKcbcP9XJct9pZ5ehi1ZJSpKxGZiT9F2ELInof3wuejMnCVEnu7igjHO8Qz5N0+BNqG4S3koIAvejv6+vYT7f8a7ZblKk+V3osbtA1VlKWmdDl1fVROjcDYcBUIYr7aKo6VwaAeOC5mOLkrGwCCRK9TVpOuYxpUnMGyWlxgL2Xl7doPHOeoUhYa5k3aaeP9SsgP+DWMvKZb10KXXH/gu2fQMRSgTYeQdPG2q2tDh0Hj2TEjSbdYuOVZ6b89lne30nueeAPTRkkrHv/TKgPZrd5vfDHfTWU9qFgfrwYcZrFkg5iRintoYrJN7R5mow8yDCNqL8WdVsf+gKC1zvtkywHv55nH9jos2KS+EMBjX6Bxj7Mr+nbJsknrZxaVnh2C77yfBJU66XGcbRrGAG1PqsRh103rImmsxxrS0aw8gvOZ3i6j8fctsTMht6BXV/qmOv0yoFvQNF0O8yZp9LKIimeW/nFZ8vFTAgn28vjAD53asMVCUMsEd16Ynwv+TaDz/hOfHuzRMl0tbOfvKMq9Bforf/LCiGAm34Y/PGOpsRM4sWMXP81DEpm6RuGCnx8DIEHdJxWvpml25mgKYGN4d2erKRQXDRKUoFE4/1wTimN/cJk5avMjGMZb0VFW5KeKjTkBIr3whT0JQTtIEaqMnF0Q78mdEoLKoz8=----ATTACHMENT:----Mzg4ODM5MzM3OTI5NzM5NSAzMDAxNTcyMjQyNDMyNzY4IDM5MDc0MzQ0OTgxMjYyMjQ=