aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormdxd44 <ogurec332@mail.ru>2022-05-20 03:02:28 +0900
committermdxd44 <ogurec332@mail.ru>2022-05-20 03:02:28 +0900
commit903fd1e1d86cdd70eddf300e3370cad0cd7d538b (patch)
tree16465aac8a009538fd6d957ac3b12bf56ccd540c
parent85b5811d3f71928f6f243e039a8bf112c0142b12 (diff)
downloadLimboAuth-903fd1e1d86cdd70eddf300e3370cad0cd7d538b.tar.gz
LimboAuth-903fd1e1d86cdd70eddf300e3370cad0cd7d538b.tar.bz2
LimboAuth-903fd1e1d86cdd70eddf300e3370cad0cd7d538b.zip
Don't initialize argon2 on startup.
-rw-r--r--src/main/java/net/elytrium/limboauth/migration/MigrationHash.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/net/elytrium/limboauth/migration/MigrationHash.java b/src/main/java/net/elytrium/limboauth/migration/MigrationHash.java
index 8707a88..5f6cb71 100644
--- a/src/main/java/net/elytrium/limboauth/migration/MigrationHash.java
+++ b/src/main/java/net/elytrium/limboauth/migration/MigrationHash.java
@@ -23,6 +23,7 @@ import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.codec.binary.Hex;
+import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@SuppressWarnings("unused")
public enum MigrationHash {
@@ -93,10 +94,15 @@ public enum MigrationHash {
private static class Argon2Verifier implements MigrationHashVerifier {
- private final Argon2 argon2 = Argon2Factory.create();
+ @MonotonicNonNull
+ private Argon2 argon2;
@Override
public boolean checkPassword(String hash, String password) {
+ if (this.argon2 == null) {
+ this.argon2 = Argon2Factory.create();
+ }
+
return this.argon2.verify(hash, password.getBytes(StandardCharsets.UTF_8));
}
}