#358 Ensure lowercase player name, issue cleanup
- Ensure within PasswordSecurity that the player name is lowercase - Remove check for MD5VB separate salt (we only generate hashes with the salt embedded, so either we need to change that or we don't need this check) - Remove obsolete TODO
This commit is contained in:
@@ -281,12 +281,6 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
public EncryptedPassword getPassword() {
|
||||
// TODO #358: Check whether this check is really necessary. It's been here since the first commit.
|
||||
/*if (Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
if (salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
return "$MD5vb$" + salt + "$" + hash;
|
||||
}
|
||||
}*/
|
||||
return password;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -67,8 +67,8 @@ public class ChangePasswordAdminCommand implements ExecutableCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO #358: Do we always pass lowercase name?? In that case we need to do that in PasswordSecurity!
|
||||
EncryptedPassword encryptedPassword = commandService.getPasswordSecurity().computeHash(playerPass, playerNameLowerCase);
|
||||
EncryptedPassword encryptedPassword = commandService.getPasswordSecurity()
|
||||
.computeHash(playerPass, playerNameLowerCase);
|
||||
auth.setPassword(encryptedPassword);
|
||||
|
||||
if (!dataSource.updatePassword(auth)) {
|
||||
|
||||
@@ -30,8 +30,9 @@ public class PasswordSecurity {
|
||||
}
|
||||
|
||||
public EncryptedPassword computeHash(HashAlgorithm algorithm, String password, String playerName) {
|
||||
EncryptionMethod method = initializeEncryptionMethod(algorithm, playerName);
|
||||
return method.computeHash(password, playerName);
|
||||
String playerLowerCase = playerName.toLowerCase();
|
||||
EncryptionMethod method = initializeEncryptionMethod(algorithm, playerLowerCase);
|
||||
return method.computeHash(password, playerLowerCase);
|
||||
}
|
||||
|
||||
public boolean comparePassword(String password, String playerName) {
|
||||
@@ -52,8 +53,9 @@ public class PasswordSecurity {
|
||||
return false;
|
||||
}
|
||||
|
||||
return method.comparePassword(password, encryptedPassword, playerName)
|
||||
|| supportOldAlgorithm && compareWithAllEncryptionMethods(password, encryptedPassword, playerName);
|
||||
String playerLowerCase = playerName.toLowerCase();
|
||||
return method.comparePassword(password, encryptedPassword, playerLowerCase)
|
||||
|| supportOldAlgorithm && compareWithAllEncryptionMethods(password, encryptedPassword, playerLowerCase);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user