mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-07-07 08:19:45 +03:00
Compare commits
10 commits
c217f1fbe9
...
a6b9023f98
Author | SHA1 | Date | |
---|---|---|---|
|
a6b9023f98 | ||
|
18419fcd3a | ||
|
73804a555e | ||
|
b16281e04a | ||
|
06f0bc873a | ||
|
05530b6664 | ||
|
8f20cbe104 | ||
|
66d8b9d9ca | ||
|
90ee90973e | ||
|
8bf58cff18 |
5 changed files with 47 additions and 4 deletions
|
@ -0,0 +1,42 @@
|
|||
package pro.gravit.launchserver.auth.password;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bouncycastle.crypto.digests.SHA256Digest;
|
||||
import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator;
|
||||
import org.bouncycastle.crypto.params.KeyParameter;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
public class DjangoPasswordVerifier extends PasswordVerifier {
|
||||
public final Integer DEFAULT_ITERATIONS = 10000;
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final String algorithm = "pbkdf2_sha256";
|
||||
|
||||
public String getEncodedHash(String password, String salt, int iterations) {
|
||||
PKCS5S2ParametersGenerator generator = new PKCS5S2ParametersGenerator(new SHA256Digest());
|
||||
generator.init(password.getBytes(StandardCharsets.UTF_8), salt.getBytes(), iterations);
|
||||
byte[] dk = ((KeyParameter) generator.generateDerivedParameters(256)).getKey();
|
||||
byte[] hashBase64 = Base64.getEncoder().encode(dk);
|
||||
return new String(hashBase64);
|
||||
}
|
||||
|
||||
public String encode(String password, String salt, int iterations) {
|
||||
String hash = getEncodedHash(password, salt, iterations);
|
||||
return String.format("%s$%d$%s$%s", algorithm, iterations, salt, hash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(String encryptedPassword, String password) {
|
||||
String[] params = encryptedPassword.split("\\$");
|
||||
if (params.length != 4) {
|
||||
logger.warn(" end 1 " + params.length);
|
||||
return false;
|
||||
}
|
||||
int iterations = Integer.parseInt(params[1]);
|
||||
String salt = params[2];
|
||||
String hash = encode(password, salt, iterations);
|
||||
return hash.equals(encryptedPassword);
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ public static void registerProviders() {
|
|||
providers.register("bcrypt", BCryptPasswordVerifier.class);
|
||||
providers.register("accept", AcceptPasswordVerifier.class);
|
||||
providers.register("reject", RejectPasswordVerifier.class);
|
||||
providers.register("django", DjangoPasswordVerifier.class);
|
||||
registeredProviders = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ public final class Version implements Comparable<Version> {
|
|||
public static final int MINOR = 6;
|
||||
public static final int PATCH = 11;
|
||||
public static final int BUILD = 1;
|
||||
public static final Version.Type RELEASE = Type.DEV;
|
||||
public static final Version.Type RELEASE = Type.STABLE;
|
||||
public final int major;
|
||||
public final int minor;
|
||||
public final int patch;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
id 'org.openjfx.javafxplugin' version '0.1.0' apply false
|
||||
}
|
||||
group = 'pro.gravit.launcher'
|
||||
version = '5.6.10'
|
||||
version = '5.6.11'
|
||||
|
||||
apply from: 'props.gradle'
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
project.ext {
|
||||
verAsm = '9.7.1'
|
||||
verNetty = '4.2.0.RC4'
|
||||
verNetty = '4.2.0.Final'
|
||||
verOshiCore = '6.8.0'
|
||||
verJunit = '5.11.4'
|
||||
verJansi = '2.4.1'
|
||||
|
@ -11,7 +11,7 @@
|
|||
verSlf4j = '2.0.17'
|
||||
verLog4j = '2.24.3'
|
||||
verMySQLConn = '9.2.0'
|
||||
verMariaDBConn = '3.5.1'
|
||||
verMariaDBConn = '3.5.3'
|
||||
verPostgreSQLConn = '42.7.5'
|
||||
verH2Conn = '2.3.232'
|
||||
verProguard = '7.7.0'
|
||||
|
|
Loading…
Reference in a new issue