[FEATURE] RejectAuthCoreProvider

This commit is contained in:
Gravita 2021-05-16 20:47:25 +07:00
parent b647f49390
commit 6f6aa81554
5 changed files with 58 additions and 0 deletions

View file

@ -23,6 +23,7 @@ public abstract class AuthCoreProvider implements AutoCloseable {
private static boolean registredProviders = false;
public static void registerProviders() {
if (!registredProviders) {
providers.register("reject", RejectAuthCoreProvider.class);
registredProviders = true;
}
}

View file

@ -0,0 +1,51 @@
package pro.gravit.launchserver.auth.core;
import pro.gravit.launcher.request.auth.AuthRequest;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.socket.response.auth.AuthResponse;
import java.io.IOException;
import java.util.UUID;
public class RejectAuthCoreProvider extends AuthCoreProvider {
@Override
public User getUserByUsername(String username) {
return null;
}
@Override
public User getUserByUUID(UUID uuid) {
return null;
}
@Override
public void verifyAuth(AuthResponse.AuthContext context) throws AuthException {
throw new AuthException("Please configure AuthCoreProvider");
}
@Override
public PasswordVerifyReport verifyPassword(User user, AuthRequest.AuthPasswordInterface password) {
return PasswordVerifyReport.FAILED;
}
@Override
public void init(LaunchServer server) {
}
@Override
protected boolean updateAuth(User user) throws IOException {
return false;
}
@Override
protected boolean updateServerID(User user, String serverID) throws IOException {
return false;
}
@Override
public void close() throws IOException {
}
}

View file

@ -18,6 +18,7 @@ public static UUID authError(String message) throws AuthException {
throw new AuthException(message);
}
@SuppressWarnings("deprecation")
public static void registerHandlers() {
if (!registredHandl) {
providers.register("null", NullAuthHandler.class);

View file

@ -5,6 +5,7 @@
import java.util.UUID;
@Deprecated
public class HibernateAuthHandler extends CachedAuthHandler implements RequiredDAO {
@Override
protected Entry fetchEntry(String username) {

View file

@ -156,6 +156,10 @@ public void verify() {
throw new NullPointerException("AuthProviderPair`s count should be at least one");
}
if(dao != null) {
logger.warn("DAO deprecated and may be remove in future release");
}
boolean isOneDefault = false;
for (AuthProviderPair pair : auth.values()) {
if (pair.isDefault) {