public function firewall($firewallKey = '')
    {
        // initialize firewall
        if (isset($this->firewalls[$firewallKey])) {
            $fw = $this->firewalls[$firewallKey];
        } else {
            if ($firewallKey == '') {
                $firewall = $this->getConfig()->Firewalls[0];
                if (empty($firewall)) {
                    throw new SecurityException("There are no firewalls defined inside your configuration.");
                }
            } else {
                $firewall = $this->getConfig()->Firewalls->get($firewallKey, false);


                if (!$firewall) {
                    throw new SecurityException("Firewall '" . $firewallKey . "' is not defined under Security.Firewalls.");
                }
            }

            $fw = new Firewall($firewallKey, $firewall, $this->getFirewallUserProviders($firewallKey),
                $this->getFirewallEncoder($firewallKey));

            $this->firewalls[$firewallKey] = $fw;
        }

        return $fw;
    }