/**
  * @param AuthenticationEvent $event
  */
 public function onAuthenticationSuccess(AuthenticationEvent $event)
 {
     $token = $event->getAuthenticationToken();
     $user = $token->getUser();
     /** @var ClientInterface $user */
     if ($user instanceof ClientInterface) {
         $accessToken = hash('sha256', uniqid(microtime(true)));
         $user->setAccessToken($accessToken);
         $this->clientProvider->updateClient($user);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function authenticate(ConnectionInterface $connection, $accessToken)
 {
     if (!isset($this->connections[$connection->getId()])) {
         throw new NotManagedConnectionException();
     }
     if (null !== ($client = $this->clientProvider->findByAccessToken($accessToken))) {
         $connection->setClient($client);
         return true;
     }
     return false;
 }