#358 Handle hash + salt as one "unit"
- Rename HashResult to EncryptedPassword to reflect its broader use - Use EncryptedPassword in methods that require the hash and the salt, instead of passing them as strings separately - Store EncryptedPassword as field in PlayerAuth; updatePassword() thus processes the entire data in the EncryptedPassword object
This commit is contained in:
@@ -8,7 +8,6 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@@ -138,7 +137,7 @@ public class AsynchronousLogin {
|
||||
|
||||
String email = pAuth.getEmail();
|
||||
boolean passwordVerified = forceLogin || plugin.getPasswordSecurity()
|
||||
.comparePassword(password, pAuth.getHash(), pAuth.getSalt(), realName);
|
||||
.comparePassword(password, pAuth.getPassword(), realName);
|
||||
|
||||
if (passwordVerified && player.isOnline()) {
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
@@ -147,8 +146,7 @@ public class AsynchronousLogin {
|
||||
.ip(getIP())
|
||||
.lastLogin(new Date().getTime())
|
||||
.email(email)
|
||||
.hash(pAuth.getHash())
|
||||
.salt(pAuth.getSalt())
|
||||
.hash(pAuth.getPassword())
|
||||
.build();
|
||||
database.updateSession(auth);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.security.crypts.HashResult;
|
||||
import fr.xephi.authme.security.crypts.EncryptedPassword;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -97,12 +97,11 @@ public class AsyncRegister {
|
||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
||||
return;
|
||||
}
|
||||
final HashResult hashResult = plugin.getPasswordSecurity().computeHash(password, name);
|
||||
final EncryptedPassword encryptedPassword = plugin.getPasswordSecurity().computeHash(password, name);
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
.name(name)
|
||||
.realName(player.getName())
|
||||
.hash(hashResult.getHash())
|
||||
.salt(hashResult.getSalt())
|
||||
.hash(encryptedPassword)
|
||||
.ip(ip)
|
||||
.locWorld(player.getLocation().getWorld().getName())
|
||||
.locX(player.getLocation().getX())
|
||||
@@ -124,12 +123,11 @@ public class AsyncRegister {
|
||||
}
|
||||
|
||||
private void passwordRegister() throws Exception {
|
||||
final HashResult hashResult = plugin.getPasswordSecurity().computeHash(password, name);
|
||||
final EncryptedPassword encryptedPassword = plugin.getPasswordSecurity().computeHash(password, name);
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
.name(name)
|
||||
.realName(player.getName())
|
||||
.hash(hashResult.getHash())
|
||||
.salt(hashResult.getSalt())
|
||||
.hash(encryptedPassword)
|
||||
.ip(ip)
|
||||
.locWorld(player.getLocation().getWorld().getName())
|
||||
.locX(player.getLocation().getX())
|
||||
|
||||
@@ -55,7 +55,7 @@ public class AsynchronousUnregister {
|
||||
public void process() {
|
||||
PlayerAuth cachedAuth = PlayerCache.getInstance().getAuth(name);
|
||||
if (force || plugin.getPasswordSecurity().comparePassword(
|
||||
password, cachedAuth.getHash(), cachedAuth.getSalt(), player.getName())) {
|
||||
password, cachedAuth.getPassword(), player.getName())) {
|
||||
if (!plugin.getDataSource().removeAuth(name)) {
|
||||
m.send(player, MessageKey.ERROR);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user