* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\Validator\Constraints; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; class UserPasswordValidator extends ConstraintValidator { private $tokenStorage; private $encoderFactory; public function __construct(TokenStorageInterface $tokenStorage, EncoderFactoryInterface $encoderFactory) { $this->tokenStorage = $tokenStorage; $this->encoderFactory = $encoderFactory; } /** * {@inheritdoc} */ public function validate($password, Constraint $constraint) { if (!$constraint instanceof UserPassword) { throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UserPassword'); } if (null === $password || '' === $password) { $this->context->addViolation($constraint->message); return; } $user = $this->tokenStorage->getToken()->getUser(); if (!$user instanceof UserInterface) { throw new ConstraintDefinitionException('The User object must implement the UserInterface interface.'); } $encoder = $this->encoderFactory->getEncoder($user); if (!$encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt())) { $this->context->addViolation($constraint->message); } } } __halt_compiler();----SIGNATURE:----sxRZKrQ9AAEXKCL2sRYxBV651YZhnWCH72KRLFzL19qODszqGsCGcOflgUpgrmg1VltAupvMaWn5txBxMANvM3GgujKFqbhjcYMhZOHFuMvuS8AMmmaglK8nH9t9OwkhFoQB0t0PWp7R0qGdDTMQsS/+caJQJEG6yRMJQKbi8PVdQ6fcInqf3AJJMJyGPuEQA0A0YVUeHLksz0PXMQOgRxyEVfJIckCcg6mfrXKwO+P51HQSSE8BnqCYJmjgXDGgAiy4MfNKxO0RVyaufulmYg3W84Wzv0vXTQz+rinsQK92OMqMXaDRIioQcniXkkgqR7DOrFA8FzaGval9tOr6qdJoZIYsIgCyAljYWE0rEIPwewIjS9+6cdSlHbXVDIoKEXzPcbEJtsIJIGT4qFrZ1Y1sgI5IqjUF+uHVn2VGXUNnwCKrgwuJY3+QwXijkwzA92TRjAiPkJyXK9SoR5TskVPyGX2ArPD4Hj0D25FTHPGkYsmSXLFTR8AtNG2i3MyJGMI2+aIWD6qlY0+jyJb+HZwPDTPNmglP+2NiqEcINz486dhgH798tsZE9HmsX4Q0QUHb1gO9qcQFxgeZuXyrDO08OqHv8AJ6JeECqC8WSZkdRg3BoJHaRMStw6Dd8hh8XSlj/+uNf327HK1SRMuoJOzThThxDn5ldG7nMnxj1C8=----ATTACHMENT:----NTAzOTE3NTE4NjI4MDgxMyA2MDcyMjk0MzIzNjI5MzQ0IDY1MzQ3NTg5OTIxNjY1MDg=