Fix BCRYPT, Add WBB3 crypt, FIX CombatTag
This commit is contained in:
@@ -129,8 +129,7 @@ public class Utils {
|
||||
final Location locat = new Location(world, x, y + 0.6D, z);
|
||||
final Location loc = locat.getBlock().getLocation();
|
||||
|
||||
Bukkit.getScheduler().runTask(AuthMe.getInstance(), new Runnable() {
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AuthMe.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(pl, loc);
|
||||
@@ -141,7 +140,6 @@ public class Utils {
|
||||
pl.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
id = Bukkit.getScheduler().runTaskTimer(AuthMe.authme, new Runnable()
|
||||
@@ -155,7 +153,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
}, 1L, 20L);
|
||||
Bukkit.getScheduler().runTaskLater(AuthMe.authme, new Runnable()
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AuthMe.authme, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class API {
|
||||
* @return true if player is authenticate
|
||||
*/
|
||||
public static boolean isAuthenticated(Player player) {
|
||||
return PlayerCache.getInstance().isAuthenticated(player.getName());
|
||||
return PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,7 @@ 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;
|
||||
|
||||
public class AuthMeEntityListener implements Listener{
|
||||
@@ -60,6 +61,9 @@ public class AuthMeEntityListener implements Listener{
|
||||
|
||||
Player player = (Player) entity;
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if(CombatTagComunicator.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
@@ -169,7 +173,7 @@ public class AuthMeEntityListener implements Listener{
|
||||
Player player = (Player) event.getEntity();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -198,7 +202,7 @@ public class AuthMeEntityListener implements Listener{
|
||||
Player player = (Player) event.getEntity();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1010,7 +1010,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1080,7 +1080,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player))
|
||||
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
|
||||
@@ -90,9 +90,14 @@ public class PasswordSecurity {
|
||||
return getMD5(getMD5(salt) + getMD5(message));
|
||||
}
|
||||
|
||||
private static String getBCrypt(String message, String salt) {
|
||||
private static String getBCrypt(String message, String salt) throws NoSuchAlgorithmException {
|
||||
return BCrypt.hashpw(message, salt);
|
||||
}
|
||||
|
||||
private static String getWBB3(String message, String salt) throws NoSuchAlgorithmException {
|
||||
|
||||
return getSHA1(salt.concat(getSHA1(salt.concat(getSHA1(message)))));
|
||||
}
|
||||
|
||||
private static String createSalt(int length) throws NoSuchAlgorithmException {
|
||||
byte[] msg = new byte[40];
|
||||
@@ -198,6 +203,18 @@ public class PasswordSecurity {
|
||||
userSalt.put(name, saltbcrypt);
|
||||
}
|
||||
return getBCrypt(password, saltbcrypt);
|
||||
case WBB3:
|
||||
String saltwbb = "";
|
||||
try {
|
||||
saltbcrypt = AuthMe.getInstance().database.getAuth(name).getSalt();
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (ArrayIndexOutOfBoundsException aioobe) {
|
||||
}
|
||||
if(saltwbb.isEmpty() || saltwbb == null) {
|
||||
saltwbb = createSalt(40);
|
||||
userSalt.put(name, saltwbb);
|
||||
}
|
||||
return getWBB3(password, saltwbb);
|
||||
default:
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
}
|
||||
@@ -208,6 +225,10 @@ public class PasswordSecurity {
|
||||
PhpBB checkHash = new PhpBB();
|
||||
return checkHash.phpbb_check_hash(password, hash);
|
||||
}
|
||||
if(!Settings.getMySQLColumnSalt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.WBB3) {
|
||||
String saltwbb3 = AuthMe.getInstance().database.getAuth(playername).getSalt();
|
||||
return hash.equals(getWBB3(password, saltwbb3));
|
||||
}
|
||||
if(!Settings.getMySQLColumnSalt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.IPB3) {
|
||||
String saltipb = AuthMe.getInstance().database.getAuth(playername).getSalt();
|
||||
return hash.equals(getSaltedIPB3(password, saltipb));
|
||||
@@ -305,7 +326,8 @@ public class PasswordSecurity {
|
||||
|
||||
public enum HashAlgorithm {
|
||||
|
||||
MD5, SHA1, SHA256, WHIRLPOOL, XAUTH, MD5VB, PHPBB, PLAINTEXT, MYBB, IPB3, PHPFUSION, SMF, XFSHA1, XFSHA256, SALTED2MD5, JOOMLA, BCRYPT
|
||||
MD5, SHA1, SHA256, WHIRLPOOL, XAUTH, MD5VB, PHPBB, PLAINTEXT, MYBB, IPB3, PHPFUSION, SMF, XFSHA1,
|
||||
XFSHA256, SALTED2MD5, JOOMLA, BCRYPT, WBB3
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user