diff options
author | xue <> | 2006-09-04 19:15:47 +0000 |
---|---|---|
committer | xue <> | 2006-09-04 19:15:47 +0000 |
commit | 56fee292c37e162c03fab9eeadd6a8b9ab85c251 (patch) | |
tree | 923510b93c707868098ae4e5f404eb3766a59553 /framework/Security/TUserManager.php | |
parent | b107cad91733d4a2a80f42cdbaab41a4f7b41c9d (diff) |
merge from 3.0 branch till 1387
Diffstat (limited to 'framework/Security/TUserManager.php')
-rw-r--r-- | framework/Security/TUserManager.php | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/framework/Security/TUserManager.php b/framework/Security/TUserManager.php index 6b10fa8b..c0bbe65d 100644 --- a/framework/Security/TUserManager.php +++ b/framework/Security/TUserManager.php @@ -35,7 +35,7 @@ Prado::using('System.Security.TUser'); * similar to the above sample.
*
* The user passwords may be specified as clear text, SH1 or MD5 hashed by setting
- * {@link setPasswordMode PasswordMode} as <b>Clear</b>, <b>SH1</b> or <b>MD5</b>.
+ * {@link setPasswordMode PasswordMode} as <b>Clear</b>, <b>SHA1</b> or <b>MD5</b>.
* The default name for a guest user is <b>Guest</b>. It may be changed
* by setting {@link setGuestName GuestName} property.
*
@@ -67,9 +67,9 @@ class TUserManager extends TModule implements IUserManager */
private $_guestName='Guest';
/**
- * @var string password mode, Clear|MD5|SH1
+ * @var TUserManagerPasswordMode password mode
*/
- private $_passwordMode='MD5';
+ private $_passwordMode=TUserManagerPasswordMode::MD5;
/**
* @var boolean whether the module has been initialized
*/
@@ -186,7 +186,7 @@ class TUserManager extends TModule implements IUserManager }
/**
- * @return string (Clear|MD5|SH1) how password is stored, clear text, or MD5 or SH1 hashed. Default to MD5.
+ * @return TUserManagerPasswordMode how password is stored, clear text, or MD5 or SHA1 hashed. Default to TUserManagerPasswordMode::MD5.
*/
public function getPasswordMode()
{
@@ -194,11 +194,11 @@ class TUserManager extends TModule implements IUserManager }
/**
- * @param string (Clear|MD5|SH1) how password is stored, clear text, or MD5 or SH1 hashed.
+ * @param TUserManagerPasswordMode how password is stored, clear text, or MD5 or SHA1 hashed.
*/
public function setPasswordMode($value)
{
- $this->_passwordMode=TPropertyValue::ensureEnum($value,array('Clear','MD5','SHA1'));
+ $this->_passwordMode=TPropertyValue::ensureEnum($value,'TUserManagerPasswordMode');
}
/**
@@ -209,9 +209,9 @@ class TUserManager extends TModule implements IUserManager */
public function validateUser($username,$password)
{
- if($this->_passwordMode==='MD5')
+ if($this->_passwordMode===TUserManagerPasswordMode::MD5)
$password=md5($password);
- else if($this->_passwordMode==='SHA1')
+ else if($this->_passwordMode===TUserManagerPasswordMode::SHA1)
$password=sha1($password);
$username=strtolower($username);
return (isset($this->_users[$username]) && $this->_users[$username]===$password);
@@ -258,4 +258,26 @@ class TUserManager extends TModule implements IUserManager }
}
+/**
+ * TUserManagerPasswordMode class.
+ * TUserManagerPasswordMode defines the enumerable type for the possible modes
+ * that user passwords can be specified for a {@link TUserManager}.
+ *
+ * The following enumerable values are defined:
+ * - Clear: the password is in plain text
+ * - MD5: the password is recorded as the MD5 hash value of the original password
+ * - SHA1: the password is recorded as the SHA1 hash value of the original password
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System.Security
+ * @since 3.0.4
+ */
+class TUserManagerPasswordMode extends TEnumerable
+{
+ const Clear='Clear';
+ const MD5='MD5';
+ const SHA1='SHA1';
+}
+
?>
\ No newline at end of file |