* The comparePassword is called when we need to match password (/login usually) *
- * - * @author Gabriele - * @version $Revision: 1.0 $ */ public interface EncryptionMethod { @@ -25,7 +22,7 @@ public interface EncryptionMethod { * etc... for customs methods) * @param name String * - * @return Hashing password * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException + * @return Hashing password */ String getHash(String password, String salt, String name) throws NoSuchAlgorithmException; @@ -35,7 +32,7 @@ public interface EncryptionMethod { * @param password * @param playerName * - * @return true if password match, false else * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException + * @return true if password match, false else */ boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException; diff --git a/src/main/java/fr/xephi/authme/security/crypts/IPB3.java b/src/main/java/fr/xephi/authme/security/crypts/IPB3.java index ecfc459e7..090303119 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/IPB3.java +++ b/src/main/java/fr/xephi/authme/security/crypts/IPB3.java @@ -10,13 +10,6 @@ import java.security.NoSuchAlgorithmException; */ public class IPB3 implements EncryptionMethod { - /** - * Method getMD5. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getMD5(String message) throws NoSuchAlgorithmException { MessageDigest md5 = MessageDigest.getInstance("MD5"); @@ -26,30 +19,12 @@ public class IPB3 implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return getMD5(getMD5(salt) + getMD5(password)); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java b/src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java index d4eb0f7f0..8e2dc7b8d 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java +++ b/src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java @@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException; */ public class JOOMLA implements EncryptionMethod { - /** - * Method getMD5. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getMD5(String message) throws NoSuchAlgorithmException { MessageDigest md5 = MessageDigest.getInstance("MD5"); @@ -24,30 +17,12 @@ public class JOOMLA implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return getMD5(password + salt) + ":" + salt; } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/MD5.java b/src/main/java/fr/xephi/authme/security/crypts/MD5.java index a4e0bc131..b2e9116a8 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/MD5.java +++ b/src/main/java/fr/xephi/authme/security/crypts/MD5.java @@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException; */ public class MD5 implements EncryptionMethod { - /** - * Method getMD5. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getMD5(String message) throws NoSuchAlgorithmException { MessageDigest md5 = MessageDigest.getInstance("MD5"); @@ -24,30 +17,12 @@ public class MD5 implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return getMD5(password); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/MD5VB.java b/src/main/java/fr/xephi/authme/security/crypts/MD5VB.java index 79892c284..90ea7fc31 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/MD5VB.java +++ b/src/main/java/fr/xephi/authme/security/crypts/MD5VB.java @@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException; */ public class MD5VB implements EncryptionMethod { - /** - * Method getMD5. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getMD5(String message) throws NoSuchAlgorithmException { MessageDigest md5 = MessageDigest.getInstance("MD5"); @@ -24,30 +17,12 @@ public class MD5VB implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return "$MD5vb$" + salt + "$" + getMD5(getMD5(password) + salt); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/MYBB.java b/src/main/java/fr/xephi/authme/security/crypts/MYBB.java index 501a591ae..444bac47d 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/MYBB.java +++ b/src/main/java/fr/xephi/authme/security/crypts/MYBB.java @@ -10,13 +10,6 @@ import java.security.NoSuchAlgorithmException; */ public class MYBB implements EncryptionMethod { - /** - * Method getMD5. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getMD5(String message) throws NoSuchAlgorithmException { MessageDigest md5 = MessageDigest.getInstance("MD5"); @@ -26,30 +19,12 @@ public class MYBB implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return getMD5(getMD5(salt) + getMD5(password)); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/PHPBB.java b/src/main/java/fr/xephi/authme/security/crypts/PHPBB.java index e852dd6d1..abac87636 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/PHPBB.java +++ b/src/main/java/fr/xephi/authme/security/crypts/PHPBB.java @@ -11,19 +11,11 @@ import java.security.NoSuchAlgorithmException; /** * @author stefano - * @version $Revision: 1.0 $ */ public class PHPBB implements EncryptionMethod { - private final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + private static final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - /** - * Method md5. - * - * @param data String - * - * @return String - */ public static String md5(String data) { try { byte[] bytes = data.getBytes("ISO-8859-1"); @@ -35,14 +27,7 @@ public class PHPBB implements EncryptionMethod { } } - /** - * Method hexToInt. - * - * @param ch char - * - * @return int - */ - static int hexToInt(char ch) { + private static int hexToInt(char ch) { if (ch >= '0' && ch <= '9') return ch - '0'; ch = Character.toUpperCase(ch); @@ -51,13 +36,6 @@ public class PHPBB implements EncryptionMethod { throw new IllegalArgumentException("Not a hex character: " + ch); } - /** - * Method bytes2hex. - * - * @param bytes byte[] - * - * @return String - */ private static String bytes2hex(byte[] bytes) { StringBuilder r = new StringBuilder(32); for (byte b : bytes) { @@ -69,14 +47,7 @@ public class PHPBB implements EncryptionMethod { return r.toString(); } - /** - * Method pack. - * - * @param hex String - * - * @return String - */ - static String pack(String hex) { + private static String pack(String hex) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < hex.length(); i += 2) { char c1 = hex.charAt(i); @@ -87,14 +58,6 @@ public class PHPBB implements EncryptionMethod { return buf.toString(); } - /** - * Method phpbb_hash. - * - * @param password String - * @param salt String - * - * @return String - */ public String phpbb_hash(String password, String salt) { String random_state = salt; StringBuilder random = new StringBuilder(); @@ -110,27 +73,10 @@ public class PHPBB implements EncryptionMethod { return md5(password); } - /** - * Method _hash_gensalt_private. - * - * @param input String - * @param itoa64 String - * - * @return String - */ private String _hash_gensalt_private(String input, String itoa64) { return _hash_gensalt_private(input, itoa64, 6); } - /** - * Method _hash_gensalt_private. - * - * @param input String - * @param itoa64 String - * @param iteration_count_log2 int - * - * @return String - */ private String _hash_gensalt_private(String input, String itoa64, int iteration_count_log2) { if (iteration_count_log2 < 4 || iteration_count_log2 > 31) { @@ -142,14 +88,6 @@ public class PHPBB implements EncryptionMethod { return output; } - /** - * Encode hash - * - * @param input String - * @param count int - * - * @return String - */ private String _hash_encode64(String input, int count) { StringBuilder output = new StringBuilder(); int i = 0; @@ -171,14 +109,6 @@ public class PHPBB implements EncryptionMethod { return output.toString(); } - /** - * Method _hash_crypt_private. - * - * @param password String - * @param setting String - * - * @return String - */ String _hash_crypt_private(String password, String setting) { String output = "*"; if (!setting.substring(0, 3).equals("$H$")) @@ -200,44 +130,18 @@ public class PHPBB implements EncryptionMethod { return output; } - /** - * Method phpbb_check_hash. - * - * @param password String - * @param hash String - * - * @return boolean - */ public boolean phpbb_check_hash(String password, String hash) { if (hash.length() == 34) return _hash_crypt_private(password, hash).equals(hash); else return md5(password).equals(hash); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return phpbb_hash(password, salt); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java b/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java index fc9440a6b..2d7bc047e 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java +++ b/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java @@ -14,13 +14,6 @@ import java.security.NoSuchAlgorithmException; */ public class PHPFUSION implements EncryptionMethod { - /** - * Method getSHA1. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getSHA1(String message) throws NoSuchAlgorithmException { MessageDigest sha1 = MessageDigest.getInstance("SHA1"); @@ -30,15 +23,6 @@ public class PHPFUSION implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { @@ -66,15 +50,6 @@ public class PHPFUSION implements EncryptionMethod { return digest; } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/PLAINTEXT.java b/src/main/java/fr/xephi/authme/security/crypts/PLAINTEXT.java index def0e1af7..0e8117868 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/PLAINTEXT.java +++ b/src/main/java/fr/xephi/authme/security/crypts/PLAINTEXT.java @@ -6,30 +6,12 @@ import java.security.NoSuchAlgorithmException; */ public class PLAINTEXT implements EncryptionMethod { - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return password; } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java b/src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java index 242a88317..76303d3fc 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java +++ b/src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java @@ -7,15 +7,6 @@ import java.security.NoSuchAlgorithmException; */ public class ROYALAUTH implements EncryptionMethod { - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { @@ -24,14 +15,6 @@ public class ROYALAUTH implements EncryptionMethod { return password; } - /** - * Method hash. - * - * @param password String - * @param salt String - * - * @return String * @throws NoSuchAlgorithmException - */ public String hash(String password, String salt) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA-512"); @@ -43,15 +26,6 @@ public class ROYALAUTH implements EncryptionMethod { return sb.toString(); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java b/src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java index 5b29db9ed..24075b728 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java +++ b/src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java @@ -10,13 +10,6 @@ import java.security.NoSuchAlgorithmException; */ public class SALTED2MD5 implements EncryptionMethod { - /** - * Method getMD5. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getMD5(String message) throws NoSuchAlgorithmException { MessageDigest md5 = MessageDigest.getInstance("MD5"); @@ -26,30 +19,12 @@ public class SALTED2MD5 implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return getMD5(getMD5(password) + salt); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java b/src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java index 27d3cc8db..02ae097e8 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java +++ b/src/main/java/fr/xephi/authme/security/crypts/SALTEDSHA512.java @@ -10,13 +10,6 @@ import java.security.NoSuchAlgorithmException; */ public class SALTEDSHA512 implements EncryptionMethod { - /** - * Method getSHA512. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getSHA512(String message) throws NoSuchAlgorithmException { MessageDigest sha512 = MessageDigest.getInstance("SHA-512"); @@ -26,30 +19,12 @@ public class SALTEDSHA512 implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return getSHA512(password + salt); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/SHA1.java b/src/main/java/fr/xephi/authme/security/crypts/SHA1.java index 360cfaf37..47ae5ca0e 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/SHA1.java +++ b/src/main/java/fr/xephi/authme/security/crypts/SHA1.java @@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException; */ public class SHA1 implements EncryptionMethod { - /** - * Method getSHA1. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getSHA1(String message) throws NoSuchAlgorithmException { MessageDigest sha1 = MessageDigest.getInstance("SHA1"); @@ -24,30 +17,12 @@ public class SHA1 implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return getSHA1(password); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/SHA256.java b/src/main/java/fr/xephi/authme/security/crypts/SHA256.java index ff25dd2f4..e14fac4f2 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/SHA256.java +++ b/src/main/java/fr/xephi/authme/security/crypts/SHA256.java @@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException; */ public class SHA256 implements EncryptionMethod { - /** - * Method getSHA256. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getSHA256(String message) throws NoSuchAlgorithmException { MessageDigest sha256 = MessageDigest.getInstance("SHA-256"); @@ -24,30 +17,12 @@ public class SHA256 implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return "$SHA$" + salt + "$" + getSHA256(getSHA256(password) + salt); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/SHA512.java b/src/main/java/fr/xephi/authme/security/crypts/SHA512.java index 3e7b93451..ae752b418 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/SHA512.java +++ b/src/main/java/fr/xephi/authme/security/crypts/SHA512.java @@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException; */ public class SHA512 implements EncryptionMethod { - /** - * Method getSHA512. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getSHA512(String message) throws NoSuchAlgorithmException { MessageDigest sha512 = MessageDigest.getInstance("SHA-512"); @@ -24,30 +17,12 @@ public class SHA512 implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return getSHA512(password); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/SMF.java b/src/main/java/fr/xephi/authme/security/crypts/SMF.java index 16f19cf7e..d4f9bcc1e 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/SMF.java +++ b/src/main/java/fr/xephi/authme/security/crypts/SMF.java @@ -8,13 +8,6 @@ import java.security.NoSuchAlgorithmException; */ public class SMF implements EncryptionMethod { - /** - * Method getSHA1. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getSHA1(String message) throws NoSuchAlgorithmException { MessageDigest sha1 = MessageDigest.getInstance("SHA1"); @@ -24,30 +17,12 @@ public class SMF implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return getSHA1(name.toLowerCase() + password); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/WBB3.java b/src/main/java/fr/xephi/authme/security/crypts/WBB3.java index c1ea4276e..992f62808 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/WBB3.java +++ b/src/main/java/fr/xephi/authme/security/crypts/WBB3.java @@ -10,13 +10,6 @@ import java.security.NoSuchAlgorithmException; */ public class WBB3 implements EncryptionMethod { - /** - * Method getSHA1. - * - * @param message String - * - * @return String * @throws NoSuchAlgorithmException - */ private static String getSHA1(String message) throws NoSuchAlgorithmException { MessageDigest sha1 = MessageDigest.getInstance("SHA1"); @@ -26,30 +19,12 @@ public class WBB3 implements EncryptionMethod { return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return getSHA1(salt.concat(getSHA1(salt.concat(getSHA1(password))))); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/WBB4.java b/src/main/java/fr/xephi/authme/security/crypts/WBB4.java index 41b528899..5a49e06d9 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/WBB4.java +++ b/src/main/java/fr/xephi/authme/security/crypts/WBB4.java @@ -6,30 +6,12 @@ import java.security.NoSuchAlgorithmException; */ public class WBB4 implements EncryptionMethod { - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { return BCRYPT.getDoubleHash(password, salt); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java b/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java index 6bf5d9f3b..0e27a04af 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java +++ b/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java @@ -164,13 +164,6 @@ public class WHIRLPOOL implements EncryptionMethod { public WHIRLPOOL() { } - /** - * Method display. - * - * @param array byte[] - * - * @return String - */ protected static String display(byte[] array) { char[] val = new char[2 * array.length]; String hex = "0123456789ABCDEF"; @@ -377,7 +370,6 @@ public class WHIRLPOOL implements EncryptionMethod { * Delivers string input data to the hashing algorithm. * * @param source plaintext data to hash (ASCII text string). - * * This method maintains the invariant: bufferBits < 512 */ public void NESSIEadd(String source) { @@ -409,15 +401,6 @@ public class WHIRLPOOL implements EncryptionMethod { return display(digest); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java b/src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java index c3e79627d..1817d9754 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java +++ b/src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java @@ -13,14 +13,6 @@ public class WORDPRESS implements EncryptionMethod { private static final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; private final SecureRandom randomGen = new SecureRandom(); - /** - * Method encode64. - * - * @param src byte[] - * @param count int - * - * @return String - */ private String encode64(byte[] src, int count) { int i, value; StringBuilder output = new StringBuilder(); @@ -55,14 +47,6 @@ public class WORDPRESS implements EncryptionMethod { return output.toString(); } - /** - * Method crypt. - * - * @param password String - * @param setting String - * - * @return String - */ private String crypt(String password, String setting) { String output = "*0"; if (((setting.length() < 2) ? setting : setting.substring(0, 2)).equalsIgnoreCase(output)) { @@ -101,13 +85,6 @@ public class WORDPRESS implements EncryptionMethod { return output; } - /** - * Method gensaltPrivate. - * - * @param input byte[] - * - * @return String - */ private String gensaltPrivate(byte[] input) { String output = "$P$"; int iterationCountLog2 = 8; @@ -116,13 +93,6 @@ public class WORDPRESS implements EncryptionMethod { return output; } - /** - * Method stringToUtf8. - * - * @param string String - * - * @return byte[] - */ private byte[] stringToUtf8(String string) { try { return string.getBytes("UTF-8"); @@ -131,15 +101,6 @@ public class WORDPRESS implements EncryptionMethod { } } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { @@ -148,15 +109,6 @@ public class WORDPRESS implements EncryptionMethod { return crypt(password, gensaltPrivate(stringToUtf8(new String(random)))); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/XAUTH.java b/src/main/java/fr/xephi/authme/security/crypts/XAUTH.java index 49500ddb5..f648677f3 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/XAUTH.java +++ b/src/main/java/fr/xephi/authme/security/crypts/XAUTH.java @@ -6,13 +6,6 @@ import java.security.NoSuchAlgorithmException; */ public class XAUTH implements EncryptionMethod { - /** - * Method getWhirlpool. - * - * @param message String - * - * @return String - */ public static String getWhirlpool(String message) { WHIRLPOOL w = new WHIRLPOOL(); byte[] digest = new byte[WHIRLPOOL.DIGESTBYTES]; @@ -22,15 +15,6 @@ public class XAUTH implements EncryptionMethod { return WHIRLPOOL.display(digest); } - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { @@ -39,15 +23,6 @@ public class XAUTH implements EncryptionMethod { return hash.substring(0, saltPos) + salt + hash.substring(saltPos); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { diff --git a/src/main/java/fr/xephi/authme/security/crypts/XF.java b/src/main/java/fr/xephi/authme/security/crypts/XF.java index a1fc45ce2..0125a6a7c 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/XF.java +++ b/src/main/java/fr/xephi/authme/security/crypts/XF.java @@ -13,30 +13,12 @@ import java.util.regex.Pattern; */ public class XF implements EncryptionMethod { - /** - * Method getHash. - * - * @param password String - * @param salt String - * @param name String - * - * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) - */ @Override public String getHash(String password, String salt, String name) throws NoSuchAlgorithmException { - return getSHA256(getSHA256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt)); + return getSha256(getSha256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt)); } - /** - * Method comparePassword. - * - * @param hash String - * @param password String - * @param playerName String - * - * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) - */ @Override public boolean comparePassword(String hash, String password, String playerName) throws NoSuchAlgorithmException { @@ -44,14 +26,7 @@ public class XF implements EncryptionMethod { return hash.equals(regmatch("\"hash\";.:..:\"(.*)\";.:.:\"salt\"", salt)); } - /** - * Method getSHA256. - * - * @param password String - * - * @return String * @throws NoSuchAlgorithmException - */ - public String getSHA256(String password) throws NoSuchAlgorithmException { + private String getSha256(String password) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(password.getBytes()); byte byteData[] = md.digest(); @@ -70,15 +45,7 @@ public class XF implements EncryptionMethod { return hexString.toString(); } - /** - * Method regmatch. - * - * @param pattern String - * @param line String - * - * @return String - */ - public String regmatch(String pattern, String line) { + private String regmatch(String pattern, String line) { Listnull
- * . On odd length leading zero will be assumed.
+ * @param s String containing hexadecimal digits. May be null
.
+ * On odd length leading zero will be assumed.
*
- * @return Array on bytes, non-null
. * @throws IllegalArgumentException
- * when string contains non-hex character
+ * @return Array on bytes, non-null
.
+ * @throws IllegalArgumentException when string contains non-hex character
*/
public static byte[] hex2bin(final String s) {
String m = s;
@@ -85,10 +88,10 @@ public class BinTools {
/**
* Convert hex digit to numerical value.
*
- * @param c 0-9, a-f, A-F allowd.
+ * @param c 0-9, a-f, A-F allowed.
*
- * @return 0-15 * @throws IllegalArgumentException
- * on non-hex character
+ * @return 0-15
+ * @throws IllegalArgumentException on non-hex character
*/
public static int hex2bin(char c) {
if (c >= '0' && c <= '9') {
@@ -103,12 +106,8 @@ public class BinTools {
throw new IllegalArgumentException("Input string may only contain hex digits, but found '" + c + "'");
}
- /**
- * Method main.
- *
- * @param args String[]
- */
- public static void main(String[] args) {
+ // TODO ljacqu 20151219: Move to a BinToolsTest class
+ private static void testUtils(String[] args) {
byte b[] = new byte[256];
byte bb = 0;
for (int i = 0; i < 256; i++) {
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/MacBasedPRF.java b/src/main/java/fr/xephi/authme/security/pbkdf2/MacBasedPRF.java
index 95651c02e..5b0268c18 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/MacBasedPRF.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/MacBasedPRF.java
@@ -63,12 +63,6 @@ public class MacBasedPRF implements PRF {
}
}
- /**
- * Constructor for MacBasedPRF.
- *
- * @param macAlgorithm String
- * @param provider String
- */
public MacBasedPRF(String macAlgorithm, String provider) {
this.macAlgorithm = macAlgorithm;
try {
@@ -79,34 +73,18 @@ public class MacBasedPRF implements PRF {
}
}
- /**
- * Method doFinal.
- *
- * @param M byte[]
- *
- * @return byte[] * @see fr.xephi.authme.security.pbkdf2.PRF#doFinal(byte[])
- */
+ @Override
public byte[] doFinal(byte[] M) {
byte[] r = mac.doFinal(M);
return r;
}
- /**
- * Method getHLen.
- *
- * @return int * @see fr.xephi.authme.security.pbkdf2.PRF#getHLen()
- */
+ @Override
public int getHLen() {
return hLen;
}
- /**
- * Method init.
- *
- * @param P byte[]
- *
- * @see fr.xephi.authme.security.pbkdf2.PRF#init(byte[])
- */
+ @Override
public void init(byte[] P) {
try {
mac.init(new SecretKeySpec(P, macAlgorithm));
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java
index 1ca3f4ce3..c78f786ad 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java
@@ -159,28 +159,15 @@ public class PBKDF2Engine implements PBKDF2 {
}
}
- /**
- * Method deriveKey.
- *
- * @param inputPassword String
- *
- * @return byte[] * @see fr.xephi.authme.security.pbkdf2.PBKDF2#deriveKey(String)
- */
+ @Override
public byte[] deriveKey(String inputPassword) {
return deriveKey(inputPassword, 0);
}
- /**
- * Method deriveKey.
- *
- * @param inputPassword String
- * @param dkLen int
- *
- * @return byte[] * @see fr.xephi.authme.security.pbkdf2.PBKDF2#deriveKey(String, int)
- */
+ @Override
public byte[] deriveKey(String inputPassword, int dkLen) {
byte[] r = null;
- byte P[] = null;
+ byte[] P = null;
String charset = parameters.getHashCharset();
if (inputPassword == null) {
inputPassword = "";
@@ -202,13 +189,7 @@ public class PBKDF2Engine implements PBKDF2 {
return r;
}
- /**
- * Method verifyKey.
- *
- * @param inputPassword String
- *
- * @return boolean * @see fr.xephi.authme.security.pbkdf2.PBKDF2#verifyKey(String)
- */
+ @Override
public boolean verifyKey(String inputPassword) {
byte[] referenceKey = getParameters().getDerivedKey();
if (referenceKey == null || referenceKey.length == 0) {
@@ -240,22 +221,12 @@ public class PBKDF2Engine implements PBKDF2 {
prf.init(P);
}
- /**
- * Method getPseudoRandomFunction.
- *
- * @return PRF * @see fr.xephi.authme.security.pbkdf2.PBKDF2#getPseudoRandomFunction()
- */
+ @Override
public PRF getPseudoRandomFunction() {
return prf;
}
- /**
- * Method setPseudoRandomFunction.
- *
- * @param prf PRF
- *
- * @see fr.xephi.authme.security.pbkdf2.PBKDF2#setPseudoRandomFunction(PRF)
- */
+ @Override
public void setPseudoRandomFunction(PRF prf) {
this.prf = prf;
}
@@ -369,22 +340,12 @@ public class PBKDF2Engine implements PBKDF2 {
dest[offset + 3] = (byte) (i);
}
- /**
- * Method getParameters.
- *
- * @return PBKDF2Parameters * @see fr.xephi.authme.security.pbkdf2.PBKDF2#getParameters()
- */
+ @Override
public PBKDF2Parameters getParameters() {
return parameters;
}
- /**
- * Method setParameters.
- *
- * @param parameters PBKDF2Parameters
- *
- * @see fr.xephi.authme.security.pbkdf2.PBKDF2#setParameters(PBKDF2Parameters)
- */
+ @Override
public void setParameters(PBKDF2Parameters parameters) {
this.parameters = parameters;
}
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2HexFormatter.java b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2HexFormatter.java
index 2309d77f1..54544a4c2 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2HexFormatter.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2HexFormatter.java
@@ -33,14 +33,7 @@ package fr.xephi.authme.security.pbkdf2;
*/
public class PBKDF2HexFormatter implements PBKDF2Formatter {
- /**
- * Method fromString.
- *
- * @param p PBKDF2Parameters
- * @param s String
- *
- * @return boolean * @see fr.xephi.authme.security.pbkdf2.PBKDF2Formatter#fromString(PBKDF2Parameters, String)
- */
+ @Override
public boolean fromString(PBKDF2Parameters p, String s) {
if (p == null || s == null) {
return true;
@@ -61,13 +54,7 @@ public class PBKDF2HexFormatter implements PBKDF2Formatter {
return false;
}
- /**
- * Method toString.
- *
- * @param p PBKDF2Parameters
- *
- * @return String * @see fr.xephi.authme.security.pbkdf2.PBKDF2Formatter#toString(PBKDF2Parameters)
- */
+ @Override
public String toString(PBKDF2Parameters p) {
String s = BinTools.bin2hex(p.getSalt()) + ":" + String.valueOf(p.getIterationCount()) + ":" + BinTools.bin2hex(p.getDerivedKey());
return s;
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Parameters.java b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Parameters.java
index d962648b2..b7b158a0c 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Parameters.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Parameters.java
@@ -99,92 +99,42 @@ public class PBKDF2Parameters {
this.derivedKey = derivedKey;
}
- /**
- * Method getIterationCount.
- *
- * @return int
- */
public int getIterationCount() {
return iterationCount;
}
- /**
- * Method setIterationCount.
- *
- * @param iterationCount int
- */
public void setIterationCount(int iterationCount) {
this.iterationCount = iterationCount;
}
- /**
- * Method getSalt.
- *
- * @return byte[]
- */
public byte[] getSalt() {
return salt;
}
- /**
- * Method setSalt.
- *
- * @param salt byte[]
- */
public void setSalt(byte[] salt) {
this.salt = salt;
}
- /**
- * Method getDerivedKey.
- *
- * @return byte[]
- */
public byte[] getDerivedKey() {
return derivedKey;
}
- /**
- * Method setDerivedKey.
- *
- * @param derivedKey byte[]
- */
public void setDerivedKey(byte[] derivedKey) {
this.derivedKey = derivedKey;
}
- /**
- * Method getHashAlgorithm.
- *
- * @return String
- */
public String getHashAlgorithm() {
return hashAlgorithm;
}
- /**
- * Method setHashAlgorithm.
- *
- * @param hashAlgorithm String
- */
public void setHashAlgorithm(String hashAlgorithm) {
this.hashAlgorithm = hashAlgorithm;
}
- /**
- * Method getHashCharset.
- *
- * @return String
- */
public String getHashCharset() {
return hashCharset;
}
- /**
- * Method setHashCharset.
- *
- * @param hashCharset String
- */
public void setHashCharset(String hashCharset) {
this.hashCharset = hashCharset;
}
diff --git a/src/tools/bathelpers/setvars.bat b/src/tools/bathelpers/setvars.bat
index 463f6080e..e8ba9ba1b 100644
--- a/src/tools/bathelpers/setvars.bat
+++ b/src/tools/bathelpers/setvars.bat
@@ -2,7 +2,7 @@
SET batdir=C:\your\path\AUTHME_DEV\bathelpers\
: The location of the generated JAR file
-SET jarfile=C:\Users\yourname\IdeaProjects\AuthMeReloaded\target\AuthMe-5.1-SNAPSHOT.jar
+SET jarfile=C:\Users\yourname\IdeaProjects\AuthMeReloaded\target\AuthMe-5.2-SNAPSHOT.jar
: The location of the pom.xml file of the project
SET pomfile=C:\Users\yourname\IdeaProjects\AuthMeReloaded\pom.xml