1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
<?php
/**
* TMembershipProvider class.
* Defines the contract that PRADO implements to provide membership services using custom membership providers.
*
* @author Jason Ragsdale <jrags@jasrags.net>
* @version $Id: TMembershipProvider.php 1398 2006-09-08 19:31:03Z xue $
* @package System.Web.Security
* @since 3.1
*/
Prado::using('System.Configuration.Provider.TProviderBase');
abstract class TMembershipProvider extends TProviderBase
{
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);
}
public function __construct()
{
}
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);
}
/**
* 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);
}
}
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 deleteUser($username,$deleteAllRelatedData);
public function encodePassword($pass,$passwordFormat,$salt)
{
}
protected function encryptPassword($password)
{
}
public abstract function findUsersByEmail($emailToMatch,$pageIndex=null,$pageSize=null);
public abstract function findUsersByName($usernameToMatch,$pageIndex=null,$pageSize=null);
public function generateSalt()
{
}
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);
}
?>
|