public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $chain = new AdapterChain();
     $adapter = $serviceLocator->get('ZfcUser\\Authentication\\Adapter\\Db');
     $chain->getEventManager()->attach('authenticate', array($adapter, 'authenticate'));
     return $chain;
 }
 /**
  * Test the logoutAdapters method.
  *
  * @depends testGetEventWithEventSet
  * @covers ZfcUser\Authentication\Adapter\AdapterChain::logoutAdapters
  */
 public function testLogoutAdapters()
 {
     $event = new AdapterChainEvent();
     $this->eventManager->expects($this->once())->method('trigger')->with('logout', $event);
     $this->adapterChain->setEvent($event);
     $this->adapterChain->logoutAdapters();
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $chain = new AdapterChain();
     $options = $this->getOptions($serviceLocator);
     //iterate and attach multiple adapters and events if offered
     foreach ($options->getAuthAdapters() as $priority => $adapterName) {
         $adapter = $serviceLocator->get($adapterName);
         if (is_callable(array($adapter, 'authenticate'))) {
             $chain->getEventManager()->attach('authenticate', array($adapter, 'authenticate'), $priority);
         }
         if (is_callable(array($adapter, 'logout'))) {
             $chain->getEventManager()->attach('logout', array($adapter, 'logout'), $priority);
         }
     }
     return $chain;
 }
 /**
  * Delegate checking of user credentials to ZfcUser's onboard adapter chain
  *
  * @param  string  $username
  * @param  string  $password
  * @return boolean
  */
 public function checkUserCredentials($username, $password)
 {
     $request = new \Zend\Http\Request();
     $request->getPost()->set('identity', $username);
     $request->getPost()->set('credential', $password);
     $adapterResult = $this->authAdapter->prepareForAuthentication($request);
     if ($adapterResult instanceof \Zend\Stdlib\ResponseInterface) {
         return false;
     }
     $authResult = $this->auth->authenticate($this->authAdapter);
     if (!$authResult->isValid()) {
         $this->authAdapter->resetAdapters();
         return false;
     }
     return true;
 }