* * 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:----naxbEdPagyw7eR7+vhVcsQ0+b5Y2BKlbiH9eXt2aJpRArKS6jJgbBPGTzMm8y4IEHaqwoW/UCOslfKqMCWCP3Lj+NreoSg7GeC+K1dgeXTsS4UdUJg/rwp82kcMfVfiSdFs9n7Li2LFGhulJ9Mc6YqUbmlvKhSNLNWprIhv4j0Nq6bEHxnMrEEg5I4pLWaynaL4HMssd/OGc2mYE0Z0oQwquwRVpx87tu/ogWy7ym3UuCnt+Qjdgntp+AuTeaTyZanoW4xjrv0bLiT3s8X1wwKvl0HtLHxhtjrC0kSmK67qhNW/BtAM2Sy+Z4P9t+UNJc12W9LXKJDxoKZ80BjdDwzshm4oKmXTcz3tdsatjY/TQJpiufaAE8xpC5VgxLGWhFvgd1qg4s79moZTXrecBl66OcKo428VdDACz+3wcw9RcMDS2l7qNkTYrzaqBoJ3pHQSUE3ClAFcNvs7dNtA/8F68i3heWmOZfxQ6jaHCBH1gguFmPFUbl5z6S+aZJxNsNCGkLgD7JViGyPo844aPeHwHkCO5zUBxQSfB50odp14A6mcDG4opAJ+8EEbCGYXtLLTaC4AyAqpPMIZQp6T+KdCxRHuF+nuosrzwfkBCxOGM4JLv1MrtAUQfBjr27yphQqYmMV74JajyT3enHGwV3H0g31trBmcMQQBORqCZHsQ=----ATTACHMENT:----NzY1MjAxODUwODUyNDg4OCAzODQyMDM4OTUxMjEyMzIwIDEwMDA1ODIyNTQ2MDkzMzg=