summaryrefslogtreecommitdiff
path: root/framework/Web/Security/TMembershipProvider.php
diff options
context:
space:
mode:
authorjrags <>2006-09-21 00:57:53 +0000
committerjrags <>2006-09-21 00:57:53 +0000
commitb6e12bedc51b56cf0f1a5930e69a4c377cd3dfe5 (patch)
tree15931a9902b97d31fb4a4788634c222587c52632 /framework/Web/Security/TMembershipProvider.php
parent5da182335ceec1c8ad68047217a33375897f1c1d (diff)
Added providers demo, sqlmembershipprovider sqlroleprovider both load via modules now, but are not totaly functional yet. TLogin* controls created but not functional yet.
Diffstat (limited to 'framework/Web/Security/TMembershipProvider.php')
-rw-r--r--framework/Web/Security/TMembershipProvider.php187
1 files changed, 150 insertions, 37 deletions
diff --git a/framework/Web/Security/TMembershipProvider.php b/framework/Web/Security/TMembershipProvider.php
index 674f338c..6a54819d 100644
--- a/framework/Web/Security/TMembershipProvider.php
+++ b/framework/Web/Security/TMembershipProvider.php
@@ -11,56 +11,169 @@
Prado::using('System.Configuration.Provider.TProviderBase');
abstract class TMembershipProvider extends TProviderBase
{
- public abstract $ApplicationName;
- public abstract $EnablePasswordReset=false;
- public abstract $EnablePasswordRetrieval=false;
- public abstract $MaxInvalidPasswordAttempts;
- public abstract $MinRequiredNonAlphanumericCharacters;
- public abstract $MinRequiredPasswordLength;
- public abstract $PasswordAttemptWindow;
- public abstract $PasswordStrengthReqularExpression;
- public abstract $RequiresQuestionAndAnswer=false;
- public abstract $RequiresUniqueEmail=false;
- // private const SALT_SIZE_IN_BYTES = 0x10;
+ private $_applicationName;
+ private $_enablePasswordReset=false;
+ private $_enablePasswordRetrieval=false;
+ private $_maxInvalidPasswordAttempts;
+ private $_minRequiredNonAlphanumericCharacters;
+ private $_minRequiredPasswordLength;
+ private $_passwordAttemptWindow;
+ private $_passwordStrengthRegularExpression;
+ private $_requiresQuestionAndAnswer=false;
+ private $_requiresUniqueEmail=false;
+ /**
+ * @var string external configuration file
+ */
+ private $_configFile=null;
+
+ public function getEnablePasswordReset()
+ {
+ return $this->_enablePasswordReset;
+ }
+ public function setEnablePasswordReset($value)
+ {
+ $this->_enablePasswordReset = TPropertyValue::ensureBoolean($value);
+ }
+ public function getEnablePasswordRetrieval()
+ {
+ return $this->_enablePasswordRetrieval;
+ }
+ public function setEnablePasswordRetrieval($value)
+ {
+ $this->_enablePasswordRetrieval = TPropertyValue::ensureBoolean($value);
+ }
+ public function getMaxInvalidPasswordAttempts()
+ {
+ return $this->_maxInvalidPasswordAttempts;
+ }
+ public function setMaxInvalidPasswordAttempts($value)
+ {
+ $this->_maxInvalidPasswordAttempts = TPropertyValue::ensureInteger($value);
+ }
+ public function getMinRequiredNonAlphanumericCharacters()
+ {
+ return $this->_minRequiredNonAlphanumericCharacters;
+ }
+ public function setMinRequiredNonAlphanumericCharacters($value)
+ {
+ $this->_minRequiredNonAlphanumericCharacters = TPropertyValue::ensureInteger($value);
+ }
+ public function getMinRequiredPasswordLength()
+ {
+ return $this->_minRequiredPasswordLength;
+ }
+ public function setMinRequiredPasswordLength($value)
+ {
+ $this->_minRequiredPasswordLength = TPropertyValue::ensureInteger($value);
+ }
+ public function getPasswordAttemptWindow()
+ {
+ return $this->_passwordAttemptWindow;
+ }
+ public function setPasswordAttemptWindow($value)
+ {
+ $this->_passwordAttemptWindow = TPropertyValue::ensureInteger($value);
+ }
+ public function getPasswordStrengthRegularExpression()
+ {
+ return $this->_passwordStrengthRegularExpression;
+ }
+ public function setPasswordStrengthRegularExpression($value)
+ {
+ $this->_passwordStrengthRegularExpression = TPropertyValue::ensureString($value);
+ }
+ public function getRequiresQuestionAndAnswer()
+ {
+ return $this->_requiresQuestionAndAnswer;
+ }
+ public function setRequiresQuestionAndAnswer($value)
+ {
+ $this->_requiresQuestionAndAnswer = TPropertyValue::ensureString($value);
+ }
+ public function getRequiresUniqueEmail()
+ {
+ return $this->_requiresUniqueEmail;
+ }
+ public function setRequiresUniqueEmail($value)
+ {
+ $this->_requiresUniqueEmail = TPropertyValue::ensureBoolean($value);
+ }
- protected function __construct()
+ public function __construct()
{
-
+
}
- public abstract function ChangePassword($username,$oldPassword,$newPassword);
- public abstract function ChangePasswordQuestionAndAnswer($username,$password,$newPasswordQuestion,$newPasswordAnswer);
- public abstract function CreateUser($username,$password,$email,$passwordQuestion,$passwordAnswer,$isApproved,$providerUserKey);
- protected function DecryptPassword($encodedPassword)
+ public function init($config)
{
-
+ if($this->_configFile!==null)
+ {
+ if(is_file($this->_configFile))
+ {
+ $dom=new TXmlDocument;
+ $dom->loadFromFile($this->_configFile);
+ $this->loadConfig($dom);
+ }
+ else
+ throw new TConfigurationException('membershipprovider_configfile_invalid',$this->_configFile);
+ }
+ $this->loadConfig($config);
+// $this->getApplication()->attachEventHandler('OnEndRequest',array($this,'collectLogs'));
}
- public abstract function DeleteUser($username,$deleteAllRelatedData);
- public function EncodePassword($pass,$passwordFormat,$salt)
+ /**
+ * Loads configuration from an XML element
+ * @param TXmlElement configuration node
+ * @throws TConfigurationException if log route class or type is not specified
+ */
+ private function loadConfig($xml)
{
-
+ foreach($xml->getElementsByTagName('provider') as $providerConfig)
+ {
+ $properties=$providerConfig->getAttributes();
+ if(($class=$properties->remove('class'))===null)
+ throw new TConfigurationException('membershipprovider_routeclass_required');
+ $provider=Prado::createComponent($class);
+ if(!($provider instanceof TMembershipProvider))
+ throw new TConfigurationException('membershipprovider_routetype_invalid');
+ foreach($properties as $name=>$value)
+ $provider->setSubproperty($name,$value);
+ $this->_providers[]=$provider;
+ $provider->init($providerConfig);
+ }
}
- protected function EncryptPassword($password)
+ public abstract function changePassword($username,$oldPassword,$newPassword);
+ public abstract function changePasswordQuestionAndAnswer($username,$password,$newPasswordQuestion,$newPasswordAnswer);
+ public abstract function createUser($username,$password,$email,$passwordQuestion,$passwordAnswer,$isApproved,$providerUserKey);
+ protected function decryptPassword($encodedPassword)
{
-
+
}
- public abstract function FindUsersByEmail($emailToMatch,$pageIndex=null,$pageSize=null);
- public abstract function FindUsersByName($usernameToMatch,$pageIndex=null,$pageSize=null);
- public function GenerateSalt()
+ public abstract function deleteUser($username,$deleteAllRelatedData);
+ public function encodePassword($pass,$passwordFormat,$salt)
{
-
+
+ }
+ protected function encryptPassword($password)
+ {
+
}
- public abstract function GetAllUsers($pageIndex=null,$pageSize=null);
- public abstract function GetNumberOfUsersOnline();
- public abstract function GetPassword($username,$answer);
- public abstract function GetUser($username=null,$providerUserKey=null,$userIsOnline);
- public abstract function GetUserNameByEmail($email);
- public abstract function ResetPassword($username,$answer);
- public function UnEncodePassword($pass,$passwordFormat)
+ public abstract function findUsersByEmail($emailToMatch,$pageIndex=null,$pageSize=null);
+ public abstract function findUsersByName($usernameToMatch,$pageIndex=null,$pageSize=null);
+ public function generateSalt()
{
}
- public abstract function UnlockUser($userName);
- public abstract function UpdateUser(TMembershipUser $user);
- public abstract function ValidateUser($username,$password);
+ public abstract function getAllUsers($pageIndex=null,$pageSize=null);
+ public abstract function getNumberOfUsersOnline();
+ public abstract function getPassword($username,$answer);
+ public abstract function getMembershipUser($username=null,$providerUserKey=null,$userIsOnline=false);
+ public abstract function getUserNameByEmail($email);
+ public abstract function resetPassword($username,$answer);
+ public function unEncodePassword($pass,$passwordFormat)
+ {
+
+ }
+ public abstract function unlockUser($userName);
+ public abstract function updateUser(TMembershipUser $user);
+ public abstract function validateUser($username,$password);
}
?> \ No newline at end of file