* * 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:----irZD/rbNsuwCdqDcvK2L8Yulho13MqhU+I6iTaAfOsH3xupTnqyiV/t+x8EIqCX5XaVbQR3uY9iZSuH4y/g4yR1JN+GCHZ2qifi2KaIOKMba+zX6t2FvGSgbjjLRl0GITflFg4L6aLr/Og/1vyT0YHUMYAerKvAHEa1s5eKiFFuugTuceavE5R5TVJfwhhHIaD733RrHTBXuGIPe3KauZyMvfWJMtZm1SbwnwrPoB2C//7rxX/7rL86vxmjj5tw7m4kXGowUnYtmIN2BB0XAzbkdGlOBK00H6n216A3ST+FlJaC1MKagWzD9zpKFOkjSAG3S07mVrmm1Kl20GIrBfPjmneojg6j0SCtJTekgQcnviqw1sx2OjQ7RcUsOD65CaxywsL2yqnbZeLLngqtyoQpO874PXNSHGSUHQ5hyIuGJb5cUOMPBvsHJGqilhr0tx+4VtgF9sEWnB3k92a4G+kLk+r1GXv2Jq4CtSPkpT3w/dCm2sn3t6yxxPQYi/bp6JOLPNFYxSsi2xku22fZeY1OPw3WZx+cUpp0JaMboa6waTXvZAFAf6H+Z6+E1rShQoyvg2jKrMnQTJyoF4mCsv2MEM6zI5Porb+B+og+vhL/R90V6FwdRU0WNsTxazy77fNDFbkIYhTpeHGhcKmEyO/pvWFRiliiVXFiNrjSDGDk=----ATTACHMENT:----NDA3MDYzMDA4NDg0MjkxMiAxNzI4NTcwNzgzODY2MzQ0IDYxMjk0OTU0NDU2NTk1NDk=