[FIX] LaunchServer instance в ProtectHandler

This commit is contained in:
Gravit 2020-08-27 20:38:59 +07:00
parent d5bab20610
commit 2e238f3dc2
No known key found for this signature in database
GPG key ID: 98A079490768CCE5
6 changed files with 11 additions and 7 deletions

View file

@ -23,7 +23,6 @@ protected Entry fetchEntry(UUID uuid) {
@Override
protected boolean updateAuth(UUID uuid, String username, String accessToken) {
User user = srv.config.dao.userDAO.findByUUID(uuid);
LogHelper.debug("UpdateAuth: %s: %s", uuid == null ? "null" : uuid.toString(), user == null ? "null" : user.getUsername());
user.setAccessToken(accessToken);
srv.config.dao.userDAO.update(user);
return true;

View file

@ -3,6 +3,7 @@
import pro.gravit.launcher.events.request.GetSecureLevelInfoRequestEvent;
import pro.gravit.launcher.events.request.HardwareReportRequestEvent;
import pro.gravit.launcher.events.request.VerifySecureLevelKeyRequestEvent;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.Reconfigurable;
import pro.gravit.launchserver.auth.protect.hwid.HWIDException;
import pro.gravit.launchserver.auth.protect.hwid.HWIDProvider;
@ -21,6 +22,7 @@
public class AdvancedProtectHandler extends StdProtectHandler implements SecureProtectHandler, HardwareProtectHandler, JoinServerProtectHandler, Reconfigurable {
public boolean enableHardwareFeature;
public HWIDProvider provider;
private LaunchServer server;
@Override
public boolean allowGetAccessToken(AuthResponse.AuthContext context) {
@ -107,9 +109,9 @@ public boolean onJoinServer(String serverID, String username, Client client) {
}
@Override
public void init() {
public void init(LaunchServer server) {
if(provider != null)
provider.init();
provider.init(server);
}
@Override

View file

@ -1,5 +1,6 @@
package pro.gravit.launchserver.auth.protect;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.socket.response.auth.AuthResponse;
import pro.gravit.utils.ProviderMap;
@ -21,7 +22,7 @@ public static void registerHandlers() {
public abstract void checkLaunchServerLicense(); //Выдает SecurityException при ошибке проверки лицензии
public void init()
public void init(LaunchServer server)
{
}

View file

@ -1,6 +1,7 @@
package pro.gravit.launchserver.auth.protect.hwid;
import pro.gravit.launcher.request.secure.HardwareReportRequest;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.helper.DamerauHelper;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.utils.ProviderMap;
@ -107,7 +108,7 @@ protected void printHardwareInfo(LogHelper.Level logLevel, HardwareReportRequest
LogHelper.log(logLevel, String.format("[HardwareInfo] HWDiskID %s | baseboardSerialNumber %s | displayId hash: %s", info.hwDiskId, info.baseboardSerialNumber, SecurityHelper.toHex(SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, info.displayId))) , false);
}
public void init()
public void init(LaunchServer server)
{
}

View file

@ -1,6 +1,7 @@
package pro.gravit.launchserver.auth.protect.hwid;
import pro.gravit.launcher.request.secure.HardwareReportRequest;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.MySQLSourceConfig;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.utils.helper.IOHelper;
@ -29,7 +30,7 @@ public class MysqlHWIDProvider extends HWIDProvider {
private String sqlUpdateUsers;
@Override
public void init() {
public void init(LaunchServer server) {
sqlFindByPublicKey = String.format("SELECT hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, battery, id, banned FROM %s WHERE `publicKey` = ?", tableHWID);
sqlFindByHardware = String.format("SELECT hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, battery, id, banned FROM %s", tableHWID);
sqlCreateHardware = String.format("INSERT INTO `%s` (`publickey`, `hwDiskId`, `baseboardSerialNumber`, `displayId`, `bitness`, `totalMemory`, `logicalProcessors`, `physicalProcessors`, `processorMaxFreq`, `battery`, `banned`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '0')", tableHWID);

View file

@ -184,7 +184,7 @@ public void init(LaunchServer.ReloadType type) {
}
if (protectHandler != null) {
server.registerObject("protectHandler", protectHandler);
protectHandler.init();
protectHandler.init(server);
protectHandler.checkLaunchServerLicense();
}
if (components != null) {