private function executeAuthenticator(AuthenticatorInterface
$authenticator, Request
$request): ?Response
{ $passport = null;
$previousToken =
$this->tokenStorage->
getToken();
try { // get the passport from the Authenticator
$passport =
$authenticator->
authenticate($request);
// check the passport (e.g. password checking)
$event =
new CheckPassportEvent($authenticator,
$passport);
$this->eventDispatcher->
dispatch($event);
// check if all badges are resolved
$resolvedBadges =
[];
foreach ($passport->
getBadges() as $badge) { if (!
$badge->
isResolved()) { throw new BadCredentialsException(sprintf('Authentication failed: Security badge "%s" is not resolved, did you forget to register the correct listeners?',
get_debug_type($badge)));
} $resolvedBadges[] =
$badge::
class;
}