/**
  * @param TokenInterface $token
  * @param UserProviderInterface $userProvider
  * @param $providerKey
  * @return UsernamePasswordToken
  */
 public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
 {
     try {
         if ($userProvider instanceof IsidoreApiUserProvider) {
             $user = $userProvider->loadUser($token->getUsername(), $token->getCredentials());
         } else {
             $user = $userProvider->loadUserByUsername($token->getUsername());
         }
     } catch (UsernameNotFoundException $e) {
         throw new CustomUserMessageAuthenticationException("Identifiant ou mot de passe incorrect. Veuillez réessayer.");
     }
     $passwordValid = $this->encoder->isPasswordValid($user, $token->getCredentials());
     if ($passwordValid) {
         return new UsernamePasswordToken($user, $user->getPassword(), $providerKey, $user->getRoles());
     }
     throw new CustomUserMessageAuthenticationException("Identifiant ou mot de passe incorrect. Veuillez réessayer.");
 }