AuthMe 3.4
This commit is contained in:
parent
ff9ec22041
commit
2638007ada
Binary file not shown.
11
pom.xml
11
pom.xml
@ -24,12 +24,12 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<version>3.3.6</version>
|
<version>3.4</version>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>1.7.5-R0.1-SNAPSHOT</version>
|
<version>1.7.9-R0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
@ -128,13 +128,6 @@
|
|||||||
<version>Pre2.9.4.1</version>
|
<version>Pre2.9.4.1</version>
|
||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${project.basedir}/lib/Essentials.jar</systemPath>
|
<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>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@ -537,7 +537,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
player.getInventory().setArmorContents(limbo.getArmour());
|
player.getInventory().setArmorContents(limbo.getArmour());
|
||||||
player.getInventory().setContents(limbo.getInventory());
|
player.getInventory().setContents(limbo.getInventory());
|
||||||
}
|
}
|
||||||
player.teleport(limbo.getLoc());
|
if (!Settings.noTeleport)
|
||||||
|
player.teleport(limbo.getLoc());
|
||||||
this.utils.addNormal(player, limbo.getGroup());
|
this.utils.addNormal(player, limbo.getGroup());
|
||||||
player.setOp(limbo.getOperator());
|
player.setOp(limbo.getOperator());
|
||||||
this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class API {
|
|||||||
*/
|
*/
|
||||||
public static AuthMe hookAuthMe() {
|
public static AuthMe hookAuthMe() {
|
||||||
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
|
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
|
||||||
if (plugin == null && !(plugin instanceof AuthMe)) {
|
if (plugin == null || !(plugin instanceof AuthMe)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (AuthMe) plugin;
|
return (AuthMe) plugin;
|
||||||
|
|||||||
@ -26,6 +26,7 @@ public class PlayerAuth {
|
|||||||
this.lastLogin = lastLogin;
|
this.lastLogin = lastLogin;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
this.realName = realName;
|
this.realName = realName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerAuth(String nickname, double x, double y, double z, String world) {
|
public PlayerAuth(String nickname, double x, double y, double z, String world) {
|
||||||
@ -34,6 +35,8 @@ public class PlayerAuth {
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
this.world = world;
|
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) {
|
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.world = world;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
this.realName = realName;
|
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) {
|
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.groupId = groupId;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
this.realName = realName;
|
this.realName = realName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerAuth(String nickname, String hash, String salt, int groupId , String ip, long lastLogin, String 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.salt = salt;
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
this.realName = realName;
|
this.realName = realName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, String 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.lastLogin = lastLogin;
|
||||||
this.salt = salt;
|
this.salt = salt;
|
||||||
this.realName = realName;
|
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) {
|
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.nickname = nickname;
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.lastLogin = lastLogin;
|
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() {
|
public String getIp() {
|
||||||
@ -218,5 +233,4 @@ public class PlayerAuth {
|
|||||||
public String getRealname() {
|
public String getRealname() {
|
||||||
return realName;
|
return realName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,11 +10,14 @@ import java.util.Scanner;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.api.API;
|
import fr.xephi.authme.api.API;
|
||||||
|
|
||||||
public class FileCache {
|
public class FileCache {
|
||||||
|
|
||||||
|
private AuthMe plugin = AuthMe.getInstance();
|
||||||
public FileCache() {
|
public FileCache() {
|
||||||
final File folder = new File("cache");
|
final File folder = new File("cache");
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
@ -127,25 +130,25 @@ public class FileCache {
|
|||||||
final File file = new File("cache/" + playername
|
final File file = new File("cache/" + playername
|
||||||
+ ".cache");
|
+ ".cache");
|
||||||
|
|
||||||
ItemStack[] stacki = new ItemStack[36];
|
ItemStack[] stacki = new ItemStack[36];
|
||||||
ItemStack[] stacka = new ItemStack[4];
|
ItemStack[] stacka = new ItemStack[4];
|
||||||
String group = null;
|
String group = null;
|
||||||
boolean op = false;
|
boolean op = false;
|
||||||
boolean flying = false;
|
boolean flying = false;
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return new DataFileCache(stacki, stacka);
|
return new DataFileCache(stacki, stacka);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scanner reader = null;
|
Scanner reader = null;
|
||||||
try {
|
try {
|
||||||
reader = new Scanner(file);
|
reader = new Scanner(file);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int a = 0;
|
int a = 0;
|
||||||
while (reader.hasNextLine()) {
|
while (reader.hasNextLine()) {
|
||||||
String line = reader.nextLine();
|
String line = reader.nextLine();
|
||||||
|
|
||||||
if (!line.contains(":")) {
|
if (!line.contains(":")) {
|
||||||
// the fist line represent the player group, operator status and flying status
|
// the fist line represent the player group, operator status and flying status
|
||||||
final String[] playerInfo = line.split(";");
|
final String[] playerInfo = line.split(";");
|
||||||
group = playerInfo[0];
|
group = playerInfo[0];
|
||||||
@ -154,77 +157,88 @@ public class FileCache {
|
|||||||
op = true;
|
op = true;
|
||||||
} else op = false;
|
} else op = false;
|
||||||
if (playerInfo.length > 2) {
|
if (playerInfo.length > 2) {
|
||||||
if (Integer.parseInt(playerInfo[2]) == 1)
|
if (Integer.parseInt(playerInfo[2]) == 1)
|
||||||
flying = true;
|
flying = true;
|
||||||
else flying = false;
|
else flying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!line.startsWith("i") && !line.startsWith("w")) {
|
if (!line.startsWith("i") && !line.startsWith("w")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String lores = "";
|
String lores = "";
|
||||||
String name = "";
|
String name = "";
|
||||||
if (line.split("\\*").length > 1) {
|
if (line.split("\\*").length > 1) {
|
||||||
lores = line.split("\\*")[1];
|
lores = line.split("\\*")[1];
|
||||||
line = line.split("\\*")[0];
|
line = line.split("\\*")[0];
|
||||||
}
|
}
|
||||||
if (line.split(";").length > 1) {
|
if (line.split(";").length > 1) {
|
||||||
name = line.split(";")[1];
|
name = line.split(";")[1];
|
||||||
line = line.split(";")[0];
|
line = line.split(";")[0];
|
||||||
}
|
}
|
||||||
final String[] in = line.split(":");
|
final String[] in = line.split(":");
|
||||||
// can enchant item? size ofstring in file - 4 all / 2 = number of enchant
|
// can enchant item? size ofstring in file - 4 all / 2 = number of enchant
|
||||||
if (in[0].equals("i")) {
|
if (in[0].equals("i")) {
|
||||||
stacki[i] = new ItemStack(Material.getMaterial(in[1]),
|
stacki[i] = new ItemStack(Material.getMaterial(in[1]),
|
||||||
Integer.parseInt(in[2]), Short.parseShort((in[3])));
|
Integer.parseInt(in[2]), Short.parseShort((in[3])));
|
||||||
if(in.length > 4 && !in[4].isEmpty()) {
|
if(in.length > 4 && !in[4].isEmpty()) {
|
||||||
for(int k=4;k<in.length-1;k++) {
|
for(int k=4;k<in.length-1;k++) {
|
||||||
stacki[i].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
|
stacki[i].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!name.isEmpty())
|
try {
|
||||||
stacki[i].getItemMeta().setDisplayName(name);
|
ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(stacki[i].getType());
|
||||||
if (!lores.isEmpty()) {
|
if (!name.isEmpty()) {
|
||||||
List<String> loreList = new ArrayList<String>();
|
meta.setDisplayName(name);
|
||||||
for (String s : lores.split("%newline%")) {
|
}
|
||||||
loreList.add(s);
|
if (!lores.isEmpty()) {
|
||||||
}
|
List<String> loreList = new ArrayList<String>();
|
||||||
stacki[i].getItemMeta().setLore(loreList);
|
for (String s : lores.split("%newline%")) {
|
||||||
}
|
loreList.add(s);
|
||||||
i++;
|
}
|
||||||
} else {
|
meta.setLore(loreList);
|
||||||
stacka[a] = new ItemStack(Material.getMaterial(in[1]),
|
}
|
||||||
Integer.parseInt(in[2]), Short.parseShort((in[3])));
|
if (meta != null)
|
||||||
if(in.length > 4 && !in[4].isEmpty()) {
|
stacki[i].setItemMeta(meta);
|
||||||
for(int k=4;k<in.length-1;k++) {
|
} catch (Exception e) {}
|
||||||
stacka[a].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
|
i++;
|
||||||
k++;
|
} else {
|
||||||
}
|
stacka[a] = new ItemStack(Material.getMaterial(in[1]),
|
||||||
}
|
Integer.parseInt(in[2]), Short.parseShort((in[3])));
|
||||||
if (!name.isEmpty())
|
if(in.length > 4 && !in[4].isEmpty()) {
|
||||||
stacka[a].getItemMeta().setDisplayName(name);
|
for(int k=4;k<in.length-1;k++) {
|
||||||
if (!lores.isEmpty()) {
|
stacka[a].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
|
||||||
List<String> loreList = new ArrayList<String>();
|
k++;
|
||||||
for (String s : lores.split("%newline%")) {
|
}
|
||||||
loreList.add(s);
|
}
|
||||||
}
|
try {
|
||||||
stacka[a].getItemMeta().setLore(loreList);
|
ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(stacka[a].getType());
|
||||||
}
|
if (!name.isEmpty())
|
||||||
a++;
|
meta.setDisplayName(name);
|
||||||
}
|
if (!lores.isEmpty()) {
|
||||||
}
|
List<String> loreList = new ArrayList<String>();
|
||||||
} catch (final Exception e) {
|
for (String s : lores.split("%newline%")) {
|
||||||
e.printStackTrace();
|
loreList.add(s);
|
||||||
} finally {
|
}
|
||||||
if (reader != null) {
|
meta.setLore(loreList);
|
||||||
reader.close();
|
}
|
||||||
}
|
if (meta != null)
|
||||||
}
|
stacki[i].setItemMeta(meta);
|
||||||
return new DataFileCache(stacki, stacka, group, op, flying);
|
} 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) {
|
public void removeCache(String playername) {
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package fr.xephi.authme.commands;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.ArrayList;
|
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.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
|
import fr.xephi.authme.converter.Converter;
|
||||||
import fr.xephi.authme.converter.FlatToSql;
|
import fr.xephi.authme.converter.FlatToSql;
|
||||||
import fr.xephi.authme.converter.FlatToSqlite;
|
import fr.xephi.authme.converter.FlatToSqlite;
|
||||||
import fr.xephi.authme.converter.RakamakConverter;
|
import fr.xephi.authme.converter.RakamakConverter;
|
||||||
import fr.xephi.authme.converter.RoyalAuthConverter;
|
import fr.xephi.authme.converter.RoyalAuthConverter;
|
||||||
import fr.xephi.authme.converter.newxAuthToFlat;
|
import fr.xephi.authme.converter.xAuthConverter;
|
||||||
import fr.xephi.authme.converter.oldxAuthToFlat;
|
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
@ -301,44 +300,26 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("convertflattosql")) {
|
} else if (args[0].equalsIgnoreCase("convertflattosql")) {
|
||||||
try {
|
FlatToSql converter = new FlatToSql();
|
||||||
FlatToSql converter = new FlatToSql();
|
try {
|
||||||
if (sender instanceof Player) {
|
converter.convert();
|
||||||
if (converter.convert())
|
} catch (Exception e) {
|
||||||
sender.sendMessage("[AuthMe] FlatFile converted to authme.sql file");
|
sender.sendMessage("[AuthMe] Error while converting to authme.sql");
|
||||||
else sender.sendMessage("[AuthMe] Error while converting to authme.sql");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
System.out.println(ex.getMessage());
|
|
||||||
}
|
|
||||||
} else if (args[0].equalsIgnoreCase("flattosqlite")) {
|
} else if (args[0].equalsIgnoreCase("flattosqlite")) {
|
||||||
try {
|
FlatToSqlite converter = new FlatToSqlite(sender);
|
||||||
String s = FlatToSqlite.convert();
|
try {
|
||||||
if (sender instanceof Player)
|
converter.convert();
|
||||||
sender.sendMessage(s);
|
} catch (Exception e) {
|
||||||
} catch (IOException e) {
|
}
|
||||||
e.printStackTrace();
|
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
System.out.println(ex.getMessage());
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("xauthimport")) {
|
} else if (args[0].equalsIgnoreCase("xauthimport")) {
|
||||||
try {
|
Converter converter = new xAuthConverter(plugin, database, sender);
|
||||||
Class.forName("com.cypherx.xauth.xAuth");
|
try {
|
||||||
oldxAuthToFlat converter = new oldxAuthToFlat(plugin, database, sender);
|
converter.convert();
|
||||||
converter.run();
|
} catch (Exception e) {
|
||||||
} catch (ClassNotFoundException e) {
|
sender.sendMessage("Error while importing xAuth data, check your logs");
|
||||||
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! ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("getemail")) {
|
} else if (args[0].equalsIgnoreCase("getemail")) {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
@ -373,15 +354,12 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
PlayerCache.getInstance().updatePlayer(getAuth);
|
PlayerCache.getInstance().updatePlayer(getAuth);
|
||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("convertfromrakamak")) {
|
} else if (args[0].equalsIgnoreCase("convertfromrakamak")) {
|
||||||
try {
|
Converter converter = new RakamakConverter(plugin, database, sender);
|
||||||
RakamakConverter.RakamakConvert();
|
try {
|
||||||
if (sender instanceof Player)
|
converter.convert();
|
||||||
sender.sendMessage("[AuthMe] Rakamak database converted to auths.db");
|
} catch (Exception e) {
|
||||||
} catch (IOException e) {
|
sender.sendMessage("Error while importing Rakamak data, check your logs");
|
||||||
e.printStackTrace();
|
}
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("setspawn")) {
|
} else if (args[0].equalsIgnoreCase("setspawn")) {
|
||||||
try {
|
try {
|
||||||
@ -509,7 +487,7 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
Utils.getInstance().setGroup(name, groupType.UNREGISTERED);
|
Utils.getInstance().setGroup(name, groupType.UNREGISTERED);
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
if (target.isOnline()) {
|
if (target.isOnline()) {
|
||||||
if (Settings.isTeleportToSpawnEnabled) {
|
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||||
Location spawn = plugin.getSpawnLocation(target);
|
Location spawn = plugin.getSpawnLocation(target);
|
||||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false);
|
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false);
|
||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
@ -587,7 +565,7 @@ public class AdminCommand implements CommandExecutor {
|
|||||||
sender.sendMessage("Usage : /authme getip onlinePlayerName");
|
sender.sendMessage("Usage : /authme getip onlinePlayerName");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Bukkit.getOfflinePlayer(args[1]).isOnline()) {
|
if (Bukkit.getPlayer(args[1]) != null) {
|
||||||
Player player = Bukkit.getPlayer(args[1]);
|
Player player = Bukkit.getPlayer(args[1]);
|
||||||
sender.sendMessage(player.getName() + " actual ip is : " + player.getAddress().getAddress().getHostAddress() + ":" + player.getAddress().getPort());
|
sender.sendMessage(player.getName() + " actual ip is : " + player.getAddress().getAddress().getHostAddress() + ":" + player.getAddress().getPort());
|
||||||
sender.sendMessage(player.getName() + " real ip is : " + plugin.getIP(player));
|
sender.sendMessage(player.getName() + " real ip is : " + plugin.getIP(player));
|
||||||
|
|||||||
@ -69,7 +69,7 @@ public class LogoutCommand implements CommandExecutor {
|
|||||||
PlayerCache.getInstance().removePlayer(name);
|
PlayerCache.getInstance().removePlayer(name);
|
||||||
database.setUnlogged(name);
|
database.setUnlogged(name);
|
||||||
|
|
||||||
if (Settings.isTeleportToSpawnEnabled) {
|
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||||
Location spawnLoc = plugin.getSpawnLocation(player);
|
Location spawnLoc = plugin.getSpawnLocation(player);
|
||||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
|
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
|
||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
|
|||||||
@ -70,7 +70,7 @@ public class UnregisterCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(Settings.isForcedRegistrationEnabled) {
|
if(Settings.isForcedRegistrationEnabled) {
|
||||||
if (Settings.isTeleportToSpawnEnabled) {
|
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||||
Location spawn = plugin.getSpawnLocation(player);
|
Location spawn = plugin.getSpawnLocation(player);
|
||||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
|
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
|
||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
@ -113,7 +113,7 @@ public class UnregisterCommand implements CommandExecutor {
|
|||||||
if(plugin.notifications != null) {
|
if(plugin.notifications != null) {
|
||||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
|
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
|
||||||
}
|
}
|
||||||
if (Settings.isTeleportToSpawnEnabled) {
|
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||||
Location spawn = plugin.getSpawnLocation(player);
|
Location spawn = plugin.getSpawnLocation(player);
|
||||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
|
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
|
||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
|
|||||||
6
src/main/java/fr/xephi/authme/converter/Converter.java
Normal file
6
src/main/java/fr/xephi/authme/converter/Converter.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
|
public interface Converter {
|
||||||
|
|
||||||
|
void convert() throws Exception;
|
||||||
|
}
|
||||||
@ -17,7 +17,7 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
*
|
*
|
||||||
* @author Xephi59
|
* @author Xephi59
|
||||||
*/
|
*/
|
||||||
public class FlatToSql {
|
public class FlatToSql implements Converter {
|
||||||
|
|
||||||
private static String tableName;
|
private static String tableName;
|
||||||
private static String columnName;
|
private static String columnName;
|
||||||
@ -49,7 +49,7 @@ public class FlatToSql {
|
|||||||
columnID = Settings.getMySQLColumnId;
|
columnID = Settings.getMySQLColumnId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean convert() throws IOException {
|
public void convert() throws IOException {
|
||||||
try {
|
try {
|
||||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
||||||
source.createNewFile();
|
source.createNewFile();
|
||||||
@ -93,12 +93,10 @@ public class FlatToSql {
|
|||||||
sql.close();
|
sql.close();
|
||||||
br.close();
|
br.close();
|
||||||
ConsoleLogger.info("The FlatFile has been converted to authme.sql file");
|
ConsoleLogger.info("The FlatFile has been converted to authme.sql file");
|
||||||
return true;
|
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,12 +12,20 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.settings.Settings;
|
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 tableName;
|
||||||
private static String columnName;
|
private static String columnName;
|
||||||
@ -34,7 +42,7 @@ public class FlatToSqlite {
|
|||||||
private static String columnID;
|
private static String columnID;
|
||||||
private static Connection con;
|
private static Connection con;
|
||||||
|
|
||||||
public static String convert() throws IOException {
|
public void convert() throws Exception {
|
||||||
database = Settings.getMySQLDatabase;
|
database = Settings.getMySQLDatabase;
|
||||||
tableName = Settings.getMySQLTablename;
|
tableName = Settings.getMySQLTablename;
|
||||||
columnName = Settings.getMySQLColumnName;
|
columnName = Settings.getMySQLColumnName;
|
||||||
@ -49,14 +57,16 @@ public class FlatToSqlite {
|
|||||||
columnID = Settings.getMySQLColumnId;
|
columnID = Settings.getMySQLColumnId;
|
||||||
ConsoleLogger.info("Converting FlatFile to SQLite ...");
|
ConsoleLogger.info("Converting FlatFile to SQLite ...");
|
||||||
if (new File(AuthMe.getInstance().getDataFolder() + File.separator + database + ".db").exists()) {
|
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 {
|
try {
|
||||||
connect();
|
connect();
|
||||||
setup();
|
setup();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.showError("Problem while trying to convert to sqlite !");
|
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 {
|
try {
|
||||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
||||||
@ -84,13 +94,15 @@ public class FlatToSqlite {
|
|||||||
br.close();
|
br.close();
|
||||||
ConsoleLogger.info("The FlatFile has been converted to " + database + ".db file");
|
ConsoleLogger.info("The FlatFile has been converted to " + database + ".db file");
|
||||||
close();
|
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) {
|
} catch (FileNotFoundException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
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 {
|
private synchronized static void connect() throws ClassNotFoundException, SQLException {
|
||||||
|
|||||||
@ -1,50 +1,52 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.converter;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.HashAlgorithm;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Xephi59
|
* @author Xephi59
|
||||||
*/
|
*/
|
||||||
public class RakamakConverter {
|
public class RakamakConverter implements Converter {
|
||||||
|
|
||||||
public AuthMe instance;
|
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.instance = instance;
|
||||||
|
this.database = database;
|
||||||
|
this.sender = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RakamakConverter getInstance() {
|
public RakamakConverter getInstance() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashAlgorithm hash;
|
|
||||||
private static Boolean useIP;
|
private static Boolean useIP;
|
||||||
private static String fileName;
|
private static String fileName;
|
||||||
private static String ipFileName;
|
private static String ipFileName;
|
||||||
private static File source;
|
private static File source;
|
||||||
private static File output;
|
|
||||||
private static File ipfiles;
|
private static File ipfiles;
|
||||||
private static boolean alreadyExist = false;
|
|
||||||
|
|
||||||
public static void RakamakConvert() throws IOException {
|
public void convert() throws Exception {
|
||||||
hash = Settings.rakamakHash;
|
HashAlgorithm hash = Settings.getPasswordHash;
|
||||||
useIP = Settings.rakamakUseIp;
|
useIP = Settings.rakamakUseIp;
|
||||||
fileName = Settings.rakamakUsers;
|
fileName = Settings.rakamakUsers;
|
||||||
ipFileName = Settings.rakamakUsersIp;
|
ipFileName = Settings.rakamakUsersIp;
|
||||||
@ -53,19 +55,12 @@ public class RakamakConverter {
|
|||||||
try {
|
try {
|
||||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
|
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
|
||||||
ipfiles = new File(AuthMe.getInstance().getDataFolder() + File.separator + ipFileName);
|
ipfiles = new File(AuthMe.getInstance().getDataFolder() + File.separator + ipFileName);
|
||||||
output = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
|
|
||||||
source.createNewFile();
|
source.createNewFile();
|
||||||
ipfiles.createNewFile();
|
ipfiles.createNewFile();
|
||||||
if (new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db").exists()) {
|
|
||||||
alreadyExist = true;
|
|
||||||
}
|
|
||||||
output.createNewFile();
|
|
||||||
BufferedReader users = null;
|
BufferedReader users = null;
|
||||||
BufferedWriter outputDB = null;
|
|
||||||
BufferedReader ipFile = null;
|
BufferedReader ipFile = null;
|
||||||
ipFile = new BufferedReader(new FileReader(ipfiles));
|
ipFile = new BufferedReader(new FileReader(ipfiles));
|
||||||
String line;
|
String line;
|
||||||
String newLine = null;
|
|
||||||
if (useIP) {
|
if (useIP) {
|
||||||
String tempLine;
|
String tempLine;
|
||||||
while ((tempLine = ipFile.readLine()) != null) {
|
while ((tempLine = ipFile.readLine()) != null) {
|
||||||
@ -81,33 +76,28 @@ public class RakamakConverter {
|
|||||||
if (line.contains("=")) {
|
if (line.contains("=")) {
|
||||||
String[] arguments = line.split("=");
|
String[] arguments = line.split("=");
|
||||||
try {
|
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) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
ConsoleLogger.showError(e.getMessage());
|
ConsoleLogger.showError(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
users.close();
|
users.close();
|
||||||
outputDB = new BufferedWriter(new FileWriter(output));
|
|
||||||
for (Entry<String, String> m : playerPSW.entrySet()) {
|
for (Entry<String, String> m : playerPSW.entrySet()) {
|
||||||
|
String player = m.getKey();
|
||||||
|
String psw = playerPSW.get(player);
|
||||||
|
String ip;
|
||||||
if (useIP) {
|
if (useIP) {
|
||||||
String player = m.getKey();
|
ip = playerIP.get(player);
|
||||||
String psw = playerPSW.get(player);
|
|
||||||
String ip = playerIP.get(player);
|
|
||||||
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0:world:your@email.com";
|
|
||||||
} else {
|
} else {
|
||||||
String player = m.getKey();
|
ip = "127.0.0.1";
|
||||||
String psw = playerPSW.get(player);
|
|
||||||
String ip = "127.0.0.1";
|
|
||||||
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0:world:your@email.com";
|
|
||||||
}
|
}
|
||||||
if (alreadyExist) outputDB.newLine();
|
PlayerAuth auth = new PlayerAuth(player, psw, ip, System.currentTimeMillis());
|
||||||
outputDB.write(newLine);
|
if (PasswordSecurity.userSalt.containsKey(player))
|
||||||
System.out.println("Write line");
|
auth.setSalt(PasswordSecurity.userSalt.get(player));
|
||||||
outputDB.newLine();
|
database.saveAuth(auth);
|
||||||
}
|
}
|
||||||
outputDB.close();
|
ConsoleLogger.info("Rakamak database has been imported correctly");
|
||||||
ConsoleLogger.info("Rakamak database has been converted to auths.db");
|
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
|
|
||||||
public class RoyalAuthConverter extends Thread {
|
public class RoyalAuthConverter extends Thread implements Converter {
|
||||||
|
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
private DataSource data;
|
private DataSource data;
|
||||||
@ -21,23 +21,27 @@ public class RoyalAuthConverter extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
35
src/main/java/fr/xephi/authme/converter/xAuthConverter.java
Normal file
35
src/main/java/fr/xephi/authme/converter/xAuthConverter.java
Normal 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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -235,7 +235,7 @@ public class MySQLDataSource implements DataSource {
|
|||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = makeSureConnectionIsReady();
|
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 = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
|
||||||
pst.setString(1, auth.getNickname());
|
pst.setString(1, auth.getNickname());
|
||||||
pst.setString(2, auth.getHash());
|
pst.setString(2, auth.getHash());
|
||||||
|
|||||||
@ -580,7 +580,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
long cur = new Date().getTime();
|
long cur = new Date().getTime();
|
||||||
if((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().equals("198.18.0.1") ) {
|
if((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().equals("198.18.0.1") ) {
|
||||||
if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip) ) {
|
if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip) ) {
|
||||||
plugin.getServer().getPluginManager().callEvent(new SessionEvent(auth, true));
|
|
||||||
if(PlayerCache.getInstance().getAuth(name) != null) {
|
if(PlayerCache.getInstance().getAuth(name) != null) {
|
||||||
PlayerCache.getInstance().updatePlayer(auth);
|
PlayerCache.getInstance().updatePlayer(auth);
|
||||||
} else {
|
} else {
|
||||||
@ -590,6 +589,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
m._(player, "valid_session");
|
m._(player, "valid_session");
|
||||||
// Restore Permission Group
|
// Restore Permission Group
|
||||||
utils.setGroup(player, Utils.groupType.LOGGEDIN);
|
utils.setGroup(player, Utils.groupType.LOGGEDIN);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(new SessionEvent(auth, true));
|
||||||
return;
|
return;
|
||||||
} else if (!Settings.sessionExpireOnIpChange){
|
} else if (!Settings.sessionExpireOnIpChange){
|
||||||
GameMode gM = gameMode.get(name);
|
GameMode gM = gameMode.get(name);
|
||||||
@ -627,15 +627,16 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Utils.forceGM(player);
|
Utils.forceGM(player);
|
||||||
this.causeByAuthMe = false;
|
this.causeByAuthMe = false;
|
||||||
}
|
}
|
||||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
if (!Settings.noTeleport)
|
||||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
|
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
|
||||||
if(!tpEvent.isCancelled()) {
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
|
if(!tpEvent.isCancelled()) {
|
||||||
player.teleport(tpEvent.getTo());
|
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
|
||||||
}
|
player.teleport(tpEvent.getTo());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
placePlayerSafely(player, spawnLoc);
|
placePlayerSafely(player, spawnLoc);
|
||||||
LimboCache.getInstance().updateLimboPlayer(player);
|
LimboCache.getInstance().updateLimboPlayer(player);
|
||||||
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(),LimboCache.getInstance().getLimboPlayer(name).getArmour());
|
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()){
|
if(!Settings.unRegisteredGroup.isEmpty()){
|
||||||
utils.setGroup(player, Utils.groupType.UNREGISTERED);
|
utils.setGroup(player, Utils.groupType.UNREGISTERED);
|
||||||
}
|
}
|
||||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
if (!Settings.noTeleport)
|
||||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
|
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
|
||||||
if(!tpEvent.isCancelled()) {
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
|
if(!tpEvent.isCancelled()) {
|
||||||
player.teleport(tpEvent.getTo());
|
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
|
||||||
}
|
player.teleport(tpEvent.getTo());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!Settings.isForcedRegistrationEnabled) {
|
if (!Settings.isForcedRegistrationEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -711,13 +713,14 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
player.performCommand("motd");
|
player.performCommand("motd");
|
||||||
|
|
||||||
// Remove the join message while the player isn't logging in
|
// Remove the join message while the player isn't logging in
|
||||||
if (Settings.enableProtection) {
|
if (Settings.enableProtection || Settings.delayJoinMessage) {
|
||||||
joinMessage.put(name, event.getJoinMessage());
|
joinMessage.put(name, event.getJoinMessage());
|
||||||
event.setJoinMessage(null);
|
event.setJoinMessage(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placePlayerSafely(Player player, Location spawnLoc) {
|
private void placePlayerSafely(Player player, Location spawnLoc) {
|
||||||
|
if (!Settings.noTeleport) return;
|
||||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
|
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
|
||||||
return;
|
return;
|
||||||
Block b = player.getLocation().getBlock();
|
Block b = player.getLocation().getBlock();
|
||||||
@ -843,6 +846,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
ConsoleLogger.showError("Problem while restore " + name + " inventory after a kick");
|
ConsoleLogger.showError("Problem while restore " + name + " inventory after a kick");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!Settings.noTeleport)
|
||||||
try {
|
try {
|
||||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
|
|||||||
@ -1,64 +1,39 @@
|
|||||||
package fr.xephi.authme.plugin.manager;
|
package fr.xephi.authme.plugin.manager;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
import com.trc202.CombatTag.CombatTag;
|
import com.trc202.CombatTag.CombatTag;
|
||||||
import com.trc202.CombatTagApi.CombatTagApi;
|
import com.trc202.CombatTagApi.CombatTagApi;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public abstract class CombatTagComunicator {
|
public abstract class CombatTagComunicator {
|
||||||
|
|
||||||
static CombatTagApi combatApi;
|
public static CombatTagApi combatApi;
|
||||||
|
|
||||||
public CombatTagComunicator() {
|
/**
|
||||||
if(Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null){
|
* Returns if the entity is an NPC
|
||||||
combatApi = new CombatTagApi((CombatTag)Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));
|
* @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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -132,36 +132,24 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Teleport the player
|
if (!Settings.noTeleport) {
|
||||||
if(Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
// Teleport the player
|
||||||
// If we have force the spawn location on join
|
if(Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||||
teleportToSpawn();
|
// If we have force the spawn location on join
|
||||||
} else {
|
teleportToSpawn();
|
||||||
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();
|
|
||||||
} else {
|
} 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
|
// Re-Force Survival GameMode if we need due to world change specification
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
|
|||||||
int nwMsg = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), msgInterval));
|
int nwMsg = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), msgInterval));
|
||||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg);
|
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg);
|
||||||
|
|
||||||
if (Settings.isTeleportToSpawnEnabled) {
|
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||||
Location loca = plugin.getSpawnLocation(player);
|
Location loca = plugin.getSpawnLocation(player);
|
||||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void forceLogin(Player player) {
|
protected void forceLogin(Player player) {
|
||||||
if (Settings.isTeleportToSpawnEnabled) {
|
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||||
Location spawnLoc = plugin.getSpawnLocation(player);
|
Location spawnLoc = plugin.getSpawnLocation(player);
|
||||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
|
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
|
||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
@ -78,7 +78,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
|||||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
player.setGameMode(limbo.getGameMode());
|
player.setGameMode(limbo.getGameMode());
|
||||||
if (Settings.isTeleportToSpawnEnabled) {
|
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||||
Location loca = plugin.getSpawnLocation(player);
|
Location loca = plugin.getSpawnLocation(player);
|
||||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
|
|||||||
@ -21,11 +21,13 @@ public enum HashAlgorithm {
|
|||||||
JOOMLA(fr.xephi.authme.security.crypts.JOOMLA.class),
|
JOOMLA(fr.xephi.authme.security.crypts.JOOMLA.class),
|
||||||
BCRYPT(fr.xephi.authme.security.crypts.BCRYPT.class),
|
BCRYPT(fr.xephi.authme.security.crypts.BCRYPT.class),
|
||||||
WBB3(fr.xephi.authme.security.crypts.WBB3.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),
|
SHA512(fr.xephi.authme.security.crypts.SHA512.class),
|
||||||
DOUBLEMD5(fr.xephi.authme.security.crypts.DOUBLEMD5.class),
|
DOUBLEMD5(fr.xephi.authme.security.crypts.DOUBLEMD5.class),
|
||||||
PBKDF2(fr.xephi.authme.security.crypts.CryptPBKDF2.class),
|
PBKDF2(fr.xephi.authme.security.crypts.CryptPBKDF2.class),
|
||||||
WORDPRESS(fr.xephi.authme.security.crypts.WORDPRESS.class),
|
WORDPRESS(fr.xephi.authme.security.crypts.WORDPRESS.class),
|
||||||
ROYALAUTH(fr.xephi.authme.security.crypts.ROYALAUTH.class),
|
ROYALAUTH(fr.xephi.authme.security.crypts.ROYALAUTH.class),
|
||||||
|
CRAZYCRYPT1(fr.xephi.authme.security.crypts.CRAZYCRYPT1.class),
|
||||||
CUSTOM(Null.class);
|
CUSTOM(Null.class);
|
||||||
|
|
||||||
Class<?> classe;
|
Class<?> classe;
|
||||||
|
|||||||
@ -80,12 +80,16 @@ public class PasswordSecurity {
|
|||||||
salt = createSalt(40);
|
salt = createSalt(40);
|
||||||
userSalt.put(playerName, salt);
|
userSalt.put(playerName, salt);
|
||||||
break;
|
break;
|
||||||
|
case WBB4:
|
||||||
|
salt = BCRYPT.gensalt(8);
|
||||||
|
userSalt.put(playerName, salt);
|
||||||
|
break;
|
||||||
case PBKDF2:
|
case PBKDF2:
|
||||||
salt = createSalt(12);
|
salt = createSalt(12);
|
||||||
userSalt.put(playerName, salt);
|
userSalt.put(playerName, salt);
|
||||||
break;
|
break;
|
||||||
case SMF:
|
case SMF:
|
||||||
return method.getHash(password, playerName.toLowerCase());
|
return method.getHash(password, null, playerName);
|
||||||
case PHPBB:
|
case PHPBB:
|
||||||
salt = createSalt(16);
|
salt = createSalt(16);
|
||||||
userSalt.put(playerName, salt);
|
userSalt.put(playerName, salt);
|
||||||
@ -96,6 +100,8 @@ public class PasswordSecurity {
|
|||||||
case PLAINTEXT:
|
case PLAINTEXT:
|
||||||
case XENFORO:
|
case XENFORO:
|
||||||
case SHA512:
|
case SHA512:
|
||||||
|
case ROYALAUTH:
|
||||||
|
case CRAZYCRYPT1:
|
||||||
case DOUBLEMD5:
|
case DOUBLEMD5:
|
||||||
case WORDPRESS:
|
case WORDPRESS:
|
||||||
case CUSTOM:
|
case CUSTOM:
|
||||||
@ -108,7 +114,7 @@ public class PasswordSecurity {
|
|||||||
method = event.getMethod();
|
method = event.getMethod();
|
||||||
if (method == null)
|
if (method == null)
|
||||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
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 {
|
public static boolean comparePasswordWithHash(String password, String hash, String playerName) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -750,8 +750,35 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
return (hashed.compareTo(hashpw(plaintext, hashed)) == 0);
|
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
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return hashpw(password, salt);
|
return hashpw(password, salt);
|
||||||
}
|
}
|
||||||
@ -761,4 +788,9 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
return checkpw(password, hash);
|
return checkpw(password, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getDoubleHash(String text, String salt) {
|
||||||
|
String hash = hashpw(text, salt);
|
||||||
|
return hashpw(text, hash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -9,7 +9,7 @@ import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters;
|
|||||||
public class CryptPBKDF2 implements EncryptionMethod {
|
public class CryptPBKDF2 implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
String result = "pbkdf2_sha256$10000$"+salt+"$";
|
String result = "pbkdf2_sha256$10000$"+salt+"$";
|
||||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);
|
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class DOUBLEMD5 implements EncryptionMethod {
|
public class DOUBLEMD5 implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(getMD5(password));
|
return getMD5(getMD5(password));
|
||||||
}
|
}
|
||||||
@ -15,7 +15,7 @@ public class DOUBLEMD5 implements EncryptionMethod {
|
|||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
return hash.equals(getHash(password, ""));
|
return hash.equals(getHash(password, "", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public interface EncryptionMethod {
|
|||||||
* @return Hashing password
|
* @return Hashing password
|
||||||
* @throws NoSuchAlgorithmException
|
* @throws NoSuchAlgorithmException
|
||||||
*/
|
*/
|
||||||
String getHash(String password, String salt) throws NoSuchAlgorithmException;
|
String getHash(String password, String salt, String name) throws NoSuchAlgorithmException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param hash
|
* @param hash
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
public class IPB3 implements EncryptionMethod {
|
public class IPB3 implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(getMD5(salt) + getMD5(password));
|
return getMD5(getMD5(salt) + getMD5(password));
|
||||||
}
|
}
|
||||||
@ -19,7 +19,7 @@ public class IPB3 implements EncryptionMethod {
|
|||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
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 {
|
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class JOOMLA implements EncryptionMethod {
|
public class JOOMLA implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(password + salt) + ":" + salt;
|
return getMD5(password + salt) + ":" + salt;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,13 +7,13 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class MD5 implements EncryptionMethod {
|
public class MD5 implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
|
public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException {
|
||||||
return getMD5(password);
|
return getMD5(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException {
|
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 {
|
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class MD5VB implements EncryptionMethod {
|
public class MD5VB implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return "$MD5vb$" + salt + "$" + getMD5(getMD5(password) + salt);
|
return "$MD5vb$" + salt + "$" + getMD5(getMD5(password) + salt);
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@ public class MD5VB implements EncryptionMethod {
|
|||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
String[] line = hash.split("\\$");
|
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 {
|
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
public class MYBB implements EncryptionMethod {
|
public class MYBB implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(getMD5(salt)+ getMD5(password));
|
return getMD5(getMD5(salt)+ getMD5(password));
|
||||||
}
|
}
|
||||||
@ -19,7 +19,7 @@ public class MYBB implements EncryptionMethod {
|
|||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
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 {
|
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -151,7 +151,7 @@ private String _hash_gensalt_private(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return phpbb_hash(password, salt);
|
return phpbb_hash(password, salt);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
public class PHPFUSION implements EncryptionMethod {
|
public class PHPFUSION implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
String digest = null;
|
String digest = null;
|
||||||
String algo = "HmacSHA256";
|
String algo = "HmacSHA256";
|
||||||
@ -45,7 +45,7 @@ public class PHPFUSION implements EncryptionMethod {
|
|||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
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 {
|
private static String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class PLAINTEXT implements EncryptionMethod {
|
public class PLAINTEXT implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,20 +6,26 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class ROYALAUTH implements EncryptionMethod {
|
public class ROYALAUTH implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException {
|
||||||
throws NoSuchAlgorithmException {
|
String data = "";
|
||||||
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
for (int i = 0; i < 25; i++)
|
||||||
md.update(password.getBytes());
|
data = hash(data, salt);
|
||||||
byte byteData[] = md.digest();
|
return data;
|
||||||
StringBuilder sb = new StringBuilder();
|
}
|
||||||
for (byte aByteData : byteData) sb.append(Integer.toString((aByteData & 0xff) + 0x100, 16).substring(1));
|
|
||||||
return sb.toString();
|
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
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException {
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
return hash.equalsIgnoreCase(getHash(password, "", ""));
|
||||||
return hash.equalsIgnoreCase(getHash(password, ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
public class SALTED2MD5 implements EncryptionMethod {
|
public class SALTED2MD5 implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getMD5(getMD5(password) + salt);
|
return getMD5(getMD5(password) + salt);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,14 +7,14 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class SHA1 implements EncryptionMethod {
|
public class SHA1 implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
|
public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException {
|
||||||
return getSHA1(password);
|
return getSHA1(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password, String playerName)
|
public boolean comparePassword(String hash, String password, String playerName)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return hash.equals(getHash(password, ""));
|
return hash.equals(getHash(password, "", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getSHA1(String message) throws NoSuchAlgorithmException {
|
private static String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class SHA256 implements EncryptionMethod {
|
public class SHA256 implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@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);
|
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)
|
public boolean comparePassword(String hash, String password, String playerName)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
String[] line = hash.split("\\$");
|
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 {
|
private static String getSHA256(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class SHA512 implements EncryptionMethod {
|
public class SHA512 implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getSHA512(password);
|
return getSHA512(password);
|
||||||
}
|
}
|
||||||
@ -15,7 +15,7 @@ public class SHA512 implements EncryptionMethod {
|
|||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
return hash.equals(getHash(password, ""));
|
return hash.equals(getHash(password, "", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getSHA512(String message) throws NoSuchAlgorithmException {
|
private static String getSHA512(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -7,15 +7,15 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class SMF implements EncryptionMethod {
|
public class SMF implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getSHA1(salt.toLowerCase() + password);
|
return getSHA1(name.toLowerCase() + password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
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 {
|
private static String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
public class WBB3 implements EncryptionMethod {
|
public class WBB3 implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getSHA1(salt.concat(getSHA1(salt.concat(getSHA1(password)))));
|
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,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
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 {
|
private static String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||||
|
|||||||
19
src/main/java/fr/xephi/authme/security/crypts/WBB4.java
Normal file
19
src/main/java/fr/xephi/authme/security/crypts/WBB4.java
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -408,7 +408,7 @@ public class WHIRLPOOL implements EncryptionMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
byte[] digest = new byte[DIGESTBYTES];
|
byte[] digest = new byte[DIGESTBYTES];
|
||||||
NESSIEinit();
|
NESSIEinit();
|
||||||
@ -420,6 +420,6 @@ public class WHIRLPOOL implements EncryptionMethod {
|
|||||||
@Override
|
@Override
|
||||||
public boolean comparePassword(String hash, String password,
|
public boolean comparePassword(String hash, String password,
|
||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
return hash.equals(getHash(password, ""));
|
return hash.equals(getHash(password, "", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,7 +99,7 @@ public class WORDPRESS implements EncryptionMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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];
|
byte random[] = new byte[6];
|
||||||
this.randomGen.nextBytes(random);
|
this.randomGen.nextBytes(random);
|
||||||
return crypt(password, gensaltPrivate(stringToUtf8(new String(random))));
|
return crypt(password, gensaltPrivate(stringToUtf8(new String(random))));
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
public class XAUTH implements EncryptionMethod {
|
public class XAUTH implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
String hash = getWhirlpool(salt + password).toLowerCase();
|
String hash = getWhirlpool(salt + password).toLowerCase();
|
||||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
||||||
@ -17,7 +17,7 @@ public class XAUTH implements EncryptionMethod {
|
|||||||
String playerName) throws NoSuchAlgorithmException {
|
String playerName) throws NoSuchAlgorithmException {
|
||||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
||||||
String salt = hash.substring(saltPos, saltPos + 12);
|
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) {
|
public static String getWhirlpool(String message) {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
public class XF implements EncryptionMethod {
|
public class XF implements EncryptionMethod {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHash(String password, String salt)
|
public String getHash(String password, String salt, String name)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
return getSHA256(getSHA256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
|
return getSHA256(getSHA256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,6 @@ public final class Settings extends YamlConfiguration {
|
|||||||
private final File file;
|
private final File file;
|
||||||
public static DataSourceType getDataSource;
|
public static DataSourceType getDataSource;
|
||||||
public static HashAlgorithm getPasswordHash;
|
public static HashAlgorithm getPasswordHash;
|
||||||
public static HashAlgorithm rakamakHash;
|
|
||||||
public static Boolean useLogging = false;
|
public static Boolean useLogging = false;
|
||||||
public static int purgeDelay = 60;
|
public static int purgeDelay = 60;
|
||||||
public static List<String> welcomeMsg = null;
|
public static List<String> welcomeMsg = null;
|
||||||
@ -60,7 +59,8 @@ public final class Settings extends YamlConfiguration {
|
|||||||
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
|
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
|
||||||
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
|
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
|
||||||
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||||
broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames;
|
broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames, delayJoinMessage,
|
||||||
|
noTeleport;
|
||||||
|
|
||||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
|
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
|
||||||
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
|
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
|
||||||
@ -178,7 +178,6 @@ public void loadConfigOptions() {
|
|||||||
rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
|
rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
|
||||||
rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
|
rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
|
||||||
rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
|
rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
|
||||||
rakamakHash = getRakamakHash();
|
|
||||||
noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
|
noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
|
||||||
removePassword = configFile.getBoolean("Security.console.removePassword", true);
|
removePassword = configFile.getBoolean("Security.console.removePassword", true);
|
||||||
getmailAccount = configFile.getString("Email.mailAccount", "");
|
getmailAccount = configFile.getString("Email.mailAccount", "");
|
||||||
@ -244,6 +243,8 @@ public void loadConfigOptions() {
|
|||||||
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
|
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
|
||||||
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
|
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
|
||||||
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
|
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
|
||||||
|
delayJoinMessage = configFile.getBoolean("settings.delayJoinMessage", false);
|
||||||
|
noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
|
||||||
|
|
||||||
// Load the welcome message
|
// Load the welcome message
|
||||||
getWelcomeMessage(plugin);
|
getWelcomeMessage(plugin);
|
||||||
@ -337,7 +338,6 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
|||||||
rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
|
rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
|
||||||
rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
|
rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
|
||||||
rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
|
rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
|
||||||
rakamakHash = getRakamakHash();
|
|
||||||
noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
|
noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
|
||||||
removePassword = configFile.getBoolean("Security.console.removePassword", true);
|
removePassword = configFile.getBoolean("Security.console.removePassword", true);
|
||||||
getmailAccount = configFile.getString("Email.mailAccount", "");
|
getmailAccount = configFile.getString("Email.mailAccount", "");
|
||||||
@ -403,6 +403,8 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
|||||||
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
|
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
|
||||||
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
|
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
|
||||||
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
|
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
|
||||||
|
delayJoinMessage = configFile.getBoolean("settings.delayJoinMessage", false);
|
||||||
|
noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
|
||||||
|
|
||||||
// Reload the welcome message
|
// Reload the welcome message
|
||||||
getWelcomeMessage(AuthMe.getInstance());
|
getWelcomeMessage(AuthMe.getInstance());
|
||||||
@ -505,10 +507,20 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
|||||||
}
|
}
|
||||||
if(getString("settings.restrictions.allowedNicknameCharacters").equals("[a-zA-Z0-9_?]*"))
|
if(getString("settings.restrictions.allowedNicknameCharacters").equals("[a-zA-Z0-9_?]*"))
|
||||||
set("settings.restrictions.allowedNicknameCharacters", "[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) {
|
if (changes) {
|
||||||
plugin.getLogger().warning("Merge new Config Options if needed..");
|
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!");
|
plugin.getLogger().warning("Please check your config.yml file for new configs!");
|
||||||
}
|
}
|
||||||
plugin.saveConfig();
|
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() {
|
private static DataSourceType getDataSource() {
|
||||||
String key = "DataSource.backend";
|
String key = "DataSource.backend";
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -264,7 +264,7 @@ public class MySQLThread extends Thread implements DataSource {
|
|||||||
PreparedStatement pst = null;
|
PreparedStatement pst = null;
|
||||||
try {
|
try {
|
||||||
con = makeSureConnectionIsReady();
|
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 = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
|
||||||
pst.setString(1, auth.getNickname());
|
pst.setString(1, auth.getNickname());
|
||||||
pst.setString(2, auth.getHash());
|
pst.setString(2, auth.getHash());
|
||||||
|
|||||||
@ -162,6 +162,8 @@ settings:
|
|||||||
maxLoginPerIp: 0
|
maxLoginPerIp: 0
|
||||||
# Maximum Join authorized by IP
|
# Maximum Join authorized by IP
|
||||||
maxJoinPerIp: 0
|
maxJoinPerIp: 0
|
||||||
|
# AuthMe will NEVER teleport players !
|
||||||
|
noTeleport: false
|
||||||
GameMode:
|
GameMode:
|
||||||
# ForceSurvivalMode to player when join ?
|
# ForceSurvivalMode to player when join ?
|
||||||
ForceSurvivalMode: false
|
ForceSurvivalMode: false
|
||||||
@ -254,6 +256,8 @@ settings:
|
|||||||
useWelcomeMessage: true
|
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
|
# 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
|
broadcastWelcomeMessage: false
|
||||||
|
# Do we need to delay the X has joined the game after /login ?
|
||||||
|
delayJoinMessage: false
|
||||||
ExternalBoardOptions:
|
ExternalBoardOptions:
|
||||||
# MySQL column for the salt , needed for some forum/cms support
|
# MySQL column for the salt , needed for some forum/cms support
|
||||||
mySQLColumnSalt: ''
|
mySQLColumnSalt: ''
|
||||||
@ -325,11 +329,6 @@ Converter:
|
|||||||
useIP: false
|
useIP: false
|
||||||
# IP file name for rakamak
|
# IP file name for rakamak
|
||||||
ipFileName: UsersIp.rak
|
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:
|
||||||
# Email SMTP server host
|
# Email SMTP server host
|
||||||
mailSMTP: smtp.gmail.com
|
mailSMTP: smtp.gmail.com
|
||||||
|
|||||||
@ -3,7 +3,7 @@ author: Xephi59
|
|||||||
website: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
|
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.
|
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
|
main: fr.xephi.authme.AuthMe
|
||||||
version: 3.3.6
|
version: 3.4
|
||||||
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn]
|
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn]
|
||||||
commands:
|
commands:
|
||||||
register:
|
register:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user