* #1874 Introduce individual ConsoleLogger instance per class - Create ConsoleLoggerFactory from which a separate logger can be created for each class - Allows to support individual log level settings in the future * Fix CodeStyle issue * Replace full class name with import * Update usages after merge from master
This commit is contained in:
@@ -3,6 +3,7 @@ package fr.xephi.authme.security.crypts;
|
||||
import de.mkammerer.argon2.Argon2Constants;
|
||||
import de.mkammerer.argon2.Argon2Factory;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.security.crypts.description.HasSalt;
|
||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||
@@ -14,6 +15,8 @@ import fr.xephi.authme.security.crypts.description.Usage;
|
||||
// and isn't exposed to the outside, so we treat it as an unsalted implementation
|
||||
public class Argon2 extends UnsaltedMethod {
|
||||
|
||||
private static ConsoleLogger logger = ConsoleLoggerFactory.get(Argon2.class);
|
||||
|
||||
private de.mkammerer.argon2.Argon2 argon2;
|
||||
|
||||
public Argon2() {
|
||||
@@ -30,7 +33,7 @@ public class Argon2 extends UnsaltedMethod {
|
||||
System.loadLibrary("argon2");
|
||||
return true;
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
ConsoleLogger.logException(
|
||||
logger.logException(
|
||||
"Cannot find argon2 library: https://github.com/AuthMe/AuthMeReloaded/wiki/Argon2-as-Password-Hash", e);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -5,6 +5,7 @@ import de.rtner.misc.BinTools;
|
||||
import de.rtner.security.auth.spi.PBKDF2Engine;
|
||||
import de.rtner.security.auth.spi.PBKDF2Parameters;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||
import fr.xephi.authme.security.crypts.description.Usage;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
@@ -16,6 +17,7 @@ import javax.inject.Inject;
|
||||
public class Pbkdf2 extends HexSaltedMethod {
|
||||
|
||||
private static final int DEFAULT_ROUNDS = 10_000;
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(Pbkdf2.class);
|
||||
private int numberOfRounds;
|
||||
|
||||
@Inject
|
||||
@@ -41,7 +43,7 @@ public class Pbkdf2 extends HexSaltedMethod {
|
||||
}
|
||||
Integer iterations = Ints.tryParse(line[1]);
|
||||
if (iterations == null) {
|
||||
ConsoleLogger.warning("Cannot read number of rounds for Pbkdf2: '" + line[1] + "'");
|
||||
logger.warning("Cannot read number of rounds for Pbkdf2: '" + line[1] + "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.primitives.Ints;
|
||||
import de.rtner.security.auth.spi.PBKDF2Engine;
|
||||
import de.rtner.security.auth.spi.PBKDF2Parameters;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.security.crypts.description.AsciiRestricted;
|
||||
|
||||
import java.util.Base64;
|
||||
@@ -12,6 +13,7 @@ import java.util.Base64;
|
||||
public class Pbkdf2Django extends HexSaltedMethod {
|
||||
|
||||
private static final int DEFAULT_ITERATIONS = 24000;
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(Pbkdf2Django.class);
|
||||
|
||||
@Override
|
||||
public String computeHash(String password, String salt, String name) {
|
||||
@@ -30,7 +32,7 @@ public class Pbkdf2Django extends HexSaltedMethod {
|
||||
}
|
||||
Integer iterations = Ints.tryParse(line[1]);
|
||||
if (iterations == null) {
|
||||
ConsoleLogger.warning("Cannot read number of rounds for Pbkdf2Django: '" + line[1] + "'");
|
||||
logger.warning("Cannot read number of rounds for Pbkdf2Django: '" + line[1] + "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.common.io.BaseEncoding;
|
||||
import com.google.common.net.UrlEscapers;
|
||||
import com.google.common.primitives.Ints;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.security.crypts.description.HasSalt;
|
||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||
@@ -34,6 +35,8 @@ public class TwoFactor extends UnsaltedMethod {
|
||||
|
||||
private static final int TIME_PRECISION = 3;
|
||||
private static final String CRYPTO_ALGO = "HmacSHA1";
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(TwoFactor.class);
|
||||
|
||||
/**
|
||||
* Creates a link to a QR barcode with the provided secret.
|
||||
@@ -71,7 +74,7 @@ public class TwoFactor extends UnsaltedMethod {
|
||||
try {
|
||||
return checkPassword(hashedPassword.getHash(), password);
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.logException("Failed to verify two auth code:", e);
|
||||
logger.logException("Failed to verify two auth code:", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package fr.xephi.authme.security.crypts;
|
||||
import at.favre.lib.crypto.bcrypt.BCrypt;
|
||||
import at.favre.lib.crypto.bcrypt.IllegalBCryptFormatException;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.security.crypts.description.HasSalt;
|
||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||
@@ -19,6 +20,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
@HasSalt(value = SaltType.TEXT, length = SALT_LENGTH_ENCODED)
|
||||
public class Wbb4 implements EncryptionMethod {
|
||||
|
||||
private final ConsoleLogger logger = ConsoleLoggerFactory.get(Wbb4.class);
|
||||
private BCryptHasher bCryptHasher = new BCryptHasher(BCrypt.Version.VERSION_2A, 8);
|
||||
private SecureRandom random = new SecureRandom();
|
||||
|
||||
@@ -44,7 +46,7 @@ public class Wbb4 implements EncryptionMethod {
|
||||
String computedHash = hashInternal(password, salt);
|
||||
return isEqual(hashedPassword.getHash(), computedHash);
|
||||
} catch (IllegalBCryptFormatException | IllegalArgumentException e) {
|
||||
ConsoleLogger.logException("Invalid WBB4 hash:", e);
|
||||
logger.logException("Invalid WBB4 hash:", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user