diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml
index 64a2c251dec73..63f4b48c73848 100644
--- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml
+++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml
@@ -58,8 +58,8 @@
-
+
diff --git a/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php
index 986c9a8ee1c4d..72f0071424389 100644
--- a/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php
+++ b/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php
@@ -31,7 +31,7 @@ class AnonymousAuthenticationListener implements ListenerInterface
private $authenticationManager;
private $logger;
- public function __construct(SecurityContextInterface $context, $key, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null)
+ public function __construct(SecurityContextInterface $context, $key, LoggerInterface $logger = null, AuthenticationManagerInterface $authenticationManager = null)
{
$this->context = $context;
$this->key = $key;
@@ -51,7 +51,10 @@ public function handle(GetResponseEvent $event)
}
try {
- $token = $this->authenticationManager->authenticate(new AnonymousToken($this->key, 'anon.', array()));
+ if (null !== $this->authenticationManager) {
+ $token = $this->authenticationManager->authenticate(new AnonymousToken($this->key, 'anon.', array()));
+ }
+
$this->context->setToken($token);
if (null !== $this->logger) {