*/ class AuthenticationProvider implements AuthenticationProviderInterface { protected $userProvider; public function __construct(UserProvider $userProvider) { $this->userProvider = $userProvider; } public function authenticate(TokenInterface $token) { $user = $this->userProvider->loadUserByUsername($token->getUser()); if ($user) { $isValid = $this->userProvider->getEncoder()->isPasswordValid( $user->getPassword(), $token->getCredentials(), $user->getSalt() ); if (!$isValid) { throw new AuthenticationException('Authentication failed.'); } return; } throw new AuthenticationException('Authentication failed.'); } public function supports(TokenInterface $token) { return $token instanceof UsernamePasswordToken; } }