This repository was archived by the owner on May 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathDefaultUser.php
More file actions
executable file
·759 lines (695 loc) · 25.4 KB
/
DefaultUser.php
File metadata and controls
executable file
·759 lines (695 loc) · 25.4 KB
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
<?php
/**
* OWASP Enterprise Security API (ESAPI)
*
* This file is part of the Open Web Application Security Project (OWASP)
* Enterprise Security API (ESAPI) project. For details, please see
* <a href="http://www.owasp.org/index.php/ESAPI">http://www.owasp.org/index.php/ESAPI</a>.
*
* Copyright (c) 2007 - 2011 The OWASP Foundation
*
* The ESAPI is published by OWASP under the BSD license. You should read and accept the
* LICENSE before you use, modify, and/or redistribute this software.
*
* @author Bipin Upadhyay <http://projectbee.org/blog/contact/>
* @created 2009
* @since 1.4
* @version 1.07
* @package ESAPI_Reference
*/
//FIXME: Cleanup to be done, as suggested by Mike
require_once dirname(__FILE__) . '/../User.php';
define("MAX_ROLE_LENGTH", 250);
/**
* Reference Implementation of the DefaultUser interface.
*
* @category OWASP
* @package ESAPI_Reference
* @author Bipin Upadhyay <http://projectbee.org/blog/contact/>
* @copyright 2009-2010 The OWASP Foundation
* @license http://www.opensource.org/licenses/bsd-license.php New BSD license
* @version Release: @package_version@
* @link http://www.owasp.org/index.php/ESAPI
*/
class DefaultUser implements User
{
//Configs
public $allowedLoginAttempts = 3;
public $sessionTimeout = 3600; #one hour
public $sessionAbsoluteTimeout = 7200; #2 hours
//TODO: load these from config
private $_username = null;
private $_password = null;
private $_uid = null;
private $_userInfo = array();
private $_PathToUsersFiles = "../../test/testresources/users.txt";
private static $IDLE_TIMEOUT_LENGTH = null;
private static $ABSOLUTE_TIMEOUT_LENGTH = null;
/** This user's account id. */
private $_accountId = 0;
/** This user's account name. */
private $_accountName = "";
/** This user's screen name (account name alias). */
private $_screenName = "";
/** This user's CSRF token. */
private $_csrfToken = "";
/** This user's assigned roles. */
private $_roles = array();
/** Whether this user's account is locked. */
private $_locked = false;
/** Whether this user is logged in. */
private $_loggedIn = true;
/** Whether this user's account is enabled. */
private $_enabled = false;
/** The last host address used by this user. */
private $_lastHostAddress = null;
/** The last password change time for this user. */
// private $lastPasswordChangeTime = new Date(0);
/** The last login time for this user. */
// private $lastLoginTime = new Date(0);
/** The last failed login time for this user. */
// private $lastFailedLoginTime = new Date(0);
/** The expiration date/time for this user's account. */
// private $expirationTime = new Date(Long.MAX_VALUE);
/** The session's this user is associated with */
private $_sessions = array();
/* A flag to indicate that the password must be changed before the account can be used. */
// private boolean requiresPasswordChange = true;
/** The failed login count for this user's account. */
private $_failedLoginCount = 0;
const MAX_ROLE_LENGTH = 250;
function __construct ($accountName) {
$this->setAccountName($accountName);
//TODO: Not the best way IMHO. I'd rather call the method via factory object each time. Needs discussion..
$this->IDLE_TIMEOUT_LENGTH = ESAPI::getSecurityConfiguration()->getSessionIdleTimeoutLength();
$this->ABSOLUTE_TIMEOUT_LENGTH = ESAPI::getSecurityConfiguration()->getSessionAbsoluteTimeoutLength();
do {
$id = ESAPI::getRandomizer()->getRandomLong();
if (ESAPI::getAuthenticator()->getUserById($id) == null && $id != 0) {
$this->setAccountID($id);
}
} while ($this->getAccountID() == 0);
}
function __destruct () {
$this->writeUserInfo();
}
/**
* This is intended to compute the password hash for a password
* @param String $Password
* @return String the hash
*/
function hashPassword ($Password) {
//TODO: code this
return "";
}
/**
* This array holds the keys for users fields in order and is used in parseUserInfo()
* @var Array
*/
private $UserInfoFields = array("accountName" , "hashedPassword" , "roles" , "locked" , "enabled" , "rememberToken" , "csrfToken" , "oldPasswordHashes" , "lastPasswordChangeTime" , "lastLoginTime" , "lastFailedLoginTime" , "expirationTime" , "failedLoginCount");
private function setUserInfo ($Field, $Value) {
$this->_userInfo[$Field] = $Value;
}
private function getUserInfo ($Field) {
if (! array_key_exists($Field, $this->_userInfo))
return null;
return $this->_userInfo[$Field];
}
private function parseUserInfo ($Data) {
$Data = explode(" | ", $Data);
$n = 0;
$this->_userInfo = array();
foreach ($Data as $D) {
$this->_userInfo[$this->_userInfoFields[$n ++]] = $D;
}
}
private function readUserInfo () {
$Compare = $this->_username;
$fp = fopen(dirname(__FILE__) . "/" . $this->_PathToUsersFiles, "r");
if (! $fp)
throw new Exception("Can not open the users.txt file!");
while (! feof($fp)) {
$Line = fgets($fp);
if (substr($Line, 0, strlen($Compare)) == $Compare) {
$Data = $Line;
$this->parseUserInfo($Data);
break;
}
}
fclose($fp);
}
private function writeUserInfo () {
$Compare = $this->_username;
$fp = fopen(dirname(__FILE__) . "/" . $this->_PathToUsersFiles, "r");
if (! $fp)
throw new Exception("Can not open the users.txt file!");
$Data = "";
while (! feof($fp)) {
$Line = fgets($fp);
$Line = trim($Line);
if (strlen($Line) > strlen($Compare) and substr($Line, 0, strlen($Compare)) != $Compare)
$Data .= $Line . "\n";
}
fclose($fp);
$fp = fopen(dirname(__FILE__) . "/" . $this->_PathToUsersFiles, "w+");
if (! $fp)
throw new Exception("Can not open the users.txt file for writing!!");
fwrite($fp, $Data);
if ($this->_userInfo)
fwrite($fp, implode(" | ", $this->_userInfo));
fclose($fp);
}
/**
* Gets this user's account name.
*
* @return the account name
*/
function getAccountName () {
//TODO: Redo
return $this->_accountName;
}
/**
* Adds a role to this user's account.
*
* @param role
* the role to add
*
* @throws AuthenticationException
* the authentication exception
*/
function addRole ($role) {
$roleName = strtolower($role);
if ( false/*ESAPI::getValidator()->isValidInput("addRole", $roleName, "RoleName", MAX_ROLE_LENGTH, false) */) {
//TODO: Verify if this is correct
$this->_roles[] = $roleName;
ESAPI::getLogger("DefaultUser")->info(ESAPILogger::SECURITY, TRUE, "Role ".$roleName." added to ".$this->getAccountName() );
} else {
//TODO: Not done in Java, but shouldn't this be logged as well?
throw new AuthenticationAccountsException( "Add role failed", "Attempt to add invalid role ".$roleName." to ".$this->getAccountName() );
}
}
/**
* Adds a set of roles to this user's account.
*
* @param Array $newRoles
* the new roles to add
*
* @throws AuthenticationException
* the authentication exception
*/
function addRoles ($newRoles) {
foreach ($newRoles as $role)
$this->addRole($role);
}
/**
* Sets the user's password, performing a verification of the user's old password, the equality of the two new
* passwords, and the strength of the new password.
*
* @param oldPassword
* the old password
* @param newPassword1
* the new password
* @param newPassword2
* the new password - used to verify that the new password was typed correctly
*
* @throws AuthenticationException
* if newPassword1 does not match newPassword2, if oldPassword does not match the stored old password, or if the new password does not meet complexity requirements
* @throws EncryptionException
*/
function changePassword ($oldPassword, $newPassword1, $newPassword2) {
ESAPI::getAuthenticator()->changePassword($this, $oldPassword, $newPassword1, $newPassword2);
}
/**
* Disable this user's account.
*/
function disable () {
$this->_enabled = FALSE;
ESAPI::getLogger("DefaultUser")->info( ESAPILogger::SECURITY, TRUE, "Account disabled: ".$this->getAccountName() );
}
/**
* Enable this user's account.
*/
function enable () {
$this->enable = TRUE;
ESAPI::getLogger("DefaultUser")->info(ESAPILogger::SECURITY, TRUE, "Account enabled: ".$this->getAccountName() );
}
/**
* Gets this user's account id number.
*
* @return Integer the account id
*/
function getAccountId () {
return $this->_accountId;
}
/**
* Gets the CSRF token for this user's current sessions.
*
* @return String the CSRF token
*/
function getCSRFToken () {
return $this->_csrfToken;
}
/**
* Returns the date that this user's account will expire.
*
* @return Date representing the account expiration time.
*/
function getExpirationTime () {
//TODO: Redo
return $this->getUserInfo("expirationTime");
}
/**
* Returns the number of failed login attempts since the last successful login for an account. This method is
* intended to be used as a part of the account lockout feature, to help protect against brute force attacks.
* However, the implementor should be aware that lockouts can be used to prevent access to an application by a
* legitimate user, and should consider the risk of denial of service.
*
* @return Integer the number of failed login attempts since the last successful login
*/
function getFailedLoginCount () {
return $this->_failedLoginCount;
}
/**
* Returns the last host address used by the user. This will be used in any log messages generated by the processing
* of this request.
*
* @return String the last host address used by the user
*/
function getLastHostAddress () {
if ($this->_lastHostAddress == null) {
return "local";
} else {
return $this->_lastHostAddress;
}
}
/**
* Returns the date of the last failed login time for a user. This date should be used in a message to users after a
* successful login, to notify them of potential attack activity on their account.
*
* @return date of the last failed login
*
* @throws AuthenticationException
* the authentication exception
*/
function getLastFailedLoginTime () {
//TODO: Redo
return $this->getUserInfo("lastFailedLoginTime");
}
/**
* Returns the date of the last successful login time for a user. This date should be used in a message to users
* after a successful login, to notify them of potential attack activity on their account.
*
* @return date of the last successful login
*/
function getLastLoginTime () {
//TODO: Redo
return $this->getUserInfo("lastLoginTime");
}
/**
* Gets the date of user's last password change.
*
* @return the date of last password change
*/
function getLastPasswordChangeTime () {
//TODO: Redo
return $this->getUserInfo("lastPasswordChangeTime");
}
/**
* Gets the roles assigned to a particular account.
*
* @return Array an immutable set of roles
*/
function getRoles () {
//TODO: Redo
return explode(",", $this->getUserInfo("roles"));
}
/**
* Gets the screen name (alias) for the current user.
*
* @return String the screen name
*/
function getScreenName () {
return $this->_screenName;
//return $this->getUserInfo("accountName");
}
/**
* Adds a session for this User.
*
* @param $HttpSession string sessionID
*/
function addSession ($HttpSession = null) {
//TODO: Redo
if (session_id() == "")//no session established, throw some errors TODO
;
if ($HttpSession===null) $HttpSession=session_id();
$_SESSION[$this->getAccountId()][$HttpSession] = array("start" => time() , "lastUpdate" => time());
}
/**
* Removes a session for this User.
*
* @param $HttpSession string session id
*/
function removeSession ($HttpSession = null) {
//TODO: Redo
if ($HttpSession===null) $HttpSession=session_id();
unset($_SESSION[$this->getAccountId()][$HttpSession]);
}
/**
* Returns the list of sessions associated with this User.
* @return Array sessions
*/
function getSessions () {
//TODO: Redo
return $_SESSION[$this->getAccountId()];
}
/**
* Increment failed login count.
*/
function incrementFailedLoginCount () {
$this->_failedLoginCount++;
}
function setFailedLoginCount ($count) {
//TODO: Redo
$this->setUserInfo("failedLoginCount", $count);
if ($this->getFailedLoginCount() >= $this->allowedLoginAttempts) {
$this->lock();
}
}
/**
* Checks if user is anonymous.
*
* @return true, if user is anonymous
*/
function isAnonymous () {
//TODO: Redo
//Need to discuss the concept of anonymous in context with PHP
if ($this->_uid === null)
return true;
else
return false;
}
/**
* Checks if this user's account is currently enabled.
*
* @return true, if account is enabled
*/
function isEnabled () {
return $this->_enabled;
}
/**
* Checks if this user's account is expired.
*
* @return true, if account is expired
*/
function isExpired () {
//TODO: Redo
$ExpTime = $this->getUserInfo("expirationTime");
if ($ExpTime < time())
return true;
else
return false;
}
/**
* Checks if this user's account is assigned a particular role.
*
* @param String $role the role for which to check
*
* @return true, if role has been assigned to user
*/
function isInRole ($role) {
return in_array( strtolower($role), $this->_roles);
}
/**
* Checks if this user's account is locked.
*
* @return true, if account is locked
*/
function isLocked () {
return $this->_locked;
}
/**
* Tests to see if the user is currently logged in.
*
* @return true, if the user is logged in
*/
function isLoggedIn () {
return $this->_loggedIn;
}
/**
* Tests to see if this user's session has exceeded the absolute time out based
* on ESAPI's configuration settings.
*
* @param String $HttpSession optional session id
* @return true, if user's session has exceeded the absolute time out
*/
function isSessionAbsoluteTimeout ($HttpSession=null) {
//TODO: Redo
if ($HttpSession===null) $HttpSession=session_id();
if (isset($_SESSION[$this->getAccountId()][$HttpSession]['start'])) {
return (time() - $_SESSION[$this->getAccountId()][$HttpSession]['start']) > $this->sessionAbsoluteTimeout;
}
return true;
}
/**
* Tests to see if the user's session has timed out from inactivity based
* on ESAPI's configuration settings.
*
* A session may timeout prior to ESAPI's configuration setting due to
* the servlet container setting for session-timeout in web.xml. The
* following is an example of a web.xml session-timeout set for one hour.
*
* <session-config>
* <session-timeout>60</session-timeout>
* </session-config>
*
* @param String $HttpSession optional session id
* @return true, if user's session has timed out from inactivity based
* on ESAPI configuration
*/
function isSessionTimeout ($HttpSession=null) {
//TODO: Redo
if ($HttpSession===null) $HttpSession=session_id();
#XXX: You should add some logic to update session time somewhere!
if (isset($_SESSION[$this->getAccountId()][$HttpSession]['lastUpdate'])) {
return (time() - $_SESSION[$this->getAccountId()][$HttpSession]['lastUpdate']) > $this->sessionTimeout;
}
return true;
}
/**
* Lock this user's account.
*/
function lock () {
$this->_locked = TRUE;
ESAPI::getLogger("DefaultUser")->info(ESAPILogger::SECURITY, TRUE, "Account locked: ".$this->getAccountName() );
}
/**
* Login with password.
*
* @param String $password the password
* @throws AuthenticationException
* if login fails
*/
function loginWithPassword ($password) {
//FIXME: time() might not be the correct format to be used?
if (is_null($password) || $password == "") {
$this->setLastFailedLoginTime(time());
$this->incrementFailedLoginCount();
throw new AuthenticationLoginException("Login failed", "Missing password: " . $this->getAccountName());
}
// don't let disabled users log in
if (! $this->isEnabled()) {
$this->setLastFailedLoginTime(time());
$this->incrementFailedLoginCount();
throw new AuthenticationLoginException("Login failed", "Disabled user attempt to login: " . $this->getAccountName());
}
// don't let locked users log in
if ($this->isLocked()) {
$this->setLastFailedLoginTime(time());
$this->incrementFailedLoginCount();
throw new AuthenticationLoginException("Login failed", "Locked user attempt to login: " . $this->getAccountName());
}
// don't let expired users log in
if ($this->isExpired()) {
$this->setLastFailedLoginTime(time());
$this->incrementFailedLoginCount();
throw new AuthenticationLoginException("Login failed", "Expired user attempt to login: " . $this->getAccountName());
}
$this->logout();
if ($this->verifyPassword($password)) {
$this->_loggedIn = true;
ESAPI::getHttpUtilities()->changeSessionIdentifier( ESAPI::currentRequest() );
ESAPI::getAuthenticator()->setCurrentUser($this);
$this->setLastLoginTime(time());
$this->setLastHostAddress( ESAPI::getHttpUtilities()->getCurrentRequest()->getRemoteHost() );
ESAPI::getLogger("DefaultUser")->trace(ESAPILogger::SECURITY, "User logged in: " . $this->_accountName );
} else {
$this->_loggedIn = false;
$this->setLastFailedLoginTime(time());
$this->incrementFailedLoginCount();
throw new AuthenticationLoginException("Login failed", "Incorrect password provided for " . $this->getAccountName());
}
}
/**
* Logout this user.
*/
function logout () {
//TODO: Redo
//TODO: ESAPI.httpUtilities().killCookie( ESAPI.currentRequest(), ESAPI.currentResponse(), HTTPUtilities.REMEMBER_TOKEN_COOKIE_NAME );
//HttpSession session = ESAPI.currentRequest().getSession(false);
if (isset($_SESSION[$this->getAccountId()])) {
unset($_SESSION[$this->getAccountId()]);
}
//TODO: ESAPI.httpUtilities().killCookie(ESAPI.currentRequest(), ESAPI.currentResponse(), "PHPSESSIONID");
$this->_loggedIn = false;
//logger.info(Logger.SECURITY_SUCCESS, "Logout successful" );
//ESAPI.authenticator().setCurrentUser(User.ANONYMOUS);
}
/**
* Removes a role from this user's account.
*
* @param String $role the role to remove
* @throws AuthenticationException
* the authentication exception
*/
function removeRole ($role) {
$role = strtolower($role);
unset($this->_roles[$role]);
ESAPI::getLogger("DefaultLogger")->trace(ESAPILogger::SECURITY, TRUE, "Role " . $role . " removed from " . $this->getAccountName() );
}
/**
* Returns a token to be used as a prevention against CSRF attacks. This token should be added to all links and
* forms. The application should verify that all requests contain the token, or they may have been generated by a
* CSRF attack. It is generally best to perform the check in a centralized location, either a filter or controller.
* See the verifyCSRFToken method.
*
* @return the new CSRF token
*
* @throws AuthenticationException
* the authentication exception
*/
function resetCSRFToken () //throws AuthenticationException;
{
//TODO: Uncomment when Encoder's implemented
// $this->_csrfToken = ESAPI::getRandomizer()->getRandomString(8, DefaultEncoder::CHAR_ALPHANUMERICS);
return $csrfToken;
}
/**
* Sets this user's account name.
*
* @param String $accountName the new account name
*/
function setAccountName ($accountName) {
$oldAccountName = $this->getAccountName();
$this->_accountName = strtolower($accountName);
if ( !is_null($oldAccountName) )
ESAPI::getLogger("DefaultUser")->info(ESAPILogger::SECURITY, TRUE, "Account name changed from " . $oldAccountName . " to " . $this->getAccountName() );
}
/**
* Sets this user's account ID
* @param integer $accountId
* @return unknown_type
*/
function setAccountID ($accountId) {
$this->_accountId = $accountId;
}
/**
* Sets the date and time when this user's account will expire.
*
* @param $ExpirationTime Timestamp the new expiration time
*/
function setExpirationTime ($ExpirationTime) {
//TODO: Redo
$this->setUserInfo("expirationTime", $ExpirationTime);
}
/**
* Sets the roles for this account.
*
* @param Array $Roles the new roles
*
* @throws AuthenticationException
* the authentication exception
*/
function setRoles ($Roles) {
//TODO: Redo
$this->setUserInfo("roles", implode(",", $Roles));
}
/**
* Sets the screen name (username alias) for this user.
*
* @param String $screenName the new screen name
*/
function setScreenName ($screenName) {
$this->_screenName = $screenName;
ESAPI::getLogger("DefaultUser")->info(ESAPILogger::SECURITY, TRUE, "ScreenName changed to ". $screenName . " for " . $this->getAccountName() );
}
/**
* Unlock this user's account.
*/
function unlock () {
$this->_locked = FALSE;
$this->_failedLoginCount = 0;
ESAPI::getLogger("DefaultUser")->info(ESAPILogger::SECURITY, TRUE, "Account unlocked: " . $this->getAccountName() );
}
/**
* Verify that the supplied password matches the password for this user. This method
* is typically used for "reauthentication" for the most sensitive functions, such
* as transactions, changing email address, and changing other account information.
*
* @param $password the password that the user entered
*
* @return true, if the password passed in matches the account's password
*
* @throws EncryptionException
*/
public function verifyPassword ($password) {
return ESAPI::getAuthenticator()->verifyPassword($this, $password);
}
/**
* Set the time of the last failed login for this user.
*
* @param Integer $LastFailedLoginTime Timestamp the date and time when the user just failed to login correctly.
*/
function setLastFailedLoginTime ($LastFailedLoginTime) {
//TODO: Redo
$this->setUserInfo("lastFailedLoginTime", $LastFailedLoginTime);
}
/**
* Set the last remote host address used by this user.
*
* @param $remoteHost The address of the user's current source host.
*/
function setLastHostAddress ($RemoteHost) {
//TODO: Redo
if ($this->_lastHostAddress != null && $this->_lastHostAddress != $RemoteHost) {
// returning remote address not remote hostname to prevent DNS lookup
new AuthenticationHostException("Host change", "User session just jumped from " . $this->_lastHostAddress . " to " . $RemoteHost);
}
$this->_lastHostAddress = $RemoteHost;
}
/**
* Set the time of the last successful login for this user.
*
* @param Integer $LastLoginTime Timestamp the date and time when the user just successfully logged in.
*/
function setLastLoginTime ($LastLoginTime) {
//TODO: Redo
$this->setUserInfo("lastLoginTime", $LastLoginTime);
}
/**
* Set the time of the last password change for this user.
*
* @param Integer $LastPasswordChangeTime Timestamp the date and time when the user just successfully changed his/her password.
*/
function setLastPasswordChangeTime ($LastPasswordChangeTime) {
//TODO: Redo
$this->setUserInfo("lastPasswordChangeTime", $LastPasswordChangeTime);
}
/**
* The ANONYMOUS user is used to represent an unidentified user. Since there is
* always a real user, the ANONYMOUS user is better than using null to represent
* this.
*/
//FIXME:
public $ANONYMOUS = null;
}
?>