mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-22 18:25:27 +01:00
AuthMe 3.0
//Changes 3.0:// * Repackaging from uk.org.whoami.authme to fr.xephi.authme, please developpers, update! * Rewrite some of parts of the plugin * Some code was already perfect , also did not change it :p * Full support for phpbb3 * Add full support for WordPress + passwordHash: WORDPRESS * Completely rewrite Management system for inventories and tp issues, Thanks to : [[http://dev.bukkit.org/profiles/Possible/|Possible]] * Rework on /passpartu command * Completely rewrite the password encryption method * Add a way for developers to add their own Password Encryption Method on AuthMe via event way (please see fr.xephi.authme.events.PasswordEncryptionEvent) * Add an auto purge with players.dat removing method and essentials files removing ( if you want authme to hook with an another plugin let me know ) * Complete Hook with BungeeCord by removing the /server command before login * message_lang.yml will never be overwritten with English Strings , but correctly update the message_lang.yml when needed to * Fix a lot of issues mentioned in tickets , commants , or by mp, Thanks for all your reports!
This commit is contained in:
parent
e6467eccf2
commit
10b4eaeca7
6
pom.xml
6
pom.xml
@ -1,6 +1,6 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>uk.org.whoami.authme.AuthMe</groupId>
|
||||
<groupId>fr.xephi.authme.AuthMe</groupId>
|
||||
<artifactId>AuthMe</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>AuthMe</name>
|
||||
@ -24,12 +24,12 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<version>2.9.4</version>
|
||||
<version>3.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.6.2-R1.0</version>
|
||||
<version>1.6.4-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
|
@ -1,25 +1,6 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme;
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -34,40 +15,6 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import uk.org.whoami.authme.api.API;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.cache.backup.FileCache;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboCache;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboPlayer;
|
||||
import uk.org.whoami.authme.commands.AdminCommand;
|
||||
import uk.org.whoami.authme.commands.CaptchaCommand;
|
||||
import uk.org.whoami.authme.commands.ChangePasswordCommand;
|
||||
import uk.org.whoami.authme.commands.EmailCommand;
|
||||
import uk.org.whoami.authme.commands.LoginCommand;
|
||||
import uk.org.whoami.authme.commands.LogoutCommand;
|
||||
import uk.org.whoami.authme.commands.RegisterCommand;
|
||||
import uk.org.whoami.authme.commands.UnregisterCommand;
|
||||
import uk.org.whoami.authme.datasource.CacheDataSource;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.datasource.FileDataSource;
|
||||
import uk.org.whoami.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import uk.org.whoami.authme.datasource.MySQLDataSource;
|
||||
import uk.org.whoami.authme.listener.AuthMeBlockListener;
|
||||
import uk.org.whoami.authme.listener.AuthMeChestShopListener;
|
||||
import uk.org.whoami.authme.listener.AuthMeEntityListener;
|
||||
import uk.org.whoami.authme.listener.AuthMePlayerListener;
|
||||
import uk.org.whoami.authme.listener.AuthMeSpoutListener;
|
||||
import uk.org.whoami.authme.plugin.manager.BungeeCordMessage;
|
||||
import uk.org.whoami.authme.plugin.manager.CitizensCommunicator;
|
||||
import uk.org.whoami.authme.plugin.manager.CombatTagComunicator;
|
||||
import uk.org.whoami.authme.plugin.manager.EssSpawn;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.PlayersLogs;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import uk.org.whoami.authme.threads.FlatFileThread;
|
||||
import uk.org.whoami.authme.threads.MySQLThread;
|
||||
import uk.org.whoami.authme.threads.SQLiteThread;
|
||||
|
||||
import me.muizers.Notifications.Notifications;
|
||||
import net.citizensnpcs.Citizens;
|
||||
@ -76,11 +23,47 @@ import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
import uk.org.whoami.authme.commands.PasspartuCommand;
|
||||
import uk.org.whoami.authme.datasource.SqliteDataSource;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.commands.AdminCommand;
|
||||
import fr.xephi.authme.commands.CaptchaCommand;
|
||||
import fr.xephi.authme.commands.ChangePasswordCommand;
|
||||
import fr.xephi.authme.commands.EmailCommand;
|
||||
import fr.xephi.authme.commands.LoginCommand;
|
||||
import fr.xephi.authme.commands.LogoutCommand;
|
||||
import fr.xephi.authme.commands.PasspartuCommand;
|
||||
import fr.xephi.authme.commands.RegisterCommand;
|
||||
import fr.xephi.authme.commands.UnregisterCommand;
|
||||
import fr.xephi.authme.datasource.CacheDataSource;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.FileDataSource;
|
||||
import fr.xephi.authme.datasource.MySQLDataSource;
|
||||
import fr.xephi.authme.datasource.SqliteDataSource;
|
||||
import fr.xephi.authme.listener.AuthMeBlockListener;
|
||||
import fr.xephi.authme.listener.AuthMeChestShopListener;
|
||||
import fr.xephi.authme.listener.AuthMeEntityListener;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.listener.AuthMeSpoutListener;
|
||||
import fr.xephi.authme.plugin.manager.BungeeCordMessage;
|
||||
import fr.xephi.authme.plugin.manager.CitizensCommunicator;
|
||||
import fr.xephi.authme.plugin.manager.CombatTagComunicator;
|
||||
import fr.xephi.authme.plugin.manager.EssSpawn;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import fr.xephi.authme.threads.FlatFileThread;
|
||||
import fr.xephi.authme.threads.MySQLThread;
|
||||
import fr.xephi.authme.threads.SQLiteThread;
|
||||
|
||||
|
||||
public class AuthMe extends JavaPlugin {
|
||||
|
||||
@ -108,8 +91,7 @@ public class AuthMe extends JavaPlugin {
|
||||
public HashMap<String, Integer> captcha = new HashMap<String, Integer>();
|
||||
public HashMap<String, String> cap = new HashMap<String, String>();
|
||||
public HashMap<String, String> realIp = new HashMap<String, String>();
|
||||
public List<String> premium = new ArrayList<String>();
|
||||
public MultiverseCore mv = null;
|
||||
public MultiverseCore multiverse = null;
|
||||
public Location essentialsSpawn;
|
||||
public Thread databaseThread = null;
|
||||
|
||||
@ -177,7 +159,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
try {
|
||||
database = new FileDataSource();
|
||||
} catch (IOException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use FLAT FILE... SHUTDOWN...");
|
||||
@ -198,25 +180,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
try {
|
||||
database = new MySQLDataSource();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
|
||||
server.shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
|
||||
server.shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
} catch(TimeoutException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
|
||||
@ -237,16 +201,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
try {
|
||||
database = new SqliteDataSource();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
|
||||
server.shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
|
||||
@ -328,6 +283,8 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
if (Settings.usePurge)
|
||||
autoPurge();
|
||||
ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " enabled");
|
||||
}
|
||||
|
||||
@ -365,19 +322,19 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
private void checkMultiverse() {
|
||||
if(!Settings.multiverse) {
|
||||
mv = null;
|
||||
multiverse = null;
|
||||
return;
|
||||
}
|
||||
if (this.getServer().getPluginManager().getPlugin("Multiverse-Core") != null && this.getServer().getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||
try {
|
||||
mv = (MultiverseCore) this.getServer().getPluginManager().getPlugin("Multiverse-Core");
|
||||
multiverse = (MultiverseCore) this.getServer().getPluginManager().getPlugin("Multiverse-Core");
|
||||
ConsoleLogger.info("Hook with Multiverse-Core for SpawnLocations");
|
||||
} catch (NullPointerException npe) {
|
||||
mv = null;
|
||||
multiverse = null;
|
||||
} catch (ClassCastException cce) {
|
||||
mv = null;
|
||||
multiverse = null;
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
mv = null;
|
||||
multiverse = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -580,4 +537,64 @@ public class AuthMe extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void autoPurge() {
|
||||
if (!Settings.usePurge) {
|
||||
return;
|
||||
}
|
||||
long days = Settings.purgeDelay * 86400000;
|
||||
long until = new Date().getTime() - days;
|
||||
List<String> cleared = this.database.autoPurgeDatabase(until);
|
||||
ConsoleLogger.info("AutoPurgeDatabase : " + cleared.size() + " accounts removed.");
|
||||
if (cleared.isEmpty())
|
||||
return;
|
||||
if (Settings.purgeEssentialsFile && this.ess != null)
|
||||
purgeEssentials(cleared);
|
||||
if (Settings.purgePlayerDat)
|
||||
purgeDat(cleared);
|
||||
}
|
||||
|
||||
private void purgeDat(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
org.bukkit.OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
if (player == null) continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File (this.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + playerName + ".dat");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
|
||||
}
|
||||
|
||||
private void purgeEssentials(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
File playerFile = new File(this.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
||||
}
|
||||
|
||||
public Location getSpawnLocation(World world) {
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
if (multiverse != null) {
|
||||
try {
|
||||
spawnLoc = multiverse.getMVWorldManager().getMVWorld(world).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (ClassCastException cce) {
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
}
|
||||
}
|
||||
if (essentialsSpawn != null) {
|
||||
spawnLoc = essentialsSpawn;
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null)
|
||||
spawnLoc = Spawn.getInstance().getLocation();
|
||||
return spawnLoc;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme;
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.LogRecord;
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme;
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
@ -26,7 +10,8 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class ConsoleLogger {
|
||||
|
436
src/main/java/fr/xephi/authme/Management.java
Normal file
436
src/main/java/fr/xephi/authme/Management.java
Normal file
@ -0,0 +1,436 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||
import fr.xephi.authme.events.LoginEvent;
|
||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
* @authors Xephi59, <a href="http://dev.bukkit.org/profiles/Possible/">Possible</a>
|
||||
*
|
||||
*/
|
||||
public class Management {
|
||||
private Messages m = Messages.getInstance();
|
||||
private PlayersLogs pllog = PlayersLogs.getInstance();
|
||||
private Utils utils = Utils.getInstance();
|
||||
private FileCache playerCache = new FileCache();
|
||||
private DataSource database;
|
||||
public AuthMe plugin;
|
||||
public static RandomString rdm = new RandomString(Settings.captchaLength);
|
||||
public PluginManager pm;
|
||||
|
||||
public Management(DataSource database, AuthMe plugin) {
|
||||
this.database = database;
|
||||
this.plugin = plugin;
|
||||
this.pm = plugin.getServer().getPluginManager();
|
||||
}
|
||||
|
||||
public void performLogin(final Player player, final String password, final boolean passpartu) {
|
||||
if (passpartu) {
|
||||
// Passpartu-Login Bypasses Password-Authentication.
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new AsyncronousPasspartuLogin(player));
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new AsyncronousLogin(player, password));
|
||||
}
|
||||
}
|
||||
|
||||
class AsyncronousLogin implements Runnable {
|
||||
protected Player player;
|
||||
protected String name;
|
||||
protected String password;
|
||||
|
||||
public AsyncronousLogin(Player player, String password) {
|
||||
this.player = player;
|
||||
this.password = password;
|
||||
name = player.getName().toLowerCase();
|
||||
}
|
||||
|
||||
protected String getIP() {
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee) {
|
||||
if (plugin.realIp.containsKey(name))
|
||||
ip = plugin.realIp.get(name);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
protected boolean needsCaptcha() {
|
||||
if (Settings.useCaptcha) {
|
||||
if (!plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.put(name, 1);
|
||||
} else {
|
||||
int i = plugin.captcha.get(name) + 1;
|
||||
plugin.captcha.remove(name);
|
||||
plugin.captcha.put(name, i);
|
||||
}
|
||||
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) > Settings.maxLoginTry) {
|
||||
player.sendMessage(m._("need_captcha"));
|
||||
plugin.cap.put(name, rdm.nextString());
|
||||
player.sendMessage("Type : /captcha " + plugin.cap.get(name));
|
||||
return true;
|
||||
} else if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) > Settings.maxLoginTry) {
|
||||
try {
|
||||
plugin.captcha.remove(name);
|
||||
plugin.cap.remove(name);
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the precondition for authentication (like user known) and returns the playerAuth-State
|
||||
*/
|
||||
protected PlayerAuth preAuth() {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
player.sendMessage(m._("logged_in"));
|
||||
return null;
|
||||
}
|
||||
if (!database.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("user_unknown"));
|
||||
return null;
|
||||
}
|
||||
PlayerAuth pAuth = database.getAuth(name);
|
||||
if (pAuth == null) {
|
||||
player.sendMessage(m._("user_unknown"));
|
||||
return null;
|
||||
}
|
||||
if (!Settings.getMySQLColumnGroup.isEmpty() && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
|
||||
player.sendMessage(m._("vb_nonActiv"));
|
||||
return null;
|
||||
}
|
||||
return pAuth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
PlayerAuth pAuth = preAuth();
|
||||
if (pAuth == null || needsCaptcha())
|
||||
return;
|
||||
|
||||
String hash = pAuth.getHash();
|
||||
String email = pAuth.getEmail();
|
||||
boolean passwordVerified = true;
|
||||
try {
|
||||
passwordVerified = PasswordSecurity.comparePasswordWithHash(password, hash, name);
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
player.sendMessage(m._("error"));
|
||||
return;
|
||||
}
|
||||
if (passwordVerified && player.isOnline()) {
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email);
|
||||
database.updateSession(auth);
|
||||
|
||||
/*
|
||||
* Little Work Around under Registration Group Switching for
|
||||
* admins that add Registration thru a web Scripts.
|
||||
*/
|
||||
if (Settings.isPermissionCheckEnabled
|
||||
&& AuthMe.permission.playerInGroup(player, Settings.unRegisteredGroup)
|
||||
&& !Settings.unRegisteredGroup.isEmpty()) {
|
||||
AuthMe.permission
|
||||
.playerRemoveGroup(player.getWorld(), player.getName(), Settings.unRegisteredGroup);
|
||||
AuthMe.permission.playerAddGroup(player.getWorld(), player.getName(), Settings.getRegisteredGroup);
|
||||
}
|
||||
|
||||
pllog.addPlayer(player);
|
||||
|
||||
if (Settings.useCaptcha) {
|
||||
if (plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.remove(name);
|
||||
}
|
||||
if (plugin.cap.containsKey(name)) {
|
||||
plugin.cap.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
player.setNoDamageTicks(0);
|
||||
player.sendMessage(m._("login"));
|
||||
|
||||
displayOtherAccounts(auth);
|
||||
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " logged in!");
|
||||
|
||||
if (plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged in!"));
|
||||
}
|
||||
|
||||
// makes player isLoggedin via API
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
|
||||
// As the scheduling executes the Task most likely after the current task, we schedule it in the end
|
||||
// so that we can be sure, and have not to care if it might be processed in other order.
|
||||
ProcessSyncronousPlayerLogin syncronousPlayerLogin = new ProcessSyncronousPlayerLogin(player);
|
||||
if (syncronousPlayerLogin.getLimbo() != null) {
|
||||
player.getServer().getScheduler().cancelTask(syncronousPlayerLogin.getLimbo().getTimeoutTaskId());
|
||||
player.getServer().getScheduler().cancelTask(syncronousPlayerLogin.getLimbo().getMessageTaskId());
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, syncronousPlayerLogin);
|
||||
} else if (player.isOnline()) {
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " used the wrong password");
|
||||
if (Settings.isKickOnWrongPasswordEnabled) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (AuthMePlayerListener.gameMode != null && AuthMePlayerListener.gameMode.containsKey(name)) {
|
||||
player.setGameMode(GameMode.getByValue(AuthMePlayerListener.gameMode.get(name)));
|
||||
}
|
||||
player.kickPlayer(m._("wrong_pwd"));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
player.sendMessage(m._("wrong_pwd"));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ConsoleLogger.showError("Player " + name + " wasn't online during login process, aborted... ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AsyncronousPasspartuLogin extends AsyncronousLogin implements Runnable {
|
||||
public AsyncronousPasspartuLogin(Player player) {
|
||||
super(player, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
PlayerAuth pAuth = preAuth();
|
||||
if (pAuth == null)
|
||||
return;
|
||||
|
||||
String hash = pAuth.getHash();
|
||||
String email = pAuth.getEmail();
|
||||
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email);
|
||||
database.updateSession(auth);
|
||||
|
||||
/*
|
||||
* Little Work Around under Registration Group Switching for
|
||||
* admins that add Registration thru a web Scripts.
|
||||
*/
|
||||
if (Settings.isPermissionCheckEnabled
|
||||
&& AuthMe.permission.playerInGroup(player, Settings.unRegisteredGroup)
|
||||
&& !Settings.unRegisteredGroup.isEmpty()) {
|
||||
AuthMe.permission
|
||||
.playerRemoveGroup(player.getWorld(), player.getName(), Settings.unRegisteredGroup);
|
||||
AuthMe.permission.playerAddGroup(player.getWorld(), player.getName(), Settings.getRegisteredGroup);
|
||||
}
|
||||
|
||||
pllog.addPlayer(player);
|
||||
|
||||
if (Settings.useCaptcha) {
|
||||
if (plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.remove(name);
|
||||
}
|
||||
if (plugin.cap.containsKey(name)) {
|
||||
plugin.cap.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
player.setNoDamageTicks(0);
|
||||
player.sendMessage(m._("login"));
|
||||
|
||||
displayOtherAccounts(auth);
|
||||
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " logged in!");
|
||||
|
||||
if (plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged in!"));
|
||||
}
|
||||
|
||||
// makes player isLoggedin via API
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
|
||||
// As the scheduling executes the Task most likely after the current task, we schedule it in the end
|
||||
// so that we can be sure, and have not to care if it might be processed in other order.
|
||||
ProcessSyncronousPlayerLogin syncronousPlayerLogin = new ProcessSyncronousPlayerLogin(player);
|
||||
if (syncronousPlayerLogin.getLimbo() != null) {
|
||||
player.getServer().getScheduler().cancelTask(syncronousPlayerLogin.getLimbo().getTimeoutTaskId());
|
||||
player.getServer().getScheduler().cancelTask(syncronousPlayerLogin.getLimbo().getMessageTaskId());
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, syncronousPlayerLogin);
|
||||
}
|
||||
}
|
||||
|
||||
class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
private LimboPlayer limbo;
|
||||
private Player player;
|
||||
private String name;
|
||||
private PlayerAuth auth;
|
||||
public ProcessSyncronousPlayerLogin(Player player) {
|
||||
this.player = player;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
this.auth = database.getAuth(name);
|
||||
}
|
||||
|
||||
public LimboPlayer getLimbo() {
|
||||
return limbo;
|
||||
}
|
||||
|
||||
protected void restoreOpState() {
|
||||
player.setOp(limbo.getOperator());
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(limbo.isFlying());
|
||||
player.setFlying(limbo.isFlying());
|
||||
}
|
||||
}
|
||||
protected void packQuitLocation() {
|
||||
utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
|
||||
}
|
||||
protected void teleportBackFromSpawn() {
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||
pm.callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
Location fLoc = tpEvent.getTo();
|
||||
if (!fLoc.getChunk().isLoaded()) {
|
||||
fLoc.getChunk().load();
|
||||
}
|
||||
player.teleport(fLoc);
|
||||
}
|
||||
}
|
||||
protected void teleportToSpawn() {
|
||||
Location spawnL = plugin.getSpawnLocation(player.getWorld());
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
|
||||
pm.callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
Location fLoc = tpEvent.getTo();
|
||||
if (!fLoc.getChunk().isLoaded()) {
|
||||
fLoc.getChunk().load();
|
||||
}
|
||||
player.teleport(fLoc);
|
||||
}
|
||||
}
|
||||
protected void restoreInventory() {
|
||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
API.setPlayerInventory(player, event.getInventory(), event.getArmor());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Limbo contains the State of the Player before /login
|
||||
if (limbo != null) {
|
||||
// Op & Flying
|
||||
restoreOpState();
|
||||
|
||||
/*
|
||||
* Restore Inventories and GameMode
|
||||
* We need to restore them before teleport the player
|
||||
* Cause in AuthMePlayerListener, we call ProtectInventoryEvent after Teleporting
|
||||
* Also it's the current world inventory !
|
||||
*/
|
||||
if (!Settings.forceOnlyAfterLogin) {
|
||||
player.setGameMode(GameMode.getByValue(limbo.getGameMode()));
|
||||
// Inventory - Make it after restore GameMode , cause we need to restore the
|
||||
// right inventory in the right gamemode
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
restoreInventory();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Inventory - Make it before force the survival GameMode to cancel all
|
||||
// inventory problem
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
restoreInventory();
|
||||
}
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
// Teleport
|
||||
if (Settings.isTeleportToSpawnEnabled && !Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||
if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
|
||||
packQuitLocation();
|
||||
} else {
|
||||
teleportBackFromSpawn();
|
||||
}
|
||||
} 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
|
||||
if (Settings.isForceSurvivalModeEnabled)
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
// Cleanup no longer used temporary data
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (playerCache.doesCacheExist(name)) {
|
||||
playerCache.removeCache(name);
|
||||
}
|
||||
}
|
||||
// The Loginevent now fires (as intended) after everything is processed
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
player.saveData();
|
||||
}
|
||||
}
|
||||
|
||||
private void displayOtherAccounts(PlayerAuth auth) {
|
||||
if (!Settings.displayOtherAccounts) {
|
||||
return;
|
||||
}
|
||||
if (auth == null) {
|
||||
return;
|
||||
}
|
||||
if (this.database.getAllAuthsByName(auth).isEmpty() || this.database.getAllAuthsByName(auth) == null) {
|
||||
return;
|
||||
}
|
||||
if (this.database.getAllAuthsByName(auth).size() == 1) {
|
||||
return;
|
||||
}
|
||||
List<String> accountList = this.database.getAllAuthsByName(auth);
|
||||
String message = "[AuthMe] ";
|
||||
int i = 0;
|
||||
for (String account : accountList) {
|
||||
i++;
|
||||
message = message + account;
|
||||
if (i != accountList.size()) {
|
||||
message = message + ", ";
|
||||
} else {
|
||||
message = message + ".";
|
||||
}
|
||||
}
|
||||
for (Player player : AuthMe.getInstance().getServer().getOnlinePlayers()) {
|
||||
if (plugin.authmePermissible(player, "authme.seeOtherAccounts")) {
|
||||
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has "
|
||||
+ String.valueOf(accountList.size()) + " accounts");
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,4 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package uk.org.whoami.authme;
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -12,7 +8,8 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme;
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
@ -13,8 +13,8 @@ import javax.mail.internet.MimeMessage;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme;
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
@ -10,20 +10,16 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import uk.org.whoami.authme.events.AuthMeTeleportEvent;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stefano
|
||||
*/
|
||||
public class Utils {
|
||||
private String currentGroup;
|
||||
private static Utils singleton;
|
||||
private String unLoggedGroup = Settings.getUnloggedinGroup;
|
||||
BukkitTask id;
|
||||
int id;
|
||||
|
||||
public void setGroup(Player player, groupType group) {
|
||||
if (!player.isOnline())
|
||||
@ -49,7 +45,6 @@ public class Utils {
|
||||
}
|
||||
|
||||
public String removeAll(Player player) {
|
||||
|
||||
if(!Utils.getInstance().useGroupSystem()){
|
||||
return null;
|
||||
}
|
||||
@ -64,7 +59,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public boolean addNormal(Player player, String group) {
|
||||
if(!Utils.getInstance().useGroupSystem()){
|
||||
if(!Utils.getInstance().useGroupSystem()){
|
||||
return false;
|
||||
}
|
||||
if(AuthMe.permission.playerRemoveGroup(player.getWorld(),player.getName().toString(),this.unLoggedGroup) && AuthMe.permission.playerAddGroup(player.getWorld(),player.getName().toString(),group)) {
|
||||
@ -74,7 +69,6 @@ public class Utils {
|
||||
}
|
||||
|
||||
private String hasPermOnJoin(Player player) {
|
||||
|
||||
Iterator<String> iter = Settings.getJoinPermissions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
String permission = iter.next();
|
||||
@ -86,25 +80,19 @@ public class Utils {
|
||||
}
|
||||
|
||||
public boolean isUnrestricted(Player player) {
|
||||
|
||||
if(Settings.getUnrestrictedName.isEmpty() || Settings.getUnrestrictedName == null)
|
||||
return false;
|
||||
|
||||
if(Settings.getUnrestrictedName.contains(player.getName()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static Utils getInstance() {
|
||||
|
||||
singleton = new Utils();
|
||||
|
||||
return singleton;
|
||||
}
|
||||
|
||||
private boolean useGroupSystem() {
|
||||
|
||||
if(Settings.isPermissionCheckEnabled && !Settings.getUnloggedinGroup.isEmpty()) {
|
||||
return true;
|
||||
} return false;
|
||||
@ -122,7 +110,7 @@ public class Utils {
|
||||
theWorld = pl.getWorld();
|
||||
final World world = theWorld;
|
||||
final int fY = y;
|
||||
final Location locat = new Location(world, x, y + 0.6D, z);
|
||||
final Location locat = new Location(world, x, y + 0.4D, z);
|
||||
final Location loc = locat.getBlock().getLocation();
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AuthMe.getInstance(), new Runnable() {
|
||||
@ -138,7 +126,7 @@ public class Utils {
|
||||
}
|
||||
});
|
||||
|
||||
id = Bukkit.getScheduler().runTaskTimer(AuthMe.authme, new Runnable()
|
||||
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(AuthMe.getInstance(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
@ -149,12 +137,12 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
}, 1L, 20L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AuthMe.authme, new Runnable()
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AuthMe.getInstance(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
id.cancel();
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getScheduler().cancelTask(id);
|
||||
}
|
||||
}, 60L);
|
||||
}
|
||||
|
||||
@ -163,37 +151,36 @@ public class Utils {
|
||||
*
|
||||
*/
|
||||
public boolean obtainToken() {
|
||||
File file = new File("plugins/AuthMe/passpartu.token");
|
||||
|
||||
if (file.exists())
|
||||
file.delete();
|
||||
File file = new File("plugins/AuthMe/passpartu.token");
|
||||
if (file.exists())
|
||||
file.delete();
|
||||
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
file.createNewFile();
|
||||
writer = new FileWriter(file);
|
||||
String token = generateToken();
|
||||
writer.write(token+":"+System.currentTimeMillis()/1000+"\r\n");
|
||||
writer.flush();
|
||||
ConsoleLogger.info("[AuthMe] Security passpartu token: "+ token);
|
||||
writer.close();
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String token = generateToken();
|
||||
writer.write(token + ":" + System.currentTimeMillis() / 1000 + API.newline);
|
||||
writer.flush();
|
||||
ConsoleLogger.info("[AuthMe] Security passpartu token: "+ token);
|
||||
writer.close();
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read Toekn
|
||||
* Read Token
|
||||
*/
|
||||
public boolean readToken(String inputToken) {
|
||||
File file = new File("plugins/AuthMe/passpartu.token");
|
||||
|
||||
if (!file.exists())
|
||||
if (!file.exists())
|
||||
return false;
|
||||
|
||||
if (inputToken.isEmpty() )
|
||||
if (inputToken.isEmpty())
|
||||
return false;
|
||||
Scanner reader = null;
|
||||
try {
|
||||
@ -201,33 +188,34 @@ public class Utils {
|
||||
while (reader.hasNextLine()) {
|
||||
final String line = reader.nextLine();
|
||||
if (line.contains(":")) {
|
||||
String[] tokenInfo = line.split(":");
|
||||
if(tokenInfo[0].equals(inputToken) && System.currentTimeMillis()/1000-30 <= Integer.parseInt(tokenInfo[1]) ) {
|
||||
file.delete();
|
||||
reader.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
reader.close();
|
||||
return false;
|
||||
String[] tokenInfo = line.split(":");
|
||||
if(tokenInfo[0].equals(inputToken) && System.currentTimeMillis()/1000-30 <= Integer.parseInt(tokenInfo[1]) ) {
|
||||
file.delete();
|
||||
reader.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate Random Token
|
||||
*/
|
||||
private String generateToken() {
|
||||
// obtain new random token
|
||||
Random rnd = new Random ();
|
||||
char[] arr = new char[5];
|
||||
for (int i=0; i<5; i++) {
|
||||
int n = rnd.nextInt (36);
|
||||
arr[i] = (char) (n < 10 ? '0'+n : 'a'+n-10);
|
||||
}
|
||||
return new String(arr);
|
||||
}
|
||||
// obtain new random token
|
||||
Random rnd = new Random ();
|
||||
char[] arr = new char[5];
|
||||
for (int i=0; i<5; i++) {
|
||||
int n = rnd.nextInt (36);
|
||||
arr[i] = (char) (n < 10 ? '0'+n : 'a'+n-10);
|
||||
}
|
||||
return new String(arr);
|
||||
}
|
||||
|
||||
public enum groupType {
|
||||
UNREGISTERED, REGISTERED, NOTLOGGEDIN, LOGGEDIN
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.api;
|
||||
package fr.xephi.authme.api;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -7,17 +7,19 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.plugin.manager.CombatTagComunicator;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.plugin.manager.CombatTagComunicator;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class API {
|
||||
|
||||
public static final String newline = System.getProperty("line.separator");
|
||||
public static AuthMe instance;
|
||||
public static DataSource database;
|
||||
|
@ -1,23 +1,7 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package fr.xephi.authme.cache.auth;
|
||||
|
||||
package uk.org.whoami.authme.cache.auth;
|
||||
|
||||
import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
public class PlayerAuth {
|
||||
|
||||
@ -134,7 +118,7 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
if(!salt.isEmpty() && Settings.getPasswordHash == PasswordSecurity.HashAlgorithm.MD5VB) {
|
||||
if(!salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
vBhash = "$MD5vb$"+salt+"$"+hash;
|
||||
return vBhash;
|
||||
}
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.cache.auth;
|
||||
package fr.xephi.authme.cache.auth;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -1,13 +1,5 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package uk.org.whoami.authme.cache.backup;
|
||||
package fr.xephi.authme.cache.backup;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stefano
|
||||
*/
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class DataFileCache {
|
@ -1,13 +1,5 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package uk.org.whoami.authme.cache.backup;
|
||||
package fr.xephi.authme.cache.backup;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stefano
|
||||
*/
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
||||
@ -15,6 +7,8 @@ import java.util.Scanner;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import fr.xephi.authme.api.API;
|
||||
|
||||
public class FileCache {
|
||||
|
||||
public FileCache() {
|
||||
@ -45,8 +39,8 @@ public class FileCache {
|
||||
|
||||
// line format Group|OperatorStatus|isFlying
|
||||
if(flying)
|
||||
writer.write(s+";1\r\n");
|
||||
else writer.write(s+";0\r\n");
|
||||
writer.write(s+";1" + API.newline);
|
||||
else writer.write(s+";0" + API.newline);
|
||||
writer.flush();
|
||||
|
||||
ItemStack[] invstack = playerData.getInventory();
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.cache.limbo;
|
||||
package fr.xephi.authme.cache.limbo;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -23,17 +7,18 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.cache.backup.FileCache;
|
||||
import uk.org.whoami.authme.events.ResetInventoryEvent;
|
||||
import uk.org.whoami.authme.events.StoreInventoryEvent;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import uk.org.whoami.authme.settings.Spawn;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.events.ResetInventoryEvent;
|
||||
import fr.xephi.authme.events.StoreInventoryEvent;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class LimboCache {
|
||||
|
||||
private static LimboCache singleton = null;
|
||||
private HashMap<String, LimboPlayer> cache;
|
||||
public HashMap<String, LimboPlayer> cache;
|
||||
private FileCache playerData = new FileCache();
|
||||
public AuthMe plugin;
|
||||
|
||||
@ -88,21 +73,14 @@ public class LimboCache {
|
||||
ResetInventoryEvent event = new ResetInventoryEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
API.setPlayerInventory(player, new ItemStack[36], new ItemStack[4]);
|
||||
player.sendMessage("Your inventory has been cleaned!");
|
||||
}
|
||||
}
|
||||
gameMode = 0;
|
||||
}
|
||||
if(player.isDead()) {
|
||||
loc = player.getWorld().getSpawnLocation();
|
||||
if (plugin.mv != null)
|
||||
{
|
||||
try {
|
||||
loc = plugin.mv.getMVWorldManager().getMVWorld(player.getWorld().getName()).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {}
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null)
|
||||
loc = Spawn.getInstance().getLocation();
|
||||
loc = plugin.getSpawnLocation(player.getWorld());
|
||||
}
|
||||
try {
|
||||
if(cache.containsKey(name) && playerGroup.isEmpty()) {
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.cache.limbo;
|
||||
package fr.xephi.authme.cache.limbo;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -73,6 +57,14 @@ public class LimboPlayer {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public void setArmour(ItemStack[] armour) {
|
||||
this.armour = armour;
|
||||
}
|
||||
|
||||
public void setInventory(ItemStack[] inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
public int getGameMode() {
|
||||
return gameMode;
|
||||
}
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.commands;
|
||||
package fr.xephi.authme.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -38,21 +22,22 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.converter.FlatToSql;
|
||||
import uk.org.whoami.authme.converter.FlatToSqlite;
|
||||
import uk.org.whoami.authme.converter.RakamakConverter;
|
||||
import uk.org.whoami.authme.converter.xAuthToFlat;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import uk.org.whoami.authme.settings.Spawn;
|
||||
import uk.org.whoami.authme.settings.SpoutCfg;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.converter.FlatToSql;
|
||||
import fr.xephi.authme.converter.FlatToSqlite;
|
||||
import fr.xephi.authme.converter.RakamakConverter;
|
||||
import fr.xephi.authme.converter.xAuthToFlat;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import fr.xephi.authme.settings.SpoutCfg;
|
||||
|
||||
|
||||
public class AdminCommand implements CommandExecutor {
|
||||
|
||||
@ -76,12 +61,17 @@ public class AdminCommand implements CommandExecutor {
|
||||
sender.sendMessage("/authme purge <days> - Purge Database");
|
||||
sender.sendMessage("/authme version - Get AuthMe version infos");
|
||||
sender.sendMessage("/authme lastlogin <playername> - Display Date about the Player's LastLogin");
|
||||
sender.sendMessage("/authme accounts <playername> - Display all player's accounts");
|
||||
sender.sendMessage("/authme setSpawn - Set AuthMe spawn to your current pos");
|
||||
sender.sendMessage("/authme spawn - Teleport you to the AuthMe SpawnPoint");
|
||||
sender.sendMessage("/authme chgemail <playername> <email> - Change player email");
|
||||
sender.sendMessage("/authme getemail <playername> - Get player email");
|
||||
return true;
|
||||
}
|
||||
|
||||
if((sender instanceof ConsoleCommandSender) && args[0].equalsIgnoreCase("passpartuToken")) {
|
||||
if(args.length > 1) {
|
||||
System.out.println("[AuthMe] command usage: authme passpartuToken");
|
||||
System.out.println("[AuthMe] command usage: /authme passpartuToken");
|
||||
return true;
|
||||
}
|
||||
if(Utils.getInstance().obtainToken()) {
|
||||
@ -146,8 +136,8 @@ public class AdminCommand implements CommandExecutor {
|
||||
}
|
||||
YamlConfiguration newConfig = YamlConfiguration.loadConfiguration(newConfigFile);
|
||||
Settings.reloadConfigOptions(newConfig);
|
||||
m.reload();
|
||||
s.reload();
|
||||
m.reLoad();
|
||||
s.reLoad();
|
||||
sender.sendMessage(m._("reload"));
|
||||
} else if (args[0].equalsIgnoreCase("lastlogin")) {
|
||||
if (args.length != 2) {
|
||||
@ -165,9 +155,13 @@ public class AdminCommand implements CommandExecutor {
|
||||
sender.sendMessage("[AuthMe] " + args[1].toLowerCase() + " lastlogin : " + d.toString());
|
||||
sender.sendMessage("[AuthMe] The player : " + player.getNickname() + " is unlogged since " + msg);
|
||||
sender.sendMessage("[AuthMe] LastPlayer IP : " + lastIP);
|
||||
} else {
|
||||
sender.sendMessage("This player does not exist");
|
||||
return true;
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
sender.sendMessage("This player does not exist");
|
||||
return true;
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("accounts")) {
|
||||
if (args.length != 2) {
|
||||
@ -268,10 +262,12 @@ public class AdminCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0);
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||
if (!database.saveAuth(auth)) {
|
||||
sender.sendMessage(m._("error"));
|
||||
return true;
|
||||
}
|
||||
database.updateSalt(auth);
|
||||
sender.sendMessage(m._("registered"));
|
||||
ConsoleLogger.info(args[1] + " registered");
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
@ -311,7 +307,11 @@ public class AdminCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
String playername = args[1].toLowerCase();
|
||||
PlayerAuth getAuth = PlayerCache.getInstance().getAuth(playername);
|
||||
PlayerAuth getAuth = database.getAuth(playername);
|
||||
if (getAuth == null) {
|
||||
sender.sendMessage("This player does not exist");
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage("[AuthMe] " + args[1] + " email : " + getAuth.getEmail());
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("chgemail")) {
|
||||
@ -320,13 +320,18 @@ public class AdminCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
String playername = args[1].toLowerCase();
|
||||
PlayerAuth getAuth = PlayerCache.getInstance().getAuth(playername);
|
||||
PlayerAuth getAuth = database.getAuth(playername);
|
||||
if (getAuth == null) {
|
||||
sender.sendMessage("This player does not exist");
|
||||
return true;
|
||||
}
|
||||
getAuth.setEmail(args[2]);
|
||||
if (!database.updateEmail(getAuth)) {
|
||||
sender.sendMessage(m._("error"));
|
||||
return true;
|
||||
}
|
||||
PlayerCache.getInstance().updatePlayer(getAuth);
|
||||
if (PlayerCache.getInstance().getAuth(playername) != null)
|
||||
PlayerCache.getInstance().updatePlayer(getAuth);
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("convertfromrakamak")) {
|
||||
try {
|
||||
@ -396,10 +401,12 @@ public class AdminCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
auth.setHash(hash);
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||
if (!database.updatePassword(auth)) {
|
||||
sender.sendMessage(m._("error"));
|
||||
return true;
|
||||
}
|
||||
database.updateSalt(auth);
|
||||
sender.sendMessage("pwd_changed");
|
||||
ConsoleLogger.info(args[1] + "'s password changed");
|
||||
} catch (NoSuchAlgorithmException ex) {
|
@ -1,15 +1,16 @@
|
||||
package uk.org.whoami.authme.commands;
|
||||
package fr.xephi.authme.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.security.RandomString;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class CaptchaCommand implements CommandExecutor {
|
||||
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.commands;
|
||||
package fr.xephi.authme.commands;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@ -25,14 +9,15 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
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 fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class ChangePasswordCommand implements CommandExecutor {
|
||||
|
||||
@ -74,10 +59,12 @@ public class ChangePasswordCommand implements CommandExecutor {
|
||||
if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache.getInstance().getAuth(name).getHash(), name)) {
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
auth.setHash(hashnew);
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||
if (!database.updatePassword(auth)) {
|
||||
player.sendMessage(m._("error"));
|
||||
return true;
|
||||
}
|
||||
database.updateSalt(auth);
|
||||
PlayerCache.getInstance().updatePlayer(auth);
|
||||
player.sendMessage(m._("pwd_changed"));
|
||||
ConsoleLogger.info(player.getName() + " changed his password");
|
@ -1,19 +1,4 @@
|
||||
/*
|
||||
* Copyright 2012 darkwarriors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package uk.org.whoami.authme.commands;
|
||||
package fr.xephi.authme.commands;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@ -22,15 +7,16 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.security.RandomString;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
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 fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -75,7 +61,7 @@ public class EmailCommand implements CommandExecutor {
|
||||
}
|
||||
if(args[1].equals(args[2]) && PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
if (auth.getEmail() == null || !auth.getEmail().contains("your@email.com")) {
|
||||
if (auth.getEmail() == null || (!auth.getEmail().equals("your@email.com") && !auth.getEmail().isEmpty())) {
|
||||
player.sendMessage("usage_email_change");
|
||||
return true;
|
||||
}
|
||||
@ -103,7 +89,7 @@ public class EmailCommand implements CommandExecutor {
|
||||
} else if(args[0].equalsIgnoreCase("change") && args.length == 3 ) {
|
||||
if(PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
if (auth.getEmail() == null || auth.getEmail().equals("your@email.com")) {
|
||||
if (auth.getEmail() == null || auth.getEmail().equals("your@email.com") || auth.getEmail().isEmpty()) {
|
||||
player.sendMessage(m._("usage_email_add"));
|
||||
return true;
|
||||
}
|
||||
@ -140,7 +126,6 @@ public class EmailCommand implements CommandExecutor {
|
||||
}
|
||||
if (plugin.mail == null) {
|
||||
player.sendMessage(m._("error"));
|
||||
ConsoleLogger.info("Missed mail.jar in lib folder");
|
||||
return true;
|
||||
}
|
||||
if (data.isAuthAvailable(name)) {
|
@ -1,28 +1,13 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.commands;
|
||||
package fr.xephi.authme.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
|
||||
|
||||
public class LoginCommand implements CommandExecutor {
|
||||
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.commands;
|
||||
package fr.xephi.authme.commands;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
|
||||
@ -27,22 +11,23 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.cache.backup.DataFileCache;
|
||||
import uk.org.whoami.authme.cache.backup.FileCache;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboCache;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.events.AuthMeTeleportEvent;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.PlayersLogs;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import uk.org.whoami.authme.settings.Spawn;
|
||||
import uk.org.whoami.authme.task.MessageTask;
|
||||
import uk.org.whoami.authme.task.TimeoutTask;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.backup.DataFileCache;
|
||||
import fr.xephi.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
|
||||
|
||||
public class LogoutCommand implements CommandExecutor {
|
||||
|
||||
@ -119,10 +104,12 @@ public class LogoutCommand implements CommandExecutor {
|
||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, m._("login_msg"), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT.getTaskId());
|
||||
try {
|
||||
if (PlayersLogs.players.contains(player.getName())) {
|
||||
PlayersLogs.players.remove(player.getName());
|
||||
pllog.save();
|
||||
}
|
||||
if (PlayersLogs.players.contains(player.getName())) {
|
||||
PlayersLogs.players.remove(player.getName());
|
||||
pllog.save();
|
||||
}
|
||||
if (player.isInsideVehicle())
|
||||
player.getVehicle().eject();
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
player.sendMessage(m._("logout"));
|
@ -1,18 +1,15 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package uk.org.whoami.authme.commands;
|
||||
package fr.xephi.authme.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@ -30,7 +27,7 @@ public class PasspartuCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmnd, String label, String[] args) {
|
||||
|
||||
if (!plugin.authmePermissible(sender, "authme.admin." + args[0].toLowerCase())) {
|
||||
if (!plugin.authmePermissible(sender, "authme." + label.toLowerCase())) {
|
||||
sender.sendMessage(m._("no_perm"));
|
||||
return true;
|
||||
}
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.commands;
|
||||
package fr.xephi.authme.commands;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Date;
|
||||
@ -31,23 +15,23 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboCache;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboPlayer;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.events.RegisterTeleportEvent;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.security.RandomString;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.PlayersLogs;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import uk.org.whoami.authme.settings.Spawn;
|
||||
import uk.org.whoami.authme.task.MessageTask;
|
||||
import uk.org.whoami.authme.task.TimeoutTask;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.RegisterTeleportEvent;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
|
||||
|
||||
public class RegisterCommand implements CommandExecutor {
|
||||
|
||||
@ -185,20 +169,7 @@ public class RegisterCommand implements CommandExecutor {
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
World world = player.getWorld();
|
||||
Location loca = world.getSpawnLocation();
|
||||
if (plugin.mv != null) {
|
||||
try {
|
||||
loca = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (ClassCastException cce) {
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
}
|
||||
}
|
||||
if (plugin.essentialsSpawn != null) {
|
||||
loca = plugin.essentialsSpawn;
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null)
|
||||
loca = Spawn.getInstance().getLocation();
|
||||
Location loca = plugin.getSpawnLocation(world);
|
||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
@ -209,6 +180,10 @@ public class RegisterCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
this.isFirstTimeJoin = true;
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
}
|
||||
player.saveData();
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " registered "+player.getAddress().getAddress().getHostAddress());
|
||||
@ -255,23 +230,7 @@ public class RegisterCommand implements CommandExecutor {
|
||||
player.setGameMode(GameMode.getByValue(limbo.getGameMode()));
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
World world = player.getWorld();
|
||||
Location loca = world.getSpawnLocation();
|
||||
if (plugin.mv != null) {
|
||||
try {
|
||||
loca = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
|
||||
} catch (ClassCastException cce) {
|
||||
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
|
||||
}
|
||||
}
|
||||
if (plugin.essentialsSpawn != null) {
|
||||
loca = plugin.essentialsSpawn;
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null)
|
||||
loca = Spawn.getInstance().getLocation();
|
||||
Location loca = plugin.getSpawnLocation(world);
|
||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
@ -293,6 +252,10 @@ public class RegisterCommand implements CommandExecutor {
|
||||
if (!Settings.getmailAccount.isEmpty())
|
||||
player.sendMessage(m._("add_email"));
|
||||
this.isFirstTimeJoin = true;
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
}
|
||||
player.saveData();
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " registered "+player.getAddress().getAddress().getHostAddress());
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.commands;
|
||||
package fr.xephi.authme.commands;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@ -29,21 +13,21 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.cache.backup.FileCache;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboCache;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.events.SpawnTeleportEvent;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.PlayersLogs;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import uk.org.whoami.authme.settings.Spawn;
|
||||
import uk.org.whoami.authme.task.MessageTask;
|
||||
import uk.org.whoami.authme.task.TimeoutTask;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
|
||||
|
||||
public class UnregisterCommand implements CommandExecutor {
|
||||
|
||||
@ -129,20 +113,7 @@ public class UnregisterCommand implements CommandExecutor {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
|
||||
}
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
Location spawn = player.getWorld().getSpawnLocation();
|
||||
if (plugin.mv != null) {
|
||||
try {
|
||||
spawn = plugin.mv.getMVWorldManager().getMVWorld(player.getWorld()).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (ClassCastException cce) {
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
}
|
||||
}
|
||||
if (plugin.essentialsSpawn != null) {
|
||||
spawn = plugin.essentialsSpawn;
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null)
|
||||
spawn = Spawn.getInstance().getLocation();
|
||||
Location spawn = plugin.getSpawnLocation(player.getWorld());
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.converter;
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
@ -8,9 +8,10 @@ import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
/**
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.converter;
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -12,9 +12,10 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class FlatToSqlite {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.converter;
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
@ -11,11 +11,12 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity.HashAlgorithm;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
/**
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.converter;
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
@ -14,9 +14,10 @@ import com.cypherx.xauth.xAuth;
|
||||
import com.cypherx.xauth.database.Table;
|
||||
import com.cypherx.xauth.utils.xAuthLog;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
|
||||
|
||||
/**
|
||||
*
|
@ -1,29 +1,14 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.datasource;
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
|
||||
|
||||
public class CacheDataSource implements DataSource {
|
||||
|
||||
@ -110,6 +95,19 @@ public class CacheDataSource implements DataSource {
|
||||
return cleared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoPurgeDatabase(long until) {
|
||||
List<String> cleared = source.autoPurgeDatabase(until);
|
||||
if (cleared.size() > 0) {
|
||||
for (PlayerAuth auth : cache.values()) {
|
||||
if(auth.getLastLogin() < until) {
|
||||
cache.remove(auth.getNickname());
|
||||
}
|
||||
}
|
||||
}
|
||||
return cleared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
if (source.removeAuth(user)) {
|
||||
@ -141,7 +139,7 @@ public class CacheDataSource implements DataSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
public synchronized boolean updateEmail(PlayerAuth auth) {
|
||||
if(source.updateEmail(auth)) {
|
||||
cache.get(auth.getNickname()).setEmail(auth.getEmail());
|
||||
return true;
|
||||
@ -150,7 +148,7 @@ public class CacheDataSource implements DataSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateSalt(PlayerAuth auth) {
|
||||
public synchronized boolean updateSalt(PlayerAuth auth) {
|
||||
if(source.updateSalt(auth)) {
|
||||
cache.get(auth.getNickname()).setSalt(auth.getSalt());
|
||||
return true;
|
||||
@ -159,22 +157,22 @@ public class CacheDataSource implements DataSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
return source.getAllAuthsByName(auth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByIp(String ip) {
|
||||
public synchronized List<String> getAllAuthsByIp(String ip) {
|
||||
return source.getAllAuthsByIp(ip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
public synchronized List<String> getAllAuthsByEmail(String email) {
|
||||
return source.getAllAuthsByEmail(email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeBanned(List<String> banned) {
|
||||
public synchronized void purgeBanned(List<String> banned) {
|
||||
source.purgeBanned(banned);
|
||||
for (PlayerAuth auth : cache.values()) {
|
||||
if (banned.contains(auth.getNickname())) {
|
@ -1,24 +1,9 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.datasource;
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
|
||||
|
||||
public interface DataSource {
|
||||
|
||||
@ -39,6 +24,8 @@ public interface DataSource {
|
||||
|
||||
int purgeDatabase(long until);
|
||||
|
||||
List<String> autoPurgeDatabase(long until);
|
||||
|
||||
boolean removeAuth(String user);
|
||||
|
||||
boolean updateQuitLoc(PlayerAuth auth);
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.datasource;
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
@ -26,17 +10,19 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class FileDataSource implements DataSource {
|
||||
|
||||
/* file layout:
|
||||
*
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:COORDS
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:LASTPOSX:LASTPOSY:LASTPOSZ:LASTPOSWORLD
|
||||
*
|
||||
* Old but compatible:
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS
|
||||
* PLAYERNAME:HASHSUM:IP
|
||||
* PLAYERNAME:HASHSUM
|
||||
*
|
||||
@ -84,13 +70,8 @@ public class FileDataSource implements DataSource {
|
||||
}
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
if( auth.getQuitLocY() == 0 ) {
|
||||
bw = new BufferedWriter(new FileWriter(source, true));
|
||||
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + "\n");
|
||||
} else {
|
||||
bw = new BufferedWriter(new FileWriter(source, true));
|
||||
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + ":" + auth.getWorld() + "\n");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
@ -118,7 +99,24 @@ public class FileDataSource implements DataSource {
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]));
|
||||
switch (args.length) {
|
||||
case 4: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), 0, 0, 0, "world");
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world");
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7]);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], 0, 0, 0, 0, "world");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -154,7 +152,24 @@ public class FileDataSource implements DataSource {
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin());
|
||||
switch (args.length) {
|
||||
case 4: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world");
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world");
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7]);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -254,7 +269,7 @@ public class FileDataSource implements DataSource {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args.length == 4) {
|
||||
if (args.length >= 4) {
|
||||
if (Long.parseLong(args[3]) >= until) {
|
||||
lines.add(line);
|
||||
continue;
|
||||
@ -289,6 +304,54 @@ public class FileDataSource implements DataSource {
|
||||
return cleared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoPurgeDatabase(long until) {
|
||||
BufferedReader br = null;
|
||||
BufferedWriter bw = null;
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
List<String> cleared = new ArrayList<String>();
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(source));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args.length >= 4) {
|
||||
if (Long.parseLong(args[3]) >= until) {
|
||||
lines.add(line);
|
||||
continue;
|
||||
} else {
|
||||
cleared.add(args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
bw = new BufferedWriter(new FileWriter(source));
|
||||
for (String l : lines) {
|
||||
bw.write(l + "\n");
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return cleared;
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return cleared;
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return cleared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
if (!isAuthAvailable(user)) {
|
@ -11,7 +11,7 @@
|
||||
// Please contact the author if you need another license.
|
||||
// This module is provided "as is", without warranties of any kind.
|
||||
|
||||
package uk.org.whoami.authme.datasource;
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Connection;
|
@ -1,23 +1,14 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.datasource;
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@ -26,11 +17,6 @@ import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
public class MySQLDataSource implements DataSource {
|
||||
|
||||
@ -247,6 +233,104 @@ public class MySQLDataSource implements DataSource {
|
||||
pst.executeUpdate();
|
||||
}
|
||||
}
|
||||
if (Settings.getPasswordHash == HashAlgorithm.PHPBB) {
|
||||
int id;
|
||||
ResultSet rs = null;
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
|
||||
pst.setString(1, auth.getNickname());
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next()) {
|
||||
id = rs.getInt(columnID);
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getPhpbbPrefix + "user_group (group_id, user_id, group_leader, user_pending) VALUES (?,?,?,?);");
|
||||
pst.setInt(1, Settings.getPhpbbGroup);
|
||||
pst.setInt(2, id);
|
||||
pst.setInt(3, 0);
|
||||
pst.setInt(4, 0);
|
||||
pst.executeUpdate();
|
||||
}
|
||||
}
|
||||
if (Settings.getPasswordHash == HashAlgorithm.WORDPRESS) {
|
||||
int id;
|
||||
ResultSet rs = null;
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
|
||||
pst.setString(1, auth.getNickname());
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next()) {
|
||||
id = rs.getInt(columnID);
|
||||
// First Name
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "first_name");
|
||||
pst.setString(3, "");
|
||||
pst.executeUpdate();
|
||||
// Last Name
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "last_name");
|
||||
pst.setString(3, "");
|
||||
pst.executeUpdate();
|
||||
// Nick Name
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "nickname");
|
||||
pst.setString(3, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
// Description
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "description");
|
||||
pst.setString(3, "");
|
||||
pst.executeUpdate();
|
||||
// Rich_Editing
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "rich_editing");
|
||||
pst.setString(3, "true");
|
||||
pst.executeUpdate();
|
||||
// Comments_Shortcuts
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "comment_shortcuts");
|
||||
pst.setString(3, "false");
|
||||
pst.executeUpdate();
|
||||
// admin_color
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "admin_color");
|
||||
pst.setString(3, "fresh");
|
||||
pst.executeUpdate();
|
||||
// use_ssl
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "use_ssl");
|
||||
pst.setString(3, "0");
|
||||
pst.executeUpdate();
|
||||
// show_admin_bar_front
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "show_admin_bar_front");
|
||||
pst.setString(3, "true");
|
||||
pst.executeUpdate();
|
||||
// wp_capabilities
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "wp_capabilities");
|
||||
pst.setString(3, "a:1:{s:10:\"subscriber\";b:1;}");
|
||||
pst.executeUpdate();
|
||||
// wp_user_level
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "wp_user_level");
|
||||
pst.setString(3, "0");
|
||||
pst.executeUpdate();
|
||||
// default_password_nag
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
|
||||
pst.setInt(1, id);
|
||||
pst.setString(2, "default_password_nag");
|
||||
pst.setString(3, "");
|
||||
pst.executeUpdate();
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
@ -328,6 +412,34 @@ public class MySQLDataSource implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<String> autoPurgeDatabase(long until) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
List<String> list = new ArrayList<String>();
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
||||
pst.setLong(1, until);
|
||||
rs = pst.executeQuery();
|
||||
while (rs.next()) {
|
||||
list.add(rs.getString(columnName));
|
||||
}
|
||||
return list;
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
Connection con = null;
|
||||
@ -430,7 +542,7 @@ public class MySQLDataSource implements DataSource {
|
||||
|
||||
@Override
|
||||
public synchronized boolean updateSalt(PlayerAuth auth) {
|
||||
if (columnSalt.isEmpty()) {
|
||||
if (columnSalt.isEmpty() || auth.getSalt() == null || auth.getSalt().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Connection con = null;
|
||||
@ -654,4 +766,5 @@ public class MySQLDataSource implements DataSource {
|
||||
conPool = new MiniConnectionPoolManager(dataSource, 10);
|
||||
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
package uk.org.whoami.authme.datasource;
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.sqlite.*;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -103,7 +104,7 @@ public class SqliteDataSource implements DataSource {
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, lastlocWorld);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT 'world' AFTER " + lastlocZ + ";");
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT 'world';");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
|
||||
@ -246,6 +247,28 @@ public class SqliteDataSource implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoPurgeDatabase(long until) {
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
List<String> list = new ArrayList<String>();
|
||||
try {
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
||||
pst.setLong(1, until);
|
||||
rs = pst.executeQuery();
|
||||
while (rs.next()) {
|
||||
list.add(rs.getString(columnName));
|
||||
}
|
||||
return list;
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
PreparedStatement pst = null;
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.events;
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
@ -1,6 +1,7 @@
|
||||
package uk.org.whoami.authme.events;
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -8,7 +9,7 @@ import org.bukkit.event.HandlerList;
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class CustomEvent extends Event {
|
||||
public class CustomEvent extends Event implements Cancellable {
|
||||
|
||||
private boolean isCancelled;
|
||||
private static final HandlerList handlers = new HandlerList();
|
@ -1,15 +1,18 @@
|
||||
package uk.org.whoami.authme.events;
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class LoginEvent extends UncancellableEvent {
|
||||
public class LoginEvent extends Event {
|
||||
|
||||
private Player player;
|
||||
private boolean isLogin;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public LoginEvent(Player player, boolean isLogin) {
|
||||
this.player = player;
|
||||
@ -24,6 +27,7 @@ public class LoginEvent extends UncancellableEvent {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setLogin(boolean isLogin) {
|
||||
this.isLogin = isLogin;
|
||||
}
|
||||
@ -32,4 +36,9 @@ public class LoginEvent extends UncancellableEvent {
|
||||
return isLogin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||
|
||||
/**
|
||||
* <p>This event is called when we need to compare or get an hash password,
|
||||
* for set a custom EncryptionMethod</p>
|
||||
*
|
||||
* @see fr.xephi.authme.security.crypts.EncryptionMethod
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class PasswordEncryptionEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private EncryptionMethod method = null;
|
||||
private String playerName = "";
|
||||
|
||||
public PasswordEncryptionEvent(EncryptionMethod method, String playerName) {
|
||||
this.method = method;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public void setMethod(EncryptionMethod method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public EncryptionMethod getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
package uk.org.whoami.authme.events;
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import uk.org.whoami.authme.api.API;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
@ -21,15 +19,8 @@ public class ProtectInventoryEvent extends CustomEvent {
|
||||
this.player = player;
|
||||
this.storedinventory = storedinventory;
|
||||
this.storedarmor = storedarmor;
|
||||
}
|
||||
|
||||
public ProtectInventoryEvent(Player player, ItemStack[] storedinventory, ItemStack[] storedarmor, int newInventory, int newArmor) {
|
||||
this.player = player;
|
||||
this.storedinventory = storedinventory;
|
||||
this.storedarmor = storedarmor;
|
||||
this.setNewInventory(new ItemStack[newInventory]);
|
||||
this.setNewArmor(new ItemStack[newArmor]);
|
||||
API.setPlayerInventory(player, new ItemStack[newInventory], new ItemStack[newArmor]);
|
||||
this.emptyInventory = new ItemStack[36];
|
||||
this.emptyArmor = new ItemStack[4];
|
||||
}
|
||||
|
||||
public ItemStack[] getStoredInventory() {
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.events;
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
@ -1,9 +1,6 @@
|
||||
package uk.org.whoami.authme.events;
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import uk.org.whoami.authme.api.API;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -15,7 +12,6 @@ public class ResetInventoryEvent extends CustomEvent {
|
||||
|
||||
public ResetInventoryEvent(Player player) {
|
||||
this.player = player;
|
||||
API.setPlayerInventory(player, new ItemStack[36], new ItemStack[4]);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.events;
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
@ -1,6 +1,6 @@
|
||||
package uk.org.whoami.authme.events;
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
|
||||
/**
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.events;
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
@ -1,9 +1,10 @@
|
||||
package uk.org.whoami.authme.events;
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import uk.org.whoami.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.cache.backup.FileCache;
|
||||
|
||||
|
||||
/**
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.gui;
|
||||
package fr.xephi.authme.gui;
|
||||
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.gui;
|
||||
package fr.xephi.authme.gui;
|
||||
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
@ -1,8 +1,5 @@
|
||||
package uk.org.whoami.authme.gui.screens;
|
||||
package fr.xephi.authme.gui.screens;
|
||||
|
||||
/**
|
||||
* @Author Hoezef
|
||||
*/
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -18,10 +15,11 @@ import org.getspout.spoutapi.gui.Widget;
|
||||
import org.getspout.spoutapi.gui.WidgetAnchor;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.gui.Clickable;
|
||||
import uk.org.whoami.authme.gui.CustomButton;
|
||||
import uk.org.whoami.authme.settings.SpoutCfg;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.gui.Clickable;
|
||||
import fr.xephi.authme.gui.CustomButton;
|
||||
import fr.xephi.authme.settings.SpoutCfg;
|
||||
|
||||
|
||||
public class LoginScreen extends GenericPopup implements Clickable{
|
||||
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.listener;
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -22,11 +6,12 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class AuthMeBlockListener implements Listener {
|
||||
|
@ -0,0 +1,53 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class AuthMeBungeeCordListener implements Listener {
|
||||
private DataSource data;
|
||||
|
||||
public AuthMeBungeeCordListener(DataSource data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onBungeeChatEvent(ChatEvent event) {
|
||||
if (!Settings.bungee) return;
|
||||
if (event.isCancelled()) return;
|
||||
if (!event.isCommand()) return;
|
||||
Player player = null;
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getAddress().getAddress().equals(event.getReceiver().getAddress().getAddress())) {
|
||||
player = p;
|
||||
}
|
||||
}
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.isAuthAvailable(name)) {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
event.setMessage("/unreacheablecommand");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.listener;
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -8,11 +8,12 @@ import org.bukkit.event.Listener;
|
||||
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
|
||||
import com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class AuthMeChestShopListener implements Listener {
|
||||
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.listener;
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -27,12 +11,13 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.plugin.manager.CombatTagComunicator;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.plugin.manager.CombatTagComunicator;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class AuthMeEntityListener implements Listener{
|
||||
|
||||
@ -59,6 +44,9 @@ public class AuthMeEntityListener implements Listener{
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance.citizens.isNPC(entity, instance))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
@ -89,6 +77,9 @@ public class AuthMeEntityListener implements Listener{
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance.citizens.isNPC(entity, instance))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
@ -116,6 +107,9 @@ public class AuthMeEntityListener implements Listener{
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance.citizens.isNPC(entity, instance))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
@ -144,6 +138,9 @@ public class AuthMeEntityListener implements Listener{
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance.citizens.isNPC(entity, instance))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
@ -177,6 +174,9 @@ public class AuthMeEntityListener implements Listener{
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance.citizens.isNPC(player, instance))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
@ -206,6 +206,9 @@ public class AuthMeEntityListener implements Listener{
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance.citizens.isNPC(player, instance))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
return;
|
||||
}
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.listener;
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -53,29 +37,29 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.api.API;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.cache.backup.DataFileCache;
|
||||
import uk.org.whoami.authme.cache.backup.FileCache;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboCache;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboPlayer;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.events.AuthMeTeleportEvent;
|
||||
import uk.org.whoami.authme.events.ProtectInventoryEvent;
|
||||
import uk.org.whoami.authme.events.RestoreInventoryEvent;
|
||||
import uk.org.whoami.authme.events.SessionEvent;
|
||||
import uk.org.whoami.authme.events.SpawnTeleportEvent;
|
||||
import uk.org.whoami.authme.plugin.manager.CombatTagComunicator;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.PlayersLogs;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import uk.org.whoami.authme.settings.Spawn;
|
||||
import uk.org.whoami.authme.task.MessageTask;
|
||||
import uk.org.whoami.authme.task.TimeoutTask;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.backup.DataFileCache;
|
||||
import fr.xephi.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
||||
import fr.xephi.authme.events.SessionEvent;
|
||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||
import fr.xephi.authme.plugin.manager.CombatTagComunicator;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
|
||||
|
||||
public class AuthMePlayerListener implements Listener {
|
||||
|
||||
@ -143,327 +127,208 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
return;
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (Settings.isForcedRegistrationEnabled) {
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler( priority = EventPriority.HIGH)
|
||||
public void onPlayerHighChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
if (event.isCancelled() || event.getPlayer() == null)
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
if (Utils.getInstance().isUnrestricted(player))
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
return;
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (Settings.isForcedRegistrationEnabled) {
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler( priority = EventPriority.MONITOR)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
if (event.isCancelled() || event.getPlayer() == null)
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
if (Utils.getInstance().isUnrestricted(player))
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
return;
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (Settings.isForcedRegistrationEnabled) {
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler( priority = EventPriority.HIGHEST)
|
||||
public void onPlayerHighestChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
if (event.isCancelled() || event.getPlayer() == null)
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
if (Utils.getInstance().isUnrestricted(player))
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
return;
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (Settings.isForcedRegistrationEnabled) {
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler( priority = EventPriority.LOWEST)
|
||||
public void onPlayerEarlyChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
if (event.isCancelled() || event.getPlayer() == null)
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
if (Utils.getInstance().isUnrestricted(player))
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
return;
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (Settings.isForcedRegistrationEnabled) {
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler( priority = EventPriority.LOW)
|
||||
public void onPlayerLowChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
if (event.isCancelled() || event.getPlayer() == null)
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
if (Utils.getInstance().isUnrestricted(player))
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
} else {
|
||||
if (Settings.isForcedRegistrationEnabled) {
|
||||
if (Settings.emailRegistration) {
|
||||
player.sendMessage(m._("reg_email_msg"));
|
||||
} else {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@ -497,20 +362,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
|
||||
int radius = Settings.getMovementRadius;
|
||||
Location spawn = player.getWorld().getSpawnLocation();
|
||||
if (plugin.mv != null) {
|
||||
try {
|
||||
spawn = plugin.mv.getMVWorldManager().getMVWorld(player.getWorld()).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (ClassCastException cce) {
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
}
|
||||
}
|
||||
if (plugin.essentialsSpawn != null) {
|
||||
spawn = plugin.essentialsSpawn;
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null && Spawn.getInstance().getLocation().getWorld().equals(player.getWorld()))
|
||||
spawn = Spawn.getInstance().getLocation();
|
||||
Location spawn = plugin.getSpawnLocation(player.getWorld());
|
||||
|
||||
if (!event.getPlayer().getWorld().equals(spawn.getWorld())) {
|
||||
event.getPlayer().teleport(spawn);
|
||||
@ -653,20 +505,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
World world = player.getWorld();
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
if (plugin.mv != null) {
|
||||
try {
|
||||
spawnLoc = plugin.mv.getMVWorldManager().getMVWorld(player.getWorld()).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (ClassCastException cce) {
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
}
|
||||
}
|
||||
if (plugin.essentialsSpawn != null) {
|
||||
spawnLoc = plugin.essentialsSpawn;
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null)
|
||||
spawnLoc = Spawn.getInstance().getLocation();
|
||||
Location spawnLoc = plugin.getSpawnLocation(world);
|
||||
gm = player.getGameMode().getValue();
|
||||
final String name = player.getName().toLowerCase();
|
||||
gameMode.put(name, gm);
|
||||
@ -739,9 +578,20 @@ public class AuthMePlayerListener implements Listener {
|
||||
// isent in session or session was ended correctly
|
||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin)
|
||||
e.getPlayer().setGameMode(GameMode.SURVIVAL);
|
||||
LimboCache.getInstance().updateLimboPlayer(player);
|
||||
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(),LimboCache.getInstance().getLimboPlayer(name).getArmour());
|
||||
playerBackup.createCache(name, dataFile, LimboCache.getInstance().getLimboPlayer(name).getGroup(),LimboCache.getInstance().getLimboPlayer(name).getOperator(),LimboCache.getInstance().getLimboPlayer(name).isFlying());
|
||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
placePlayerSafely(player, spawnLoc);
|
||||
LimboCache.getInstance().updateLimboPlayer(player);
|
||||
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(),LimboCache.getInstance().getLimboPlayer(name).getArmour());
|
||||
playerBackup.createCache(name, dataFile, LimboCache.getInstance().getLimboPlayer(name).getGroup(),LimboCache.getInstance().getLimboPlayer(name).getOperator(),LimboCache.getInstance().getLimboPlayer(name).isFlying());
|
||||
} else {
|
||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin)
|
||||
e.getPlayer().setGameMode(GameMode.SURVIVAL);
|
||||
@ -752,30 +602,20 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(Settings.protectInventoryBeforeLogInEnabled) {
|
||||
try {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||
ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour(), 36, 4);
|
||||
ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
|
||||
plugin.getServer().getPluginManager().callEvent(ev);
|
||||
if (ev.isCancelled()) {
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
|
||||
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
|
||||
} else {
|
||||
API.setPlayerInventory(player, ev.getEmptyInventory(), ev.getEmptyArmor());
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
}
|
||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
placePlayerSafely(player, spawnLoc);
|
||||
String msg = "";
|
||||
if(Settings.emailRegistration) {
|
||||
msg = data.isAuthAvailable(name) ? m._("login_msg") : m._("reg_email_msg");
|
||||
@ -794,8 +634,10 @@ public class AuthMePlayerListener implements Listener {
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
if(player.isOp())
|
||||
player.setOp(false);
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
if (!Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}
|
||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT.getTaskId());
|
||||
player.setNoDamageTicks(Settings.getRegistrationTimeout * 20);
|
||||
@ -832,12 +674,12 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
|
||||
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
|
||||
final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(),loc.getBlockX(),loc.getBlockY(),loc.getBlockZ(),loc.getWorld().getName());
|
||||
final PlayerAuth auth = new PlayerAuth(name,loc.getBlockX(),loc.getBlockY(),loc.getBlockZ(),loc.getWorld().getName());
|
||||
try {
|
||||
if (data instanceof Thread) {
|
||||
data.updateQuitLoc(auth);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable(){
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
data.updateQuitLoc(auth);
|
||||
@ -859,9 +701,10 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
utils.addNormal(player, limbo.getGroup());
|
||||
player.setOp(limbo.getOperator());
|
||||
if (player.getGameMode() != GameMode.CREATIVE)
|
||||
player.setAllowFlight(limbo.isFlying());
|
||||
player.setFlying(limbo.isFlying());
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(limbo.isFlying());
|
||||
player.setFlying(limbo.isFlying());
|
||||
}
|
||||
this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if(playerBackup.doesCacheExist(name)) {
|
||||
@ -876,7 +719,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
if (gameMode.containsKey(name)) gameMode.remove(name);
|
||||
plugin.premium.remove(player.getName());
|
||||
player.saveData();
|
||||
}
|
||||
|
||||
@ -907,12 +749,12 @@ public class AuthMePlayerListener implements Listener {
|
||||
String name = player.getName().toLowerCase();
|
||||
if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead()) &&
|
||||
(Settings.isSaveQuitLocationEnabled) && data.isAuthAvailable(name)) {
|
||||
final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(),loc.getWorld().getName());
|
||||
final PlayerAuth auth = new PlayerAuth(name, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(),loc.getWorld().getName());
|
||||
try {
|
||||
if (data instanceof Thread) {
|
||||
data.updateQuitLoc(auth);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable(){
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
data.updateQuitLoc(auth);
|
||||
@ -949,9 +791,10 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
this.utils.addNormal(player, limbo.getGroup());
|
||||
player.setOp(limbo.getOperator());
|
||||
if (player.getGameMode() != GameMode.CREATIVE)
|
||||
player.setAllowFlight(limbo.isFlying());
|
||||
player.setFlying(limbo.isFlying());
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(limbo.isFlying());
|
||||
player.setFlying(limbo.isFlying());
|
||||
}
|
||||
this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (this.playerBackup.doesCacheExist(name)) {
|
||||
@ -965,7 +808,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (gameMode.containsKey(name)) gameMode.remove(name);
|
||||
player.getVehicle().eject();
|
||||
player.saveData();
|
||||
plugin.premium.remove(player.getName());
|
||||
} catch (NullPointerException ex) {}
|
||||
}
|
||||
|
||||
@ -982,6 +824,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
@ -1006,6 +851,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
@ -1032,6 +880,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
@ -1055,6 +906,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
@ -1105,6 +959,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
@ -1174,6 +1031,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
|
||||
return;
|
||||
|
||||
if(plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
|
||||
@ -1184,20 +1044,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (!Settings.isTeleportToSpawnEnabled && !Settings.isForceSpawnLocOnJoinEnabled)
|
||||
return;
|
||||
|
||||
Location spawn = player.getWorld().getSpawnLocation();
|
||||
if (plugin.mv != null) {
|
||||
try {
|
||||
spawn = plugin.mv.getMVWorldManager().getMVWorld(player.getWorld()).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (ClassCastException cce) {
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
}
|
||||
}
|
||||
if (plugin.essentialsSpawn != null) {
|
||||
spawn = plugin.essentialsSpawn;
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null && Spawn.getInstance().getLocation().getWorld().equals(player.getWorld()))
|
||||
spawn = Spawn.getInstance().getLocation();
|
||||
Location spawn = plugin.getSpawnLocation(player.getWorld());
|
||||
event.setRespawnLocation(spawn);
|
||||
}
|
||||
|
@ -1,18 +1,13 @@
|
||||
package uk.org.whoami.authme.listener;
|
||||
|
||||
/**
|
||||
* @Author Hoezef
|
||||
*/
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||
|
||||
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.gui.screens.LoginScreen;
|
||||
import uk.org.whoami.authme.settings.SpoutCfg;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.gui.screens.LoginScreen;
|
||||
import fr.xephi.authme.settings.SpoutCfg;
|
||||
|
||||
public class AuthMeSpoutListener implements Listener {
|
||||
private DataSource data;
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.plugin.manager;
|
||||
package fr.xephi.authme.plugin.manager;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
@ -7,7 +7,7 @@ import java.io.IOException;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
public class BungeeCordMessage implements PluginMessageListener {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package uk.org.whoami.authme.plugin.manager;
|
||||
package fr.xephi.authme.plugin.manager;
|
||||
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.CitizensManager;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
public class CitizensCommunicator {
|
||||
|
||||
@ -26,7 +26,7 @@ public class CitizensCommunicator {
|
||||
}
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
return false;
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (Exception npe) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,8 +1,4 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package uk.org.whoami.authme.plugin.manager;
|
||||
package fr.xephi.authme.plugin.manager;
|
||||
|
||||
import com.trc202.CombatTag.CombatTag;
|
||||
import com.trc202.CombatTagApi.CombatTagApi;
|
||||
@ -11,10 +7,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stefano
|
||||
*/
|
||||
public abstract class CombatTagComunicator {
|
||||
|
||||
static CombatTagApi combatApi;
|
@ -1,16 +1,12 @@
|
||||
package uk.org.whoami.authme.plugin.manager;
|
||||
package fr.xephi.authme.plugin.manager;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import uk.org.whoami.authme.settings.CustomConfiguration;
|
||||
import fr.xephi.authme.settings.CustomConfiguration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class EssSpawn extends CustomConfiguration {
|
||||
|
||||
private static EssSpawn spawn;
|
39
src/main/java/fr/xephi/authme/security/HashAlgorithm.java
Normal file
39
src/main/java/fr/xephi/authme/security/HashAlgorithm.java
Normal file
@ -0,0 +1,39 @@
|
||||
package fr.xephi.authme.security;
|
||||
|
||||
import org.apache.commons.lang.ObjectUtils.Null;
|
||||
|
||||
public enum HashAlgorithm {
|
||||
|
||||
MD5(fr.xephi.authme.security.crypts.MD5.class),
|
||||
SHA1(fr.xephi.authme.security.crypts.SHA1.class),
|
||||
SHA256(fr.xephi.authme.security.crypts.SHA256.class),
|
||||
WHIRLPOOL(fr.xephi.authme.security.crypts.WHIRLPOOL.class),
|
||||
XAUTH(fr.xephi.authme.security.crypts.XAUTH.class),
|
||||
MD5VB(fr.xephi.authme.security.crypts.MD5VB.class),
|
||||
PHPBB(fr.xephi.authme.security.crypts.PHPBB.class),
|
||||
PLAINTEXT(fr.xephi.authme.security.crypts.PLAINTEXT.class),
|
||||
MYBB(fr.xephi.authme.security.crypts.MYBB.class),
|
||||
IPB3(fr.xephi.authme.security.crypts.IPB3.class),
|
||||
PHPFUSION(fr.xephi.authme.security.crypts.PHPFUSION.class),
|
||||
SMF(fr.xephi.authme.security.crypts.SMF.class),
|
||||
XENFORO(fr.xephi.authme.security.crypts.XF.class),
|
||||
SALTED2MD5(fr.xephi.authme.security.crypts.SALTED2MD5.class),
|
||||
JOOMLA(fr.xephi.authme.security.crypts.JOOMLA.class),
|
||||
BCRYPT(fr.xephi.authme.security.crypts.BCRYPT.class),
|
||||
WBB3(fr.xephi.authme.security.crypts.WBB3.class),
|
||||
SHA512(fr.xephi.authme.security.crypts.SHA512.class),
|
||||
DOUBLEMD5(fr.xephi.authme.security.crypts.DOUBLEMD5.class),
|
||||
PBKDF2(fr.xephi.authme.security.crypts.CryptPBKDF2.class),
|
||||
WORDPRESS(fr.xephi.authme.security.crypts.WORDPRESS.class),
|
||||
CUSTOM(Null.class);
|
||||
|
||||
Class<?> classe;
|
||||
|
||||
HashAlgorithm(Class<?> classe) {
|
||||
this.classe = classe;
|
||||
}
|
||||
|
||||
public Class<?> getclass() {
|
||||
return classe;
|
||||
}
|
||||
}
|
156
src/main/java/fr/xephi/authme/security/PasswordSecurity.java
Normal file
156
src/main/java/fr/xephi/authme/security/PasswordSecurity.java
Normal file
@ -0,0 +1,156 @@
|
||||
package fr.xephi.authme.security;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.HashMap;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.events.PasswordEncryptionEvent;
|
||||
import fr.xephi.authme.security.crypts.BCRYPT;
|
||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class PasswordSecurity {
|
||||
|
||||
private static SecureRandom rnd = new SecureRandom();
|
||||
public static HashMap<String, String> userSalt = new HashMap<String, String>();
|
||||
|
||||
private static String createSalt(int length) throws NoSuchAlgorithmException {
|
||||
byte[] msg = new byte[40];
|
||||
rnd.nextBytes(msg);
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
byte[] digest = sha1.digest(msg);
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest)).substring(0, length);
|
||||
}
|
||||
|
||||
public static String getHash(HashAlgorithm alg, String password, String playerName) throws NoSuchAlgorithmException {
|
||||
EncryptionMethod method;
|
||||
try {
|
||||
if (alg != HashAlgorithm.CUSTOM)
|
||||
method = (EncryptionMethod) alg.getclass().newInstance();
|
||||
else method = null;
|
||||
} catch (InstantiationException e) {
|
||||
throw new NoSuchAlgorithmException("Problem with this hash algorithm");
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new NoSuchAlgorithmException("Problem with this hash algorithm");
|
||||
}
|
||||
String salt = "";
|
||||
switch (alg) {
|
||||
case MD5:
|
||||
case SHA1:
|
||||
case WHIRLPOOL:
|
||||
case PHPBB:
|
||||
case PLAINTEXT:
|
||||
case XENFORO:
|
||||
case SHA512:
|
||||
case DOUBLEMD5:
|
||||
case WORDPRESS:
|
||||
case CUSTOM:
|
||||
break;
|
||||
case SHA256:
|
||||
salt = createSalt(16);
|
||||
break;
|
||||
case MD5VB:
|
||||
salt = createSalt(16);
|
||||
break;
|
||||
case XAUTH:
|
||||
salt = createSalt(12);
|
||||
break;
|
||||
case MYBB:
|
||||
salt = createSalt(8);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case IPB3:
|
||||
salt = createSalt(5);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case PHPFUSION:
|
||||
salt = createSalt(12);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case SALTED2MD5:
|
||||
salt = createSalt(Settings.saltLength);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case JOOMLA:
|
||||
salt = createSalt(32);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case BCRYPT:
|
||||
salt = BCRYPT.gensalt(Settings.bCryptLog2Rounds);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case WBB3:
|
||||
salt = createSalt(40);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case PBKDF2:
|
||||
salt = createSalt(12);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case SMF:
|
||||
return method.getHash(password, playerName.toLowerCase());
|
||||
default:
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
}
|
||||
PasswordEncryptionEvent event = new PasswordEncryptionEvent(method, playerName);
|
||||
method = event.getMethod();
|
||||
if (method == null)
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
return method.getHash(password, salt);
|
||||
}
|
||||
|
||||
public static boolean comparePasswordWithHash(String password, String hash, String playerName) throws NoSuchAlgorithmException {
|
||||
HashAlgorithm algo = Settings.getPasswordHash;
|
||||
EncryptionMethod method;
|
||||
try {
|
||||
if (algo != HashAlgorithm.CUSTOM)
|
||||
method = (EncryptionMethod) algo.getclass().newInstance();
|
||||
else method = null;
|
||||
} catch (InstantiationException e) {
|
||||
throw new NoSuchAlgorithmException("Problem with this hash algorithm");
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new NoSuchAlgorithmException("Problem with this hash algorithm");
|
||||
}
|
||||
PasswordEncryptionEvent event = new PasswordEncryptionEvent(method, playerName);
|
||||
method = event.getMethod();
|
||||
if (method == null)
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
|
||||
if (method.comparePassword(hash, password, playerName))
|
||||
return true;
|
||||
if (Settings.supportOldPassword) {
|
||||
try {
|
||||
if (compareWithAllEncryptionMethod(password, hash, playerName))
|
||||
return true;
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean compareWithAllEncryptionMethod(String password, String hash, String playerName) throws NoSuchAlgorithmException {
|
||||
for (HashAlgorithm algo : HashAlgorithm.values()) {
|
||||
try {
|
||||
if (algo != HashAlgorithm.CUSTOM)
|
||||
if (((EncryptionMethod) algo.getclass().newInstance()).comparePassword(hash, password, playerName)) {
|
||||
PlayerAuth nAuth = AuthMe.getInstance().database.getAuth(playerName);
|
||||
if (nAuth != null) {
|
||||
nAuth.setHash(getHash(Settings.getPasswordHash, password, playerName));
|
||||
nAuth.setSalt(userSalt.get(playerName));
|
||||
AuthMe.getInstance().database.updatePassword(nAuth);
|
||||
AuthMe.getInstance().database.updateSalt(nAuth);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (InstantiationException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.security;
|
||||
package fr.xephi.authme.security;
|
||||
|
||||
import java.util.Random;
|
||||
|
@ -11,12 +11,16 @@
|
||||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
package uk.org.whoami.authme.security;
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
|
||||
/**
|
||||
* BCrypt implements OpenBSD-style Blowfish password hashing using
|
||||
* the scheme described in "A Future-Adaptable Password Scheme" by
|
||||
@ -60,7 +64,7 @@ import java.security.SecureRandom;
|
||||
* @author Damien Miller
|
||||
* @version 0.2
|
||||
*/
|
||||
public class BCrypt {
|
||||
public class BCRYPT implements EncryptionMethod {
|
||||
// BCrypt parameters
|
||||
private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10;
|
||||
private static final int BCRYPT_SALT_LEN = 16;
|
||||
@ -645,7 +649,7 @@ public class BCrypt {
|
||||
* @return the hashed password
|
||||
*/
|
||||
public static String hashpw(String password, String salt) {
|
||||
BCrypt B;
|
||||
BCRYPT B;
|
||||
String real_salt;
|
||||
byte passwordb[], saltb[], hashed[];
|
||||
char minor = (char)0;
|
||||
@ -677,7 +681,7 @@ public class BCrypt {
|
||||
|
||||
saltb = decode_base64(real_salt, BCRYPT_SALT_LEN);
|
||||
|
||||
B = new BCrypt();
|
||||
B = new BCRYPT();
|
||||
hashed = B.crypt_raw(passwordb, saltb, rounds);
|
||||
|
||||
rs.append("$2");
|
||||
@ -748,4 +752,17 @@ public class BCrypt {
|
||||
public static boolean checkpw(String plaintext, String hashed) {
|
||||
return (hashed.compareTo(hashpw(plaintext, hashed)) == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return hashpw(password, salt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(hashpw(password, salt));
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import fr.xephi.authme.security.pbkdf2.PBKDF2Engine;
|
||||
import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters;
|
||||
|
||||
|
||||
public class CryptPBKDF2 implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
String result = "pbkdf2_sha256$10000$"+salt+"$";
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);
|
||||
PBKDF2Engine engine = new PBKDF2Engine(params);
|
||||
|
||||
return result + engine.deriveKey(password,64).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String[] line = hash.split("\\$");
|
||||
String salt = line[2];
|
||||
String derivedKey = line[3];
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000, derivedKey.getBytes());
|
||||
PBKDF2Engine engine = new PBKDF2Engine(params);
|
||||
return engine.verifyKey(password);
|
||||
}
|
||||
|
||||
}
|
29
src/main/java/fr/xephi/authme/security/crypts/DOUBLEMD5.java
Normal file
29
src/main/java/fr/xephi/authme/security/crypts/DOUBLEMD5.java
Normal file
@ -0,0 +1,29 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class DOUBLEMD5 implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(password));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
return hash.equals(getHash(password, ""));
|
||||
}
|
||||
|
||||
private String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* <p>Public interface for Custom Password encryption method</p>
|
||||
* <p>The getHash function is called when we need to crypt the password (/register usually)</p>
|
||||
* <p>The comparePassword is called when we need to match password (/login usually)</p>
|
||||
*/
|
||||
public interface EncryptionMethod {
|
||||
|
||||
/**
|
||||
* @param password
|
||||
* @param salt (can be an other data like playerName;salt , playerName, etc...
|
||||
* for customs methods)
|
||||
* @return Hashing password
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
String getHash(String password, String salt) throws NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* @param hash
|
||||
* @param password
|
||||
* @param playerName
|
||||
* @return true if password match, false else
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException;
|
||||
|
||||
}
|
32
src/main/java/fr/xephi/authme/security/crypts/IPB3.java
Normal file
32
src/main/java/fr/xephi/authme/security/crypts/IPB3.java
Normal file
@ -0,0 +1,32 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
|
||||
public class IPB3 implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(salt) + getMD5(password));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(getHash(password, salt));
|
||||
}
|
||||
|
||||
private String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
}
|
29
src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java
Normal file
29
src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java
Normal file
@ -0,0 +1,29 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class JOOMLA implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(password + salt) + ":" + salt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = hash.split(":")[1];
|
||||
return hash.equals(getMD5(password + salt) + ":" + salt);
|
||||
}
|
||||
|
||||
private String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
}
|
23
src/main/java/fr/xephi/authme/security/crypts/MD5.java
Normal file
23
src/main/java/fr/xephi/authme/security/crypts/MD5.java
Normal file
@ -0,0 +1,23 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class MD5 implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(password.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException {
|
||||
return hash.equals(getHash(password, ""));
|
||||
}
|
||||
|
||||
}
|
30
src/main/java/fr/xephi/authme/security/crypts/MD5VB.java
Normal file
30
src/main/java/fr/xephi/authme/security/crypts/MD5VB.java
Normal file
@ -0,0 +1,30 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class MD5VB implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return "$MD5vb$" + salt + "$" + getMD5(getMD5(password) + salt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String[] line = hash.split("\\$");
|
||||
return hash.equals(getHash(password, line[2]));
|
||||
}
|
||||
|
||||
private String getMD5(String password) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(password.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
|
||||
}
|
32
src/main/java/fr/xephi/authme/security/crypts/MYBB.java
Normal file
32
src/main/java/fr/xephi/authme/security/crypts/MYBB.java
Normal file
@ -0,0 +1,32 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
|
||||
public class MYBB implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(salt)+ getMD5(password));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(getHash(password, salt));
|
||||
}
|
||||
|
||||
private String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
}
|
@ -2,17 +2,18 @@
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package uk.org.whoami.authme.security;
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stefano
|
||||
*/
|
||||
public class PhpBB {
|
||||
public class PHPBB implements EncryptionMethod {
|
||||
private static final int PHP_VERSION = 4;
|
||||
private String itoa64 =
|
||||
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
@ -157,4 +158,16 @@ private String _hash_gensalt_private(
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return phpbb_hash(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password, String playerName)
|
||||
throws NoSuchAlgorithmException {
|
||||
return phpbb_check_hash(password, hash);
|
||||
}
|
||||
}
|
59
src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java
Normal file
59
src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java
Normal file
@ -0,0 +1,59 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
|
||||
public class PHPFUSION implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
String digest = null;
|
||||
String algo = "HmacSHA256";
|
||||
String keyString = getSHA1(salt);
|
||||
try {
|
||||
SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), algo);
|
||||
Mac mac = Mac.getInstance(algo);
|
||||
mac.init(key);
|
||||
byte[] bytes = mac.doFinal(password.getBytes("ASCII"));
|
||||
StringBuffer hash = new StringBuffer();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
String hex = Integer.toHexString(0xFF & bytes[i]);
|
||||
if (hex.length() == 1) {
|
||||
hash.append('0');
|
||||
}
|
||||
hash.append(hex);
|
||||
}
|
||||
digest = hash.toString();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
} catch (InvalidKeyException e) {
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
}
|
||||
return digest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(getHash(password, salt));
|
||||
}
|
||||
|
||||
private String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
byte[] digest = sha1.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
|
||||
}
|
19
src/main/java/fr/xephi/authme/security/crypts/PLAINTEXT.java
Normal file
19
src/main/java/fr/xephi/authme/security/crypts/PLAINTEXT.java
Normal file
@ -0,0 +1,19 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class PLAINTEXT implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
return hash.equals(password);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
|
||||
public class SALTED2MD5 implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(password) + salt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(getMD5(getMD5(password) + salt));
|
||||
}
|
||||
|
||||
private String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
}
|
24
src/main/java/fr/xephi/authme/security/crypts/SHA1.java
Normal file
24
src/main/java/fr/xephi/authme/security/crypts/SHA1.java
Normal file
@ -0,0 +1,24 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class SHA1 implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(password.getBytes());
|
||||
byte[] digest = sha1.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password, String playerName)
|
||||
throws NoSuchAlgorithmException {
|
||||
return hash.equals(getHash(password, ""));
|
||||
}
|
||||
|
||||
}
|
29
src/main/java/fr/xephi/authme/security/crypts/SHA256.java
Normal file
29
src/main/java/fr/xephi/authme/security/crypts/SHA256.java
Normal file
@ -0,0 +1,29 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class SHA256 implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
|
||||
return "$SHA$" + salt + "$" + getSha256(getSha256(password) + salt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password, String playerName)
|
||||
throws NoSuchAlgorithmException {
|
||||
String[] line = hash.split("\\$");
|
||||
return hash.equals(getHash(password, line[2]));
|
||||
}
|
||||
|
||||
private String getSha256(String password) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
|
||||
sha256.reset();
|
||||
sha256.update(password.getBytes());
|
||||
byte[] digest = sha256.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
|
||||
}
|
25
src/main/java/fr/xephi/authme/security/crypts/SHA512.java
Normal file
25
src/main/java/fr/xephi/authme/security/crypts/SHA512.java
Normal file
@ -0,0 +1,25 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class SHA512 implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest sha512 = MessageDigest.getInstance("SHA-512");
|
||||
sha512.reset();
|
||||
sha512.update(password.getBytes());
|
||||
byte[] digest = sha512.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
return hash.equals(getHash(password, ""));
|
||||
}
|
||||
|
||||
}
|
28
src/main/java/fr/xephi/authme/security/crypts/SMF.java
Normal file
28
src/main/java/fr/xephi/authme/security/crypts/SMF.java
Normal file
@ -0,0 +1,28 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class SMF implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return getSHA1(salt.toLowerCase() + password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
return hash.equals(getHash(password, playerName.toLowerCase()));
|
||||
}
|
||||
|
||||
private String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
byte[] digest = sha1.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
}
|
32
src/main/java/fr/xephi/authme/security/crypts/WBB3.java
Normal file
32
src/main/java/fr/xephi/authme/security/crypts/WBB3.java
Normal file
@ -0,0 +1,32 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
|
||||
public class WBB3 implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return getSHA1(salt.concat(getSHA1(salt.concat(getSHA1(password)))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(getHash(password, salt));
|
||||
}
|
||||
|
||||
private String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
byte[] digest = sha1.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.security;
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
/**
|
||||
* The Whirlpool hashing function.
|
||||
@ -57,9 +57,12 @@ package uk.org.whoami.authme.security;
|
||||
*
|
||||
*/
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
class Whirlpool {
|
||||
public class WHIRLPOOL implements EncryptionMethod {
|
||||
|
||||
public WHIRLPOOL() {}
|
||||
|
||||
/**
|
||||
* The message digest size (in bits)
|
||||
@ -178,9 +181,6 @@ class Whirlpool {
|
||||
protected long[] block = new long[8];
|
||||
protected long[] state = new long[8];
|
||||
|
||||
public Whirlpool() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The core Whirlpool transform.
|
||||
*/
|
||||
@ -405,4 +405,20 @@ class Whirlpool {
|
||||
}
|
||||
return String.valueOf(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
byte[] digest = new byte[DIGESTBYTES];
|
||||
NESSIEinit();
|
||||
NESSIEadd(password);
|
||||
NESSIEfinalize(digest);
|
||||
return display(digest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
return hash.equals(getHash(password, ""));
|
||||
}
|
||||
}
|
115
src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java
Normal file
115
src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java
Normal file
@ -0,0 +1,115 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class WORDPRESS implements EncryptionMethod {
|
||||
private static String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
private int iterationCountLog2 = 8;
|
||||
private SecureRandom randomGen = new SecureRandom();
|
||||
|
||||
private String encode64(byte[] src, int count) {
|
||||
int i, value;
|
||||
String output = "";
|
||||
i = 0;
|
||||
|
||||
if (src.length < count) {
|
||||
byte[] t = new byte[count];
|
||||
System.arraycopy(src, 0, t, 0, src.length);
|
||||
Arrays.fill(t, src.length, count - 1, (byte) 0);
|
||||
}
|
||||
|
||||
do {
|
||||
value = src[i] + (src[i] < 0 ? 256 : 0);
|
||||
++i;
|
||||
output += itoa64.charAt(value & 63);
|
||||
if (i < count) {
|
||||
value |= (src[i] + (src[i] < 0 ? 256 : 0)) << 8;
|
||||
}
|
||||
output += itoa64.charAt((value >> 6) & 63);
|
||||
if (i++ >= count) {
|
||||
break;
|
||||
}
|
||||
if (i < count) {
|
||||
value |= (src[i] + (src[i] < 0 ? 256 : 0)) << 16;
|
||||
}
|
||||
output += itoa64.charAt((value >> 12) & 63);
|
||||
if (i++ >= count) {
|
||||
break;
|
||||
}
|
||||
output += itoa64.charAt((value >> 18) & 63);
|
||||
} while (i < count);
|
||||
return output;
|
||||
}
|
||||
|
||||
private String crypt(String password, String setting) {
|
||||
String output = "*0";
|
||||
if (((setting.length() < 2) ? setting : setting.substring(0, 2)).equalsIgnoreCase(output)) {
|
||||
output = "*1";
|
||||
}
|
||||
String id = (setting.length() < 3) ? setting : setting.substring(0, 3);
|
||||
if (!(id.equals("$P$") || id.equals("$H$"))) {
|
||||
return output;
|
||||
}
|
||||
int countLog2 = itoa64.indexOf(setting.charAt(3));
|
||||
if (countLog2 < 7 || countLog2 > 30) {
|
||||
return output;
|
||||
}
|
||||
int count = 1 << countLog2;
|
||||
String salt = setting.substring(4, 4 + 8);
|
||||
if (salt.length() != 8) {
|
||||
return output;
|
||||
}
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return output;
|
||||
}
|
||||
byte[] pass = stringToUtf8(password);
|
||||
byte[] hash = md.digest(stringToUtf8(salt + password));
|
||||
do {
|
||||
byte[] t = new byte[hash.length + pass.length];
|
||||
System.arraycopy(hash, 0, t, 0, hash.length);
|
||||
System.arraycopy(pass, 0, t, hash.length, pass.length);
|
||||
hash = md.digest(t);
|
||||
} while (--count > 0);
|
||||
output = setting.substring(0, 12);
|
||||
output += encode64(hash, 16);
|
||||
return output;
|
||||
}
|
||||
|
||||
private String gensaltPrivate(byte[] input) {
|
||||
String output = "$P$";
|
||||
output += itoa64.charAt(Math.min(this.iterationCountLog2 + 5, 30));
|
||||
output += encode64(input, 6);
|
||||
return output;
|
||||
}
|
||||
|
||||
private byte[] stringToUtf8(String string) {
|
||||
try {
|
||||
return string.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new UnsupportedOperationException("This system doesn't support UTF-8!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
|
||||
byte random[] = new byte[6];
|
||||
this.randomGen.nextBytes(random);
|
||||
return crypt(password, gensaltPrivate(stringToUtf8(new String(random))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String comparedHash = crypt(password, hash);
|
||||
return comparedHash.equals(hash);
|
||||
}
|
||||
|
||||
}
|
24
src/main/java/fr/xephi/authme/security/crypts/XAUTH.java
Normal file
24
src/main/java/fr/xephi/authme/security/crypts/XAUTH.java
Normal file
@ -0,0 +1,24 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class XAUTH implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
WHIRLPOOL w = new WHIRLPOOL();
|
||||
String hash = w.getHash((salt + password).toLowerCase(), "");
|
||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
||||
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
||||
String salt = hash.substring(saltPos, saltPos + 12);
|
||||
return hash.equals(getHash(password, salt));
|
||||
}
|
||||
|
||||
}
|
61
src/main/java/fr/xephi/authme/security/crypts/XF.java
Normal file
61
src/main/java/fr/xephi/authme/security/crypts/XF.java
Normal file
@ -0,0 +1,61 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
|
||||
public class XF implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return getSHA256(getSHA256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(regmatch("\"hash\";.:..:\"(.*)\";.:.:\"salt\"", salt));
|
||||
}
|
||||
|
||||
public String getSHA256(String password) throws NoSuchAlgorithmException
|
||||
{
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
md.update(password.getBytes());
|
||||
byte byteData[] = md.digest();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (byte element : byteData)
|
||||
{
|
||||
sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
StringBuffer hexString = new StringBuffer();
|
||||
for (byte element : byteData)
|
||||
{
|
||||
String hex = Integer.toHexString(0xff & element);
|
||||
if (hex.length() == 1)
|
||||
{
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
}
|
||||
|
||||
public String regmatch(String pattern, String line)
|
||||
{
|
||||
List<String> allMatches = new ArrayList<String>();
|
||||
Matcher m = Pattern.compile(pattern).matcher(line);
|
||||
while (m.find())
|
||||
{
|
||||
allMatches.add(m.group(1));
|
||||
}
|
||||
return allMatches.get(0);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.security.pbkdf2;
|
||||
package fr.xephi.authme.security.pbkdf2;
|
||||
|
||||
/**
|
||||
* <p>
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.security.pbkdf2;
|
||||
package fr.xephi.authme.security.pbkdf2;
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.security.pbkdf2;
|
||||
package fr.xephi.authme.security.pbkdf2;
|
||||
|
||||
/**
|
||||
* <p>
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.security.pbkdf2;
|
||||
package fr.xephi.authme.security.pbkdf2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.security.pbkdf2;
|
||||
package fr.xephi.authme.security.pbkdf2;
|
||||
|
||||
/**
|
||||
* <p>
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.security.pbkdf2;
|
||||
package fr.xephi.authme.security.pbkdf2;
|
||||
|
||||
/**
|
||||
* <p>
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.security.pbkdf2;
|
||||
package fr.xephi.authme.security.pbkdf2;
|
||||
|
||||
/**
|
||||
* <p>
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.security.pbkdf2;
|
||||
package fr.xephi.authme.security.pbkdf2;
|
||||
|
||||
/**
|
||||
* <p>
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.settings;
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -29,7 +29,7 @@ public class CustomConfiguration extends YamlConfiguration{
|
||||
super.load(configFile);
|
||||
} catch (FileNotFoundException e) {
|
||||
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not find " + configFile.getName() + ", creating new one...");
|
||||
reload();
|
||||
reLoad();
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not load " + configFile.getName(), e);
|
||||
} catch (InvalidConfigurationException e) {
|
||||
@ -37,7 +37,7 @@ public class CustomConfiguration extends YamlConfiguration{
|
||||
}
|
||||
}
|
||||
|
||||
public boolean reload() {
|
||||
public boolean reLoad() {
|
||||
boolean out = true;
|
||||
if (!configFile.exists())
|
||||
{
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.settings;
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -96,10 +80,17 @@ public class Messages extends CustomConfiguration {
|
||||
if (loc != null) {
|
||||
return loc.replace("&", "\u00a7");
|
||||
}
|
||||
return msg;
|
||||
if (loc == null && !contains(msg)) {
|
||||
set(msg, this.getDefault(msg));
|
||||
save();
|
||||
loc = (String) this.get(msg);
|
||||
}
|
||||
if (loc == null)
|
||||
return "Error with Translation files; Please contact the admin";
|
||||
return loc.replace("&", "\u00a7");
|
||||
}
|
||||
|
||||
public static Messages getInstance() {
|
||||
public static Messages getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new Messages();
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
package uk.org.whoami.authme.settings;
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class PlayersLogs extends CustomConfiguration {
|
||||
|
||||
private static PlayersLogs pllog = null;
|
||||
public static List<String> players;
|
||||
|
||||
@ -28,4 +29,12 @@ public class PlayersLogs extends CustomConfiguration {
|
||||
return pllog;
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
List<String> players = this.getStringList("players");
|
||||
if (!players.contains(player.getName())) {
|
||||
players.add(player.getName());
|
||||
this.set("players", players);
|
||||
save();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +1,4 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.settings;
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
@ -26,11 +10,11 @@ import org.bukkit.configuration.MemoryConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.datasource.DataSource.DataSourceType;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity.HashAlgorithm;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.DataSource.DataSourceType;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
|
||||
|
||||
public final class Settings extends YamlConfiguration {
|
||||
|
||||
@ -60,7 +44,8 @@ public final class Settings extends YamlConfiguration {
|
||||
getEnablePasswordVerifier, protectInventoryBeforeLogInEnabled, isBackupActivated, isBackupOnStart,
|
||||
isBackupOnStop, enablePasspartu, isStopEnabled, reloadSupport, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
|
||||
useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
|
||||
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd;
|
||||
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
|
||||
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword;
|
||||
|
||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
|
||||
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
|
||||
@ -68,12 +53,13 @@ public final class Settings extends YamlConfiguration {
|
||||
getMySQLColumnSalt, getMySQLColumnGroup, getMySQLColumnEmail, unRegisteredGroup, backupWindowsPath,
|
||||
getcUnrestrictedName, getRegisteredGroup, messagesLanguage, getMySQLlastlocX, getMySQLlastlocY, getMySQLlastlocZ,
|
||||
rakamakUsers, rakamakUsersIp, getmailAccount, getmailPassword, getmailSMTP, getMySQLColumnId, getmailSenderName,
|
||||
getPredefinedSalt, getMailSubject, getMailText, getMySQLlastlocWorld;
|
||||
getMailSubject, getMailText, getMySQLlastlocWorld, defaultWorld,
|
||||
getPhpbbPrefix, getWordPressPrefix;
|
||||
|
||||
public static int getWarnMessageInterval, getSessionTimeout, getRegistrationTimeout, getMaxNickLength,
|
||||
getMinNickLength, getPasswordMinLen, getMovementRadius, getmaxRegPerIp, getNonActivatedGroup,
|
||||
passwordMaxLength, getRecoveryPassLength, getMailPort, maxLoginTry, captchaLength, saltLength, getmaxRegPerEmail,
|
||||
bCryptLog2Rounds;
|
||||
bCryptLog2Rounds, purgeDelay, getPhpbbGroup;
|
||||
|
||||
protected static YamlConfiguration configFile;
|
||||
|
||||
@ -189,7 +175,6 @@ public void loadConfigOptions() {
|
||||
displayOtherAccounts = configFile.getBoolean("settings.restrictions.displayOtherAccounts", true);
|
||||
getMySQLColumnId = configFile.getString("DataSource.mySQLColumnId", "id");
|
||||
getmailSenderName = configFile.getString("Email.mailSenderName", "");
|
||||
getPredefinedSalt = configFile.getString("Xenoforo.predefinedSalt", "");
|
||||
useCaptcha = configFile.getBoolean("Security.captcha.useCaptcha", false);
|
||||
maxLoginTry = configFile.getInt("Security.captcha.maxLoginTry", 5);
|
||||
captchaLength = configFile.getInt("Security.captcha.captchaLength", 5);
|
||||
@ -208,10 +193,19 @@ public void loadConfigOptions() {
|
||||
sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
|
||||
useLogging = configFile.getBoolean("Security.console.logConsole", false);
|
||||
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
|
||||
useMultiThreading = configFile.getBoolean("Performances.useMultiThreading", false);
|
||||
useMultiThreading = configFile.getBoolean("Performances.useMultiThreading", true);
|
||||
bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
|
||||
forceOnlyAfterLogin = configFile.getBoolean("settings.GameMode.ForceOnlyAfterLogin", false);
|
||||
useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
|
||||
usePurge = configFile.getBoolean("Purge.useAutoPurge", false);
|
||||
purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60);
|
||||
purgePlayerDat = configFile.getBoolean("Purge.removePlayerDat", false);
|
||||
purgeEssentialsFile = configFile.getBoolean("Purge.removeEssentialsFile", false);
|
||||
defaultWorld = configFile.getString("Purge.defaultWorld", "world");
|
||||
getPhpbbPrefix = configFile.getString("ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
|
||||
getPhpbbGroup = configFile.getInt("ExternalBoardOptions.phpbbActivatedGroupId", 2);
|
||||
supportOldPassword = configFile.getBoolean("settings.security.supportOldPasswordHash", false);
|
||||
getWordPressPrefix = configFile.getString("ExternalBoardOptions.wordpressTablePrefix", "wp_");
|
||||
|
||||
saveDefaults();
|
||||
}
|
||||
@ -314,7 +308,6 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
||||
displayOtherAccounts = configFile.getBoolean("settings.restrictions.displayOtherAccounts", true);
|
||||
getMySQLColumnId = configFile.getString("DataSource.mySQLColumnId", "id");
|
||||
getmailSenderName = configFile.getString("Email.mailSenderName", "");
|
||||
getPredefinedSalt = configFile.getString("Xenoforo.predefinedSalt", "");
|
||||
useCaptcha = configFile.getBoolean("Security.captcha.useCaptcha", false);
|
||||
maxLoginTry = configFile.getInt("Security.captcha.maxLoginTry", 5);
|
||||
captchaLength = configFile.getInt("Security.captcha.captchaLength", 5);
|
||||
@ -333,25 +326,24 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
||||
sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
|
||||
useLogging = configFile.getBoolean("Security.console.logConsole", false);
|
||||
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
|
||||
useMultiThreading = configFile.getBoolean("Performances.useMultiThreading", false);
|
||||
useMultiThreading = configFile.getBoolean("Performances.useMultiThreading", true);
|
||||
bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
|
||||
forceOnlyAfterLogin = configFile.getBoolean("settings.GameMode.ForceOnlyAfterLogin", false);
|
||||
useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
|
||||
usePurge = configFile.getBoolean("Purge.useAutoPurge", false);
|
||||
purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60);
|
||||
purgePlayerDat = configFile.getBoolean("Purge.removePlayerDat", false);
|
||||
purgeEssentialsFile = configFile.getBoolean("Purge.removeEssentialsFile", false);
|
||||
defaultWorld = configFile.getString("Purge.defaultWorld", "world");
|
||||
getPhpbbPrefix = configFile.getString("ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
|
||||
getPhpbbGroup = configFile.getInt("ExternalBoardOptions.phpbbActivatedGroupId", 2);
|
||||
supportOldPassword = configFile.getBoolean("settings.security.supportOldPasswordHash", false);
|
||||
getWordPressPrefix = configFile.getString("ExternalBoardOptions.wordpressTablePrefix", "wp_");
|
||||
}
|
||||
|
||||
public void mergeConfig() {
|
||||
if (contains("settings.restrictions.allowedPluginTeleportHandler"))
|
||||
set("settings.restrictions.allowedPluginTeleportHandler", null);
|
||||
if(!contains("DataSource.mySQLColumnEmail"))
|
||||
set("DataSource.mySQLColumnEmail","email");
|
||||
if(contains("Email.GmailAccount")) {
|
||||
set("Email.mailAccount", getString("Email.GmailAccount"));
|
||||
set("Email.GmailAccount", null);
|
||||
}
|
||||
if(contains("Email.GmailPassword")) {
|
||||
set("Email.mailPassword", getString("Email.GmailPassword"));
|
||||
set("Email.GmailPassword", null);
|
||||
}
|
||||
if(!contains("Email.RecoveryPasswordLength"))
|
||||
set("Email.RecoveryPasswordLength", 8);
|
||||
if(!contains("Email.mailPort"))
|
||||
@ -370,8 +362,6 @@ public void mergeConfig() {
|
||||
set("DataSource.mySQLColumnId", "id");
|
||||
if(!contains("Email.mailSenderName"))
|
||||
set("Email.mailSenderName", "");
|
||||
if(!contains("Xenoforo.predefinedSalt"))
|
||||
set("Xenoforo.predefinedSalt", "");
|
||||
if(!contains("Security.captcha.useCaptcha"))
|
||||
set("Security.captcha.useCaptcha", false);
|
||||
if(!contains("Security.captcha.maxLoginTry"))
|
||||
@ -415,7 +405,7 @@ public void mergeConfig() {
|
||||
if(!contains("Hooks.disableSocialSpy"))
|
||||
set("Hooks.disableSocialSpy", true);
|
||||
if(!contains("Performances.useMultiThreading"))
|
||||
set("Performances.useMultiThreading", false);
|
||||
set("Performances.useMultiThreading", true);
|
||||
if(!contains("ExternalBoardOptions.bCryptLog2Round"))
|
||||
set("ExternalBoardOptions.bCryptLog2Round", 10);
|
||||
if(!contains("DataSource.mySQLlastlocWorld"))
|
||||
@ -424,6 +414,25 @@ public void mergeConfig() {
|
||||
set("settings.GameMode.ForceOnlyAfterLogin", false);
|
||||
if(!contains("Hooks.useEssentialsMotd"))
|
||||
set("Hooks.useEssentialsMotd", false);
|
||||
if(!contains("Purge.useAutoPurge")) {
|
||||
set("Purge.useAutoPurge", false);
|
||||
set("Purge.daysBeforeRemovePlayer", 60);
|
||||
set("Purge.removePlayerDat", false);
|
||||
set("Purge.removeEssentialsFile", false);
|
||||
set("Purge.defaultWorld", "world");
|
||||
}
|
||||
if(!contains("ExternalBoardOptions.phpbbTablePrefix")) {
|
||||
set("ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
|
||||
set("ExternalBoardOptions.phpbbActivatedGroupId", 2);
|
||||
}
|
||||
if(!contains("settings.security.supportOldPasswordHash"))
|
||||
set("settings.security.supportOldPasswordHash", false);
|
||||
if(!contains("ExternalBoardOptions.wordpressTablePrefix"))
|
||||
set("ExternalBoardOptions.wordpressTablePrefix", "wp_");
|
||||
if(contains("Xenoforo.predefinedSalt"))
|
||||
set("Xenoforo.predefinedSalt", null);
|
||||
if(configFile.getString("settings.security.passwordHash","SHA256").toUpperCase().equals("XFSHA1") || configFile.getString("settings.security.passwordHash","SHA256").toUpperCase().equals("XFSHA256"))
|
||||
set("settings.security.passwordHash", "XENFORO");
|
||||
|
||||
plugin.getLogger().info("Merge new Config Options if needed..");
|
||||
plugin.saveConfig();
|
||||
@ -434,10 +443,10 @@ public void mergeConfig() {
|
||||
private static HashAlgorithm getPasswordHash() {
|
||||
String key = "settings.security.passwordHash";
|
||||
try {
|
||||
return PasswordSecurity.HashAlgorithm.valueOf(configFile.getString(key,"SHA256").toUpperCase());
|
||||
return HashAlgorithm.valueOf(configFile.getString(key,"SHA256").toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
ConsoleLogger.showError("Unknown Hash Algorithm; defaulting to SHA256");
|
||||
return PasswordSecurity.HashAlgorithm.SHA256;
|
||||
return HashAlgorithm.SHA256;
|
||||
}
|
||||
}
|
||||
|
||||
@ -445,10 +454,10 @@ public void mergeConfig() {
|
||||
String key = "Converter.Rakamak.newPasswordHash";
|
||||
|
||||
try {
|
||||
return PasswordSecurity.HashAlgorithm.valueOf(configFile.getString(key,"SHA256").toUpperCase());
|
||||
return HashAlgorithm.valueOf(configFile.getString(key,"SHA256").toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
ConsoleLogger.showError("Unknown Hash Algorithm; defaulting to SHA256");
|
||||
return PasswordSecurity.HashAlgorithm.SHA256;
|
||||
return HashAlgorithm.SHA256;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.settings;
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
@ -1,8 +1,5 @@
|
||||
package uk.org.whoami.authme.settings;
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
/**
|
||||
* @Author Hoezef
|
||||
*/
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -1,28 +1,13 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.task;
|
||||
package fr.xephi.authme.task;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
|
||||
|
||||
public class MessageTask implements Runnable {
|
||||
|
@ -1,32 +1,17 @@
|
||||
/*
|
||||
* Copyright 2011 Sebastian Köhler <sebkoehler@whoami.org.uk>.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package uk.org.whoami.authme.task;
|
||||
package fr.xephi.authme.task;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.cache.backup.FileCache;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboPlayer;
|
||||
import uk.org.whoami.authme.cache.limbo.LimboCache;
|
||||
import uk.org.whoami.authme.listener.AuthMePlayerListener;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
|
||||
|
||||
|
||||
public class TimeoutTask implements Runnable {
|
@ -1,4 +1,4 @@
|
||||
package uk.org.whoami.authme.threads;
|
||||
package fr.xephi.authme.threads;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
@ -10,19 +10,21 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class FlatFileThread extends Thread implements DataSource {
|
||||
|
||||
/* file layout:
|
||||
*
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:COORDS
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:LASTPOSX:LASTPOSY:LASTPOSZ:LASTPOSWORLD
|
||||
*
|
||||
* Old but compatible:
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS
|
||||
* PLAYERNAME:HASHSUM:IP
|
||||
* PLAYERNAME:HASHSUM
|
||||
*
|
||||
@ -81,13 +83,8 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
}
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
if( auth.getQuitLocY() == 0 ) {
|
||||
bw = new BufferedWriter(new FileWriter(source, true));
|
||||
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + "\n");
|
||||
} else {
|
||||
bw = new BufferedWriter(new FileWriter(source, true));
|
||||
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + ":" + auth.getWorld() + "\n");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
@ -115,7 +112,24 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]));
|
||||
switch (args.length) {
|
||||
case 4: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), 0, 0, 0, "world");
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world");
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7]);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], 0, 0, 0, 0, "world");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -151,7 +165,24 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin());
|
||||
switch (args.length) {
|
||||
case 4: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world");
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world");
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7]);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -251,7 +282,7 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args.length == 4) {
|
||||
if (args.length >= 4) {
|
||||
if (Long.parseLong(args[3]) >= until) {
|
||||
lines.add(line);
|
||||
continue;
|
||||
@ -286,6 +317,54 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
return cleared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoPurgeDatabase(long until) {
|
||||
BufferedReader br = null;
|
||||
BufferedWriter bw = null;
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
List<String> cleared = new ArrayList<String>();
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(source));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args.length >= 4) {
|
||||
if (Long.parseLong(args[3]) >= until) {
|
||||
lines.add(line);
|
||||
continue;
|
||||
} else {
|
||||
cleared.add(args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
bw = new BufferedWriter(new FileWriter(source));
|
||||
for (String l : lines) {
|
||||
bw.write(l + "\n");
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return cleared;
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return cleared;
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return cleared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
if (!isAuthAvailable(user)) {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user