diff --git a/README.md b/README.md index 2f12855f9..3f12a0cc4 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,10 @@ typing commands or use the inventory. It can also kick players with uncommon lon EUR: USD:

+#####Sponsor +GameHosting.it is leader in Italy as Game Server Provider. With its own DataCenter offers Anti-DDoS solutions at affordable prices. Game Server of Minecraft based on Multicraft are equipped with the latest technology in hardware. +[![GameHosting](http://www.gamehosting.it/images/bn3.png)](http://www.gamehosting.it) + #####Credits

Team members: Xephi(Main Developer, Author), Maxetto(Contributor) and sgdc3(Contributor)

Credit for old version of the plugin to: d4rkwarriors, fabe1337 , Whoami2 and pomo4ka

diff --git a/pom.xml b/pom.xml index 7182eff48..b34222f3e 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,7 @@ com.zaxxer:HikariCP org.slf4j:slf4j-simple + org.slf4j:slf4j-api com.maxmind.geoip:geoip-api com.sun.mail:javax.mail com.comphenix.attribute:AttributeStorage @@ -195,6 +196,18 @@ 2.4.1 compile + + org.slf4j + slf4j-api + 1.7.12 + compile + + + org.slf4j + slf4j-simple + 1.7.12 + compile + diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 9f7834abf..ff8a6babb 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -231,8 +231,9 @@ public class AuthMe extends JavaPlugin { dataManager = new DataManager(this); - // Setup API + // Setup the new API api = new NewAPI(this); + // Old deprecated API new API(this); // Setup Management @@ -308,6 +309,7 @@ public class AuthMe extends JavaPlugin { // Sponsor message ConsoleLogger.info("AuthMe hooks perfectly with the VERYGAMES server hosting!"); + ConsoleLogger.info("Development builds are available on our jenkins, thanks to our sponsor GameHosting.it - leader in Italy as Game Server Provider"); ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " correctly enabled!"); } diff --git a/src/main/java/fr/xephi/authme/commands/AdminCommand.java b/src/main/java/fr/xephi/authme/commands/AdminCommand.java index 1cc04829b..76269f8fd 100644 --- a/src/main/java/fr/xephi/authme/commands/AdminCommand.java +++ b/src/main/java/fr/xephi/authme/commands/AdminCommand.java @@ -520,6 +520,7 @@ public class AdminCommand implements CommandExecutor { m.send(sender, "error"); return true; } + @SuppressWarnings("deprecation") Player target = Bukkit.getPlayer(name); PlayerCache.getInstance().removePlayer(name); Utils.getInstance().setGroup(name, groupType.UNREGISTERED); @@ -602,6 +603,7 @@ public class AdminCommand implements CommandExecutor { sender.sendMessage("Usage: /authme getip "); return true; } + @SuppressWarnings("deprecation") Player player = Bukkit.getPlayer(args[1]); if (player == null) { sender.sendMessage("This player is not actually online"); @@ -617,6 +619,7 @@ public class AdminCommand implements CommandExecutor { return true; } try { + @SuppressWarnings("deprecation") Player player = Bukkit.getPlayer(args[1]); if (player == null || !player.isOnline()) { sender.sendMessage("Player needs to be online!"); diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 15e5eb8e2..a12bc3d25 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -150,10 +150,9 @@ public class MySQL implements DataSource { } private synchronized Connection getConnection() throws SQLException { - if (connection == null || connection.isClosed()) { - connection = ds.getConnection(); - } - return connection; + Connection con = null; + con = ds.getConnection(); + return con; } private synchronized void setupConnection() throws SQLException { diff --git a/src/main/java/fr/xephi/authme/datasource/SQLite_HIKARI.java b/src/main/java/fr/xephi/authme/datasource/SQLite_HIKARI.java index 2b6ea3869..9ac800553 100644 --- a/src/main/java/fr/xephi/authme/datasource/SQLite_HIKARI.java +++ b/src/main/java/fr/xephi/authme/datasource/SQLite_HIKARI.java @@ -100,7 +100,7 @@ public class SQLite_HIKARI implements DataSource { this.setupConnection(); } catch (SQLException e) { ConsoleLogger.showError(e.getMessage()); - ConsoleLogger.showError("Can't initialize the MySQL database... Please check your database settings in the config.yml file! SHUTDOWN..."); + ConsoleLogger.showError("Can't initialize the SQLite database... Please check your database settings in the config.yml file! SHUTDOWN..."); ConsoleLogger.showError("If this error persists, please report it to the developer! SHUTDOWN..."); this.close(); if (Settings.isStopEnabled) { @@ -133,30 +133,18 @@ public class SQLite_HIKARI implements DataSource { ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!"); } - private synchronized Connection getRawConnection() { - Connection con = null; - while(con == null){ - try { - con = ds.getConnection(); - } catch (SQLException ce) { - return null; - } + private synchronized void reloadArguments() + throws ClassNotFoundException, IllegalArgumentException { + if (ds != null){ + ds.close(); } - return con; + setConnectionArguments(); + ConsoleLogger.info("Hikari ConnectionPool arguments reloaded!"); } - private synchronized Connection getConnection() { - Connection con; - con = getRawConnection(); - if(con == null){ - ds.close(); - ConsoleLogger.showError("Database connection is LOST! SHUTDOWN..."); - if (Settings.isStopEnabled) { - AuthMe.getInstance().getServer().shutdown(); - } else { - AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance()); - } - } + private synchronized Connection getConnection() throws SQLException { + Connection con = null; + con = ds.getConnection(); return con; } @@ -165,17 +153,7 @@ public class SQLite_HIKARI implements DataSource { Statement st = null; ResultSet rs = null; try { - con = getRawConnection(); - if(con == null){ - ds.close(); - if (Settings.isStopEnabled) { - ConsoleLogger.showError("Can't connect to the SQLite database... Please check your database settings in the config.yml file! SHUTDOWN..."); - AuthMe.getInstance().getServer().shutdown(); - } else { - AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance()); - } - return; - } + con = getConnection(); st = con.createStatement(); st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL," + columnLastLogin + " BIGINT," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT '" + Settings.defaultWorld + "'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));"); rs = con.getMetaData().getColumns(null, null, tableName, columnPassword); @@ -807,6 +785,17 @@ public class SQLite_HIKARI implements DataSource { @Override public void reload() { + try { + reloadArguments(); + } catch (Exception e) { + ConsoleLogger.showError(e.getMessage()); + ConsoleLogger.showError("Can't reconnect to SQLite database... Please check your SQLite informations ! SHUTDOWN..."); + if (Settings.isStopEnabled) { + AuthMe.getInstance().getServer().shutdown(); + } + if (!Settings.isStopEnabled) + AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance()); + } } @Override diff --git a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java index 312b6df01..935c9c1c1 100644 --- a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java +++ b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java @@ -25,6 +25,7 @@ public enum HashAlgorithm { SHA512(fr.xephi.authme.security.crypts.SHA512.class), DOUBLEMD5(fr.xephi.authme.security.crypts.DOUBLEMD5.class), PBKDF2(fr.xephi.authme.security.crypts.CryptPBKDF2.class), + PBKDF2DJANGO(fr.xephi.authme.security.crypts.CryptPBKDF2Django.class), WORDPRESS(fr.xephi.authme.security.crypts.WORDPRESS.class), ROYALAUTH(fr.xephi.authme.security.crypts.ROYALAUTH.class), CRAZYCRYPT1(fr.xephi.authme.security.crypts.CRAZYCRYPT1.class), diff --git a/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2.java b/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2.java index e6fb9bc50..2914e47c8 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2.java +++ b/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2.java @@ -28,4 +28,4 @@ public class CryptPBKDF2 implements EncryptionMethod { return engine.verifyKey(password); } -} +} \ No newline at end of file diff --git a/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2Django.java b/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2Django.java new file mode 100644 index 000000000..fc9986649 --- /dev/null +++ b/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2Django.java @@ -0,0 +1,32 @@ +package fr.xephi.authme.security.crypts; + +import java.security.NoSuchAlgorithmException; + +import fr.xephi.authme.security.pbkdf2.PBKDF2Engine; +import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters; +import javax.xml.bind.DatatypeConverter; + +public class CryptPBKDF2Django implements EncryptionMethod { + + @Override + public String getHash(String password, String salt, String name) + throws NoSuchAlgorithmException { + String result = "pbkdf2_sha256$15000$" + salt + "$"; + PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 15000); + PBKDF2Engine engine = new PBKDF2Engine(params); + + return result + String.valueOf(DatatypeConverter.printBase64Binary(engine.deriveKey(password, 32))); + } + + @Override + public boolean comparePassword(String hash, String password, + String playerName) throws NoSuchAlgorithmException { + String[] line = hash.split("\\$"); + String salt = line[2]; + byte[] derivedKey = DatatypeConverter.parseBase64Binary(line[3]); + PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 15000, derivedKey); + PBKDF2Engine engine = new PBKDF2Engine(params); + return engine.verifyKey(password); + } + +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 89f16d2c2..768ce22f3 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -200,7 +200,7 @@ settings: # possible values: MD5, SHA1, SHA256, WHIRLPOOL, XAUTH, MD5VB, PHPBB, # PLAINTEXT ( unhashed password), # MYBB, IPB3, PHPFUSION, SMF, XENFORO, SALTED2MD5, JOOMLA, BCRYPT, WBB3, SHA512, - # DOUBLEMD5, PBKDF2, WORDPRESS, ROYALAUTH, CUSTOM(for developpers only) + # DOUBLEMD5, PBKDF2, PBKDF2DJANGO, WORDPRESS, ROYALAUTH, CUSTOM(for developpers only) passwordHash: SHA256 # salt length for the SALTED2MD5 MD5(MD5(password)+salt) doubleMD5SaltLength: 8 diff --git a/team.txt b/team.txt index 634bcee58..e5ac3a1a6 100644 --- a/team.txt +++ b/team.txt @@ -3,6 +3,7 @@ AuthMe-Team: Xephi (Xephi59) - Leader, Main developer darkwarriors (d4rkwarriors) - Old AuthMe Reloaded Author Kloudy - Developer (Inactive, Will be avariable soon) +DNx5 - Developer Gabriele C. (sgdc3) - Ticket Manager, Project Page and Structure Manager, Contributor Maxetto - Ticket Manager, Italian Translator, Basic Developer, Contributor Gnat008 - Contributor