~horux-dev/horux-webcli/thfo

« back to all changes in this revision

Viewing changes to yii/framework/web/auth/CUserIdentity.php

  • Committer: Thierry Forchelet
  • Date: 2011-02-25 13:30:15 UTC
  • Revision ID: thierry.forchelet@letux.ch-20110225133015-zxyj9w7sqv8ly971
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * CUserIdentity class file
 
4
 *
 
5
 * @author Qiang Xue <qiang.xue@gmail.com>
 
6
 * @link http://www.yiiframework.com/
 
7
 * @copyright Copyright &copy; 2008-2011 Yii Software LLC
 
8
 * @license http://www.yiiframework.com/license/
 
9
 */
 
10
 
 
11
/**
 
12
 * CUserIdentity is a base class for representing identities that are authenticated based on a username and a password.
 
13
 *
 
14
 * Derived classes should implement {@link authenticate} with the actual
 
15
 * authentication scheme (e.g. checking username and password against a DB table).
 
16
 *
 
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.
 
19
 *
 
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
 
23
 * @since 1.0
 
24
 */
 
25
class CUserIdentity extends CBaseUserIdentity
 
26
{
 
27
        /**
 
28
         * @var string username
 
29
         */
 
30
        public $username;
 
31
        /**
 
32
         * @var string password
 
33
         */
 
34
        public $password;
 
35
 
 
36
        /**
 
37
         * Constructor.
 
38
         * @param string $username username
 
39
         * @param string $password password
 
40
         */
 
41
        public function __construct($username,$password)
 
42
        {
 
43
                $this->username=$username;
 
44
                $this->password=$password;
 
45
        }
 
46
 
 
47
        /**
 
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.
 
52
         */
 
53
        public function authenticate()
 
54
        {
 
55
                throw new CException(Yii::t('yii','{class}::authenticate() must be implemented.',array('{class}'=>get_class($this))));
 
56
        }
 
57
 
 
58
        /**
 
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.
 
63
         */
 
64
        public function getId()
 
65
        {
 
66
                return $this->username;
 
67
        }
 
68
 
 
69
        /**
 
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.
 
74
         */
 
75
        public function getName()
 
76
        {
 
77
                return $this->username;
 
78
        }
 
79
}