Update 3.2
//Changes 3.2:// * Fix Password showed in console ( support for Log4J ) * Quit Location will be more precise ( now double instead of int ) * Force command after the /register too * Close inventory when player try to open one unlogged * Fix old password supports * Remove some Magic Values ( 1.7.2+ ) * Fix threads not start correctly * Add a recall email adding message * Fix catpcha messages * Add multilines messages ( add &n ) * Fix some inventory problem * Fix some events problem * Call login event after /register
This commit is contained in:
@@ -129,8 +129,11 @@ public class PasswordSecurity {
|
||||
if (method == null)
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
|
||||
if (method.comparePassword(hash, password, playerName))
|
||||
return true;
|
||||
try {
|
||||
if (method.comparePassword(hash, password, playerName))
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (Settings.supportOldPassword) {
|
||||
try {
|
||||
if (compareWithAllEncryptionMethod(password, hash, playerName))
|
||||
@@ -142,9 +145,9 @@ public class PasswordSecurity {
|
||||
|
||||
private static boolean compareWithAllEncryptionMethod(String password, String hash, String playerName) throws NoSuchAlgorithmException {
|
||||
for (HashAlgorithm algo : HashAlgorithm.values()) {
|
||||
try {
|
||||
EncryptionMethod method = (EncryptionMethod) algo.getclass().newInstance();
|
||||
if (algo != HashAlgorithm.CUSTOM) {
|
||||
if (algo != HashAlgorithm.CUSTOM)
|
||||
try {
|
||||
EncryptionMethod method = (EncryptionMethod) algo.getclass().newInstance();
|
||||
if (method.comparePassword(hash, password, playerName)) {
|
||||
PlayerAuth nAuth = AuthMe.getInstance().database.getAuth(playerName);
|
||||
if (nAuth != null) {
|
||||
@@ -155,8 +158,7 @@ public class PasswordSecurity {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class DOUBLEMD5 implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, ""));
|
||||
}
|
||||
|
||||
private String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
|
||||
@@ -22,7 +22,7 @@ public class IPB3 implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, salt));
|
||||
}
|
||||
|
||||
private String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
|
||||
@@ -19,7 +19,7 @@ public class JOOMLA implements EncryptionMethod {
|
||||
return hash.equals(getMD5(password + salt) + ":" + salt);
|
||||
}
|
||||
|
||||
private String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
|
||||
@@ -8,11 +8,7 @@ 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));
|
||||
return getMD5(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,4 +16,11 @@ public class MD5 implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, ""));
|
||||
}
|
||||
|
||||
private static 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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ public class MD5VB implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, line[2]));
|
||||
}
|
||||
|
||||
private String getMD5(String password) throws NoSuchAlgorithmException {
|
||||
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(password.getBytes());
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class MYBB implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, salt));
|
||||
}
|
||||
|
||||
private String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
|
||||
@@ -48,7 +48,7 @@ public class PHPFUSION implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, salt));
|
||||
}
|
||||
|
||||
private String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||
private static String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SALTED2MD5 implements EncryptionMethod {
|
||||
return hash.equals(getMD5(getMD5(password) + salt));
|
||||
}
|
||||
|
||||
private String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
|
||||
@@ -8,11 +8,7 @@ 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));
|
||||
return getSHA1(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,5 +16,13 @@ public class SHA1 implements EncryptionMethod {
|
||||
throws NoSuchAlgorithmException {
|
||||
return hash.equals(getHash(password, ""));
|
||||
}
|
||||
|
||||
private static 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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public class SHA256 implements EncryptionMethod {
|
||||
|
||||
@Override
|
||||
public String getHash(String password, String salt) throws NoSuchAlgorithmException {
|
||||
return "$SHA$" + salt + "$" + getSha256(getSha256(password) + salt);
|
||||
return "$SHA$" + salt + "$" + getSHA256(getSHA256(password) + salt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -18,12 +18,12 @@ public class SHA256 implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, line[2]));
|
||||
}
|
||||
|
||||
private String getSha256(String password) throws NoSuchAlgorithmException {
|
||||
private static String getSHA256(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
|
||||
sha256.reset();
|
||||
sha256.update(password.getBytes());
|
||||
sha256.update(message.getBytes());
|
||||
byte[] digest = sha256.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,11 +9,7 @@ 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));
|
||||
return getSHA512(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,4 +18,11 @@ public class SHA512 implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, ""));
|
||||
}
|
||||
|
||||
private static String getSHA512(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha512 = MessageDigest.getInstance("SHA-512");
|
||||
sha512.reset();
|
||||
sha512.update(message.getBytes());
|
||||
byte[] digest = sha512.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class SMF implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, playerName.toLowerCase()));
|
||||
}
|
||||
|
||||
private String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||
private static String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
|
||||
@@ -22,7 +22,7 @@ public class WBB3 implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, salt));
|
||||
}
|
||||
|
||||
private String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||
private static String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
|
||||
Reference in New Issue
Block a user