From 8d1c7621cfe5a8c9701779ef7d414b2b2a04087f Mon Sep 17 00:00:00 2001 From: Gravit Date: Tue, 5 May 2020 10:55:08 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=A3=D0=BB=D1=83=D1=87=D1=88?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=81=D0=BD=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20HWID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/protect/AdvancedProtectHandler.java | 28 +++++++++++++++++-- .../interfaces/SecureProtectHandler.java | 5 ++++ .../secure/HardwareReportResponse.java | 11 +++++++- .../secure/VerifySecureLevelKeyResponse.java | 2 +- .../VerifySecureLevelKeyRequestEvent.java | 9 ++++++ 5 files changed, 51 insertions(+), 4 deletions(-) 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";