equal
deleted
inserted
replaced
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Auth |
16 * @package Zend_Auth |
17 * @subpackage Adapter |
17 * @subpackage Adapter |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: DbTable.php 22613 2010-07-17 13:43:22Z dragonbe $ |
20 * @version $Id: DbTable.php 24593 2012-01-05 20:35:02Z matthew $ |
21 */ |
21 */ |
22 |
22 |
23 |
23 |
24 /** |
24 /** |
25 * @see Zend_Auth_Adapter_Interface |
25 * @see Zend_Auth_Adapter_Interface |
39 |
39 |
40 /** |
40 /** |
41 * @category Zend |
41 * @category Zend |
42 * @package Zend_Auth |
42 * @package Zend_Auth |
43 * @subpackage Adapter |
43 * @subpackage Adapter |
44 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
44 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
45 * @license http://framework.zend.com/license/new-bsd New BSD License |
45 * @license http://framework.zend.com/license/new-bsd New BSD License |
46 */ |
46 */ |
47 class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface |
47 class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface |
48 { |
48 { |
49 |
49 |
112 * $_resultRow - Results of database authentication query |
112 * $_resultRow - Results of database authentication query |
113 * |
113 * |
114 * @var array |
114 * @var array |
115 */ |
115 */ |
116 protected $_resultRow = null; |
116 protected $_resultRow = null; |
117 |
117 |
118 /** |
118 /** |
119 * $_ambiguityIdentity - Flag to indicate same Identity can be used with |
119 * $_ambiguityIdentity - Flag to indicate same Identity can be used with |
120 * different credentials. Default is FALSE and need to be set to true to |
120 * different credentials. Default is FALSE and need to be set to true to |
121 * allow ambiguity usage. |
121 * allow ambiguity usage. |
122 * |
122 * |
123 * @var boolean |
123 * @var boolean |
124 */ |
124 */ |
125 protected $_ambiguityIdentity = false; |
125 protected $_ambiguityIdentity = false; |
126 |
126 |
127 /** |
127 /** |
157 } |
157 } |
158 |
158 |
159 /** |
159 /** |
160 * _setDbAdapter() - set the database adapter to be used for quering |
160 * _setDbAdapter() - set the database adapter to be used for quering |
161 * |
161 * |
162 * @param Zend_Db_Adapter_Abstract |
162 * @param Zend_Db_Adapter_Abstract |
163 * @throws Zend_Auth_Adapter_Exception |
163 * @throws Zend_Auth_Adapter_Exception |
164 * @return Zend_Auth_Adapter_DbTable |
164 * @return Zend_Auth_Adapter_DbTable |
165 */ |
165 */ |
166 protected function _setDbAdapter(Zend_Db_Adapter_Abstract $zendDb = null) |
166 protected function _setDbAdapter(Zend_Db_Adapter_Abstract $zendDb = null) |
167 { |
167 { |
176 if (null === $this->_zendDb) { |
176 if (null === $this->_zendDb) { |
177 require_once 'Zend/Auth/Adapter/Exception.php'; |
177 require_once 'Zend/Auth/Adapter/Exception.php'; |
178 throw new Zend_Auth_Adapter_Exception('No database adapter present'); |
178 throw new Zend_Auth_Adapter_Exception('No database adapter present'); |
179 } |
179 } |
180 } |
180 } |
181 |
181 |
182 return $this; |
182 return $this; |
183 } |
183 } |
184 |
184 |
185 /** |
185 /** |
186 * setTableName() - set the table name to be used in the select query |
186 * setTableName() - set the table name to be used in the select query |
263 public function setCredential($credential) |
263 public function setCredential($credential) |
264 { |
264 { |
265 $this->_credential = $credential; |
265 $this->_credential = $credential; |
266 return $this; |
266 return $this; |
267 } |
267 } |
268 |
268 |
269 /** |
269 /** |
270 * setAmbiguityIdentity() - sets a flag for usage of identical identities |
270 * setAmbiguityIdentity() - sets a flag for usage of identical identities |
271 * with unique credentials. It accepts integers (0, 1) or boolean (true, |
271 * with unique credentials. It accepts integers (0, 1) or boolean (true, |
272 * false) parameters. Default is false. |
272 * false) parameters. Default is false. |
273 * |
273 * |
274 * @param int|bool $flag |
274 * @param int|bool $flag |
275 * @return Zend_Auth_Adapter_DbTable |
275 * @return Zend_Auth_Adapter_DbTable |
276 */ |
276 */ |
277 public function setAmbiguityIdentity($flag) |
277 public function setAmbiguityIdentity($flag) |
278 { |
278 { |
282 $this->_ambiguityIdentity = $flag; |
282 $this->_ambiguityIdentity = $flag; |
283 } |
283 } |
284 return $this; |
284 return $this; |
285 } |
285 } |
286 /** |
286 /** |
287 * getAmbiguityIdentity() - returns TRUE for usage of multiple identical |
287 * getAmbiguityIdentity() - returns TRUE for usage of multiple identical |
288 * identies with different credentials, FALSE if not used. |
288 * identies with different credentials, FALSE if not used. |
289 * |
289 * |
290 * @return bool |
290 * @return bool |
291 */ |
291 */ |
292 public function getAmbiguityIdentity() |
292 public function getAmbiguityIdentity() |
293 { |
293 { |
294 return $this->_ambiguityIdentity; |
294 return $this->_ambiguityIdentity; |
365 public function authenticate() |
365 public function authenticate() |
366 { |
366 { |
367 $this->_authenticateSetup(); |
367 $this->_authenticateSetup(); |
368 $dbSelect = $this->_authenticateCreateSelect(); |
368 $dbSelect = $this->_authenticateCreateSelect(); |
369 $resultIdentities = $this->_authenticateQuerySelect($dbSelect); |
369 $resultIdentities = $this->_authenticateQuerySelect($dbSelect); |
370 |
370 |
371 if ( ($authResult = $this->_authenticateValidateResultSet($resultIdentities)) instanceof Zend_Auth_Result) { |
371 if ( ($authResult = $this->_authenticateValidateResultSet($resultIdentities)) instanceof Zend_Auth_Result) { |
372 return $authResult; |
372 return $authResult; |
373 } |
373 } |
374 |
374 |
375 if (true === $this->getAmbiguityIdentity()) { |
375 if (true === $this->getAmbiguityIdentity()) { |
380 $validIdentities[] = $identity; |
380 $validIdentities[] = $identity; |
381 } |
381 } |
382 } |
382 } |
383 $resultIdentities = $validIdentities; |
383 $resultIdentities = $validIdentities; |
384 } |
384 } |
385 |
385 |
386 $authResult = $this->_authenticateValidateResult(array_shift($resultIdentities)); |
386 $authResult = $this->_authenticateValidateResult(array_shift($resultIdentities)); |
387 return $authResult; |
387 return $authResult; |
388 } |
388 } |
389 |
389 |
390 /** |
390 /** |
475 try { |
475 try { |
476 if ($this->_zendDb->getFetchMode() != Zend_DB::FETCH_ASSOC) { |
476 if ($this->_zendDb->getFetchMode() != Zend_DB::FETCH_ASSOC) { |
477 $origDbFetchMode = $this->_zendDb->getFetchMode(); |
477 $origDbFetchMode = $this->_zendDb->getFetchMode(); |
478 $this->_zendDb->setFetchMode(Zend_DB::FETCH_ASSOC); |
478 $this->_zendDb->setFetchMode(Zend_DB::FETCH_ASSOC); |
479 } |
479 } |
480 $resultIdentities = $this->_zendDb->fetchAll($dbSelect->__toString()); |
480 $resultIdentities = $this->_zendDb->fetchAll($dbSelect); |
481 if (isset($origDbFetchMode)) { |
481 if (isset($origDbFetchMode)) { |
482 $this->_zendDb->setFetchMode($origDbFetchMode); |
482 $this->_zendDb->setFetchMode($origDbFetchMode); |
483 unset($origDbFetchMode); |
483 unset($origDbFetchMode); |
484 } |
484 } |
485 } catch (Exception $e) { |
485 } catch (Exception $e) { |