diff --git a/Launcher/build.gradle b/Launcher/build.gradle index 79220380..0f716c96 100644 --- a/Launcher/build.gradle +++ b/Launcher/build.gradle @@ -28,6 +28,7 @@ dependencies { pack project(':LauncherAPI') // Not error on obf. bundle 'com.github.oshi:oshi-core:3.11.0' + bundle 'commons-codec:commons-codec:1.11' } task genRuntimeJS(type: Zip) { diff --git a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java index 34793bfb..63a7f593 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java @@ -1,17 +1,18 @@ package ru.gravit.launcher.guard; import ru.gravit.launcher.Launcher; +import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.client.ClientLauncherContext; import ru.gravit.launcher.client.DirBridge; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.JVMHelper; -import ru.gravit.utils.helper.UnpackHelper; +import ru.gravit.utils.helper.*; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Base64; import java.util.Collection; import java.util.Collections; +import java.util.Map; public class LauncherWrapperGuard implements LauncherGuardInterface { @Override @@ -52,6 +53,19 @@ public void addCustomParams(ClientLauncherContext context) { @Override public void addCustomEnv(ClientLauncherContext context) { - context.builder.environment().put("JAVA_HOME", System.getProperty("java.home")); + Map env = context.builder.environment(); + env.put("JAVA_HOME", System.getProperty("java.home")); + LauncherConfig config = Launcher.getConfig(); + if(config.guardLicenseName != null) + env.put("GUARD_LICENSE_NAME", config.guardLicenseName); + if(config.guardLicenseKey != null && config.guardLicenseEncryptKey != null) + { + try { + byte[] encrypt = SecurityHelper.encrypt(config.guardLicenseEncryptKey,config.guardLicenseKey); + env.put("GUARD_LICENSE_NAME", Base64.getEncoder().encodeToString(encrypt)); + } catch (Exception e) { + LogHelper.error(e); + } + } } } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java index 15595196..6d21dfec 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/LauncherConfig.java @@ -43,6 +43,10 @@ public static AutogenConfig getAutogenConfig() { public final boolean isDownloadJava; public final boolean isWarningMissArchJava; + public final String guardLicenseName; + public final String guardLicenseKey; + public final String guardLicenseEncryptKey; + @LauncherAPI public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException { String localAddress = config.address; @@ -55,6 +59,9 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException isDownloadJava = config.isDownloadJava; isUsingWrapper = config.isUsingWrapper; isWarningMissArchJava = config.isWarningMissArchJava; + guardLicenseEncryptKey = config.guardLicenseEncryptKey; + guardLicenseKey = config.guardLicenseKey; + guardLicenseName = config.guardLicenseName; nettyPort = config.nettyPort; LauncherEnvironment env; if (config.env == 0) env = LauncherEnvironment.DEV; @@ -86,6 +93,9 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map(runtime)); this.projectname = projectname; this.clientPort = 32148; + this.guardLicenseName = "FREE"; + this.guardLicenseKey = "AAAA-BBBB-CCCC-DDDD"; + this.guardLicenseEncryptKey = "12345"; isUsingWrapper = true; isDownloadJava = false; isWarningMissArchJava = true; @@ -97,6 +107,9 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map(runtime)); this.projectname = "Minecraft"; + this.guardLicenseName = "FREE"; + this.guardLicenseKey = "AAAA-BBBB-CCCC-DDDD"; + this.guardLicenseEncryptKey = "12345"; this.clientPort = 32148; isUsingWrapper = true; isDownloadJava = false;