#364 Create first EncryptionMethod tests

This commit is contained in:
ljacqu
2015-12-20 00:50:34 +01:00
parent 4f6c7d579c
commit bf7a0c5a49
9 changed files with 201 additions and 19 deletions
@@ -36,7 +36,7 @@ public class PasswordSecurity {
EncryptionMethod method;
try {
if (alg != HashAlgorithm.CUSTOM)
method = (EncryptionMethod) alg.getclasse().newInstance();
method = alg.getClazz().newInstance();
else method = null;
} catch (InstantiationException | IllegalAccessException e) {
throw new NoSuchAlgorithmException("Problem with hash algorithm '" + alg + "'", e);
@@ -131,10 +131,11 @@ public class PasswordSecurity {
HashAlgorithm algorithm = Settings.getPasswordHash;
EncryptionMethod method;
try {
if (algorithm != HashAlgorithm.CUSTOM)
method = (EncryptionMethod) algorithm.getclasse().newInstance();
else
if (algorithm != HashAlgorithm.CUSTOM) {
method = algorithm.getClazz().newInstance();
} else {
method = null;
}
PasswordEncryptionEvent event = new PasswordEncryptionEvent(method, playerName);
Bukkit.getPluginManager().callEvent(event);
@@ -161,7 +162,7 @@ public class PasswordSecurity {
for (HashAlgorithm algo : HashAlgorithm.values()) {
if (algo != HashAlgorithm.CUSTOM) {
try {
EncryptionMethod method = (EncryptionMethod) algo.getclasse().newInstance();
EncryptionMethod method = algo.getClazz().newInstance();
if (method.comparePassword(hash, password, playerName)) {
PlayerAuth nAuth = AuthMe.getInstance().database.getAuth(playerName);
if (nAuth != null) {