From 1c12278c4b0a7f30edc3eb06f8b06133c7646f93 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Mon, 28 Dec 2015 22:39:15 +0100 Subject: [PATCH] #369 Remove XENFORO enum entry --- .../fr/xephi/authme/datasource/MySQL.java | 98 +------------------ .../authme/security/PasswordSecurity.java | 1 - 2 files changed, 1 insertion(+), 98 deletions(-) diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index e779afff..7135d6ad 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -303,16 +303,6 @@ public class MySQL implements DataSource { .build(); rs.close(); pst.close(); - if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { - 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.setHash(new String(bytes)); - } - } } catch (SQLException ex) { ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.writeStackTrace(ex); @@ -502,25 +492,6 @@ public class MySQL implements DataSource { } rs.close(); pst.close(); - } else if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { - pst = con.prepareStatement("SELECT " + columnID + " FROM " + tableName + " WHERE " + columnName + "=?;"); - pst.setString(1, auth.getNickname()); - rs = pst.executeQuery(); - if (rs.next()) { - int id = rs.getInt(columnID); - // Insert password in the correct table - pst2 = con.prepareStatement("INSERT INTO xf_user_authenticate (user_id, scheme_class, data) VALUES (?,?,?);"); - pst2.setInt(1, id); - pst2.setString(2, "XenForo_Authentication_Core12"); - byte[] bytes = auth.getHash().getBytes(); - Blob blob = con.createBlob(); - blob.setBytes(1, bytes); - pst2.setBlob(3, blob); - pst2.executeUpdate(); - pst2.close(); - } - rs.close(); - pst.close(); } return true; } catch (SQLException ex) { @@ -548,34 +519,6 @@ public class MySQL implements DataSource { pst.setString(2, auth.getNickname()); pst.executeUpdate(); pst.close(); - if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { - sql = "SELECT " + columnID + " FROM " + tableName + " WHERE " + columnName + "=?;"; - pst = con.prepareStatement(sql); - pst.setString(1, auth.getNickname()); - ResultSet rs = pst.executeQuery(); - if (rs.next()) { - int id = rs.getInt(columnID); - // Insert password in the correct table - sql = "UPDATE xf_user_authenticate SET data=? WHERE " + columnID + "=?;"; - PreparedStatement pst2 = con.prepareStatement(sql); - byte[] bytes = auth.getHash().getBytes(); - Blob blob = con.createBlob(); - blob.setBytes(1, bytes); - pst2.setBlob(1, blob); - pst2.setInt(2, id); - pst2.executeUpdate(); - pst2.close(); - // ... - sql = "UPDATE xf_user_authenticate SET scheme_class=? WHERE " + columnID + "=?;"; - pst2 = con.prepareStatement(sql); - pst2.setString(1, "XenForo_Authentication_Core12"); - pst2.setInt(2, id); - pst2.executeUpdate(); - pst2.close(); - } - rs.close(); - pst.close(); - } return true; } catch (SQLException ex) { ConsoleLogger.showError(ex.getMessage()); @@ -679,24 +622,7 @@ public class MySQL implements DataSource { public synchronized boolean removeAuth(String user) { user = user.toLowerCase(); try (Connection con = getConnection()) { - String sql; - PreparedStatement pst; - if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { - sql = "SELECT " + columnID + " FROM " + tableName + " WHERE " + columnName + "=?;"; - pst = con.prepareStatement(sql); - pst.setString(1, user); - ResultSet rs = pst.executeQuery(); - if (rs.next()) { - int id = rs.getInt(columnID); - sql = "DELETE FROM xf_user_authenticate WHERE " + columnID + "=" + id; - Statement st = con.createStatement(); - st.executeUpdate(sql); - st.close(); - } - rs.close(); - pst.close(); - } - pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;"); + PreparedStatement pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;"); pst.setString(1, user); pst.executeUpdate(); return true; @@ -1136,17 +1062,6 @@ public class MySQL implements DataSource { .groupId(group) .build(); - if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { - 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.setHash(new String(bytes)); - } - rs2.close(); - } auths.add(pAuth); } pst.close(); @@ -1191,17 +1106,6 @@ public class MySQL implements DataSource { .groupId(group) .build(); - if (Settings.getPasswordHash == HashAlgorithm.XENFORO) { - 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.setHash(new String(bytes)); - } - rs2.close(); - } auths.add(pAuth); } } catch (Exception ex) { diff --git a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java index b733d55a..d84b6870 100644 --- a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java +++ b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java @@ -106,7 +106,6 @@ public class PasswordSecurity { case SHA1: case WHIRLPOOL: case PLAINTEXT: - case XENFORO: case SHA512: case ROYALAUTH: case CRAZYCRYPT1: