mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] BCryptPasswordVerifier
This commit is contained in:
parent
8bec134611
commit
86f9f20b52
2 changed files with 18 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
|||
package pro.gravit.launchserver.auth.password;
|
||||
|
||||
import org.bouncycastle.crypto.generators.OpenBSDBCrypt;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
public class BCryptPasswordVerifier extends PasswordVerifier {
|
||||
public int cost = 10;
|
||||
@Override
|
||||
public boolean check(String encryptedPassword, String password) {
|
||||
return OpenBSDBCrypt.checkPassword(encryptedPassword, password.toCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encrypt(String password) {
|
||||
return OpenBSDBCrypt.generate(password.toCharArray(), SecurityHelper.randomBytes(16), cost);
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ public static void registerProviders() {
|
|||
providers.register("digest", DigestPasswordVerifier.class);
|
||||
providers.register("doubleDigest", DoubleDigestPasswordVerifier.class);
|
||||
providers.register("json", JsonPasswordVerifier.class);
|
||||
providers.register("bcrypt", BCryptPasswordVerifier.class);
|
||||
providers.register("accept", AcceptPasswordVerifier.class);
|
||||
providers.register("reject", RejectPasswordVerifier.class);
|
||||
registeredProviders = true;
|
||||
|
|
Loading…
Reference in a new issue