mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-22 00:27:36 +01:00
Rename XF class into XFBCRYPT.
This commit is contained in:
parent
781a005c25
commit
da5de58afb
@ -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();
|
||||
}
|
||||
|
@ -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<? extends EncryptionMethod> clazz;
|
||||
|
@ -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
|
@ -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!");
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user