diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java index d792cde5..fe86458a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/AdvancedProtectHandler.java @@ -1,12 +1,16 @@ package pro.gravit.launchserver.auth.protect; 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.auth.protect.interfaces.HardwareProtectHandler; import pro.gravit.launchserver.auth.protect.interfaces.SecureProtectHandler; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.auth.AuthResponse; +import pro.gravit.launchserver.socket.response.secure.HardwareReportResponse; -public class AdvancedProtectHandler extends ProtectHandler implements SecureProtectHandler { - +public class AdvancedProtectHandler extends StdProtectHandler implements SecureProtectHandler, HardwareProtectHandler { + public boolean enableHardwareFeature; @Override public boolean allowGetAccessToken(AuthResponse.AuthContext context) { return (context.authType == AuthResponse.ConnectTypes.CLIENT) && context.client.checkSign; @@ -26,4 +30,24 @@ public GetSecureLevelInfoRequestEvent onGetSecureLevelInfo(GetSecureLevelInfoReq public boolean allowGetSecureLevelInfo(Client client) { return client.checkSign; } + + @Override + public void onHardwareReport(HardwareReportResponse response, Client client) { + if(!enableHardwareFeature) + { + response.sendResult(new HardwareReportRequestEvent()); + return; + } + + response.sendResult(new HardwareReportRequestEvent()); + } + + @Override + public VerifySecureLevelKeyRequestEvent onSuccessVerify(Client client) { + if(enableHardwareFeature) + { + return new VerifySecureLevelKeyRequestEvent(true); + } + return new VerifySecureLevelKeyRequestEvent(); + } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/SecureProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/SecureProtectHandler.java index 26b5e810..d19b9538 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/SecureProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/interfaces/SecureProtectHandler.java @@ -2,6 +2,7 @@ import pro.gravit.launcher.events.request.GetSecureLevelInfoRequestEvent; import pro.gravit.launcher.events.request.SecurityReportRequestEvent; +import pro.gravit.launcher.events.request.VerifySecureLevelKeyRequestEvent; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.secure.SecurityReportResponse; import pro.gravit.utils.helper.SecurityHelper; @@ -31,4 +32,8 @@ default void verifySecureLevelKey(byte[] publicKey, byte[] data, byte[] signatur default SecurityReportRequestEvent onSecurityReport(SecurityReportResponse report, Client client) { return new SecurityReportRequestEvent(); } + default VerifySecureLevelKeyRequestEvent onSuccessVerify(Client client) + { + return new VerifySecureLevelKeyRequestEvent(); + } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java index c9aa8db2..c5414576 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java @@ -1,7 +1,9 @@ package pro.gravit.launchserver.socket.response.secure; import io.netty.channel.ChannelHandlerContext; +import pro.gravit.launcher.events.request.HardwareReportRequestEvent; import pro.gravit.launcher.request.secure.HardwareReportRequest; +import pro.gravit.launchserver.auth.protect.interfaces.HardwareProtectHandler; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.SimpleResponse; @@ -15,6 +17,13 @@ public String getType() { @Override public void execute(ChannelHandlerContext ctx, Client client) throws Exception { - + if(server.config.protectHandler instanceof HardwareProtectHandler) + { + ((HardwareProtectHandler) server.config.protectHandler).onHardwareReport(this, client); + } + else + { + sendResult(new HardwareReportRequestEvent()); + } } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java index bd4c95e8..8037a821 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/VerifySecureLevelKeyResponse.java @@ -39,6 +39,6 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception { } client.trustLevel.keyChecked = true; client.trustLevel.publicKey = publicKey; - sendResult(new VerifySecureLevelKeyRequestEvent()); + sendResult(secureProtectHandler.onSuccessVerify(client)); } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureLevelKeyRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureLevelKeyRequestEvent.java index 785c3f53..c6a63041 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureLevelKeyRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureLevelKeyRequestEvent.java @@ -3,6 +3,15 @@ import pro.gravit.launcher.events.RequestEvent; public class VerifySecureLevelKeyRequestEvent extends RequestEvent { + public boolean needHardwareInfo; + + public VerifySecureLevelKeyRequestEvent() { + } + + public VerifySecureLevelKeyRequestEvent(boolean needHardwareInfo) { + this.needHardwareInfo = needHardwareInfo; + } + @Override public String getType() { return "verifySecureLevelKey";