summaryrefslogtreecommitdiffstats
path: root/Authentication/Provider
diff options
context:
space:
mode:
authorJohannes Schmitt <schmittjoh@gmail.com>2010-12-21 16:10:53 +0100
committerJohannes Schmitt <schmittjoh@gmail.com>2010-12-21 16:23:46 +0100
commit59fad126fb69ad04228cb1f98a5b1f78ad04dd25 (patch)
treee4511c680da314fe05f0b9c7275617cc9e328fb6 /Authentication/Provider
parent5853e1f130f888bfe2e5e5830ed930218cfe693b (diff)
downloadsymfony-security-59fad126fb69ad04228cb1f98a5b1f78ad04dd25.zip
symfony-security-59fad126fb69ad04228cb1f98a5b1f78ad04dd25.tar.gz
symfony-security-59fad126fb69ad04228cb1f98a5b1f78ad04dd25.tar.bz2
added generic encoder factory
Diffstat (limited to 'Authentication/Provider')
-rw-r--r--Authentication/Provider/DaoAuthenticationProvider.php16
1 files changed, 6 insertions, 10 deletions
diff --git a/Authentication/Provider/DaoAuthenticationProvider.php b/Authentication/Provider/DaoAuthenticationProvider.php
index eaf3242..a44584f 100644
--- a/Authentication/Provider/DaoAuthenticationProvider.php
+++ b/Authentication/Provider/DaoAuthenticationProvider.php
@@ -2,11 +2,10 @@
namespace Symfony\Component\Security\Authentication\Provider;
+use Symfony\Component\Security\Encoder\EncoderFactoryInterface;
use Symfony\Component\Security\User\UserProviderInterface;
use Symfony\Component\Security\User\AccountCheckerInterface;
use Symfony\Component\Security\User\AccountInterface;
-use Symfony\Component\Security\Encoder\PasswordEncoderInterface;
-use Symfony\Component\Security\Encoder\PlaintextPasswordEncoder;
use Symfony\Component\Security\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Exception\AuthenticationServiceException;
use Symfony\Component\Security\Exception\BadCredentialsException;
@@ -29,7 +28,7 @@ use Symfony\Component\Security\Authentication\Token\UsernamePasswordToken;
*/
class DaoAuthenticationProvider extends UserAuthenticationProvider
{
- protected $passwordEncoder;
+ protected $encoderFactory;
protected $userProvider;
/**
@@ -37,16 +36,13 @@ class DaoAuthenticationProvider extends UserAuthenticationProvider
*
* @param UserProviderInterface $userProvider A UserProviderInterface instance
* @param AccountCheckerInterface $accountChecker An AccountCheckerInterface instance
- * @param PasswordEncoderInterface $passwordEncoder A PasswordEncoderInterface instance
+ * @param EncoderFactoryInterface $encoderFactory A EncoderFactoryInterface instance
*/
- public function __construct(UserProviderInterface $userProvider, AccountCheckerInterface $accountChecker, PasswordEncoderInterface $passwordEncoder = null, $hideUserNotFoundExceptions = true)
+ public function __construct(UserProviderInterface $userProvider, AccountCheckerInterface $accountChecker, EncoderFactoryInterface $encoderFactory, $hideUserNotFoundExceptions = true)
{
parent::__construct($accountChecker, $hideUserNotFoundExceptions);
- if (null === $passwordEncoder) {
- $passwordEncoder = new PlaintextPasswordEncoder();
- }
- $this->passwordEncoder = $passwordEncoder;
+ $this->encoderFactory = $encoderFactory;
$this->userProvider = $userProvider;
}
@@ -65,7 +61,7 @@ class DaoAuthenticationProvider extends UserAuthenticationProvider
throw new BadCredentialsException('Bad credentials');
}
- if (!$this->passwordEncoder->isPasswordValid($account->getPassword(), $presentedPassword, $account->getSalt())) {
+ if (!$this->encoderFactory->getEncoder($account)->isPasswordValid($account->getPassword(), $presentedPassword, $account->getSalt())) {
throw new BadCredentialsException('Bad credentials');
}
}