Update PasswordVerifier.java

Добавил:
1. Способ верификации "django", для осуществления авторизации с помощью PBKDF2 с SHA256.
2. Исключение на отсутствующий алгоритм(NoSuchAlgorithmException)
3. Исключение на неверные ключи(InvalidKeySpecException)
This commit is contained in:
Metall 2022-09-21 08:40:40 +05:00 committed by GitHub
parent 8bf58cff18
commit 90ee90973e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,9 @@
import pro.gravit.utils.ProviderMap; import pro.gravit.utils.ProviderMap;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
public abstract class PasswordVerifier { public abstract class PasswordVerifier {
public static final ProviderMap<PasswordVerifier> providers = new ProviderMap<>("PasswordVerifier"); public static final ProviderMap<PasswordVerifier> providers = new ProviderMap<>("PasswordVerifier");
private static boolean registeredProviders = false; private static boolean registeredProviders = false;
@ -14,11 +17,12 @@ public static void registerProviders() {
providers.register("json", JsonPasswordVerifier.class); providers.register("json", JsonPasswordVerifier.class);
providers.register("accept", AcceptPasswordVerifier.class); providers.register("accept", AcceptPasswordVerifier.class);
providers.register("reject", RejectPasswordVerifier.class); providers.register("reject", RejectPasswordVerifier.class);
providers.register("django", DjangoPasswordVerifier.class);
registeredProviders = true; registeredProviders = true;
} }
} }
public abstract boolean check(String encryptedPassword, String password); public abstract boolean check(String encryptedPassword, String password) throws NoSuchAlgorithmException, InvalidKeySpecException;
public String encrypt(String password) { public String encrypt(String password) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();