Stuff from the common floobits workspace
Author: AuthMe-Team <AuthMeTeam@123NoEmail.com>
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -8,13 +14,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CacheDataSource implements DataSource {
|
||||
@@ -25,7 +24,8 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Constructor for CacheDataSource.
|
||||
* @param pl AuthMe
|
||||
*
|
||||
* @param pl AuthMe
|
||||
* @param src DataSource
|
||||
*/
|
||||
public CacheDataSource(final AuthMe pl, DataSource src) {
|
||||
@@ -51,10 +51,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
return cache.containsKey(user.toLowerCase());
|
||||
@@ -62,10 +62,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) */
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(String user) {
|
||||
user = user.toLowerCase();
|
||||
@@ -77,10 +77,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean saveAuth(final PlayerAuth auth) {
|
||||
cache.put(auth.getNickname(), auth);
|
||||
@@ -97,10 +97,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updatePassword(final PlayerAuth auth) {
|
||||
if (!cache.containsKey(auth.getNickname())) {
|
||||
@@ -123,10 +123,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSession(final PlayerAuth auth) {
|
||||
if (!cache.containsKey(auth.getNickname())) {
|
||||
@@ -158,10 +158,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateQuitLoc(final PlayerAuth auth) {
|
||||
if (!cache.containsKey(auth.getNickname())) {
|
||||
@@ -196,10 +196,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
int count = 0;
|
||||
@@ -213,10 +213,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public int purgeDatabase(long until) {
|
||||
int cleared = source.purgeDatabase(until);
|
||||
@@ -232,10 +232,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public List<String> autoPurgeDatabase(long until) {
|
||||
List<String> cleared = source.autoPurgeDatabase(until);
|
||||
@@ -251,10 +251,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param username String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String username) {
|
||||
final String user = username.toLowerCase();
|
||||
@@ -273,6 +273,7 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
||||
*/
|
||||
@Override
|
||||
@@ -283,6 +284,7 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
||||
*/
|
||||
@Override
|
||||
@@ -305,10 +307,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateEmail(final PlayerAuth auth) {
|
||||
try {
|
||||
@@ -324,10 +326,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateSalt(final PlayerAuth auth) {
|
||||
if (!cache.containsKey(auth.getNickname())) {
|
||||
@@ -351,10 +353,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
List<String> result = new ArrayList<>();
|
||||
@@ -368,11 +370,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
|
||||
* @return List<String> * @throws Exception * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) */
|
||||
* @return List<String> * @throws Exception * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByIp(final String ip) throws Exception {
|
||||
return exec.submit(new Callable<List<String>>() {
|
||||
@@ -384,11 +385,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
|
||||
|
||||
|
||||
* @return List<String> * @throws Exception * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) */
|
||||
* @return List<String> * @throws Exception * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByEmail(final String email) throws Exception {
|
||||
return exec.submit(new Callable<List<String>>() {
|
||||
@@ -400,9 +400,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void purgeBanned(final List<String> banned) {
|
||||
exec.execute(new Runnable() {
|
||||
@@ -420,9 +421,9 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType() */
|
||||
*
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
||||
*/
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return source.getType();
|
||||
@@ -430,10 +431,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
user = user.toLowerCase();
|
||||
@@ -442,9 +443,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setLogged(final String user) {
|
||||
exec.execute(new Runnable() {
|
||||
@@ -457,9 +459,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setUnlogged(final String user) {
|
||||
exec.execute(new Runnable() {
|
||||
@@ -472,6 +475,7 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeLogged.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
||||
*/
|
||||
@Override
|
||||
@@ -486,9 +490,9 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() */
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
||||
*/
|
||||
@Override
|
||||
public int getAccountsRegistered() {
|
||||
return cache.size();
|
||||
@@ -496,10 +500,11 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public void updateName(final String oldone, final String newone) {
|
||||
if (cache.containsKey(oldone)) {
|
||||
@@ -516,9 +521,9 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
return new ArrayList<>(cache.values());
|
||||
@@ -526,9 +531,9 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
return new ArrayList<>(PlayerCache.getInstance().getCache().values());
|
||||
|
||||
@@ -1,13 +1,204 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isAuthAvailable(String user);
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
* @return PlayerAuth
|
||||
*/
|
||||
PlayerAuth getAuth(String user);
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean saveAuth(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateSession(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updatePassword(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
* @return int
|
||||
*/
|
||||
int purgeDatabase(long until);
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> autoPurgeDatabase(long until);
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
* @return boolean
|
||||
*/
|
||||
boolean removeAuth(String user);
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateQuitLoc(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
* @return int
|
||||
*/
|
||||
int getIps(String ip);
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> getAllAuthsByName(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
* @return List<String> * @throws Exception
|
||||
*/
|
||||
List<String> getAllAuthsByIp(String ip) throws Exception;
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
* @return List<String> * @throws Exception
|
||||
*/
|
||||
List<String> getAllAuthsByEmail(String email) throws Exception;
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateEmail(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateSalt(PlayerAuth auth);
|
||||
|
||||
void close();
|
||||
|
||||
void reload();
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
*/
|
||||
void purgeBanned(List<String> banned);
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
*
|
||||
* @return DataSourceType
|
||||
*/
|
||||
DataSourceType getType();
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isLogged(String user);
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
*/
|
||||
void setLogged(String user);
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
*/
|
||||
void setUnlogged(String user);
|
||||
|
||||
void purgeLogged();
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int getAccountsRegistered();
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
*/
|
||||
void updateName(String oldone, String newone);
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
*
|
||||
* @return List<PlayerAuth>
|
||||
*/
|
||||
List<PlayerAuth> getAllAuths();
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
*
|
||||
* @return List<PlayerAuth>
|
||||
*/
|
||||
List<PlayerAuth> getLoggedPlayers();
|
||||
|
||||
/**
|
||||
*/
|
||||
enum DataSourceType {
|
||||
@@ -16,173 +207,4 @@ public interface DataSource {
|
||||
SQLITE
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
* @param user String
|
||||
|
||||
* @return boolean */
|
||||
boolean isAuthAvailable(String user);
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
* @param user String
|
||||
|
||||
* @return PlayerAuth */
|
||||
PlayerAuth getAuth(String user);
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean saveAuth(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean updateSession(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean updatePassword(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
* @param until long
|
||||
|
||||
* @return int */
|
||||
int purgeDatabase(long until);
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
* @param until long
|
||||
|
||||
* @return List<String> */
|
||||
List<String> autoPurgeDatabase(long until);
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
* @param user String
|
||||
|
||||
* @return boolean */
|
||||
boolean removeAuth(String user);
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean updateQuitLoc(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
* @param ip String
|
||||
|
||||
* @return int */
|
||||
int getIps(String ip);
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return List<String> */
|
||||
List<String> getAllAuthsByName(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return List<String> * @throws Exception */
|
||||
List<String> getAllAuthsByIp(String ip) throws Exception;
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
* @param email String
|
||||
|
||||
|
||||
* @return List<String> * @throws Exception */
|
||||
List<String> getAllAuthsByEmail(String email) throws Exception;
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean updateEmail(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean updateSalt(PlayerAuth auth);
|
||||
|
||||
void close();
|
||||
|
||||
void reload();
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
* @param banned List<String>
|
||||
*/
|
||||
void purgeBanned(List<String> banned);
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
* @return DataSourceType */
|
||||
DataSourceType getType();
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
* @param user String
|
||||
|
||||
* @return boolean */
|
||||
boolean isLogged(String user);
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
* @param user String
|
||||
*/
|
||||
void setLogged(String user);
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
* @param user String
|
||||
*/
|
||||
void setUnlogged(String user);
|
||||
|
||||
void purgeLogged();
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
* @return int */
|
||||
int getAccountsRegistered();
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
*/
|
||||
void updateName(String oldone, String newone);
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
* @return List<PlayerAuth> */
|
||||
List<PlayerAuth> getAllAuths();
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
* @return List<PlayerAuth> */
|
||||
List<PlayerAuth> getLoggedPlayers();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DatabaseCalls implements DataSource {
|
||||
|
||||
private DataSource database;
|
||||
private final ExecutorService exec;
|
||||
private DataSource database;
|
||||
|
||||
/**
|
||||
* Constructor for DatabaseCalls.
|
||||
*
|
||||
* @param database DataSource
|
||||
*/
|
||||
public DatabaseCalls(DataSource database) {
|
||||
@@ -26,10 +27,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(final String user) {
|
||||
try {
|
||||
@@ -45,10 +46,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) */
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(final String user) {
|
||||
try {
|
||||
@@ -64,10 +65,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean saveAuth(final PlayerAuth auth) {
|
||||
try {
|
||||
@@ -83,10 +84,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateSession(final PlayerAuth auth) {
|
||||
try {
|
||||
@@ -102,10 +103,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updatePassword(final PlayerAuth auth) {
|
||||
try {
|
||||
@@ -121,10 +122,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public synchronized int purgeDatabase(final long until) {
|
||||
try {
|
||||
@@ -140,10 +141,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> autoPurgeDatabase(final long until) {
|
||||
try {
|
||||
@@ -159,10 +160,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean removeAuth(final String user) {
|
||||
try {
|
||||
@@ -178,10 +179,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateQuitLoc(final PlayerAuth auth) {
|
||||
try {
|
||||
@@ -197,10 +198,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized int getIps(final String ip) {
|
||||
try {
|
||||
@@ -217,10 +218,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByName(final PlayerAuth auth) {
|
||||
try {
|
||||
@@ -236,10 +237,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByIp(final String ip) {
|
||||
try {
|
||||
@@ -255,10 +256,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByEmail(final String email) {
|
||||
try {
|
||||
@@ -274,10 +275,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateEmail(final PlayerAuth auth) {
|
||||
try {
|
||||
@@ -293,10 +294,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateSalt(final PlayerAuth auth) {
|
||||
try {
|
||||
@@ -312,6 +313,7 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
||||
*/
|
||||
@Override
|
||||
@@ -322,6 +324,7 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
||||
*/
|
||||
@Override
|
||||
@@ -331,9 +334,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void purgeBanned(final List<String> banned) {
|
||||
new Thread(new Runnable() {
|
||||
@@ -345,9 +349,9 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType() */
|
||||
*
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
||||
*/
|
||||
@Override
|
||||
public synchronized DataSourceType getType() {
|
||||
return database.getType();
|
||||
@@ -355,10 +359,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isLogged(final String user) {
|
||||
try {
|
||||
@@ -374,9 +378,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void setLogged(final String user) {
|
||||
exec.execute(new Runnable() {
|
||||
@@ -388,9 +393,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void setUnlogged(final String user) {
|
||||
exec.execute(new Runnable() {
|
||||
@@ -402,6 +408,7 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeLogged.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
||||
*/
|
||||
@Override
|
||||
@@ -415,9 +422,9 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() */
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
||||
*/
|
||||
@Override
|
||||
public synchronized int getAccountsRegistered() {
|
||||
try {
|
||||
@@ -433,10 +440,11 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void updateName(final String oldone, final String newone) {
|
||||
exec.execute(new Runnable() {
|
||||
@@ -448,9 +456,9 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<PlayerAuth> getAllAuths() {
|
||||
try {
|
||||
@@ -466,9 +474,9 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
try {
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.settings.Settings;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class FlatFile implements DataSource {
|
||||
@@ -52,10 +46,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
BufferedReader br = null;
|
||||
@@ -87,10 +81,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean saveAuth(PlayerAuth auth) {
|
||||
if (isAuthAvailable(auth.getNickname())) {
|
||||
@@ -116,10 +110,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updatePassword(PlayerAuth auth) {
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
@@ -181,10 +175,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSession(PlayerAuth auth) {
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
@@ -246,10 +240,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateQuitLoc(PlayerAuth auth) {
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
@@ -290,10 +284,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
BufferedReader br = null;
|
||||
@@ -326,10 +320,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public int purgeDatabase(long until) {
|
||||
BufferedReader br = null;
|
||||
@@ -378,10 +372,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public List<String> autoPurgeDatabase(long until) {
|
||||
BufferedReader br = null;
|
||||
@@ -430,10 +424,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
if (!isAuthAvailable(user)) {
|
||||
@@ -480,10 +474,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) */
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(String user) {
|
||||
BufferedReader br = null;
|
||||
@@ -528,6 +522,7 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
||||
*/
|
||||
@Override
|
||||
@@ -536,6 +531,7 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
||||
*/
|
||||
@Override
|
||||
@@ -544,10 +540,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
@@ -588,10 +584,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSalt(PlayerAuth auth) {
|
||||
return false;
|
||||
@@ -599,10 +595,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
BufferedReader br = null;
|
||||
@@ -635,10 +631,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByIp(String ip) {
|
||||
BufferedReader br = null;
|
||||
@@ -671,10 +667,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
BufferedReader br = null;
|
||||
@@ -707,9 +703,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
public void purgeBanned(List<String> banned) {
|
||||
BufferedReader br = null;
|
||||
@@ -756,9 +753,9 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType() */
|
||||
*
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
||||
*/
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.FILE;
|
||||
@@ -766,10 +763,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return PlayerCache.getInstance().isAuthenticated(user);
|
||||
@@ -777,24 +774,27 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeLogged.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
||||
*/
|
||||
@Override
|
||||
@@ -803,9 +803,9 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() */
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
||||
*/
|
||||
@Override
|
||||
public int getAccountsRegistered() {
|
||||
BufferedReader br = null;
|
||||
@@ -831,10 +831,11 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public void updateName(String oldone, String newone) {
|
||||
PlayerAuth auth = this.getAuth(oldone);
|
||||
@@ -845,9 +846,9 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
BufferedReader br = null;
|
||||
@@ -897,9 +898,9 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
return new ArrayList<>();
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import com.zaxxer.hikari.pool.PoolInitializationException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MySQL implements DataSource {
|
||||
@@ -49,10 +43,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Constructor for MySQL.
|
||||
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws SQLException * @throws PoolInitializationException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws SQLException * @throws PoolInitializationException
|
||||
*/
|
||||
public MySQL() throws ClassNotFoundException, SQLException, PoolInitializationException {
|
||||
this.host = Settings.getMySQLHost;
|
||||
this.port = Settings.getMySQLPort;
|
||||
@@ -108,9 +101,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setConnectionArguments.
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws IllegalArgumentException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws IllegalArgumentException
|
||||
*/
|
||||
private synchronized void setConnectionArguments()
|
||||
throws ClassNotFoundException, IllegalArgumentException {
|
||||
HikariConfig config = new HikariConfig();
|
||||
@@ -132,9 +125,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reloadArguments.
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws IllegalArgumentException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws IllegalArgumentException
|
||||
*/
|
||||
private synchronized void reloadArguments()
|
||||
throws ClassNotFoundException, IllegalArgumentException {
|
||||
if (ds != null) {
|
||||
@@ -146,17 +139,18 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getConnection.
|
||||
|
||||
|
||||
* @return Connection * @throws SQLException */
|
||||
*
|
||||
* @return Connection * @throws SQLException
|
||||
*/
|
||||
private synchronized Connection getConnection() throws SQLException {
|
||||
return ds.getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setupConnection.
|
||||
|
||||
* @throws SQLException */
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
private synchronized void setupConnection() throws SQLException {
|
||||
Connection con = null;
|
||||
Statement st = null;
|
||||
@@ -222,10 +216,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
Connection con = null;
|
||||
@@ -250,10 +244,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) */
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(String user) {
|
||||
Connection con = null;
|
||||
@@ -309,10 +303,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean saveAuth(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@@ -522,10 +516,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updatePassword(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@@ -573,10 +567,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateSession(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@@ -602,10 +596,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public synchronized int purgeDatabase(long until) {
|
||||
Connection con = null;
|
||||
@@ -627,10 +621,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> autoPurgeDatabase(long until) {
|
||||
Connection con = null;
|
||||
@@ -663,10 +657,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
Connection con = null;
|
||||
@@ -706,10 +700,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateQuitLoc(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@@ -736,10 +730,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized int getIps(String ip) {
|
||||
Connection con = null;
|
||||
@@ -768,10 +762,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateEmail(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@@ -796,10 +790,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateSalt(PlayerAuth auth) {
|
||||
if (columnSalt.isEmpty()) {
|
||||
@@ -826,6 +820,7 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
||||
*/
|
||||
@Override
|
||||
@@ -845,6 +840,7 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
||||
*/
|
||||
@Override
|
||||
@@ -855,6 +851,7 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @param o AutoCloseable
|
||||
*/
|
||||
private void close(AutoCloseable o) {
|
||||
@@ -870,10 +867,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@@ -902,10 +899,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByIp(String ip) {
|
||||
Connection con = null;
|
||||
@@ -934,11 +931,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
|
||||
|
||||
|
||||
* @return List<String> * @throws SQLException * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) */
|
||||
* @return List<String> * @throws SQLException * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByEmail(String email) throws SQLException {
|
||||
final Connection con = getConnection();
|
||||
@@ -963,9 +959,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void purgeBanned(List<String> banned) {
|
||||
Connection con = null;
|
||||
@@ -988,9 +985,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType() */
|
||||
*
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
||||
*/
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.MYSQL;
|
||||
@@ -998,10 +995,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
Connection con = null;
|
||||
@@ -1028,9 +1025,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
Connection con = null;
|
||||
@@ -1052,9 +1050,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
Connection con = null;
|
||||
@@ -1077,6 +1076,7 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeLogged.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
||||
*/
|
||||
@Override
|
||||
@@ -1100,9 +1100,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() */
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
||||
*/
|
||||
@Override
|
||||
public int getAccountsRegistered() {
|
||||
int result = 0;
|
||||
@@ -1129,10 +1129,11 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public void updateName(String oldone, String newone) {
|
||||
Connection con = null;
|
||||
@@ -1154,9 +1155,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
@@ -1210,9 +1211,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class SQLite implements DataSource {
|
||||
@@ -37,9 +32,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Constructor for SQLite.
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws SQLException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws SQLException
|
||||
*/
|
||||
public SQLite() throws ClassNotFoundException, SQLException {
|
||||
this.database = Settings.getMySQLDatabase;
|
||||
this.tableName = Settings.getMySQLTablename;
|
||||
@@ -69,9 +64,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method connect.
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws SQLException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws SQLException
|
||||
*/
|
||||
private synchronized void connect() throws ClassNotFoundException, SQLException {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
ConsoleLogger.info("SQLite driver loaded");
|
||||
@@ -81,8 +76,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setup.
|
||||
|
||||
* @throws SQLException */
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
private synchronized void setup() throws SQLException {
|
||||
Statement st = null;
|
||||
ResultSet rs = null;
|
||||
@@ -139,10 +135,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -163,10 +159,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) */
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -199,10 +195,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean saveAuth(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -236,10 +232,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updatePassword(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -259,10 +255,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSession(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -284,10 +280,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public int purgeDatabase(long until) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -306,10 +302,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public List<String> autoPurgeDatabase(long until) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -334,10 +330,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -356,10 +352,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateQuitLoc(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -382,10 +378,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -410,10 +406,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -433,10 +429,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSalt(PlayerAuth auth) {
|
||||
if (columnSalt.isEmpty()) {
|
||||
@@ -459,6 +455,7 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
||||
*/
|
||||
@Override
|
||||
@@ -472,6 +469,7 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
||||
*/
|
||||
@Override
|
||||
@@ -480,6 +478,7 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @param st Statement
|
||||
*/
|
||||
private void close(Statement st) {
|
||||
@@ -494,6 +493,7 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @param rs ResultSet
|
||||
*/
|
||||
private void close(ResultSet rs) {
|
||||
@@ -508,10 +508,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -538,10 +538,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByIp(String ip) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -568,10 +568,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -598,9 +598,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
public void purgeBanned(List<String> banned) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -619,9 +620,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType() */
|
||||
*
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
||||
*/
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.SQLITE;
|
||||
@@ -629,10 +630,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -655,9 +656,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -675,9 +677,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -696,6 +699,7 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeLogged.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
||||
*/
|
||||
@Override
|
||||
@@ -715,9 +719,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() */
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
||||
*/
|
||||
@Override
|
||||
public int getAccountsRegistered() {
|
||||
int result = 0;
|
||||
@@ -740,10 +744,11 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public void updateName(String oldone, String newone) {
|
||||
PreparedStatement pst = null;
|
||||
@@ -761,9 +766,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
@@ -796,9 +801,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user