#1128 Rename to camel case (PR #235)

* rename classes according to cammel case and make code reflect these updates

* rename according to cammel case

* rename to camel case more accuratley

* rename to camel case try 3; fix Ipb4 java doc

* retry rename camel case

* rename to camel case
This commit is contained in:
ljacqu
2017-03-17 18:49:30 +01:00
committed by GitHub
parent 18dbcfde89
commit 731d085ccd
56 changed files with 168 additions and 167 deletions
+2 -2
View File
@@ -24,7 +24,7 @@ import fr.xephi.authme.listener.PlayerListener19;
import fr.xephi.authme.listener.ServerListener;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PermissionsSystemType;
import fr.xephi.authme.security.crypts.SHA256;
import fr.xephi.authme.security.crypts.Sha256;
import fr.xephi.authme.service.BackupService;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.GeoIpService;
@@ -219,7 +219,7 @@ public class AuthMe extends JavaPlugin {
instantiateServices(injector);
// Convert deprecated PLAINTEXT hash entries
MigrationService.changePlainTextToSha256(settings, database, new SHA256());
MigrationService.changePlainTextToSha256(settings, database, new Sha256());
// TODO: does this still make sense? -sgdc3
// If the server is empty (fresh start) just set all the players as unlogged
@@ -7,7 +7,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.security.crypts.XFBCRYPT;
import fr.xephi.authme.security.crypts.XfBCrypt;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
@@ -286,7 +286,7 @@ public class MySQL implements DataSource {
if (rs.next()) {
Blob blob = rs.getBlob("data");
byte[] bytes = blob.getBytes(1, (int) blob.length());
auth.setPassword(new HashedPassword(XFBCRYPT.getHashFromBlob(bytes)));
auth.setPassword(new HashedPassword(XfBCrypt.getHashFromBlob(bytes)));
}
}
}
@@ -482,8 +482,8 @@ public class MySQL implements DataSource {
sql = "INSERT INTO xf_user_authenticate (user_id, scheme_class, data) VALUES (?,?,?)";
pst2 = con.prepareStatement(sql);
pst2.setInt(1, id);
pst2.setString(2, XFBCRYPT.SCHEME_CLASS);
String serializedHash = XFBCRYPT.serializeHash(auth.getPassword().getHash());
pst2.setString(2, XfBCrypt.SCHEME_CLASS);
String serializedHash = XfBCrypt.serializeHash(auth.getPassword().getHash());
byte[] bytes = serializedHash.getBytes();
Blob blob = con.createBlob();
blob.setBytes(1, bytes);
@@ -538,7 +538,7 @@ public class MySQL implements DataSource {
// Insert password in the correct table
sql = "UPDATE xf_user_authenticate SET data=? WHERE " + col.ID + "=?;";
PreparedStatement pst2 = con.prepareStatement(sql);
String serializedHash = XFBCRYPT.serializeHash(password.getHash());
String serializedHash = XfBCrypt.serializeHash(password.getHash());
byte[] bytes = serializedHash.getBytes();
Blob blob = con.createBlob();
blob.setBytes(1, bytes);
@@ -549,7 +549,7 @@ public class MySQL implements DataSource {
// ...
sql = "UPDATE xf_user_authenticate SET scheme_class=? WHERE " + col.ID + "=?;";
pst2 = con.prepareStatement(sql);
pst2.setString(1, XFBCRYPT.SCHEME_CLASS);
pst2.setString(1, XfBCrypt.SCHEME_CLASS);
pst2.setInt(2, id);
pst2.executeUpdate();
pst2.close();
@@ -824,7 +824,7 @@ public class MySQL implements DataSource {
if (rs2.next()) {
Blob blob = rs2.getBlob("data");
byte[] bytes = blob.getBytes(1, (int) blob.length());
pAuth.setPassword(new HashedPassword(XFBCRYPT.getHashFromBlob(bytes)));
pAuth.setPassword(new HashedPassword(XfBCrypt.getHashFromBlob(bytes)));
}
rs2.close();
}
@@ -856,7 +856,7 @@ public class MySQL implements DataSource {
if (rs2.next()) {
Blob blob = rs2.getBlob("data");
byte[] bytes = blob.getBytes(1, (int) blob.length());
pAuth.setPassword(new HashedPassword(XFBCRYPT.getHashFromBlob(bytes)));
pAuth.setPassword(new HashedPassword(XfBCrypt.getHashFromBlob(bytes)));
}
rs2.close();
}
@@ -7,36 +7,36 @@ import fr.xephi.authme.security.crypts.EncryptionMethod;
*/
public enum HashAlgorithm {
BCRYPT(fr.xephi.authme.security.crypts.BCRYPT.class),
BCRYPT2Y(fr.xephi.authme.security.crypts.BCRYPT2Y.class),
CRAZYCRYPT1(fr.xephi.authme.security.crypts.CRAZYCRYPT1.class),
DOUBLEMD5(fr.xephi.authme.security.crypts.DOUBLEMD5.class),
IPB3(fr.xephi.authme.security.crypts.IPB3.class),
IPB4(fr.xephi.authme.security.crypts.IPB4.class),
JOOMLA(fr.xephi.authme.security.crypts.JOOMLA.class),
MD5(fr.xephi.authme.security.crypts.MD5.class),
MD5VB(fr.xephi.authme.security.crypts.MD5VB.class),
MYBB(fr.xephi.authme.security.crypts.MYBB.class),
BCRYPT(fr.xephi.authme.security.crypts.BCrypt.class),
BCRYPT2Y(fr.xephi.authme.security.crypts.BCrypt2y.class),
CRAZYCRYPT1(fr.xephi.authme.security.crypts.CrazyCrypt1.class),
DOUBLEMD5(fr.xephi.authme.security.crypts.DoubleMd5.class),
IPB3(fr.xephi.authme.security.crypts.Ipb3.class),
IPB4(fr.xephi.authme.security.crypts.Ipb4.class),
JOOMLA(fr.xephi.authme.security.crypts.Joomla.class),
MD5(fr.xephi.authme.security.crypts.Md5.class),
MD5VB(fr.xephi.authme.security.crypts.Md5vB.class),
MYBB(fr.xephi.authme.security.crypts.MyBB.class),
PBKDF2(fr.xephi.authme.security.crypts.Pbkdf2.class),
PBKDF2DJANGO(fr.xephi.authme.security.crypts.Pbkdf2Django.class),
PHPBB(fr.xephi.authme.security.crypts.PHPBB.class),
PHPFUSION(fr.xephi.authme.security.crypts.PHPFUSION.class),
PHPBB(fr.xephi.authme.security.crypts.PhpBB.class),
PHPFUSION(fr.xephi.authme.security.crypts.PhpFusion.class),
@Deprecated
PLAINTEXT(fr.xephi.authme.security.crypts.PLAINTEXT.class),
ROYALAUTH(fr.xephi.authme.security.crypts.ROYALAUTH.class),
SALTED2MD5(fr.xephi.authme.security.crypts.SALTED2MD5.class),
SALTEDSHA512(fr.xephi.authme.security.crypts.SALTEDSHA512.class),
SHA1(fr.xephi.authme.security.crypts.SHA1.class),
SHA256(fr.xephi.authme.security.crypts.SHA256.class),
SHA512(fr.xephi.authme.security.crypts.SHA512.class),
SMF(fr.xephi.authme.security.crypts.SMF.class),
PLAINTEXT(fr.xephi.authme.security.crypts.PlainText.class),
ROYALAUTH(fr.xephi.authme.security.crypts.RoyalAuth.class),
SALTED2MD5(fr.xephi.authme.security.crypts.Salted2Md5.class),
SALTEDSHA512(fr.xephi.authme.security.crypts.SaltedSha512.class),
SHA1(fr.xephi.authme.security.crypts.Sha1.class),
SHA256(fr.xephi.authme.security.crypts.Sha256.class),
SHA512(fr.xephi.authme.security.crypts.Sha512.class),
SMF(fr.xephi.authme.security.crypts.Smf.class),
TWO_FACTOR(fr.xephi.authme.security.crypts.TwoFactor.class),
WBB3(fr.xephi.authme.security.crypts.WBB3.class),
WBB4(fr.xephi.authme.security.crypts.WBB4.class),
WHIRLPOOL(fr.xephi.authme.security.crypts.WHIRLPOOL.class),
WORDPRESS(fr.xephi.authme.security.crypts.WORDPRESS.class),
XAUTH(fr.xephi.authme.security.crypts.XAUTH.class),
XFBCRYPT(fr.xephi.authme.security.crypts.XFBCRYPT.class),
WBB3(fr.xephi.authme.security.crypts.Wbb3.class),
WBB4(fr.xephi.authme.security.crypts.Wbb4.class),
WHIRLPOOL(fr.xephi.authme.security.crypts.Whirlpool.class),
WORDPRESS(fr.xephi.authme.security.crypts.Wordpress.class),
XAUTH(fr.xephi.authme.security.crypts.XAuth.class),
XFBCRYPT(fr.xephi.authme.security.crypts.XfBCrypt.class),
CUSTOM(null);
private final Class<? extends EncryptionMethod> clazz;
@@ -14,12 +14,12 @@ import javax.inject.Inject;
@Recommendation(Usage.RECOMMENDED) // provided the salt length is >= 8
@HasSalt(value = SaltType.TEXT) // length depends on the bcryptLog2Rounds setting
public class BCRYPT implements EncryptionMethod {
public class BCrypt implements EncryptionMethod {
private final int bCryptLog2Rounds;
@Inject
public BCRYPT(Settings settings) {
public BCrypt(Settings settings) {
bCryptLog2Rounds = settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND);
}
@@ -4,7 +4,7 @@ import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@Recommendation(Usage.RECOMMENDED)
public class BCRYPT2Y extends HexSaltedMethod {
public class BCrypt2y extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -6,7 +6,7 @@ import fr.xephi.authme.security.MessageDigestAlgorithm;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
public class CRAZYCRYPT1 extends UsernameSaltMethod {
public class CrazyCrypt1 extends UsernameSaltMethod {
private static final char[] CRYPTCHARS =
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import static fr.xephi.authme.security.HashUtils.md5;
public class DOUBLEMD5 extends UnsaltedMethod {
public class DoubleMd5 extends UnsaltedMethod {
@Override
public String computeHash(String password) {
@@ -10,7 +10,7 @@ import static fr.xephi.authme.security.HashUtils.md5;
@Recommendation(Usage.ACCEPTABLE)
@HasSalt(value = SaltType.TEXT, length = 5)
public class IPB3 extends SeparateSaltMethod {
public class Ipb3 extends SeparateSaltMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -11,15 +11,15 @@ import fr.xephi.authme.util.StringUtils;
/**
* Implementation for IPB4 (Invision Power Board 4).
* Implementation for Ipb4 (Invision Power Board 4).
* <p>
* The hash uses standard BCrypt with 13 as log<sub>2</sub> number of rounds. Additionally,
* IPB4 requires that the salt be stored additionally in the column "members_pass_hash"
* Ipb4 requires that the salt be stored additionally in the column "members_pass_hash"
* (even though BCrypt hashes already have the salt in the result).
*/
@Recommendation(Usage.DOES_NOT_WORK)
@HasSalt(value = SaltType.TEXT, length = 22)
public class IPB4 implements EncryptionMethod {
public class Ipb4 implements EncryptionMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -5,7 +5,7 @@ import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@Recommendation(Usage.ACCEPTABLE)
public class JOOMLA extends HexSaltedMethod {
public class Joomla extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
public class MD5 extends UnsaltedMethod {
public class Md5 extends UnsaltedMethod {
@Override
public String computeHash(String password) {
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import static fr.xephi.authme.security.HashUtils.md5;
public class MD5VB extends HexSaltedMethod {
public class Md5vB extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -10,7 +10,7 @@ import static fr.xephi.authme.security.HashUtils.md5;
@Recommendation(Usage.ACCEPTABLE)
@HasSalt(value = SaltType.TEXT, length = 8)
public class MYBB extends SeparateSaltMethod {
public class MyBB extends SeparateSaltMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -9,7 +9,7 @@ import java.security.MessageDigest;
/**
* @author stefano
*/
public class PHPBB extends HexSaltedMethod {
public class PhpBB extends HexSaltedMethod {
private static final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -14,7 +14,7 @@ import java.security.NoSuchAlgorithmException;
@Recommendation(Usage.DO_NOT_USE)
@AsciiRestricted
public class PHPFUSION extends SeparateSaltMethod {
public class PhpFusion extends SeparateSaltMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -6,7 +6,7 @@ package fr.xephi.authme.security.crypts;
* @deprecated Using this is no longer supported. AuthMe will migrate to SHA256 on startup.
*/
@Deprecated
public class PLAINTEXT extends UnsaltedMethod {
public class PlainText extends UnsaltedMethod {
@Override
public String computeHash(String password) {
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
public class ROYALAUTH extends UnsaltedMethod {
public class RoyalAuth extends UnsaltedMethod {
@Override
public String computeHash(String password) {
@@ -14,12 +14,12 @@ import static fr.xephi.authme.security.HashUtils.md5;
@Recommendation(Usage.ACCEPTABLE) // presuming that length is something sensible (>= 8)
@HasSalt(value = SaltType.TEXT) // length defined by the doubleMd5SaltLength setting
public class SALTED2MD5 extends SeparateSaltMethod {
public class Salted2Md5 extends SeparateSaltMethod {
private final int saltLength;
@Inject
public SALTED2MD5(Settings settings) {
public Salted2Md5(Settings settings) {
saltLength = settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH);
}
@@ -6,7 +6,7 @@ import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@Recommendation(Usage.RECOMMENDED)
public class SALTEDSHA512 extends SeparateSaltMethod {
public class SaltedSha512 extends SeparateSaltMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
public class SHA1 extends UnsaltedMethod {
public class Sha1 extends UnsaltedMethod {
@Override
public String computeHash(String password) {
@@ -6,7 +6,7 @@ import fr.xephi.authme.security.crypts.description.Usage;
import static fr.xephi.authme.security.HashUtils.sha256;
@Recommendation(Usage.RECOMMENDED)
public class SHA256 extends HexSaltedMethod {
public class Sha256 extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
public class SHA512 extends UnsaltedMethod {
public class Sha512 extends UnsaltedMethod {
@Override
public String computeHash(String password) {
@@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
public class SMF extends UsernameSaltMethod {
public class Smf extends UsernameSaltMethod {
@Override
public HashedPassword computeHash(String password, String name) {
@@ -10,7 +10,7 @@ import static fr.xephi.authme.security.HashUtils.sha1;
@Recommendation(Usage.ACCEPTABLE)
@HasSalt(value = SaltType.TEXT, length = 40)
public class WBB3 extends SeparateSaltMethod {
public class Wbb3 extends SeparateSaltMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -6,7 +6,7 @@ import fr.xephi.authme.security.crypts.description.Usage;
import static fr.xephi.authme.security.crypts.BCryptService.hashpw;
@Recommendation(Usage.RECOMMENDED)
public class WBB4 extends HexSaltedMethod {
public class Wbb4 extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
@@ -61,7 +61,7 @@ package fr.xephi.authme.security.crypts;
import java.util.Arrays;
public class WHIRLPOOL extends UnsaltedMethod {
public class Whirlpool extends UnsaltedMethod {
/**
* The message digest size (in bits)
@@ -158,7 +158,7 @@ public class WHIRLPOOL extends UnsaltedMethod {
protected final long[] block = new long[8];
protected final long[] state = new long[8];
public WHIRLPOOL() {
public Whirlpool() {
}
protected static String display(byte[] array) {
@@ -16,7 +16,7 @@ import java.util.Arrays;
@HasSalt(value = SaltType.TEXT, length = 9)
// Note ljacqu 20151228: Wordpress is actually a salted algorithm but salt generation is handled internally
// and isn't exposed to the outside, so we treat it as an unsalted implementation
public class WORDPRESS extends UnsaltedMethod {
public class Wordpress extends UnsaltedMethod {
private static final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
private final SecureRandom randomGen = new SecureRandom();
@@ -4,15 +4,15 @@ import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@Recommendation(Usage.RECOMMENDED)
public class XAUTH extends HexSaltedMethod {
public class XAuth extends HexSaltedMethod {
private static String getWhirlpool(String message) {
WHIRLPOOL w = new WHIRLPOOL();
byte[] digest = new byte[WHIRLPOOL.DIGESTBYTES];
Whirlpool w = new Whirlpool();
byte[] digest = new byte[Whirlpool.DIGESTBYTES];
w.NESSIEinit();
w.NESSIEadd(message);
w.NESSIEfinalize(digest);
return WHIRLPOOL.display(digest);
return Whirlpool.display(digest);
}
@Override
@@ -7,7 +7,7 @@ import fr.xephi.authme.util.StringUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class XFBCRYPT implements EncryptionMethod {
public class XfBCrypt implements EncryptionMethod {
public static final String SCHEME_CLASS = "XenForo_Authentication_Core12";
private static final Pattern HASH_PATTERN = Pattern.compile("\"hash\";s.*\"(.*)?\"");
@@ -5,7 +5,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.security.crypts.SHA256;
import fr.xephi.authme.security.crypts.Sha256;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
@@ -20,14 +20,14 @@ public final class MigrationService {
}
/**
* Hash all passwords to SHA256 and updated the setting if the password hash is set to the deprecated PLAINTEXT.
* Hash all passwords to Sha256 and updated the setting if the password hash is set to the deprecated PLAINTEXT.
*
* @param settings The settings instance
* @param dataSource The data source
* @param authmeSha256 Instance to the AuthMe SHA256 encryption method implementation
* @param authmeSha256 Instance to the AuthMe Sha256 encryption method implementation
*/
public static void changePlainTextToSha256(Settings settings, DataSource dataSource,
SHA256 authmeSha256) {
Sha256 authmeSha256) {
if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) {
ConsoleLogger.warning("Your HashAlgorithm has been detected as plaintext and is now deprecated;"
+ " it will be changed and hashed now to the AuthMe default hashing method");