* * 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:----Q9ggA/UunxUQbg8koFbg8URI0Aq9ImllOHZtM3vwBEEkZIHUpeoNi9mEKAI2/K9oFnMitGp58346fpi+3o3Q4pwsakferuN9bdwmAw8eO7QSI0/wkA0KG3Kic50oHAh+L+5WC2bSPRdg4nsHPHENh8sRNXorfEdJjYwSebDc1o76WR21u7Ow01hsNT38IPbqYXPKFaj0+t5nHI3Y0es44fqAizK4Z01+gRVUk4sgkBX7+uIdjT+qz6S9JnjpPMqJiUIIjPTWWG4o5JiSxZXHlpMuI/xg5/Sqag37eMr9Wlzo4uMJcccZXBCh3kBOwIrEudVHog37Ji+IwhWlJKu+44W56ZI8tATRTuKKWY/0asKrph+2QONKOuD4KyqcMOoULr4XJzcevhIDrIwje7+XUM0zNcng4uP0wt9S816d9FdWBmBMlIfAUwpfyvuekyScS1kywRkgCL+kp2QBfb/KT2zfqg1xRkrPE5iNETffEVIdEI+cmO+5FiFTvAqhVw2jvbnyAxZGhRFnNvkKPxeVeMJbEm2ag6GCALhpV4hRoUK+j1poErf6g5Vu543jm+5JOvQ2/W16DNwigQPHnqROqc9sUWih4biC9Jjrrlh04G/U09bfA6HvtaEd4ENxzz8U6Mev7h7l+3Yr+CVw5Mn871su1hJp7452GL4aUA56+B8=----ATTACHMENT:----ODgwNzczODU3NzI2NDI5OCAyNzM5MzE1ODQ1OTE4NjU1IDI5MjI2ODgyOTgxMzg1MjM=