/library/Zend/Auth/Adapter/DbTable.php
PHP | 561 lines | 249 code | 66 blank | 246 comment | 32 complexity | 827e6aa0bb5d509b970138f0ecdf761b MD5 | raw file
Possible License(s): AGPL-1.0
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Auth
- * @subpackage Adapter
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: DbTable.php 24594 2012-01-05 21:27:01Z matthew $
- */
- /**
- * @see Zend_Auth_Adapter_Interface
- */
- require_once 'Zend/Auth/Adapter/Interface.php';
- /**
- * @see Zend_Db_Adapter_Abstract
- */
- require_once 'Zend/Db/Adapter/Abstract.php';
- /**
- * @see Zend_Auth_Result
- */
- require_once 'Zend/Auth/Result.php';
- /**
- * @category Zend
- * @package Zend_Auth
- * @subpackage Adapter
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- class Zend_Auth_Adapter_DbTable implements Zend_Auth_Adapter_Interface
- {
- /**
- * Database Connection
- *
- * @var Zend_Db_Adapter_Abstract
- */
- protected $_zendDb = null;
- /**
- * @var Zend_Db_Select
- */
- protected $_dbSelect = null;
- /**
- * $_tableName - the table name to check
- *
- * @var string
- */
- protected $_tableName = null;
- /**
- * $_identityColumn - the column to use as the identity
- *
- * @var string
- */
- protected $_identityColumn = null;
- /**
- * $_credentialColumns - columns to be used as the credentials
- *
- * @var string
- */
- protected $_credentialColumn = null;
- /**
- * $_identity - Identity value
- *
- * @var string
- */
- protected $_identity = null;
- /**
- * $_credential - Credential values
- *
- * @var string
- */
- protected $_credential = null;
- /**
- * $_credentialTreatment - Treatment applied to the credential, such as MD5() or PASSWORD()
- *
- * @var string
- */
- protected $_credentialTreatment = null;
- /**
- * $_authenticateResultInfo
- *
- * @var array
- */
- protected $_authenticateResultInfo = null;
- /**
- * $_resultRow - Results of database authentication query
- *
- * @var array
- */
- protected $_resultRow = null;
- /**
- * $_ambiguityIdentity - Flag to indicate same Identity can be used with
- * different credentials. Default is FALSE and need to be set to true to
- * allow ambiguity usage.
- *
- * @var boolean
- */
- protected $_ambiguityIdentity = false;
- /**
- * __construct() - Sets configuration options
- *
- * @param Zend_Db_Adapter_Abstract $zendDb If null, default database adapter assumed
- * @param string $tableName
- * @param string $identityColumn
- * @param string $credentialColumn
- * @param string $credentialTreatment
- * @return void
- */
- public function __construct(Zend_Db_Adapter_Abstract $zendDb = null, $tableName = null, $identityColumn = null,
- $credentialColumn = null, $credentialTreatment = null)
- {
- $this->_setDbAdapter($zendDb);
- if (null !== $tableName) {
- $this->setTableName($tableName);
- }
- if (null !== $identityColumn) {
- $this->setIdentityColumn($identityColumn);
- }
- if (null !== $credentialColumn) {
- $this->setCredentialColumn($credentialColumn);
- }
- if (null !== $credentialTreatment) {
- $this->setCredentialTreatment($credentialTreatment);
- }
- }
- /**
- * _setDbAdapter() - set the database adapter to be used for quering
- *
- * @param Zend_Db_Adapter_Abstract
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Adapter_DbTable
- */
- protected function _setDbAdapter(Zend_Db_Adapter_Abstract $zendDb = null)
- {
- $this->_zendDb = $zendDb;
- /**
- * If no adapter is specified, fetch default database adapter.
- */
- if(null === $this->_zendDb) {
- require_once 'Zend/Db/Table/Abstract.php';
- $this->_zendDb = Zend_Db_Table_Abstract::getDefaultAdapter();
- if (null === $this->_zendDb) {
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('No database adapter present');
- }
- }
- return $this;
- }
- /**
- * setTableName() - set the table name to be used in the select query
- *
- * @param string $tableName
- * @return Zend_Auth_Adapter_DbTable Provides a fluent interface
- */
- public function setTableName($tableName)
- {
- $this->_tableName = $tableName;
- return $this;
- }
- /**
- * setIdentityColumn() - set the column name to be used as the identity column
- *
- * @param string $identityColumn
- * @return Zend_Auth_Adapter_DbTable Provides a fluent interface
- */
- public function setIdentityColumn($identityColumn)
- {
- $this->_identityColumn = $identityColumn;
- return $this;
- }
- /**
- * setCredentialColumn() - set the column name to be used as the credential column
- *
- * @param string $credentialColumn
- * @return Zend_Auth_Adapter_DbTable Provides a fluent interface
- */
- public function setCredentialColumn($credentialColumn)
- {
- $this->_credentialColumn = $credentialColumn;
- return $this;
- }
- /**
- * setCredentialTreatment() - allows the developer to pass a parameterized string that is
- * used to transform or treat the input credential data.
- *
- * In many cases, passwords and other sensitive data are encrypted, hashed, encoded,
- * obscured, or otherwise treated through some function or algorithm. By specifying a
- * parameterized treatment string with this method, a developer may apply arbitrary SQL
- * upon input credential data.
- *
- * Examples:
- *
- * 'PASSWORD(?)'
- * 'MD5(?)'
- *
- * @param string $treatment
- * @return Zend_Auth_Adapter_DbTable Provides a fluent interface
- */
- public function setCredentialTreatment($treatment)
- {
- $this->_credentialTreatment = $treatment;
- return $this;
- }
- /**
- * setIdentity() - set the value to be used as the identity
- *
- * @param string $value