[FEATURE] ExtendedCheckServer support in SQLAuthCoreProvider

This commit is contained in:
Gravita 2024-10-02 20:50:36 +07:00
parent eaf685897f
commit abe904d73c
No known key found for this signature in database
GPG key ID: 543A8F335C9CD633

View file

@ -7,8 +7,10 @@
import pro.gravit.launchserver.auth.MySQLSourceConfig; import pro.gravit.launchserver.auth.MySQLSourceConfig;
import pro.gravit.launchserver.auth.SQLSourceConfig; import pro.gravit.launchserver.auth.SQLSourceConfig;
import pro.gravit.launchserver.auth.core.interfaces.UserHardware; import pro.gravit.launchserver.auth.core.interfaces.UserHardware;
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportExtendedCheckServer;
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware; import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware;
import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportHardware; import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportHardware;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.IOHelper;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -19,7 +21,7 @@
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public class SQLCoreProvider extends AbstractSQLCoreProvider implements AuthSupportHardware { public class SQLCoreProvider extends AbstractSQLCoreProvider implements AuthSupportHardware, AuthSupportExtendedCheckServer {
public HikariSQLSourceConfig holder; public HikariSQLSourceConfig holder;
@Override @Override
@ -291,6 +293,18 @@ protected AbstractSQLCoreProvider.SQLUserSession createSession(AbstractSQLCorePr
return new SQLUserSession(user); return new SQLUserSession(user);
} }
@Override
public UserSession extendedCheckServer(Client client, String username, String serverID) throws IOException {
AbstractSQLCoreProvider.SQLUser user = (AbstractSQLCoreProvider.SQLUser) getUserByUsername(username);
if (user == null) {
return null;
}
if (user.getUsername().equals(username) && user.getServerId().equals(serverID)) {
return createSession(user);
}
return null;
}
public class SQLUserSession extends AbstractSQLCoreProvider.SQLUserSession implements UserSessionSupportHardware { public class SQLUserSession extends AbstractSQLCoreProvider.SQLUserSession implements UserSessionSupportHardware {
private transient SQLUser SQLUser; private transient SQLUser SQLUser;
protected transient SQLUserHardware hardware; protected transient SQLUserHardware hardware;