#704 Remove reloading from hash algorithms

- A new instance is created for every hash operation, so reloading will never happen on those classes
This commit is contained in:
ljacqu 2016-05-18 19:09:25 +02:00
parent 7229a8b02b
commit 92a8a5dd41
2 changed files with 6 additions and 16 deletions

View File

@ -1,7 +1,6 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.SaltType;
@ -14,13 +13,13 @@ import javax.inject.Inject;
@Recommendation(Usage.RECOMMENDED) // provided the salt length is >= 8
@HasSalt(value = SaltType.TEXT) // length depends on the bcryptLog2Rounds setting
public class BCRYPT implements EncryptionMethod, SettingsDependent {
public class BCRYPT implements EncryptionMethod {
private int bCryptLog2Rounds;
private final int bCryptLog2Rounds;
@Inject
public BCRYPT(NewSetting settings) {
loadSettings(settings);
bCryptLog2Rounds = settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND);
}
@Override
@ -54,8 +53,4 @@ public class BCRYPT implements EncryptionMethod, SettingsDependent {
return false;
}
@Override
public void loadSettings(NewSetting settings) {
bCryptLog2Rounds = settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND);
}
}

View File

@ -1,6 +1,5 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
@ -15,13 +14,13 @@ import static fr.xephi.authme.security.HashUtils.md5;
@Recommendation(Usage.ACCEPTABLE) // presuming that length is something sensible (>= 8)
@HasSalt(value = SaltType.TEXT) // length defined by the doubleMd5SaltLength setting
public class SALTED2MD5 extends SeparateSaltMethod implements SettingsDependent {
public class SALTED2MD5 extends SeparateSaltMethod {
private int saltLength;
private final int saltLength;
@Inject
public SALTED2MD5(NewSetting settings) {
loadSettings(settings);
saltLength = settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH);
}
@Override
@ -34,9 +33,5 @@ public class SALTED2MD5 extends SeparateSaltMethod implements SettingsDependent
return RandomString.generateHex(saltLength);
}
@Override
public void loadSettings(NewSetting settings) {
saltLength = settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH);
}
}