本文整理汇总了PHP中Zend\Authentication\AuthenticationService::setAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthenticationService::setAdapter方法的具体用法?PHP AuthenticationService::setAdapter怎么用?PHP AuthenticationService::setAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Authentication\AuthenticationService
的用法示例。
在下文中一共展示了AuthenticationService::setAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('Album\\Model\\AlbumTable' => function ($sm) {
$tableGateway = $sm->get('AlbumTableGateway');
$table = new AlbumTable($tableGateway);
return $table;
}, 'AlbumTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Album());
return new TableGateway('z_album', $dbAdapter, null, $resultSetPrototype);
}, 'Album\\Model\\MyAuthStorage' => function ($sm) {
return new \Album\Model\MyAuthStorage('Album');
}, 'AuthService' => function ($sm) {
//My assumption, you've alredy set dbAdapter
//and has users table with columns : user_name and pass_word
//that password hashed with md5
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'z_user', 'user_name', 'password', "sha(CONCAT(sha(?), '{$this->_salt}'))");
$authService = new AuthenticationService();
$authService->setAdapter($dbTableAuthAdapter);
$authService->setStorage($sm->get('Album\\Model\\MyAuthStorage'));
return $authService;
}));
}
示例2: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$adapter = $serviceLocator->get('auth-adapter');
$auth = new AuthenticationService();
$auth->setAdapter($adapter);
return $auth;
}
示例3: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('Common\\HttpApi\\SmsApi' => function ($sm) {
$curlAdapter = new Curl();
return new \Common\HttpApi\SmsApi($curlAdapter);
}, 'Zend\\Log' => function ($sm) {
$config = $sm->get('Config');
$log = new \Zend\Log\Logger();
$writer = new \Zend\Log\Writer\Stream('./' . $config['logger']['path']);
$log->addWriter($writer);
$filter = new \Zend\Log\Filter\Priority($config['logger']['priority']);
$writer->addFilter($filter);
return $log;
}, 'Common\\Authentication\\Adapter' => function ($sm) {
$em = $sm->get('doctrine.entitymanager.orm_default');
$adapter = new \Common\Authentication\DoctrineAdapter($em);
return $adapter;
}, 'Common\\Authentication\\Service' => function ($sm) {
$service = new AuthenticationService();
$authAdapter = $sm->get('Common\\Authentication\\Adapter');
$service->setAdapter($authAdapter);
return $service;
}, 'Common\\Authentication\\BjyAuthorizeIdentityProvider' => function ($sm) {
$authService = $sm->get('Common\\Authentication\\Service');
return new \Common\Authentication\BjyAuthorizeIdentityProvider($authService);
}));
}
示例4: authenticate
public function authenticate(array $credentials)
{
$username = $credentials['username'];
$password = $credentials['password'];
$dbAdapter = $this->serviceManager->get('Zend\\Db\\Adapter\\Adapter');
$dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'users', 'username', 'password', 'MD5(?)');
$dbTableAuthAdapter->setIdentity($username);
$dbTableAuthAdapter->setCredential($password);
$authService = new AuthenticationService();
$authService->setAdapter($dbTableAuthAdapter);
//$authService->setStorage($this->getServiceManager()->get('IdAuth\Storage'));
$authResult = $authService->authenticate();
$result = new ProviderResult();
$result->setAuthCode($authResult->getCode());
$result->setMessages($authResult->getMessages());
$result->setValid($authResult->isValid());
$result->setName('IdAuth\\Providers\\DbTable');
$config = $this->serviceManager->get('Config');
$options = $config['idAuth']['providerOptions']['DbTable'];
$result->setOptions($options);
if ($authResult->isValid()) {
$result->setIdentity($this->queryIdentity($username));
}
return $result;
}
示例5: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$authAdapter = $serviceLocator->get("TSCore\\Auth\\Adapter");
$auth = new AuthenticationService();
$auth->setAdapter($authAdapter);
return $auth;
}
示例6: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('Zend\\Db\\Adapter\\Adapter' => 'Zend\\Db\\Adapter\\AdapterServiceFactory', 'SanAuth\\Model\\MyAuthStorage' => function ($sm) {
return new \SanAuth\Model\MyAuthStorage('zf_tutorial');
}, 'AuthService' => function ($sm) {
$dbTableAuthAdapter = $sm->get('TableAuthService');
$authService = new AuthenticationService();
$authService->setStorage(new \Zend\Authentication\Storage\Session('Auth'));
// $authService->setStorage($sm->get('SanAuth\Model\MyAuthStorage')); //
$authService->setAdapter($dbTableAuthAdapter);
return $authService;
}, 'AuthService2' => function ($sm) {
$dbTableAuthAdapter = $sm->get('TableAuth2Service');
$authService = new AuthenticationService();
$authService->setStorage(new \Zend\Authentication\Storage\Session('Auth'));
// $authService->setStorage($sm->get('SanAuth\Model\MyAuthStorage')); //
$authService->setAdapter($dbTableAuthAdapter);
return $authService;
}, 'TableAuthService' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'ta_cliente', 'va_email', 'va_contrasena', 'SHA1(?)');
//
return $dbTableAuthAdapter;
}, 'TableAuth2Service' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'ta_cliente', 'va_email', 'va_contrasena_facebook', 'SHA1(?)');
//
return $dbTableAuthAdapter;
}));
}
示例7: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('Admin\\Model\\AdminTable' => function ($sm) {
$tableGateway = $sm->get('AdminTableGateway');
$table = new AdminTable($tableGateway);
return $table;
}, 'AdminTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Admin());
return new TableGateway('admin', $dbAdapter, null, $resultSetPrototype);
}, 'Admin\\Model\\PlayerTable' => function ($sm) {
$tableGateway = $sm->get('PlayerTableGateway');
$table = new PlayerTable($tableGateway);
return $table;
}, 'PlayerTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Player());
return new TableGateway('player', $dbAdapter, null, $resultSetPrototype);
}, 'Admin\\Model\\MyAuthStorage' => function ($sm) {
return new \Admin\Model\MyAuthStorage('adminstore');
}, 'AuthService' => function ($sm) {
//My assumption, you've alredy set dbAdapter
//and has users table with columns : user_name and pass_word
//that password hashed with md5
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'admin', 'email', 'password', 'MD5(?)');
$authService = new AuthenticationService();
$authService->setAdapter($dbTableAuthAdapter);
$authService->setStorage($sm->get('Admin\\Model\\MyAuthStorage'));
return $authService;
}));
}
示例8: authenticate
public function authenticate($username, $password)
{
$callback = function ($password, $hash) {
$bcrypt = new Bcrypt();
return $bcrypt->verify($hash, $password);
};
$authenticationService = new AuthenticationService();
$callbackCheckAdapter = new CallbackCheckAdapter($this->dbAdapter, "users", 'username', 'password', $callback);
$callbackCheckAdapter->setIdentity($username)->setCredential($password);
$authenticationService->setAdapter($callbackCheckAdapter);
$authResult = $authenticationService->authenticate();
if ($authResult->isValid()) {
$userObject = $callbackCheckAdapter->getResultRowObject();
$authenticationService->getStorage()->write($userObject);
if ($userObject->status == 0) {
$authenticationService->clearIdentity();
$this->setCode(-5);
return false;
} else {
return true;
}
} else {
$this->setCode($authResult->getCode());
return false;
}
}
示例9: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('Application\\Model\\LoginTable' => function ($sm) {
$tableGateway = $sm->get('LoginTableGateway');
$table = new LoginTable($tableGateway);
return $table;
}, 'LoginTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Login());
return new TableGateway('users', $dbAdapter, null, $resultSetPrototype);
}, 'Application\\Model\\JobsTable' => function ($sm) {
$tableGateway = $sm->get('JobsTableGateway');
$table = new JobsTable($tableGateway);
return $table;
}, 'JobsTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Job());
return new TableGateway('jobs', $dbAdapter, null, $resultSetPrototype);
}, 'LoginAuthAdapter' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
return new AuthAdapter($dbAdapter, 'users', 'username', 'password');
}, 'AuthStatus' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$authAdapter = new AuthAdapter($dbAdapter, 'users', 'username', 'password');
$authStatus = new AuthenticationService();
$authStatus->setAdapter($authAdapter);
return $authStatus;
}));
}
示例10: createService
public function createService(ServiceLocatorInterface $servicelocator)
{
$dbAdapter = $servicelocator->get('Zend\\Db\\Adapter\\Adapter');
$dbTableAuthAdapter = new DbTable($dbAdapter, 'user', 'username', 'password', 'MD5(?)');
$authService = new AuthenticationService();
$authService->setAdapter($dbTableAuthAdapter);
$authService->setStorage(new MyAuthStorage());
return $authService;
}
示例11: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('AuthService' => function ($serviceManager) {
$adapter = $serviceManager->get('Zend\\Db\\Adapter\\Adapter');
$dbAuthAdapter = new DbAuthAdapter($adapter, 'users', 'username', 'password', 'md5(?)');
$auth = new AuthenticationService();
$auth->setAdapter($dbAuthAdapter);
return $auth;
}));
}
示例12: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('AuthService' => function ($sm) {
$dbAdapter = $sm->get('DbAdapter');
$dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'users', 'email', 'password', 'MD5(?)');
$authService = new AuthenticationService();
$authService->setAdapter($dbTableAuthAdapter);
return $authService;
}));
}
示例13: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$dbAdapter = $serviceLocator->get('ZendDbAdapter');
$authStorage = $serviceLocator->get('AdminAuthStorage');
$authAdapter = new DbTable($dbAdapter, 'Users', 'username', 'password', 'MD5(?)');
$authService = new AuthenticationService();
$authService->setAdapter($authAdapter);
$authService->setStorage($authStorage);
return $authService;
}
示例14: getAuthService
public function getAuthService()
{
if (!$this->authservice) {
$dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
$dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'user', 'email', 'password', 'MD5(?)');
$authService = new AuthenticationService();
$authService->setAdapter($dbTableAuthAdapter);
$this->authservice = $authService;
}
return $this->authservice;
}
示例15: getServiceConfig
public function getServiceConfig()
{
return array('factories' => array('Application\\Service\\Model' => function ($sm) {
return new \Application\Service\Model();
}, 'Zend\\Authentication\\AuthenticationService' => function ($sm) {
$dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
$authAdapter = new CredentialTreatmentAdapter($dbAdapter, 'admin', 'username', 'password', 'MD5(?)');
$authService = new AuthenticationService();
$authService->setAdapter($authAdapter);
return $authService;
}));
}