3
* CUserIdentity class file
5
* @author Qiang Xue <qiang.xue@gmail.com>
6
* @link http://www.yiiframework.com/
7
* @copyright Copyright © 2008-2011 Yii Software LLC
8
* @license http://www.yiiframework.com/license/
12
* CUserIdentity is a base class for representing identities that are authenticated based on a username and a password.
14
* Derived classes should implement {@link authenticate} with the actual
15
* authentication scheme (e.g. checking username and password against a DB table).
17
* By default, CUserIdentity assumes the {@link username} is a unique identifier
18
* and thus use it as the {@link id ID} of the identity.
20
* @author Qiang Xue <qiang.xue@gmail.com>
21
* @version $Id: CUserIdentity.php 2799 2011-01-01 19:31:13Z qiang.xue $
22
* @package system.web.auth
25
class CUserIdentity extends CBaseUserIdentity
28
* @var string username
32
* @var string password
38
* @param string $username username
39
* @param string $password password
41
public function __construct($username,$password)
43
$this->username=$username;
44
$this->password=$password;
48
* Authenticates a user based on {@link username} and {@link password}.
49
* Derived classes should override this method, or an exception will be thrown.
50
* This method is required by {@link IUserIdentity}.
51
* @return boolean whether authentication succeeds.
53
public function authenticate()
55
throw new CException(Yii::t('yii','{class}::authenticate() must be implemented.',array('{class}'=>get_class($this))));
59
* Returns the unique identifier for the identity.
60
* The default implementation simply returns {@link username}.
61
* This method is required by {@link IUserIdentity}.
62
* @return string the unique identifier for the identity.
64
public function getId()
66
return $this->username;
70
* Returns the display name for the identity.
71
* The default implementation simply returns {@link username}.
72
* This method is required by {@link IUserIdentity}.
73
* @return string the display name for the identity.
75
public function getName()
77
return $this->username;