[FEATURE] Улучшение основы для HWID

This commit is contained in:
Gravit 2020-05-05 10:55:08 +07:00
parent 80e919f4a1
commit 8d1c7621cf
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
5 changed files with 51 additions and 4 deletions

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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());
}
}
}

View file

@ -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));
}
}

View file

@ -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";