diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index ebaf5d8d6..0e17ea566 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -7,7 +7,7 @@ import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.security.HashAlgorithm; import fr.xephi.authme.security.crypts.HashedPassword; -import fr.xephi.authme.security.crypts.XF; +import fr.xephi.authme.security.crypts.XFBCRYPT; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.util.StringUtils; @@ -300,14 +300,14 @@ public class MySQL implements DataSource { .build(); rs.close(); pst.close(); - if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { + if (Settings.getPasswordHash == HashAlgorithm.XFBCRYPT) { pst = con.prepareStatement("SELECT data FROM xf_user_authenticate WHERE " + columnID + "=?;"); pst.setInt(1, id); rs = pst.executeQuery(); if (rs.next()) { Blob blob = rs.getBlob("data"); byte[] bytes = blob.getBytes(1, (int) blob.length()); - pAuth.setPassword(new HashedPassword(XF.getHashFromBlob(bytes))); + pAuth.setPassword(new HashedPassword(XFBCRYPT.getHashFromBlob(bytes))); } } } catch (SQLException ex) { @@ -490,7 +490,7 @@ public class MySQL implements DataSource { } rs.close(); pst.close(); - } else if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { + } else if (Settings.getPasswordHash == HashAlgorithm.XFBCRYPT) { pst = con.prepareStatement("SELECT " + columnID + " FROM " + tableName + " WHERE " + columnName + "=?;"); pst.setString(1, auth.getNickname()); rs = pst.executeQuery(); @@ -544,7 +544,7 @@ public class MySQL implements DataSource { } pst.executeUpdate(); pst.close(); - if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { + if (Settings.getPasswordHash == HashAlgorithm.XFBCRYPT) { String sql = "SELECT " + columnID + " FROM " + tableName + " WHERE " + columnName + "=?;"; pst = con.prepareStatement(sql); pst.setString(1, user); @@ -641,7 +641,7 @@ public class MySQL implements DataSource { try (Connection con = getConnection()) { String sql; PreparedStatement pst; - if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { + if (Settings.getPasswordHash == HashAlgorithm.XFBCRYPT) { sql = "SELECT " + columnID + " FROM " + tableName + " WHERE " + columnName + "=?;"; pst = con.prepareStatement(sql); pst.setString(1, user); @@ -942,14 +942,14 @@ public class MySQL implements DataSource { .groupId(group) .build(); - if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { + if (Settings.getPasswordHash == HashAlgorithm.XFBCRYPT) { int id = rs.getInt(columnID); pst.setInt(1, id); ResultSet rs2 = pst.executeQuery(); if (rs2.next()) { Blob blob = rs2.getBlob("data"); byte[] bytes = blob.getBytes(1, (int) blob.length()); - pAuth.setPassword(new HashedPassword(XF.getHashFromBlob(bytes))); + pAuth.setPassword(new HashedPassword(XFBCRYPT.getHashFromBlob(bytes))); } rs2.close(); } @@ -989,14 +989,14 @@ public class MySQL implements DataSource { .groupId(group) .build(); - if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { + if (Settings.getPasswordHash == HashAlgorithm.XFBCRYPT) { int id = rs.getInt(columnID); pst.setInt(1, id); ResultSet rs2 = pst.executeQuery(); if (rs2.next()) { Blob blob = rs2.getBlob("data"); byte[] bytes = blob.getBytes(1, (int) blob.length()); - pAuth.setPassword(new HashedPassword(XF.getHashFromBlob(bytes))); + pAuth.setPassword(new HashedPassword(XFBCRYPT.getHashFromBlob(bytes))); } rs2.close(); } diff --git a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java index 6d9ab98dc..389ad485f 100644 --- a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java +++ b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java @@ -35,7 +35,7 @@ public enum HashAlgorithm { WHIRLPOOL(fr.xephi.authme.security.crypts.WHIRLPOOL.class), WORDPRESS(fr.xephi.authme.security.crypts.WORDPRESS.class), XAUTH(fr.xephi.authme.security.crypts.XAUTH.class), - XENFORO(fr.xephi.authme.security.crypts.XF.class), + XFBCRYPT(fr.xephi.authme.security.crypts.XFBCRYPT.class), CUSTOM(null); private final Class clazz; diff --git a/src/main/java/fr/xephi/authme/security/crypts/XF.java b/src/main/java/fr/xephi/authme/security/crypts/XFBCRYPT.java similarity index 93% rename from src/main/java/fr/xephi/authme/security/crypts/XF.java rename to src/main/java/fr/xephi/authme/security/crypts/XFBCRYPT.java index cd3bcf165..6666a076c 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/XF.java +++ b/src/main/java/fr/xephi/authme/security/crypts/XFBCRYPT.java @@ -3,7 +3,7 @@ package fr.xephi.authme.security.crypts; import java.util.regex.Matcher; import java.util.regex.Pattern; -public class XF extends BCRYPT { +public class XFBCRYPT extends BCRYPT { private static final Pattern HASH_PATTERN = Pattern.compile("\"hash\";s.*\"(.*)?\""); @Override diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index cfb28f75e..4adfe15bd 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -515,11 +515,6 @@ public final class Settings { set("Xenoforo.predefinedSalt", null); changes = true; } - if (configFile.getString("settings.security.passwordHash", "SHA256").toUpperCase().equals("XFSHA1") || - configFile.getString("settings.security.passwordHash", "SHA256").toUpperCase().equals("XFSHA256")) { - set("settings.security.passwordHash", "XENFORO"); - changes = true; - } if (!contains("Protection.enableProtection")) { set("Protection.enableProtection", false); changes = true; @@ -528,10 +523,6 @@ public final class Settings { set("settings.restrictions.removeSpeed", true); changes = true; } - if (!contains("DataSource.mySQLMaxConections")) { - set("DataSource.mySQLMaxConections", 25); - changes = true; - } if (!contains("Protection.countries")) { countries = new ArrayList<>(); countries.add("US"); @@ -741,6 +732,7 @@ public final class Settings { } if (changes) { + save(); plugin.getLogger().warning("Merged new Config Options - I'm not an error, please don't report me"); plugin.getLogger().warning("Please check your config.yml file for new configs!"); } diff --git a/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java b/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java index 4583940e2..0ecfdb20b 100644 --- a/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java @@ -48,8 +48,8 @@ public class HashAlgorithmIntegrationTest { // given / when / then for (HashAlgorithm algorithm : HashAlgorithm.values()) { // TODO #137: Remove this check - if (HashAlgorithm.XENFORO.equals(algorithm)) { - System.out.println("Note: Currently skipping XENFORO hash (TODO #137: Fix it)"); + if (HashAlgorithm.XFBCRYPT.equals(algorithm)) { + System.out.println("Note: Currently skipping XFBCRYPT hash (TODO #137: Fix it)"); continue; } diff --git a/src/test/java/fr/xephi/authme/security/crypts/XFTest.java b/src/test/java/fr/xephi/authme/security/crypts/XFBCRYPTTest.java similarity index 58% rename from src/test/java/fr/xephi/authme/security/crypts/XFTest.java rename to src/test/java/fr/xephi/authme/security/crypts/XFBCRYPTTest.java index d9226baca..b62fb01e9 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/XFTest.java +++ b/src/test/java/fr/xephi/authme/security/crypts/XFBCRYPTTest.java @@ -4,16 +4,16 @@ import org.junit.Ignore; import org.junit.Test; /** - * Test for {@link XF}. + * Test for {@link XFBCRYPT}. */ @Ignore // TODO #137: Create a test class as for the other encryption methods. Simply run the following test and copy the -// output -- that's your test class! (Once XF.java actually works properly) -// @org.junit.Test public void a() { AbstractEncryptionMethodTest.generateTest(new XF()); } -public class XFTest { +// output -- that's your test class! (Once XFBCRYPT.java actually works properly) +// @org.junit.Test public void a() { AbstractEncryptionMethodTest.generateTest(new XFBCRYPT()); } +public class XFBCRYPTTest { @Test public void shouldComputeHash() { - System.out.println(new XF().computeHash("Test", "name")); + System.out.println(new XFBCRYPT().computeHash("Test", "name")); } }