diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/security/PasswordPolicyService.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/security/PasswordPolicyService.java index d6a9fe575..a9fbcf35b 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/security/PasswordPolicyService.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/security/PasswordPolicyService.java @@ -227,13 +227,13 @@ public class PasswordPolicyService { private long getPasswordAge(ModeledUser user) { // If no password was set, then no time has elapsed - PasswordRecordModel previousPassword = user.getPreviousPassword(); - if (previousPassword == null) + PasswordRecordModel passwordRecord = user.getPasswordRecord(); + if (passwordRecord == null) return 0; // Pull both current time and the time the password was last reset 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 return TimeUnit.DAYS.convert(currentTime - lastResetTime, TimeUnit.MILLISECONDS); @@ -306,12 +306,13 @@ public class PasswordPolicyService { * user is limited by the password policy. * * @param user - * The user whose previous password should be recorded. + * The user whose password should be recorded within the password + * history. * * @throws GuacamoleException * If the password policy cannot be parsed. */ - public void recordPreviousPassword(ModeledUser user) + public void recordPassword(ModeledUser user) throws GuacamoleException { // Retrieve password policy from environment @@ -323,7 +324,7 @@ public class PasswordPolicyService { return; // Store previous password in history - passwordRecordMapper.insert(user.getPreviousPassword(), historySize); + passwordRecordMapper.insert(user.getPasswordRecord(), historySize); } diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java index 18a13eccb..d3570030a 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java @@ -192,7 +192,7 @@ public class ModeledUser extends ModeledDirectoryObject implements Us * The data associated with this user's password at the time this user was * queried. If the user is new, this will be null. */ - private PasswordRecordModel previousPassword = null; + private PasswordRecordModel passwordRecord = null; /** * Creates a new, empty ModeledUser. @@ -207,7 +207,7 @@ public class ModeledUser extends ModeledDirectoryObject implements Us // Store previous password, if any if (model.getPasswordHash() != null) - this.previousPassword = new PasswordRecordModel(model); + this.passwordRecord = new PasswordRecordModel(model); } @@ -245,19 +245,19 @@ public class ModeledUser extends ModeledDirectoryObject implements Us } /** - * Returns the data associated with this user's previous password as a - * password record. If the user is new, this will be null. Unlike the other - * password-related functions of UserModel, this data returned by this - * function is historical and is unaffected by calls to setPassword(). It - * will always return the values stored in the database at the time this - * user was queried. + * Returns the this user's current password record. If the user is new, this + * will be null. Note that this may represent a different password than what + * is returned by getPassword(): unlike the other password-related functions + * of ModeledUser, the data returned by this function is historical and is + * unaffected by calls to setPassword(). It will always return the values + * stored in the database at the time this user was queried. * * @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. */ - public PasswordRecordModel getPreviousPassword() { - return previousPassword; + public PasswordRecordModel getPasswordRecord() { + return passwordRecord; } /** diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/UserService.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/UserService.java index 74503b5b8..5939b041c 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/UserService.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/UserService.java @@ -243,7 +243,7 @@ public class UserService extends ModeledDirectoryObjectService