Example #1
0
 public function authenticate(TokenInterface $token)
 {
     if (!$this->supports($token)) {
         return null;
     }
     $user = $this->userProvider->loadUserByUsername($token->getUsername());
     if ($user) {
         $authenticatedToken = new SamlUserToken($user->getRoles());
         $authenticatedToken->setUser($user);
         $authenticatedToken->setAuthenticated(true);
         $authenticatedToken->setAttributes($token->getAttributes());
         $authenticatedToken->setDirectEntry($token->getDirectEntry());
         return $authenticatedToken;
     }
     throw new AuthenticationException('The SAML authentication failed.');
 }