public function authenticate(TokenInterface $token)
 {
     if (!$this->supports($token)) {
         return null;
     }
     if (!($user = $token->getUser())) {
         throw new BadCredentialsException('No pre-authenticated shibboleth principal found in request.');
     }
     try {
         $user = $this->retrieveUser($token);
         $this->checkAuthentication($user, $token);
         if ($user instanceof UserInterface) {
             $this->userChecker->checkPostAuth($user);
         }
         $authenticatedToken = new ShibbolethUserToken($user, $token->getAttributes());
         $authenticatedToken->setAuthenticated(true);
         if (null !== $this->logger) {
             $this->logger->debug(sprintf('ShibbolethAuthProvider: authenticated token: %s', $authenticatedToken));
         }
         return $authenticatedToken;
     } catch (UsernameNotFoundException $notFound) {
         throw $notFound;
     }
 }