public function authenticate(SecurityContextInterface $context)
 {
     $token = $this->generateEmptyToken();
     $client = null;
     try {
         $client = $this->userAuthenticationProvider->loadClientByCredentials($token->getClient()->getCredentials());
     } catch (ClientCredentialsNotFoundException $e) {
         $this->logger->addAlert('Client not found ' . $e->getMessage());
         throw $e;
     }
     //validate the client, if good then add to the context
     if (!is_null($client)) {
         if ($this->statusIsLocked($client)) {
             $this->container->get('EventDispatcher')->dispatch(__YML_KEY, 'login_status_locked', array('client' => $client));
             setSession('_security_secured_area', null);
         } elseif (!$this->checkPasswordsMatch($client->getPassword(), $token->getClient()->getPassword())) {
             $this->container->get('EventDispatcher')->dispatch(__YML_KEY, 'login_password_mismatch', array('client' => $client));
         } elseif (!$this->checkStatus($client)) {
             $this->container->get('EventDispatcher')->dispatch(__YML_KEY, 'login_status_not_active', array('client' => $client));
         }
         $token->setClient($client);
     }
     $context->setToken($token);
     setSession('_security_secured_area', serialize($token));
     $this->container->set('securityContext', 'core\\components\\security\\core\\SecurityContext', $context);
 }
 public function authenticate(SecurityContextInterface $context)
 {
     $token = $this->generateEmptyToken();
     try {
         $this->userAuthenticationProvider->loadClientByCredentials($token->getClient()->getCredentials());
     } catch (ClientCredentialsNotFoundException $e) {
         $this->logger->addAlert('Client not found ' . $e->getMessage());
         throw $e;
     }
     //validate the client, if good then add to the context
     if (true) {
         $context->setToken($token);
     }
 }