summaryrefslogtreecommitdiffstats
path: root/Core/Authentication/AuthenticationProviderManager.php
diff options
context:
space:
mode:
authorJohannes Schmitt <schmittjoh@gmail.com>2011-07-07 21:28:39 +0200
committerDariusz Górecki <darek.krk@gmail.com>2011-11-22 14:44:41 +0100
commita02663ada4f50a7e49961085a4ef55e185226d6e (patch)
treeadfac065807c43806848649f5da78ee0dad0c03c /Core/Authentication/AuthenticationProviderManager.php
parente5ad66509f2739df908408c73b783186c43d07bf (diff)
downloadsymfony-security-a02663ada4f50a7e49961085a4ef55e185226d6e.zip
symfony-security-a02663ada4f50a7e49961085a4ef55e185226d6e.tar.gz
symfony-security-a02663ada4f50a7e49961085a4ef55e185226d6e.tar.bz2
added authentication success/failure events
Diffstat (limited to 'Core/Authentication/AuthenticationProviderManager.php')
-rw-r--r--Core/Authentication/AuthenticationProviderManager.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/Core/Authentication/AuthenticationProviderManager.php b/Core/Authentication/AuthenticationProviderManager.php
index a82b9fb..7ca46c0 100644
--- a/Core/Authentication/AuthenticationProviderManager.php
+++ b/Core/Authentication/AuthenticationProviderManager.php
@@ -11,6 +11,10 @@
namespace Symfony\Component\Security\Core\Authentication;
+use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent;
+use Symfony\Component\Security\Core\Event\AuthenticationEvent;
+use Symfony\Component\Security\Core\AuthenticationEvents;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Security\Core\Exception\AccountStatusException;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\ProviderNotFoundException;
@@ -22,11 +26,13 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
* instances to authenticate a Token.
*
* @author Fabien Potencier <fabien@symfony.com>
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class AuthenticationProviderManager implements AuthenticationManagerInterface
{
private $providers;
private $eraseCredentials;
+ private $eventDispatcher;
/**
* Constructor.
@@ -44,6 +50,11 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface
$this->eraseCredentials = (Boolean) $eraseCredentials;
}
+ public function setEventDispatcher(EventDispatcherInterface $dispatcher)
+ {
+ $this->eventDispatcher = $dispatcher;
+ }
+
/**
* {@inheritdoc}
*/
@@ -77,6 +88,10 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface
$result->eraseCredentials();
}
+ if (null !== $this->eventDispatcher) {
+ $this->eventDispatcher->dispatch(AuthenticationEvents::AUTHENTICATION_SUCCESS, new AuthenticationEvent($result));
+ }
+
return $result;
}
@@ -84,6 +99,10 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface
$lastException = new ProviderNotFoundException(sprintf('No Authentication Provider found for token of class "%s".', get_class($token)));
}
+ if (null !== $this->eventDispatcher) {
+ $this->eventDispatcher->dispatch(AuthenticationEvents::AUTHENTICATION_FAILURE, new AuthenticationFailureEvent($token, $lastException));
+ }
+
$lastException->setExtraInformation($token);
throw $lastException;