Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into 358-encryptn-mthd-refactor
This commit is contained in:
@@ -40,6 +40,8 @@ import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.OtherAccounts;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
@@ -578,13 +580,26 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
if (Settings.getDataSource == DataSource.DataSourceType.FILE) {
|
||||
ConsoleLogger.showError("FlatFile backend has been detected and is now deprecated, it will be changed to SQLite... Connection will be impossible until conversion is done!");
|
||||
ForceFlatToSqlite converter = new ForceFlatToSqlite(database, this);
|
||||
ForceFlatToSqlite converter = new ForceFlatToSqlite(database);
|
||||
DataSource source = converter.run();
|
||||
if (source != null) {
|
||||
database = source;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Move this to another place maybe ?
|
||||
if (Settings.getPasswordHash == HashAlgorithm.PLAINTEXT)
|
||||
{
|
||||
ConsoleLogger.showError("Your HashAlgorithm has been detected has plaintext and is now deprecrated, it will be changed and hashed now to AuthMe default hashing method");
|
||||
for (PlayerAuth auth : database.getAllAuths())
|
||||
{
|
||||
auth.setHash(PasswordSecurity.getHash(HashAlgorithm.SHA256, auth.getHash(), auth.getNickname()));
|
||||
database.updatePassword(auth);
|
||||
}
|
||||
Settings.setValue("settings.security.passwordHash", "SHA256");
|
||||
Settings.reload();
|
||||
}
|
||||
|
||||
if (Settings.isCachingEnabled) {
|
||||
database = new CacheDataSource(database);
|
||||
}
|
||||
|
||||
@@ -222,8 +222,8 @@ public final class CommandInitializer {
|
||||
.labels("resetpos", "purgelastposition", "purgelastpos", "resetposition",
|
||||
"resetlastposition", "resetlastpos")
|
||||
.description("Purge player's last position")
|
||||
.detailedDescription("Purge the last know position of the specified player.")
|
||||
.withArgument("player", "Player name", false)
|
||||
.detailedDescription("Purge the last know position of the specified player or all of them.")
|
||||
.withArgument("player/*", "Player name or * for all players", false)
|
||||
.permissions(OP_ONLY, AdminPermission.PURGE_LAST_POSITION)
|
||||
.executableCommand(new PurgeLastPositionCommand())
|
||||
.build();
|
||||
|
||||
+31
-14
@@ -15,21 +15,38 @@ public class PurgeLastPositionCommand implements ExecutableCommand {
|
||||
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||
String playerNameLowerCase = playerName.toLowerCase();
|
||||
|
||||
// Get the user auth and make sure the user exists
|
||||
PlayerAuth auth = commandService.getDataSource().getAuth(playerNameLowerCase);
|
||||
if (auth == null) {
|
||||
commandService.send(sender, MessageKey.UNKNOWN_USER);
|
||||
return;
|
||||
if (playerNameLowerCase.equalsIgnoreCase("*"))
|
||||
{
|
||||
for (PlayerAuth auth : commandService.getDataSource().getAllAuths())
|
||||
{
|
||||
// Set the last position
|
||||
auth.setQuitLocX(0D);
|
||||
auth.setQuitLocY(0D);
|
||||
auth.setQuitLocZ(0D);
|
||||
auth.setWorld("world");
|
||||
commandService.getDataSource().updateQuitLoc(auth);
|
||||
}
|
||||
sender.sendMessage("All players last position locations are now reset");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the user auth and make sure the user exists
|
||||
PlayerAuth auth = commandService.getDataSource().getAuth(playerNameLowerCase);
|
||||
if (auth == null) {
|
||||
commandService.send(sender, MessageKey.UNKNOWN_USER);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the last position
|
||||
auth.setQuitLocX(0D);
|
||||
auth.setQuitLocY(0D);
|
||||
auth.setQuitLocZ(0D);
|
||||
auth.setWorld("world");
|
||||
commandService.getDataSource().updateQuitLoc(auth);
|
||||
|
||||
// Show a status message
|
||||
sender.sendMessage(playerNameLowerCase + "'s last position location is now reset");
|
||||
}
|
||||
|
||||
// Set the last position
|
||||
auth.setQuitLocX(0D);
|
||||
auth.setQuitLocY(0D);
|
||||
auth.setQuitLocZ(0D);
|
||||
auth.setWorld("world");
|
||||
commandService.getDataSource().updateQuitLoc(auth);
|
||||
|
||||
// Show a status message
|
||||
sender.sendMessage(playerNameLowerCase + "'s last position location is now reset");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,11 @@ import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
public class CrazyLoginConverter implements Converter {
|
||||
|
||||
public final AuthMe instance;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
private final DataSource database;
|
||||
private final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for CrazyLoginConverter.
|
||||
@@ -29,7 +27,6 @@ public class CrazyLoginConverter implements Converter {
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
public CrazyLoginConverter(AuthMe instance, CommandSender sender) {
|
||||
this.instance = instance;
|
||||
this.database = instance.database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
@@ -13,21 +12,10 @@ public class ForceFlatToSqlite {
|
||||
|
||||
private final DataSource data;
|
||||
|
||||
/**
|
||||
* Constructor for ForceFlatToSqlite.
|
||||
*
|
||||
* @param data DataSource
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public ForceFlatToSqlite(DataSource data, AuthMe plugin) {
|
||||
public ForceFlatToSqlite(DataSource data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public DataSource run() {
|
||||
DataSource sqlite = null;
|
||||
try {
|
||||
@@ -39,7 +27,7 @@ public class ForceFlatToSqlite {
|
||||
Settings.setValue("DataSource.backend", "sqlite");
|
||||
ConsoleLogger.info("Database successfully converted to sqlite !");
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError("An error occured while trying to convert flatfile to sqlite ...");
|
||||
ConsoleLogger.showError("An error occurred while trying to convert flatfile to sqlite ...");
|
||||
return null;
|
||||
}
|
||||
return sqlite;
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
public class RakamakConverter implements Converter {
|
||||
|
||||
@@ -27,32 +26,16 @@ public class RakamakConverter implements Converter {
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for RakamakConverter.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
public RakamakConverter(AuthMe instance, CommandSender sender) {
|
||||
this.instance = instance;
|
||||
this.database = instance.database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
*
|
||||
* @return RakamakConverter
|
||||
*/
|
||||
public RakamakConverter getInstance() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
HashAlgorithm hash = Settings.getPasswordHash;
|
||||
|
||||
@@ -8,28 +8,16 @@ import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class RoyalAuthConverter implements Converter {
|
||||
|
||||
public final AuthMe plugin;
|
||||
private final AuthMe plugin;
|
||||
private final DataSource data;
|
||||
|
||||
/**
|
||||
* Constructor for RoyalAuthConverter.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public RoyalAuthConverter(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
this.data = plugin.database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) {
|
||||
|
||||
@@ -4,35 +4,18 @@ import fr.xephi.authme.settings.CustomConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class RoyalAuthYamlReader extends CustomConfiguration {
|
||||
class RoyalAuthYamlReader extends CustomConfiguration {
|
||||
|
||||
/**
|
||||
* Constructor for RoyalAuthYamlReader.
|
||||
*
|
||||
* @param file File
|
||||
*/
|
||||
public RoyalAuthYamlReader(File file) {
|
||||
super(file);
|
||||
load();
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getLastLogin.
|
||||
*
|
||||
* @return long
|
||||
*/
|
||||
public long getLastLogin() {
|
||||
return getLong("timestamps.quit");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHash.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getHash() {
|
||||
return getString("login.password");
|
||||
}
|
||||
|
||||
@@ -2,38 +2,22 @@ package fr.xephi.authme.converter;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class vAuthConverter implements Converter {
|
||||
|
||||
public final AuthMe plugin;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
private final AuthMe plugin;
|
||||
private final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for vAuthConverter.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
public vAuthConverter(AuthMe plugin, CommandSender sender) {
|
||||
this.plugin = plugin;
|
||||
this.database = plugin.database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
new vAuthFileReader(plugin, sender).convert();
|
||||
new vAuthFileReader(plugin).convert();
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(e.getMessage());
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
|
||||
@@ -6,30 +6,24 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class vAuthFileReader {
|
||||
class vAuthFileReader {
|
||||
|
||||
public final AuthMe plugin;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
private final AuthMe plugin;
|
||||
private final DataSource database;
|
||||
|
||||
/**
|
||||
* Constructor for vAuthFileReader.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
public vAuthFileReader(AuthMe plugin, CommandSender sender) {
|
||||
public vAuthFileReader(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
this.database = plugin.database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public void convert() {
|
||||
@@ -68,13 +62,6 @@ public class vAuthFileReader {
|
||||
return s.length() > 8 && s.charAt(8) == '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getName.
|
||||
*
|
||||
* @param uuid UUID
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
private String getName(UUID uuid) {
|
||||
try {
|
||||
for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {
|
||||
|
||||
@@ -5,8 +5,8 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
public class xAuthConverter implements Converter {
|
||||
|
||||
public final AuthMe plugin;
|
||||
public final CommandSender sender;
|
||||
private final AuthMe plugin;
|
||||
private final CommandSender sender;
|
||||
|
||||
public xAuthConverter(AuthMe plugin, CommandSender sender) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -16,11 +16,11 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class xAuthToFlat {
|
||||
class xAuthToFlat {
|
||||
|
||||
public final AuthMe instance;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
private final AuthMe instance;
|
||||
private final DataSource database;
|
||||
private final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for xAuthToFlat.
|
||||
@@ -57,14 +57,14 @@ public class xAuthToFlat {
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("[AuthMe] Successfully convert from xAuth database");
|
||||
sender.sendMessage("[AuthMe] Successfully converted from xAuth database");
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage("[AuthMe] An error has been thrown while import xAuth database, the import hadn't fail but can be not complete ");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getIdPlayer(int id) {
|
||||
private String getIdPlayer(int id) {
|
||||
String realPass = "";
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
@@ -86,7 +86,7 @@ public class xAuthToFlat {
|
||||
return realPass;
|
||||
}
|
||||
|
||||
public List<Integer> getXAuthPlayers() {
|
||||
private List<Integer> getXAuthPlayers() {
|
||||
List<Integer> xP = new ArrayList<>();
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
@@ -107,7 +107,7 @@ public class xAuthToFlat {
|
||||
return xP;
|
||||
}
|
||||
|
||||
public String getPassword(int accountId) {
|
||||
private String getPassword(int accountId) {
|
||||
String realPass = "";
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
|
||||
@@ -70,8 +70,7 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
} else if ("register".equals(act)) {
|
||||
ConsoleLogger.info("Player " + auth.getNickname()
|
||||
+ " has registered out from one of your server!");
|
||||
}
|
||||
else if ("changepassword".equals(act)) {
|
||||
} else if ("changepassword".equals(act)) {
|
||||
final String password = args[2];
|
||||
auth.setHash(password);
|
||||
if (args.length == 4)
|
||||
|
||||
@@ -16,9 +16,15 @@ public class AuthMeServerStop extends Thread {
|
||||
public void run() {
|
||||
// TODO: add a MessageKey
|
||||
if (Settings.kickPlayersBeforeStopping) {
|
||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
p.kickPlayer("Server is restarting");
|
||||
}
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
p.kickPlayer("Server is restarting");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public enum MessageKey {
|
||||
|
||||
FORGOT_PASSWORD_MESSAGE("recovery_email"),
|
||||
|
||||
USAGE_CAPTCHA("usage_captcha"),
|
||||
USAGE_CAPTCHA("usage_captcha", "<theCaptcha>"),
|
||||
|
||||
CAPTCHA_WRONG_ERROR("wrong_captcha", "THE_CAPTCHA"),
|
||||
|
||||
|
||||
@@ -80,8 +80,6 @@ public class AsyncChangeEmail {
|
||||
return;
|
||||
}
|
||||
m.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||
// TODO ljacqu 20151124: Did I really miss "email_defined" or is it not present in the 'en' messages?
|
||||
// player.sendMessage(Arrays.toString(m.send("email_defined")) + auth.getEmail());
|
||||
} else {
|
||||
if (plugin.database.isAuthAvailable(playerName)) {
|
||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class AsynchronousJoin {
|
||||
}
|
||||
|
||||
final String ip = plugin.getIP(player);
|
||||
if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
|
||||
if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip, player.getAddress().getHostName())) {
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ public enum HashAlgorithm {
|
||||
XAUTH(fr.xephi.authme.security.crypts.XAUTH.class),
|
||||
MD5VB(fr.xephi.authme.security.crypts.MD5VB.class),
|
||||
PHPBB(fr.xephi.authme.security.crypts.PHPBB.class),
|
||||
@Deprecated
|
||||
PLAINTEXT(fr.xephi.authme.security.crypts.PLAINTEXT.class),
|
||||
MYBB(fr.xephi.authme.security.crypts.MYBB.class),
|
||||
IPB3(fr.xephi.authme.security.crypts.IPB3.class),
|
||||
|
||||
@@ -385,7 +385,7 @@ public final class Settings {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean getRestrictedIp(String name, String ip) {
|
||||
public static boolean getRestrictedIp(String name, String ip, String domain) {
|
||||
|
||||
Iterator<String> iterator = getRestrictedIp.iterator();
|
||||
boolean trueOnce = false;
|
||||
@@ -396,8 +396,17 @@ public final class Settings {
|
||||
String testIp = args[1];
|
||||
if (testName.equalsIgnoreCase(name)) {
|
||||
nameFound = true;
|
||||
if (testIp.equalsIgnoreCase(ip)) {
|
||||
trueOnce = true;
|
||||
if (ip != null)
|
||||
{
|
||||
if (testIp.equalsIgnoreCase(ip)) {
|
||||
trueOnce = true;
|
||||
}
|
||||
}
|
||||
if (domain != null)
|
||||
{
|
||||
if (testIp.equalsIgnoreCase(domain)) {
|
||||
trueOnce = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -746,7 +755,7 @@ public final class Settings {
|
||||
|
||||
if (!contains("Email.emailOauth2Token"))
|
||||
set("Email.emailOauth2Token", "");
|
||||
|
||||
|
||||
if (!contains("Hook.sendPlayerTo"))
|
||||
{
|
||||
set("Hooks.sendPlayerTo", "");
|
||||
|
||||
Reference in New Issue
Block a user