public function getFirewall($configName = null, array $options = array(), Request $request = null)
    {
        if (!$request) {
            if ($this->container->has('request_stack')) {
                $requestStack = $this->container->get('request_stack');
                $request = $requestStack->getCurrentRequest();
            } elseif ($this->container->has('request')) {
                $request = $this->container->get('request');
            } else {
                throw new \Exception('Request object undefined');
            }
        }

        $firewall = new $this->firewallClass();
        $firewall->setProvider($this);
        $firewall->setRequest($request);

        $this->setDefaults($firewall, $configName, $options);

        $this->firewalls[] = $firewall;

        return $firewall;
    }