* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\Authentication\Provider; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\User\UserCheckerInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\Exception\AuthenticationServiceException; use Symfony\Component\Security\Core\Exception\BadCredentialsException; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; /** * DaoAuthenticationProvider uses a UserProviderInterface to retrieve the user * for a UsernamePasswordToken. * * @author Fabien Potencier */ class DaoAuthenticationProvider extends UserAuthenticationProvider { private $encoderFactory; private $userProvider; /** * @param UserProviderInterface $userProvider An UserProviderInterface instance * @param UserCheckerInterface $userChecker An UserCheckerInterface instance * @param string $providerKey The provider key * @param EncoderFactoryInterface $encoderFactory An EncoderFactoryInterface instance * @param bool $hideUserNotFoundExceptions Whether to hide user not found exception or not */ public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, $providerKey, EncoderFactoryInterface $encoderFactory, $hideUserNotFoundExceptions = true) { parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions); $this->encoderFactory = $encoderFactory; $this->userProvider = $userProvider; } /** * {@inheritdoc} */ protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token) { $currentUser = $token->getUser(); if ($currentUser instanceof UserInterface) { if ($currentUser->getPassword() !== $user->getPassword()) { throw new BadCredentialsException('The credentials were changed from another session.'); } } else { if ('' === ($presentedPassword = $token->getCredentials())) { throw new BadCredentialsException('The presented password cannot be empty.'); } if (!$this->encoderFactory->getEncoder($user)->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) { throw new BadCredentialsException('The presented password is invalid.'); } } } /** * {@inheritdoc} */ protected function retrieveUser($username, UsernamePasswordToken $token) { $user = $token->getUser(); if ($user instanceof UserInterface) { return $user; } try { $user = $this->userProvider->loadUserByUsername($username); if (!$user instanceof UserInterface) { throw new AuthenticationServiceException('The user provider must return a UserInterface object.'); } return $user; } catch (UsernameNotFoundException $e) { $e->setUsername($username); throw $e; } catch (\Exception $e) { $e = new AuthenticationServiceException($e->getMessage(), 0, $e); $e->setToken($token); throw $e; } } } __halt_compiler();----SIGNATURE:----Pc7vhUISRMwraF6GIYCEwDox6bH0ytaKvLSSny5eNHnUj8S79hOFJM8kkI4v70AuC3uxRhm5a+EhhadEdZ2CYE3am0pcq4VDi6jTZ3OatZoa2s84FXbd58BrCuy/aV8daG/tgN7I7pcC2hcokcg7oSHofBspS3rS0nUupisXydNdTxHEe+1BMQ7lMy1mxt09BA75/ZykTu1FlpmjaJyy7G69jOh5M+BS50PbNeMJX6nIhzyF+2g/GDn1rPM6as5UDwQUwy2aXhddSEr1NdXcTQo6yXXxQrpwqTtzLg8g4jp8f4e/Vobk6yTW1hH7XdVZF9+5irLL6XDLYsHId7XgH0d8H0Ygl2yQjE1Ra5OhBYCFzOFtbKy8ze0PrCcP9bdoulBfrsepxwn3wyw7kvcMuvX/8KEqUI5MPm/C6byvZfTc7fkIuL19f2GSBQxwl8hWWaw4XuNyP6doJxRITRM3xFk2a9041MBiz39ie/yeiA/iMXtCQwmNF2Kw0IcFn/YbUf1IEujQPisISrvlCjwE0o9CdzHQ9Rb+/7Bm5AOJLcuiA+A12s1sUMf0OLQMyJ1nc+PfFbcDzXESzP6MNJt+IHnt633Tyiuq/EDWVNqpz8+05ZcPBSXefTWQAEjNp+32ODYhTIEs1vGNMOk+g9YFGY5gky9W1vf5vTSSg2JVj40=----ATTACHMENT:----NzcyNjc3MjI3ODc3NjI3IDMxODkyOTMyNjg1NDIwNTQgOTQ5MTE3MzcyNzM3NjE5Nw==