mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-24 17:47:38 +01:00
Minor - make AuthMe.database private
- In favor of AuthMe.getDataSource()
This commit is contained in:
parent
571cb6d36b
commit
531327dd9b
@ -102,12 +102,12 @@ public class AuthMe extends JavaPlugin {
|
||||
private JsonCache playerBackup;
|
||||
private ModuleManager moduleManager;
|
||||
private PasswordSecurity passwordSecurity;
|
||||
private DataSource database;
|
||||
|
||||
// Public Instances
|
||||
public NewAPI api;
|
||||
public SendMailSSL mail;
|
||||
public DataManager dataManager;
|
||||
public DataSource database;
|
||||
public OtherAccounts otherAccounts;
|
||||
public Location essentialsSpawn;
|
||||
|
||||
|
@ -4,6 +4,7 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.crypts.HashResult;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -12,34 +13,37 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* Deprecated API of AuthMe. Please use {@link NewAPI} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class API {
|
||||
|
||||
public static final String newline = System.getProperty("line.separator");
|
||||
public static AuthMe instance;
|
||||
private static PasswordSecurity passwordSecurity;
|
||||
|
||||
/**
|
||||
* Constructor for API.
|
||||
* Constructor for the deprecated API.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
*/
|
||||
@Deprecated
|
||||
public API(AuthMe instance) {
|
||||
API.instance = instance;
|
||||
passwordSecurity = instance.getPasswordSecurity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook into AuthMe
|
||||
* Hook into AuthMe.
|
||||
*
|
||||
* @return AuthMe instance
|
||||
*/
|
||||
@Deprecated
|
||||
public static AuthMe hookAuthMe() {
|
||||
if (instance != null)
|
||||
if (instance != null) {
|
||||
return instance;
|
||||
}
|
||||
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
|
||||
if (plugin == null || !(plugin instanceof AuthMe)) {
|
||||
return null;
|
||||
@ -49,9 +53,10 @@ public class API {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* Return whether the player is authenticated.
|
||||
*
|
||||
* @return true if player is authenticate
|
||||
* @param player The player to verify
|
||||
* @return true if the player is authenticated
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isAuthenticated(Player player) {
|
||||
@ -59,8 +64,9 @@ public class API {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* Return whether the player is unrestricted.
|
||||
*
|
||||
* @param player The player to verify
|
||||
* @return true if the player is unrestricted
|
||||
*/
|
||||
@Deprecated
|
||||
@ -68,13 +74,6 @@ public class API {
|
||||
return Utils.isUnrestricted(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getLastLocation.
|
||||
*
|
||||
* @param player Player
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
@Deprecated
|
||||
public static Location getLastLocation(Player player) {
|
||||
try {
|
||||
@ -92,13 +91,6 @@ public class API {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setPlayerInventory.
|
||||
*
|
||||
* @param player Player
|
||||
* @param content ItemStack[]
|
||||
* @param armor ItemStack[]
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setPlayerInventory(Player player, ItemStack[] content,
|
||||
ItemStack[] armor) {
|
||||
@ -110,21 +102,23 @@ public class API {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playerName
|
||||
* Check whether the given player name is registered.
|
||||
*
|
||||
* @param playerName The player name to verify
|
||||
* @return true if player is registered
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isRegistered(String playerName) {
|
||||
String player = playerName.toLowerCase();
|
||||
return instance.database.isAuthAvailable(player);
|
||||
return instance.getDataSource().isAuthAvailable(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playerName String
|
||||
* @param passwordToCheck String
|
||||
* Check the password for the given player.
|
||||
*
|
||||
* @return true if the password is correct , false else
|
||||
* @param playerName The name of the player
|
||||
* @param passwordToCheck The password to check
|
||||
* @return true if the password is correct, false otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean checkPassword(String playerName,
|
||||
@ -132,71 +126,53 @@ public class API {
|
||||
if (!isRegistered(playerName))
|
||||
return false;
|
||||
String player = playerName.toLowerCase();
|
||||
PlayerAuth auth = instance.database.getAuth(player);
|
||||
try {
|
||||
return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
return false;
|
||||
}
|
||||
PlayerAuth auth = instance.getDataSource().getAuth(player);
|
||||
return passwordSecurity.comparePassword(passwordToCheck, auth.getHash(), playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a player
|
||||
* Register a player.
|
||||
*
|
||||
* @param playerName String
|
||||
* @param password String
|
||||
*
|
||||
* @return true if the player is register correctly
|
||||
* @param playerName The name of the player
|
||||
* @param password The password
|
||||
* @return true if the player was registered correctly
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean registerPlayer(String playerName, String password) {
|
||||
try {
|
||||
String name = playerName.toLowerCase();
|
||||
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
|
||||
if (isRegistered(name)) {
|
||||
return false;
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com", playerName);
|
||||
return instance.database.saveAuth(auth);
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
String name = playerName.toLowerCase();
|
||||
HashResult hashResult = passwordSecurity.computeHash(Settings.getPasswordHash, password, name);
|
||||
if (isRegistered(name)) {
|
||||
return false;
|
||||
}
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
.name(name)
|
||||
.hash(hashResult.getHash())
|
||||
.lastLogin(0)
|
||||
.realName(playerName)
|
||||
.build();
|
||||
return instance.getDataSource().saveAuth(auth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force a player to login
|
||||
* Force a player to log in.
|
||||
*
|
||||
* @param player * player
|
||||
* @param player The player to log in
|
||||
*/
|
||||
@Deprecated
|
||||
public static void forceLogin(Player player) {
|
||||
instance.getManagement().performLogin(player, "dontneed", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getPlugin.
|
||||
*
|
||||
* @return AuthMe
|
||||
*/
|
||||
@Deprecated
|
||||
public AuthMe getPlugin() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* Check whether the player is an NPC.
|
||||
*
|
||||
* @return true if player is a npc
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isaNPC(Player player) {
|
||||
return Utils.isNPC(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*
|
||||
* @return true if player is a npc
|
||||
* @param player The player to verify
|
||||
* @return true if player is an npc
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isNPC(Player player) {
|
||||
|
@ -7,7 +7,6 @@ import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.crypts.HashResult;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -72,10 +71,8 @@ public class ChangePasswordAdminCommand implements ExecutableCommand {
|
||||
HashResult hashResult = commandService.getPasswordSecurity().computeHash(playerPass, playerNameLowerCase);
|
||||
auth.setHash(hashResult.getHash());
|
||||
auth.setSalt(hashResult.getSalt());
|
||||
if (PasswordSecurity.userSalt.containsKey(playerNameLowerCase)) {
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(playerNameLowerCase));
|
||||
commandService.getDataSource().updateSalt(auth);
|
||||
}
|
||||
|
||||
// TODO #358: updatePassword(auth) needs to update the salt, too.
|
||||
if (!dataSource.updatePassword(auth)) {
|
||||
commandService.send(sender, MessageKey.ERROR);
|
||||
} else {
|
||||
|
@ -24,7 +24,7 @@ public class PurgeBannedPlayersCommand implements ExecutableCommand {
|
||||
}
|
||||
|
||||
// Purge the banned players
|
||||
plugin.database.purgeBanned(bannedPlayers);
|
||||
plugin.getDataSource().purgeBanned(bannedPlayers);
|
||||
if (Settings.purgeEssentialsFile && plugin.ess != null)
|
||||
plugin.dataManager.purgeEssentials(bannedPlayers);
|
||||
if (Settings.purgePlayerDat)
|
||||
|
@ -27,7 +27,7 @@ public class CrazyLoginConverter implements Converter {
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
public CrazyLoginConverter(AuthMe instance, CommandSender sender) {
|
||||
this.database = instance.database;
|
||||
this.database = instance.getDataSource();
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class RoyalAuthConverter implements Converter {
|
||||
|
||||
public RoyalAuthConverter(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
this.data = plugin.database;
|
||||
this.data = plugin.getDataSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,16 +21,14 @@ public class SqliteToSql implements Converter {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.database.getType() != DataSourceType.MYSQL)
|
||||
{
|
||||
if (plugin.getDataSource().getType() != DataSourceType.MYSQL) {
|
||||
sender.sendMessage("Please config your mySQL connection and re-run this command");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
SQLite data = new SQLite();
|
||||
for (PlayerAuth auth : data.getAllAuths())
|
||||
{
|
||||
plugin.database.saveAuth(auth);
|
||||
for (PlayerAuth auth : data.getAllAuths()) {
|
||||
plugin.getDataSource().saveAuth(auth);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(plugin.getMessages().retrieve(MessageKey.ERROR));
|
||||
|
@ -23,7 +23,7 @@ class vAuthFileReader {
|
||||
*/
|
||||
public vAuthFileReader(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
this.database = plugin.database;
|
||||
this.database = plugin.getDataSource();
|
||||
}
|
||||
|
||||
public void convert() {
|
||||
|
@ -30,7 +30,7 @@ class xAuthToFlat {
|
||||
*/
|
||||
public xAuthToFlat(AuthMe instance, CommandSender sender) {
|
||||
this.instance = instance;
|
||||
this.database = instance.database;
|
||||
this.database = instance.getDataSource();
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
@ -24,15 +25,6 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method onPluginMessageReceived.
|
||||
*
|
||||
* @param channel String
|
||||
* @param player Player
|
||||
* @param message byte[]
|
||||
*
|
||||
* @see org.bukkit.plugin.messaging.PluginMessageListener#onPluginMessageReceived(String, Player, byte[])
|
||||
*/
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
@ -50,21 +42,22 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
final String[] args = str.split(";");
|
||||
final String act = args[0];
|
||||
final String name = args[1];
|
||||
final DataSource dataSource = plugin.getDataSource();
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlayerAuth auth = plugin.database.getAuth(name);
|
||||
PlayerAuth auth = dataSource.getAuth(name);
|
||||
if (auth == null) {
|
||||
return;
|
||||
}
|
||||
if ("login".equals(act)) {
|
||||
PlayerCache.getInstance().updatePlayer(auth);
|
||||
plugin.database.setLogged(name);
|
||||
dataSource.setLogged(name);
|
||||
ConsoleLogger.info("Player " + auth.getNickname()
|
||||
+ " has logged in from one of your server!");
|
||||
} else if ("logout".equals(act)) {
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
plugin.database.setUnlogged(name);
|
||||
dataSource.setUnlogged(name);
|
||||
ConsoleLogger.info("Player " + auth.getNickname()
|
||||
+ " has logged out from one of your server!");
|
||||
} else if ("register".equals(act)) {
|
||||
@ -73,10 +66,11 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
} else if ("changepassword".equals(act)) {
|
||||
final String password = args[2];
|
||||
auth.setHash(password);
|
||||
if (args.length == 4)
|
||||
auth.setSalt(args[3]);
|
||||
if (args.length == 4) {
|
||||
auth.setSalt(args[3]);
|
||||
}
|
||||
PlayerCache.getInstance().updatePlayer(auth);
|
||||
plugin.database.updatePassword(auth);
|
||||
dataSource.updatePassword(auth);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.database.isAuthAvailable(player.getName().toLowerCase())) {
|
||||
if (plugin.getDataSource().isAuthAvailable(player.getName().toLowerCase())) {
|
||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
} else {
|
||||
if (Settings.emailRegistration) {
|
||||
@ -221,8 +221,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||
PlayerAuth auth = plugin.database.getAuth(event.getName());
|
||||
if (auth != null && auth.getRealName() != null && !auth.getRealName().isEmpty() && !auth.getRealName().equals("Player") && !auth.getRealName().equals(event.getName())) {
|
||||
PlayerAuth auth = plugin.getDataSource().getAuth(event.getName());
|
||||
if (auth != null && auth.getRealName() != null && !auth.getRealName().isEmpty() &&
|
||||
!auth.getRealName().equals("Player") && !auth.getRealName().equals(event.getName())) {
|
||||
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||
event.setKickMessage("You should join using username: " + ChatColor.AQUA + auth.getRealName() +
|
||||
ChatColor.RESET + "\nnot: " + ChatColor.RED + event.getName()); // TODO: write a better message
|
||||
@ -231,7 +232,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
if (auth != null && auth.getRealName().equals("Player")) {
|
||||
auth.setRealName(event.getName());
|
||||
plugin.database.saveAuth(auth);
|
||||
plugin.getDataSource().saveAuth(auth);
|
||||
}
|
||||
|
||||
if (auth == null && Settings.enableProtection) {
|
||||
@ -302,7 +303,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
|
||||
final String name = player.getName().toLowerCase();
|
||||
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
||||
boolean isAuthAvailable = plugin.getDataSource().isAuthAvailable(name);
|
||||
|
||||
if (Settings.isKickNonRegisteredEnabled && !isAuthAvailable) {
|
||||
if (Settings.antiBotInAction) {
|
||||
@ -475,9 +476,16 @@ public class AuthMePlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
Location spawn = plugin.getSpawnLocation(player);
|
||||
if (Settings.isSaveQuitLocationEnabled && plugin.database.isAuthAvailable(name)) {
|
||||
PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName(), player.getName());
|
||||
plugin.database.updateQuitLoc(auth);
|
||||
if (Settings.isSaveQuitLocationEnabled && plugin.getDataSource().isAuthAvailable(name)) {
|
||||
PlayerAuth auth = PlayerAuth.builder()
|
||||
.name(name)
|
||||
.realName(player.getName())
|
||||
.locX(spawn.getX())
|
||||
.locY(spawn.getY())
|
||||
.locZ(spawn.getZ())
|
||||
.locWorld(spawn.getWorld().getName())
|
||||
.build();
|
||||
plugin.getDataSource().updateQuitLoc(auth);
|
||||
}
|
||||
if (spawn != null && spawn.getWorld() != null) {
|
||||
event.setRespawnLocation(spawn);
|
||||
|
@ -33,7 +33,7 @@ public class Management {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousLogin(player, password, forceLogin, plugin, plugin.database).process();
|
||||
new AsynchronousLogin(player, password, forceLogin, plugin, plugin.getDataSource()).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class Management {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousLogout(player, plugin, plugin.database).process();
|
||||
new AsynchronousLogout(player, plugin, plugin.getDataSource()).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -53,7 +53,7 @@ public class Management {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncRegister(player, password, email, plugin, plugin.database).process();
|
||||
new AsyncRegister(player, password, email, plugin, plugin.getDataSource()).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -73,7 +73,7 @@ public class Management {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousJoin(player, plugin, plugin.database).process();
|
||||
new AsynchronousJoin(player, plugin, plugin.getDataSource()).process();
|
||||
}
|
||||
|
||||
});
|
||||
@ -84,7 +84,7 @@ public class Management {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousQuit(player, plugin, plugin.database, isKick).process();
|
||||
new AsynchronousQuit(player, plugin, plugin.getDataSource(), isKick).process();
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -40,7 +40,7 @@ public class AsyncChangeEmail {
|
||||
|
||||
if (Settings.getmaxRegPerEmail > 0) {
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
||||
&& plugin.database.getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
|
||||
&& plugin.getDataSource().getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
|
||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
||||
return;
|
||||
}
|
||||
@ -68,7 +68,7 @@ public class AsyncChangeEmail {
|
||||
}
|
||||
String old = auth.getEmail();
|
||||
auth.setEmail(newEmail);
|
||||
if (!plugin.database.updateEmail(auth)) {
|
||||
if (!plugin.getDataSource().updateEmail(auth)) {
|
||||
m.send(player, MessageKey.ERROR);
|
||||
auth.setEmail(old);
|
||||
return;
|
||||
@ -81,7 +81,7 @@ public class AsyncChangeEmail {
|
||||
}
|
||||
m.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||
} else {
|
||||
if (plugin.database.isAuthAvailable(playerName)) {
|
||||
if (plugin.getDataSource().isAuthAvailable(playerName)) {
|
||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
} else {
|
||||
if (Settings.emailRegistration) {
|
||||
|
@ -6,7 +6,6 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.backup.JsonCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
@ -20,16 +19,12 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AsynchronousUnregister {
|
||||
|
||||
protected final Player player;
|
||||
protected final String name;
|
||||
protected final String password;
|
||||
protected final boolean force;
|
||||
private final Player player;
|
||||
private final String name;
|
||||
private final String password;
|
||||
private final boolean force;
|
||||
private final AuthMe plugin;
|
||||
private final Messages m;
|
||||
private final JsonCache playerCache;
|
||||
@ -52,18 +47,13 @@ public class AsynchronousUnregister {
|
||||
this.playerCache = new JsonCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getIp.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
protected String getIp() {
|
||||
return plugin.getIP(player);
|
||||
}
|
||||
|
||||
public void process() {
|
||||
if (force || plugin.getPasswordSecurity().comparePassword(password, PlayerCache.getInstance().getAuth(name).getHash(), player.getName())) {
|
||||
if (!plugin.database.removeAuth(name)) {
|
||||
if (!plugin.getDataSource().removeAuth(name)) {
|
||||
m.send(player, MessageKey.ERROR);
|
||||
return;
|
||||
}
|
||||
|
@ -28,16 +28,6 @@ public class PasswordSecurity {
|
||||
this.supportOldAlgorithm = supportOldAlgorithm;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String createSalt(int length) {
|
||||
return RandomString.generateHex(length);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String getHash(HashAlgorithm alg, String password, String playerName) throws NoSuchAlgorithmException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean comparePasswordWithHash(String password, String hash,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
@ -142,12 +132,12 @@ public class PasswordSecurity {
|
||||
try {
|
||||
EncryptionMethod method = algo.getClazz().newInstance();
|
||||
if (method.comparePassword(hash, password, salt, playerName)) {
|
||||
PlayerAuth nAuth = AuthMe.getInstance().database.getAuth(playerName);
|
||||
PlayerAuth nAuth = AuthMe.getInstance().getDataSource().getAuth(playerName);
|
||||
if (nAuth != null) {
|
||||
nAuth.setHash(getHash(Settings.getPasswordHash, password, playerName));
|
||||
// nAuth.setHash(getHash(Settings.getPasswordHash, password, playerName));
|
||||
nAuth.setSalt(userSalt.containsKey(playerName) ? userSalt.get(playerName) : "");
|
||||
AuthMe.getInstance().database.updatePassword(nAuth);
|
||||
AuthMe.getInstance().database.updateSalt(nAuth);
|
||||
AuthMe.getInstance().getDataSource().updatePassword(nAuth);
|
||||
AuthMe.getInstance().getDataSource().updateSalt(nAuth);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package fr.xephi.authme.security.crypts.description;
|
||||
|
||||
/**
|
||||
* The type of salt used by an encryption algorithms.
|
||||
* The type of salt used by an encryption algorithm.
|
||||
*/
|
||||
public enum SaltType {
|
||||
|
||||
|
@ -143,13 +143,9 @@ public final class Utils {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
// TODO ljacqu 20151123: Use a getter to retrieve things from AuthMe
|
||||
if (!plugin.database.isAuthAvailable(player.getName())) {
|
||||
return true;
|
||||
}
|
||||
if (!Settings.isForcedRegistrationEnabled && !plugin.getDataSource().isAuthAvailable(player.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -159,15 +155,6 @@ public final class Utils {
|
||||
&& (Settings.getUnrestrictedName.contains(player.getName().toLowerCase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method packCoords.
|
||||
*
|
||||
* @param x double
|
||||
* @param y double
|
||||
* @param z double
|
||||
* @param w String
|
||||
* @param pl Player
|
||||
*/
|
||||
public static void packCoords(double x, double y, double z, String w, final Player pl) {
|
||||
World theWorld;
|
||||
if (w.equals("unavailableworld")) {
|
||||
|
Loading…
Reference in New Issue
Block a user