mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-36: Clarify function naming regarding a user's current (at time of query) password record.
This commit is contained in:
@@ -227,13 +227,13 @@ public class PasswordPolicyService {
|
|||||||
private long getPasswordAge(ModeledUser user) {
|
private long getPasswordAge(ModeledUser user) {
|
||||||
|
|
||||||
// If no password was set, then no time has elapsed
|
// If no password was set, then no time has elapsed
|
||||||
PasswordRecordModel previousPassword = user.getPreviousPassword();
|
PasswordRecordModel passwordRecord = user.getPasswordRecord();
|
||||||
if (previousPassword == null)
|
if (passwordRecord == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Pull both current time and the time the password was last reset
|
// Pull both current time and the time the password was last reset
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
long lastResetTime = previousPassword.getPasswordDate().getTime();
|
long lastResetTime = passwordRecord.getPasswordDate().getTime();
|
||||||
|
|
||||||
// Calculate the number of days elapsed since the password was last reset
|
// Calculate the number of days elapsed since the password was last reset
|
||||||
return TimeUnit.DAYS.convert(currentTime - lastResetTime, TimeUnit.MILLISECONDS);
|
return TimeUnit.DAYS.convert(currentTime - lastResetTime, TimeUnit.MILLISECONDS);
|
||||||
@@ -306,12 +306,13 @@ public class PasswordPolicyService {
|
|||||||
* user is limited by the password policy.
|
* user is limited by the password policy.
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* The user whose previous password should be recorded.
|
* The user whose password should be recorded within the password
|
||||||
|
* history.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If the password policy cannot be parsed.
|
* If the password policy cannot be parsed.
|
||||||
*/
|
*/
|
||||||
public void recordPreviousPassword(ModeledUser user)
|
public void recordPassword(ModeledUser user)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Retrieve password policy from environment
|
// Retrieve password policy from environment
|
||||||
@@ -323,7 +324,7 @@ public class PasswordPolicyService {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Store previous password in history
|
// Store previous password in history
|
||||||
passwordRecordMapper.insert(user.getPreviousPassword(), historySize);
|
passwordRecordMapper.insert(user.getPasswordRecord(), historySize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -192,7 +192,7 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
* The data associated with this user's password at the time this user was
|
* The data associated with this user's password at the time this user was
|
||||||
* queried. If the user is new, this will be null.
|
* queried. If the user is new, this will be null.
|
||||||
*/
|
*/
|
||||||
private PasswordRecordModel previousPassword = null;
|
private PasswordRecordModel passwordRecord = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new, empty ModeledUser.
|
* Creates a new, empty ModeledUser.
|
||||||
@@ -207,7 +207,7 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
|
|
||||||
// Store previous password, if any
|
// Store previous password, if any
|
||||||
if (model.getPasswordHash() != null)
|
if (model.getPasswordHash() != null)
|
||||||
this.previousPassword = new PasswordRecordModel(model);
|
this.passwordRecord = new PasswordRecordModel(model);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,19 +245,19 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the data associated with this user's previous password as a
|
* Returns the this user's current password record. If the user is new, this
|
||||||
* password record. If the user is new, this will be null. Unlike the other
|
* will be null. Note that this may represent a different password than what
|
||||||
* password-related functions of UserModel, this data returned by this
|
* is returned by getPassword(): unlike the other password-related functions
|
||||||
* function is historical and is unaffected by calls to setPassword(). It
|
* of ModeledUser, the data returned by this function is historical and is
|
||||||
* will always return the values stored in the database at the time this
|
* unaffected by calls to setPassword(). It will always return the values
|
||||||
* user was queried.
|
* stored in the database at the time this user was queried.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* The data associated with this user's previous password, or null if
|
* The historical data associated with this user's password, or null if
|
||||||
* the user is new.
|
* the user is new.
|
||||||
*/
|
*/
|
||||||
public PasswordRecordModel getPreviousPassword() {
|
public PasswordRecordModel getPasswordRecord() {
|
||||||
return previousPassword;
|
return passwordRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -243,7 +243,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
|
|||||||
passwordPolicyService.verifyPassword(object.getIdentifier(), object.getPassword());
|
passwordPolicyService.verifyPassword(object.getIdentifier(), object.getPassword());
|
||||||
|
|
||||||
// Store previous password in history
|
// Store previous password in history
|
||||||
passwordPolicyService.recordPreviousPassword(object);
|
passwordPolicyService.recordPassword(object);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user