AuthMe 3.4

This commit is contained in:
Xephi 2014-06-13 05:56:59 +02:00
parent ff9ec22041
commit 2638007ada
52 changed files with 504 additions and 383 deletions

Binary file not shown.

11
pom.xml
View File

@ -24,12 +24,12 @@
</plugin>
</plugins>
</build>
<version>3.3.6</version>
<version>3.4</version>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.5-R0.1-SNAPSHOT</version>
<version>1.7.9-R0.2</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
@ -128,13 +128,6 @@
<version>Pre2.9.4.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Essentials.jar</systemPath>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.7.2-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/bungeecord-api.jar</systemPath>
</dependency>
</dependencies>
</project>

View File

@ -537,7 +537,8 @@ public class AuthMe extends JavaPlugin {
player.getInventory().setArmorContents(limbo.getArmour());
player.getInventory().setContents(limbo.getInventory());
}
player.teleport(limbo.getLoc());
if (!Settings.noTeleport)
player.teleport(limbo.getLoc());
this.utils.addNormal(player, limbo.getGroup());
player.setOp(limbo.getOperator());
this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());

View File

@ -32,7 +32,7 @@ public class API {
*/
public static AuthMe hookAuthMe() {
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
if (plugin == null && !(plugin instanceof AuthMe)) {
if (plugin == null || !(plugin instanceof AuthMe)) {
return null;
}
return (AuthMe) plugin;

View File

@ -26,6 +26,7 @@ public class PlayerAuth {
this.lastLogin = lastLogin;
this.email = email;
this.realName = realName;
}
public PlayerAuth(String nickname, double x, double y, double z, String world) {
@ -34,6 +35,8 @@ public class PlayerAuth {
this.y = y;
this.z = z;
this.world = world;
this.lastLogin = System.currentTimeMillis();
}
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
@ -47,6 +50,7 @@ public class PlayerAuth {
this.world = world;
this.email = email;
this.realName = realName;
}
public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
@ -62,6 +66,7 @@ public class PlayerAuth {
this.groupId = groupId;
this.email = email;
this.realName = realName;
}
public PlayerAuth(String nickname, String hash, String salt, int groupId , String ip, long lastLogin, String realName) {
@ -72,6 +77,7 @@ public class PlayerAuth {
this.salt = salt;
this.groupId = groupId;
this.realName = realName;
}
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, String realName) {
@ -81,6 +87,7 @@ public class PlayerAuth {
this.lastLogin = lastLogin;
this.salt = salt;
this.realName = realName;
}
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
@ -101,6 +108,14 @@ public class PlayerAuth {
this.nickname = nickname;
this.ip = ip;
this.lastLogin = lastLogin;
}
public PlayerAuth(String nickname, String hash, String ip, long lastLogin) {
this.nickname = nickname;
this.ip = ip;
this.lastLogin = lastLogin;
this.hash = hash;
}
public String getIp() {
@ -218,5 +233,4 @@ public class PlayerAuth {
public String getRealname() {
return realName;
}
}

View File

@ -10,11 +10,14 @@ import java.util.Scanner;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.api.API;
public class FileCache {
private AuthMe plugin = AuthMe.getInstance();
public FileCache() {
final File folder = new File("cache");
if (!folder.exists()) {
@ -127,25 +130,25 @@ public class FileCache {
final File file = new File("cache/" + playername
+ ".cache");
ItemStack[] stacki = new ItemStack[36];
ItemStack[] stacka = new ItemStack[4];
String group = null;
boolean op = false;
boolean flying = false;
if (!file.exists()) {
return new DataFileCache(stacki, stacka);
}
ItemStack[] stacki = new ItemStack[36];
ItemStack[] stacka = new ItemStack[4];
String group = null;
boolean op = false;
boolean flying = false;
if (!file.exists()) {
return new DataFileCache(stacki, stacka);
}
Scanner reader = null;
try {
reader = new Scanner(file);
Scanner reader = null;
try {
reader = new Scanner(file);
int i = 0;
int a = 0;
while (reader.hasNextLine()) {
String line = reader.nextLine();
int i = 0;
int a = 0;
while (reader.hasNextLine()) {
String line = reader.nextLine();
if (!line.contains(":")) {
if (!line.contains(":")) {
// the fist line represent the player group, operator status and flying status
final String[] playerInfo = line.split(";");
group = playerInfo[0];
@ -154,77 +157,88 @@ public class FileCache {
op = true;
} else op = false;
if (playerInfo.length > 2) {
if (Integer.parseInt(playerInfo[2]) == 1)
flying = true;
else flying = false;
if (Integer.parseInt(playerInfo[2]) == 1)
flying = true;
else flying = false;
}
continue;
}
}
if (!line.startsWith("i") && !line.startsWith("w")) {
continue;
}
String lores = "";
String name = "";
if (line.split("\\*").length > 1) {
lores = line.split("\\*")[1];
line = line.split("\\*")[0];
}
if (line.split(";").length > 1) {
name = line.split(";")[1];
line = line.split(";")[0];
}
final String[] in = line.split(":");
if (!line.startsWith("i") && !line.startsWith("w")) {
continue;
}
String lores = "";
String name = "";
if (line.split("\\*").length > 1) {
lores = line.split("\\*")[1];
line = line.split("\\*")[0];
}
if (line.split(";").length > 1) {
name = line.split(";")[1];
line = line.split(";")[0];
}
final String[] in = line.split(":");
// can enchant item? size ofstring in file - 4 all / 2 = number of enchant
if (in[0].equals("i")) {
stacki[i] = new ItemStack(Material.getMaterial(in[1]),
Integer.parseInt(in[2]), Short.parseShort((in[3])));
if(in.length > 4 && !in[4].isEmpty()) {
for(int k=4;k<in.length-1;k++) {
stacki[i].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
k++;
}
}
if (!name.isEmpty())
stacki[i].getItemMeta().setDisplayName(name);
if (!lores.isEmpty()) {
List<String> loreList = new ArrayList<String>();
for (String s : lores.split("%newline%")) {
loreList.add(s);
}
stacki[i].getItemMeta().setLore(loreList);
}
i++;
} else {
stacka[a] = new ItemStack(Material.getMaterial(in[1]),
Integer.parseInt(in[2]), Short.parseShort((in[3])));
if(in.length > 4 && !in[4].isEmpty()) {
for(int k=4;k<in.length-1;k++) {
stacka[a].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
k++;
}
}
if (!name.isEmpty())
stacka[a].getItemMeta().setDisplayName(name);
if (!lores.isEmpty()) {
List<String> loreList = new ArrayList<String>();
for (String s : lores.split("%newline%")) {
loreList.add(s);
}
stacka[a].getItemMeta().setLore(loreList);
}
a++;
}
}
} catch (final Exception e) {
e.printStackTrace();
} finally {
if (reader != null) {
reader.close();
}
}
return new DataFileCache(stacki, stacka, group, op, flying);
if (in[0].equals("i")) {
stacki[i] = new ItemStack(Material.getMaterial(in[1]),
Integer.parseInt(in[2]), Short.parseShort((in[3])));
if(in.length > 4 && !in[4].isEmpty()) {
for(int k=4;k<in.length-1;k++) {
stacki[i].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
k++;
}
}
try {
ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(stacki[i].getType());
if (!name.isEmpty()) {
meta.setDisplayName(name);
}
if (!lores.isEmpty()) {
List<String> loreList = new ArrayList<String>();
for (String s : lores.split("%newline%")) {
loreList.add(s);
}
meta.setLore(loreList);
}
if (meta != null)
stacki[i].setItemMeta(meta);
} catch (Exception e) {}
i++;
} else {
stacka[a] = new ItemStack(Material.getMaterial(in[1]),
Integer.parseInt(in[2]), Short.parseShort((in[3])));
if(in.length > 4 && !in[4].isEmpty()) {
for(int k=4;k<in.length-1;k++) {
stacka[a].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
k++;
}
}
try {
ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(stacka[a].getType());
if (!name.isEmpty())
meta.setDisplayName(name);
if (!lores.isEmpty()) {
List<String> loreList = new ArrayList<String>();
for (String s : lores.split("%newline%")) {
loreList.add(s);
}
meta.setLore(loreList);
}
if (meta != null)
stacki[i].setItemMeta(meta);
} catch (Exception e) {}
a++;
}
}
} catch (final Exception e) {
e.printStackTrace();
} finally {
if (reader != null) {
reader.close();
}
}
return new DataFileCache(stacki, stacka, group, op, flying);
}
public void removeCache(String playername) {

View File

@ -2,7 +2,6 @@ package fr.xephi.authme.commands;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
@ -33,12 +32,12 @@ import fr.xephi.authme.api.API;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.converter.Converter;
import fr.xephi.authme.converter.FlatToSql;
import fr.xephi.authme.converter.FlatToSqlite;
import fr.xephi.authme.converter.RakamakConverter;
import fr.xephi.authme.converter.RoyalAuthConverter;
import fr.xephi.authme.converter.newxAuthToFlat;
import fr.xephi.authme.converter.oldxAuthToFlat;
import fr.xephi.authme.converter.xAuthConverter;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.security.PasswordSecurity;
@ -301,44 +300,26 @@ public class AdminCommand implements CommandExecutor {
}
return true;
} else if (args[0].equalsIgnoreCase("convertflattosql")) {
try {
FlatToSql converter = new FlatToSql();
if (sender instanceof Player) {
if (converter.convert())
sender.sendMessage("[AuthMe] FlatFile converted to authme.sql file");
else sender.sendMessage("[AuthMe] Error while converting to authme.sql");
}
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException ex) {
System.out.println(ex.getMessage());
}
FlatToSql converter = new FlatToSql();
try {
converter.convert();
} catch (Exception e) {
sender.sendMessage("[AuthMe] Error while converting to authme.sql");
}
} else if (args[0].equalsIgnoreCase("flattosqlite")) {
try {
String s = FlatToSqlite.convert();
if (sender instanceof Player)
sender.sendMessage(s);
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException ex) {
System.out.println(ex.getMessage());
}
FlatToSqlite converter = new FlatToSqlite(sender);
try {
converter.convert();
} catch (Exception e) {
}
return true;
} else if (args[0].equalsIgnoreCase("xauthimport")) {
try {
Class.forName("com.cypherx.xauth.xAuth");
oldxAuthToFlat converter = new oldxAuthToFlat(plugin, database, sender);
converter.run();
} catch (ClassNotFoundException e) {
try {
Class.forName("de.luricos.bukkit.xAuth.xAuth");
newxAuthToFlat converter = new newxAuthToFlat(plugin, database, sender);
converter.run();
} catch (ClassNotFoundException ce) {
sender.sendMessage("[AuthMe] No version of xAuth found or xAuth isn't enable! ");
}
}
Converter converter = new xAuthConverter(plugin, database, sender);
try {
converter.convert();
} catch (Exception e) {
sender.sendMessage("Error while importing xAuth data, check your logs");
}
return true;
} else if (args[0].equalsIgnoreCase("getemail")) {
if (args.length != 2) {
@ -373,15 +354,12 @@ public class AdminCommand implements CommandExecutor {
PlayerCache.getInstance().updatePlayer(getAuth);
return true;
} else if (args[0].equalsIgnoreCase("convertfromrakamak")) {
try {
RakamakConverter.RakamakConvert();
if (sender instanceof Player)
sender.sendMessage("[AuthMe] Rakamak database converted to auths.db");
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException ex) {
ConsoleLogger.showError(ex.getMessage());
}
Converter converter = new RakamakConverter(plugin, database, sender);
try {
converter.convert();
} catch (Exception e) {
sender.sendMessage("Error while importing Rakamak data, check your logs");
}
return true;
} else if (args[0].equalsIgnoreCase("setspawn")) {
try {
@ -509,7 +487,7 @@ public class AdminCommand implements CommandExecutor {
Utils.getInstance().setGroup(name, groupType.UNREGISTERED);
if (target != null) {
if (target.isOnline()) {
if (Settings.isTeleportToSpawnEnabled) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawn = plugin.getSpawnLocation(target);
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
@ -587,7 +565,7 @@ public class AdminCommand implements CommandExecutor {
sender.sendMessage("Usage : /authme getip onlinePlayerName");
return true;
}
if (Bukkit.getOfflinePlayer(args[1]).isOnline()) {
if (Bukkit.getPlayer(args[1]) != null) {
Player player = Bukkit.getPlayer(args[1]);
sender.sendMessage(player.getName() + " actual ip is : " + player.getAddress().getAddress().getHostAddress() + ":" + player.getAddress().getPort());
sender.sendMessage(player.getName() + " real ip is : " + plugin.getIP(player));

View File

@ -69,7 +69,7 @@ public class LogoutCommand implements CommandExecutor {
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
if (Settings.isTeleportToSpawnEnabled) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawnLoc = plugin.getSpawnLocation(player);
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
plugin.getServer().getPluginManager().callEvent(tpEvent);

View File

@ -70,7 +70,7 @@ public class UnregisterCommand implements CommandExecutor {
return true;
}
if(Settings.isForcedRegistrationEnabled) {
if (Settings.isTeleportToSpawnEnabled) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawn = plugin.getSpawnLocation(player);
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
@ -113,7 +113,7 @@ public class UnregisterCommand implements CommandExecutor {
if(plugin.notifications != null) {
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
}
if (Settings.isTeleportToSpawnEnabled) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawn = plugin.getSpawnLocation(player);
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);

View File

@ -0,0 +1,6 @@
package fr.xephi.authme.converter;
public interface Converter {
void convert() throws Exception;
}

View File

@ -17,7 +17,7 @@ import fr.xephi.authme.settings.Settings;
*
* @author Xephi59
*/
public class FlatToSql {
public class FlatToSql implements Converter {
private static String tableName;
private static String columnName;
@ -49,7 +49,7 @@ public class FlatToSql {
columnID = Settings.getMySQLColumnId;
}
public boolean convert() throws IOException {
public void convert() throws IOException {
try {
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
source.createNewFile();
@ -93,12 +93,10 @@ public class FlatToSql {
sql.close();
br.close();
ConsoleLogger.info("The FlatFile has been converted to authme.sql file");
return true;
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
}
return false;
}
}

View File

@ -12,12 +12,20 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.Settings;
public class FlatToSqlite {
public class FlatToSqlite implements Converter {
public CommandSender sender;
public FlatToSqlite(CommandSender sender) {
this.sender = sender;
}
private static String tableName;
private static String columnName;
@ -34,7 +42,7 @@ public class FlatToSqlite {
private static String columnID;
private static Connection con;
public static String convert() throws IOException {
public void convert() throws Exception {
database = Settings.getMySQLDatabase;
tableName = Settings.getMySQLTablename;
columnName = Settings.getMySQLColumnName;
@ -49,14 +57,16 @@ public class FlatToSqlite {
columnID = Settings.getMySQLColumnId;
ConsoleLogger.info("Converting FlatFile to SQLite ...");
if (new File(AuthMe.getInstance().getDataFolder() + File.separator + database + ".db").exists()) {
return "The Database " + database + ".db can't be created cause the file already exist";
sender.sendMessage("The Database " + database + ".db can't be created cause the file already exist");
return;
}
try {
connect();
setup();
} catch (Exception e) {
ConsoleLogger.showError("Problem while trying to convert to sqlite !");
return "Problem while trying to convert to sqlite !";
sender.sendMessage("Problem while trying to convert to sqlite !");
return;
}
try {
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
@ -84,13 +94,15 @@ public class FlatToSqlite {
br.close();
ConsoleLogger.info("The FlatFile has been converted to " + database + ".db file");
close();
return ("The FlatFile has been converted to " + database + ".db file");
sender.sendMessage("The FlatFile has been converted to " + database + ".db file");
return;
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
}
return "Errors appears while trying to convert to SQLite";
sender.sendMessage("Errors appears while trying to convert to SQLite");
return;
}
private synchronized static void connect() throws ClassNotFoundException, SQLException {

View File

@ -1,50 +1,52 @@
package fr.xephi.authme.converter;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map.Entry;
import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings;
/**
*
* @author Xephi59
*/
public class RakamakConverter {
public class RakamakConverter implements Converter {
public AuthMe instance;
public DataSource database;
public CommandSender sender;
public RakamakConverter (AuthMe instance) {
public RakamakConverter (AuthMe instance, DataSource database, CommandSender sender) {
this.instance = instance;
this.database = database;
this.sender = sender;
}
public RakamakConverter getInstance() {
return this;
}
private static HashAlgorithm hash;
private static Boolean useIP;
private static String fileName;
private static String ipFileName;
private static File source;
private static File output;
private static File ipfiles;
private static boolean alreadyExist = false;
public static void RakamakConvert() throws IOException {
hash = Settings.rakamakHash;
public void convert() throws Exception {
HashAlgorithm hash = Settings.getPasswordHash;
useIP = Settings.rakamakUseIp;
fileName = Settings.rakamakUsers;
ipFileName = Settings.rakamakUsersIp;
@ -53,19 +55,12 @@ public class RakamakConverter {
try {
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
ipfiles = new File(AuthMe.getInstance().getDataFolder() + File.separator + ipFileName);
output = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
source.createNewFile();
ipfiles.createNewFile();
if (new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db").exists()) {
alreadyExist = true;
}
output.createNewFile();
BufferedReader users = null;
BufferedWriter outputDB = null;
BufferedReader ipFile = null;
ipFile = new BufferedReader(new FileReader(ipfiles));
String line;
String newLine = null;
if (useIP) {
String tempLine;
while ((tempLine = ipFile.readLine()) != null) {
@ -81,33 +76,28 @@ public class RakamakConverter {
if (line.contains("=")) {
String[] arguments = line.split("=");
try {
playerPSW.put(arguments[0],PasswordSecurity.getHash(hash, arguments[1], arguments[0].toLowerCase()));
playerPSW.put(arguments[0],PasswordSecurity.getHash(hash, arguments[1], arguments[0]));
} catch (NoSuchAlgorithmException e) {
ConsoleLogger.showError(e.getMessage());
}
}
}
users.close();
outputDB = new BufferedWriter(new FileWriter(output));
for (Entry<String, String> m : playerPSW.entrySet()) {
String player = m.getKey();
String psw = playerPSW.get(player);
String ip;
if (useIP) {
String player = m.getKey();
String psw = playerPSW.get(player);
String ip = playerIP.get(player);
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0:world:your@email.com";
ip = playerIP.get(player);
} else {
String player = m.getKey();
String psw = playerPSW.get(player);
String ip = "127.0.0.1";
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0:world:your@email.com";
ip = "127.0.0.1";
}
if (alreadyExist) outputDB.newLine();
outputDB.write(newLine);
System.out.println("Write line");
outputDB.newLine();
PlayerAuth auth = new PlayerAuth(player, psw, ip, System.currentTimeMillis());
if (PasswordSecurity.userSalt.containsKey(player))
auth.setSalt(PasswordSecurity.userSalt.get(player));
database.saveAuth(auth);
}
outputDB.close();
ConsoleLogger.info("Rakamak database has been converted to auths.db");
ConsoleLogger.info("Rakamak database has been imported correctly");
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
} catch (IOException ex) {

View File

@ -9,7 +9,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
public class RoyalAuthConverter extends Thread {
public class RoyalAuthConverter extends Thread implements Converter {
public AuthMe plugin;
private DataSource data;
@ -21,23 +21,27 @@ public class RoyalAuthConverter extends Thread {
}
public void run() {
for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) {
try {
String name = o.getName().toLowerCase();
String separator = File.separator;
File file = new File("." + separator + "plugins" + separator + "RoyalAuth" + separator + "userdata" + separator + name + ".yml");
if (data.isAuthAvailable(name))
continue;
if (!file.exists())
continue;
RoyalAuthYamlReader ra = new RoyalAuthYamlReader(file);
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com", o.getName());
data.saveAuth(auth);
} catch (Exception e) {
ConsoleLogger.showError("Error while trying to import "+ o.getName() + " RoyalAuth datas");
}
}
this.interrupt();
}
@Override
public void convert() throws Exception {
for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) {
try {
String name = o.getName().toLowerCase();
String separator = File.separator;
File file = new File("." + separator + "plugins" + separator + "RoyalAuth" + separator + "userdata" + separator + name + ".yml");
if (data.isAuthAvailable(name))
continue;
if (!file.exists())
continue;
RoyalAuthYamlReader ra = new RoyalAuthYamlReader(file);
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com", o.getName());
data.saveAuth(auth);
} catch (Exception e) {
ConsoleLogger.showError("Error while trying to import "+ o.getName() + " RoyalAuth datas");
}
}
this.interrupt();
}
}

View File

@ -0,0 +1,35 @@
package fr.xephi.authme.converter;
import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.datasource.DataSource;
public class xAuthConverter implements Converter {
public AuthMe plugin;
public DataSource database;
public CommandSender sender;
public xAuthConverter(AuthMe plugin, DataSource database, CommandSender sender) {
this.plugin = plugin;
this.database = database;
this.sender = sender;
}
@Override
public void convert() throws Exception {
try {
Class.forName("com.cypherx.xauth.xAuth");
oldxAuthToFlat converter = new oldxAuthToFlat(plugin, database, sender);
converter.run();
} catch (ClassNotFoundException e) {
try {
Class.forName("de.luricos.bukkit.xAuth.xAuth");
newxAuthToFlat converter = new newxAuthToFlat(plugin, database, sender);
converter.run();
} catch (ClassNotFoundException ce) {
}
}
}
}

View File

@ -235,7 +235,7 @@ public class MySQLDataSource implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
if ((columnSalt == null || columnSalt.isEmpty()) && (auth.getSalt() == null || auth.getSalt().isEmpty())) {
if ((columnSalt == null || columnSalt.isEmpty()) || (auth.getSalt() == null || auth.getSalt().isEmpty())) {
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());

View File

@ -580,7 +580,6 @@ public class AuthMePlayerListener implements Listener {
long cur = new Date().getTime();
if((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().equals("198.18.0.1") ) {
if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip) ) {
plugin.getServer().getPluginManager().callEvent(new SessionEvent(auth, true));
if(PlayerCache.getInstance().getAuth(name) != null) {
PlayerCache.getInstance().updatePlayer(auth);
} else {
@ -590,6 +589,7 @@ public class AuthMePlayerListener implements Listener {
m._(player, "valid_session");
// Restore Permission Group
utils.setGroup(player, Utils.groupType.LOGGEDIN);
plugin.getServer().getPluginManager().callEvent(new SessionEvent(auth, true));
return;
} else if (!Settings.sessionExpireOnIpChange){
GameMode gM = gameMode.get(name);
@ -627,15 +627,16 @@ public class AuthMePlayerListener implements Listener {
Utils.forceGM(player);
this.causeByAuthMe = false;
}
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
player.teleport(tpEvent.getTo());
}
if (!Settings.noTeleport)
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
player.teleport(tpEvent.getTo());
}
}
}
}
placePlayerSafely(player, spawnLoc);
LimboCache.getInstance().updateLimboPlayer(player);
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(),LimboCache.getInstance().getLimboPlayer(name).getArmour());
@ -649,15 +650,16 @@ public class AuthMePlayerListener implements Listener {
if(!Settings.unRegisteredGroup.isEmpty()){
utils.setGroup(player, Utils.groupType.UNREGISTERED);
}
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
player.teleport(tpEvent.getTo());
}
if (!Settings.noTeleport)
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
player.teleport(tpEvent.getTo());
}
}
}
}
if (!Settings.isForcedRegistrationEnabled) {
return;
}
@ -711,13 +713,14 @@ public class AuthMePlayerListener implements Listener {
player.performCommand("motd");
// Remove the join message while the player isn't logging in
if (Settings.enableProtection) {
if (Settings.enableProtection || Settings.delayJoinMessage) {
joinMessage.put(name, event.getJoinMessage());
event.setJoinMessage(null);
}
}
private void placePlayerSafely(Player player, Location spawnLoc) {
if (!Settings.noTeleport) return;
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
return;
Block b = player.getLocation().getBlock();
@ -843,6 +846,7 @@ public class AuthMePlayerListener implements Listener {
ConsoleLogger.showError("Problem while restore " + name + " inventory after a kick");
}
}
if (!Settings.noTeleport)
try {
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
plugin.getServer().getPluginManager().callEvent(tpEvent);

View File

@ -1,64 +1,39 @@
package fr.xephi.authme.plugin.manager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import com.trc202.CombatTag.CombatTag;
import com.trc202.CombatTagApi.CombatTagApi;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public abstract class CombatTagComunicator {
static CombatTagApi combatApi;
public static CombatTagApi combatApi;
public CombatTagComunicator() {
if(Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null){
combatApi = new CombatTagApi((CombatTag)Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));
}
/**
* Returns if the entity is an NPC
* @param player
* @return true if the player is an NPC
*/
public static boolean isNPC(Entity player) {
try {
if(Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null){
combatApi = new CombatTagApi((CombatTag) Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));
try {
combatApi.getClass().getMethod("isNPC");
} catch (Exception e) {
return false;
}
return combatApi.isNPC(player);
}
} catch (ClassCastException ex) {
return false;
} catch (NullPointerException npe) {
return false;
} catch (NoClassDefFoundError ncdfe) {
return false;
}
return false;
}
/**
* Checks to see if the player is in combat. The combat time can be configured by the server owner
* If the player has died while in combat the player is no longer considered in combat and as such will return false
* @param playerName
* @return true if player is in combat
*/
public abstract boolean isInCombat(String player);
/**
* Checks to see if the player is in combat. The combat time can be configured by the server owner
* If the player has died while in combat the player is no longer considered in combat and as such will return false
* @param player
* @return true if player is in combat
*/
public abstract boolean isInCombat(Player player);
/**
* Returns the time before the tag is over
* -1 if the tag has expired
* -2 if the player is not in combat
* @param player
* @return
*/
public abstract long getRemainingTagTime(String player);
/**
* Returns if the entity is an NPC
* @param player
* @return true if the player is an NPC
*/
public static boolean isNPC(Entity player) {
try {
if(Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null){
combatApi = new CombatTagApi((CombatTag) Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));
return combatApi.isNPC(player);
}
} catch (ClassCastException ex) {
return false;
} catch (NullPointerException npe) {
return false;
} catch (NoClassDefFoundError ncdfe) {
return false;
}
return false;
}
}

View File

@ -132,36 +132,24 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
player.setGameMode(GameMode.SURVIVAL);
}
// Teleport the player
if(Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
// If we have force the spawn location on join
teleportToSpawn();
} else {
if (Settings.isTeleportToSpawnEnabled) {
// If and only if teleport unauthed to spawn is activate
teleportBackFromSpawn();
} else {
if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
// Teleport the player on the saved location
packQuitLocation();
} else {
// Do not move the player from his position
}
}
}
// Teleport
if (Settings.isTeleportToSpawnEnabled && !Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
packQuitLocation();
if (!Settings.noTeleport) {
// Teleport the player
if(Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
// If we have force the spawn location on join
teleportToSpawn();
} else {
teleportBackFromSpawn();
if (Settings.isTeleportToSpawnEnabled) {
// If and only if teleport unauthed to spawn is activate
teleportBackFromSpawn();
} else {
if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
// Teleport the player on the saved location
packQuitLocation();
} else {
// Do not move the player from his position
}
}
}
} else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
teleportToSpawn();
} else if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
packQuitLocation();
} else {
teleportBackFromSpawn();
}
// Re-Force Survival GameMode if we need due to world change specification

View File

@ -46,7 +46,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
int nwMsg = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg);
if (Settings.isTeleportToSpawnEnabled) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location loca = plugin.getSpawnLocation(player);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent);

View File

@ -42,7 +42,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
}
protected void forceLogin(Player player) {
if (Settings.isTeleportToSpawnEnabled) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawnLoc = plugin.getSpawnLocation(player);
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
plugin.getServer().getPluginManager().callEvent(tpEvent);
@ -78,7 +78,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (limbo != null) {
player.setGameMode(limbo.getGameMode());
if (Settings.isTeleportToSpawnEnabled) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location loca = plugin.getSpawnLocation(player);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent);

View File

@ -21,11 +21,13 @@ public enum HashAlgorithm {
JOOMLA(fr.xephi.authme.security.crypts.JOOMLA.class),
BCRYPT(fr.xephi.authme.security.crypts.BCRYPT.class),
WBB3(fr.xephi.authme.security.crypts.WBB3.class),
WBB4(fr.xephi.authme.security.crypts.WBB4.class),
SHA512(fr.xephi.authme.security.crypts.SHA512.class),
DOUBLEMD5(fr.xephi.authme.security.crypts.DOUBLEMD5.class),
PBKDF2(fr.xephi.authme.security.crypts.CryptPBKDF2.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),
CUSTOM(Null.class);
Class<?> classe;

View File

@ -80,12 +80,16 @@ public class PasswordSecurity {
salt = createSalt(40);
userSalt.put(playerName, salt);
break;
case WBB4:
salt = BCRYPT.gensalt(8);
userSalt.put(playerName, salt);
break;
case PBKDF2:
salt = createSalt(12);
userSalt.put(playerName, salt);
break;
case SMF:
return method.getHash(password, playerName.toLowerCase());
return method.getHash(password, null, playerName);
case PHPBB:
salt = createSalt(16);
userSalt.put(playerName, salt);
@ -96,6 +100,8 @@ public class PasswordSecurity {
case PLAINTEXT:
case XENFORO:
case SHA512:
case ROYALAUTH:
case CRAZYCRYPT1:
case DOUBLEMD5:
case WORDPRESS:
case CUSTOM:
@ -108,7 +114,7 @@ public class PasswordSecurity {
method = event.getMethod();
if (method == null)
throw new NoSuchAlgorithmException("Unknown hash algorithm");
return method.getHash(password, salt);
return method.getHash(password, salt, playerName);
}
public static boolean comparePasswordWithHash(String password, String hash, String playerName) throws NoSuchAlgorithmException {

View File

@ -750,8 +750,35 @@ public class BCRYPT implements EncryptionMethod {
return (hashed.compareTo(hashpw(plaintext, hashed)) == 0);
}
/**
* Check that a text password matches a previously hashed
* one with the specified number of rounds using recursion
*
* @param text plaintext or hashed text
* @param hashed the previously-hashed password
* @param rounds number of rounds to hash the password
* @return
*/
public static boolean checkpw(String text, String hashed, int rounds) {
boolean matched = false;
if (rounds > 0) {
String hash = hashpw(text, hashed);
if (rounds > 1) {
matched = checkpw(hash, hashed, rounds - 1);
} else {
matched = hash.compareTo(hashed) == 0;
}
} else {
matched = text.compareTo(hashed) == 0;
}
return matched;
}
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return hashpw(password, salt);
}
@ -761,4 +788,9 @@ public class BCRYPT implements EncryptionMethod {
String playerName) throws NoSuchAlgorithmException {
return checkpw(password, hash);
}
public static String getDoubleHash(String text, String salt) {
String hash = hashpw(text, salt);
return hashpw(text, hash);
}
}

View File

@ -0,0 +1,44 @@
package fr.xephi.authme.security.crypts;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class CRAZYCRYPT1 implements EncryptionMethod {
protected final Charset charset = Charset.forName("UTF-8");
private static final char[] CRYPTCHARS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
@Override
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
final String text = "ÜÄaeut//&/=I " + password + "7421€547" + name + "__+IÄIH§%NK " + password;
try
{
final MessageDigest md = MessageDigest.getInstance("SHA-512");
md.update(text.getBytes(charset), 0, text.length());
return byteArrayToHexString(md.digest());
}
catch (final NoSuchAlgorithmException e)
{
return null;
}
}
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
return hash.equals(getHash(password, null, playerName));
}
public static String byteArrayToHexString(final byte... args)
{
final char[] chars = new char[args.length * 2];
for (int i = 0; i < args.length; i++) {
chars[i * 2] = CRYPTCHARS[(args[i] >> 4) & 0xF];
chars[i * 2 + 1] = CRYPTCHARS[(args[i]) & 0xF];
}
return new String(chars);
}
}

View File

@ -9,7 +9,7 @@ import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters;
public class CryptPBKDF2 implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
String result = "pbkdf2_sha256$10000$"+salt+"$";
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);

View File

@ -7,7 +7,7 @@ import java.security.NoSuchAlgorithmException;
public class DOUBLEMD5 implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return getMD5(getMD5(password));
}
@ -15,7 +15,7 @@ public class DOUBLEMD5 implements EncryptionMethod {
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
return hash.equals(getHash(password, ""));
return hash.equals(getHash(password, "", ""));
}
private static String getMD5(String message) throws NoSuchAlgorithmException {

View File

@ -16,7 +16,7 @@ public interface EncryptionMethod {
* @return Hashing password
* @throws NoSuchAlgorithmException
*/
String getHash(String password, String salt) throws NoSuchAlgorithmException;
String getHash(String password, String salt, String name) throws NoSuchAlgorithmException;
/**
* @param hash

View File

@ -10,7 +10,7 @@ import fr.xephi.authme.AuthMe;
public class IPB3 implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return getMD5(getMD5(salt) + getMD5(password));
}
@ -19,7 +19,7 @@ public class IPB3 implements EncryptionMethod {
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
return hash.equals(getHash(password, salt));
return hash.equals(getHash(password, salt, playerName));
}
private static String getMD5(String message) throws NoSuchAlgorithmException {

View File

@ -7,7 +7,7 @@ import java.security.NoSuchAlgorithmException;
public class JOOMLA implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return getMD5(password + salt) + ":" + salt;
}

View File

@ -7,13 +7,13 @@ import java.security.NoSuchAlgorithmException;
public class MD5 implements EncryptionMethod {
@Override
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException {
return getMD5(password);
}
@Override
public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException {
return hash.equals(getHash(password, ""));
return hash.equals(getHash(password, "", ""));
}
private static String getMD5(String message) throws NoSuchAlgorithmException {

View File

@ -7,7 +7,7 @@ import java.security.NoSuchAlgorithmException;
public class MD5VB implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return "$MD5vb$" + salt + "$" + getMD5(getMD5(password) + salt);
}
@ -16,7 +16,7 @@ public class MD5VB implements EncryptionMethod {
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
String[] line = hash.split("\\$");
return hash.equals(getHash(password, line[2]));
return hash.equals(getHash(password, line[2], ""));
}
private static String getMD5(String message) throws NoSuchAlgorithmException {

View File

@ -10,7 +10,7 @@ import fr.xephi.authme.AuthMe;
public class MYBB implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return getMD5(getMD5(salt)+ getMD5(password));
}
@ -19,7 +19,7 @@ public class MYBB implements EncryptionMethod {
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
return hash.equals(getHash(password, salt));
return hash.equals(getHash(password, salt, playerName));
}
private static String getMD5(String message) throws NoSuchAlgorithmException {

View File

@ -151,7 +151,7 @@ private String _hash_gensalt_private(
}
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return phpbb_hash(password, salt);
}

View File

@ -15,7 +15,7 @@ import fr.xephi.authme.AuthMe;
public class PHPFUSION implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
String digest = null;
String algo = "HmacSHA256";
@ -45,7 +45,7 @@ public class PHPFUSION implements EncryptionMethod {
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
return hash.equals(getHash(password, salt));
return hash.equals(getHash(password, salt, ""));
}
private static String getSHA1(String message) throws NoSuchAlgorithmException {

View File

@ -5,7 +5,7 @@ import java.security.NoSuchAlgorithmException;
public class PLAINTEXT implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return password;
}

View File

@ -6,20 +6,26 @@ import java.security.NoSuchAlgorithmException;
public class ROYALAUTH implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-512");
md.update(password.getBytes());
byte byteData[] = md.digest();
StringBuilder sb = new StringBuilder();
for (byte aByteData : byteData) sb.append(Integer.toString((aByteData & 0xff) + 0x100, 16).substring(1));
return sb.toString();
public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException {
String data = "";
for (int i = 0; i < 25; i++)
data = hash(data, salt);
return data;
}
public String hash(String password, String salt) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-512");
md.update(password.getBytes());
byte byteData[] = md.digest();
StringBuilder sb = new StringBuilder();
for (byte aByteData : byteData)
sb.append(Integer.toString((aByteData & 0xff) + 0x100, 16).substring(1));
return sb.toString();
}
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
return hash.equalsIgnoreCase(getHash(password, ""));
public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException {
return hash.equalsIgnoreCase(getHash(password, "", ""));
}
}

View File

@ -10,7 +10,7 @@ import fr.xephi.authme.AuthMe;
public class SALTED2MD5 implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return getMD5(getMD5(password) + salt);
}

View File

@ -7,14 +7,14 @@ import java.security.NoSuchAlgorithmException;
public class SHA1 implements EncryptionMethod {
@Override
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException {
return getSHA1(password);
}
@Override
public boolean comparePassword(String hash, String password, String playerName)
throws NoSuchAlgorithmException {
return hash.equals(getHash(password, ""));
return hash.equals(getHash(password, "", ""));
}
private static String getSHA1(String message) throws NoSuchAlgorithmException {

View File

@ -7,7 +7,7 @@ import java.security.NoSuchAlgorithmException;
public class SHA256 implements EncryptionMethod {
@Override
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException {
return "$SHA$" + salt + "$" + getSHA256(getSHA256(password) + salt);
}
@ -15,7 +15,7 @@ public class SHA256 implements EncryptionMethod {
public boolean comparePassword(String hash, String password, String playerName)
throws NoSuchAlgorithmException {
String[] line = hash.split("\\$");
return hash.equals(getHash(password, line[2]));
return hash.equals(getHash(password, line[2], ""));
}
private static String getSHA256(String message) throws NoSuchAlgorithmException {

View File

@ -7,7 +7,7 @@ import java.security.NoSuchAlgorithmException;
public class SHA512 implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return getSHA512(password);
}
@ -15,7 +15,7 @@ public class SHA512 implements EncryptionMethod {
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
return hash.equals(getHash(password, ""));
return hash.equals(getHash(password, "", ""));
}
private static String getSHA512(String message) throws NoSuchAlgorithmException {

View File

@ -7,15 +7,15 @@ import java.security.NoSuchAlgorithmException;
public class SMF implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return getSHA1(salt.toLowerCase() + password);
return getSHA1(name.toLowerCase() + password);
}
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
return hash.equals(getHash(password, playerName.toLowerCase()));
return hash.equals(getHash(password, null, playerName));
}
private static String getSHA1(String message) throws NoSuchAlgorithmException {

View File

@ -10,7 +10,7 @@ import fr.xephi.authme.AuthMe;
public class WBB3 implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return getSHA1(salt.concat(getSHA1(salt.concat(getSHA1(password)))));
}
@ -19,7 +19,7 @@ public class WBB3 implements EncryptionMethod {
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
return hash.equals(getHash(password, salt));
return hash.equals(getHash(password, salt, ""));
}
private static String getSHA1(String message) throws NoSuchAlgorithmException {

View File

@ -0,0 +1,19 @@
package fr.xephi.authme.security.crypts;
import java.security.NoSuchAlgorithmException;
public class WBB4 implements EncryptionMethod {
@Override
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return BCRYPT.getDoubleHash(password, salt);
}
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
return BCRYPT.checkpw(password, hash, 2);
}
}

View File

@ -408,7 +408,7 @@ public class WHIRLPOOL implements EncryptionMethod {
}
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
byte[] digest = new byte[DIGESTBYTES];
NESSIEinit();
@ -420,6 +420,6 @@ public class WHIRLPOOL implements EncryptionMethod {
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
return hash.equals(getHash(password, ""));
return hash.equals(getHash(password, "", ""));
}
}

View File

@ -99,7 +99,7 @@ public class WORDPRESS implements EncryptionMethod {
}
@Override
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException {
byte random[] = new byte[6];
this.randomGen.nextBytes(random);
return crypt(password, gensaltPrivate(stringToUtf8(new String(random))));

View File

@ -5,7 +5,7 @@ import java.security.NoSuchAlgorithmException;
public class XAUTH implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
String hash = getWhirlpool(salt + password).toLowerCase();
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
@ -17,7 +17,7 @@ public class XAUTH implements EncryptionMethod {
String playerName) throws NoSuchAlgorithmException {
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
String salt = hash.substring(saltPos, saltPos + 12);
return hash.equals(getHash(password, salt));
return hash.equals(getHash(password, salt, ""));
}
public static String getWhirlpool(String message) {

View File

@ -13,7 +13,7 @@ import fr.xephi.authme.AuthMe;
public class XF implements EncryptionMethod {
@Override
public String getHash(String password, String salt)
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
return getSHA256(getSHA256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
}

View File

@ -43,7 +43,6 @@ public final class Settings extends YamlConfiguration {
private final File file;
public static DataSourceType getDataSource;
public static HashAlgorithm getPasswordHash;
public static HashAlgorithm rakamakHash;
public static Boolean useLogging = false;
public static int purgeDelay = 60;
public static List<String> welcomeMsg = null;
@ -60,7 +59,8 @@ public final class Settings extends YamlConfiguration {
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames;
broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames, delayJoinMessage,
noTeleport;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
@ -178,7 +178,6 @@ public void loadConfigOptions() {
rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
rakamakHash = getRakamakHash();
noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
removePassword = configFile.getBoolean("Security.console.removePassword", true);
getmailAccount = configFile.getString("Email.mailAccount", "");
@ -244,6 +243,8 @@ public void loadConfigOptions() {
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
delayJoinMessage = configFile.getBoolean("settings.delayJoinMessage", false);
noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
// Load the welcome message
getWelcomeMessage(plugin);
@ -337,7 +338,6 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
rakamakHash = getRakamakHash();
noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
removePassword = configFile.getBoolean("Security.console.removePassword", true);
getmailAccount = configFile.getString("Email.mailAccount", "");
@ -403,6 +403,8 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
delayJoinMessage = configFile.getBoolean("settings.delayJoinMessage", false);
noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
// Reload the welcome message
getWelcomeMessage(AuthMe.getInstance());
@ -505,10 +507,20 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
}
if(getString("settings.restrictions.allowedNicknameCharacters").equals("[a-zA-Z0-9_?]*"))
set("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_]*");
if(!contains("settings.delayJoinMessage")) {
set("settings.delayJoinMessage", false);
changes = true;
}
if(!contains("settings.restrictions.noTeleport")) {
set("settings.restrictions.noTeleport", false);
changes = true;
}
if(contains("Converter.Rakamak.newPasswordHash"))
set("Converter.Rakamak.newPasswordHash", null);
if (changes) {
plugin.getLogger().warning("Merge new Config Options if needed..");
plugin.getLogger().warning("Please check your config.yml file!");
plugin.getLogger().warning("Merge 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!");
}
plugin.saveConfig();
@ -525,17 +537,6 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
}
}
private static HashAlgorithm getRakamakHash() {
String key = "Converter.Rakamak.newPasswordHash";
try {
return HashAlgorithm.valueOf(configFile.getString(key,"SHA256").toUpperCase());
} catch (IllegalArgumentException ex) {
ConsoleLogger.showError("Unknown Hash Algorithm; defaulting to SHA256");
return HashAlgorithm.SHA256;
}
}
private static DataSourceType getDataSource() {
String key = "DataSource.backend";
try {

View File

@ -264,7 +264,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
if ((columnSalt == null || columnSalt.isEmpty()) && (auth.getSalt() == null || auth.getSalt().isEmpty())) {
if ((columnSalt == null || columnSalt.isEmpty()) || (auth.getSalt() == null || auth.getSalt().isEmpty())) {
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());

View File

@ -162,6 +162,8 @@ settings:
maxLoginPerIp: 0
# Maximum Join authorized by IP
maxJoinPerIp: 0
# AuthMe will NEVER teleport players !
noTeleport: false
GameMode:
# ForceSurvivalMode to player when join ?
ForceSurvivalMode: false
@ -254,6 +256,8 @@ settings:
useWelcomeMessage: true
# Do we need to broadcast the welcome message to all server or only to the player? set true for server or false for player
broadcastWelcomeMessage: false
# Do we need to delay the X has joined the game after /login ?
delayJoinMessage: false
ExternalBoardOptions:
# MySQL column for the salt , needed for some forum/cms support
mySQLColumnSalt: ''
@ -325,11 +329,6 @@ Converter:
useIP: false
# IP file name for rakamak
ipFileName: UsersIp.rak
# 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, CUSTOM(for developpers only)
newPasswordHash: SHA256
Email:
# Email SMTP server host
mailSMTP: smtp.gmail.com

View File

@ -3,7 +3,7 @@ author: Xephi59
website: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
main: fr.xephi.authme.AuthMe
version: 3.3.6
version: 3.4
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn]
commands:
register: