From 4c6360b8afe14c37c58c41822a542eec1d781dd7 Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 6 Feb 2019 16:21:17 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=9D=D0=BE=D0=B2=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D1=8B=20=D0=B2?= =?UTF-8?q?=20GuardLicense?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launcher/client/ClientLauncher.java | 3 +++ .../launcher/client/ClientLauncherContext.java | 5 +++++ .../gravit/launcher/guard/LauncherWrapperGuard.java | 12 +++++------- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 5be74320..a567d4ce 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -336,6 +336,9 @@ public static Process launch( checkJVMBitsAndVersion(); LogHelper.debug("Resolving JVM binary"); Path javaBin = LauncherGuardManager.getGuardJavaBinPath(); + context.javaBin = javaBin; + context.clientProfile = profile; + context.playerProfile = params.pp; context.args.add(javaBin.toString()); context.args.add(MAGICAL_INTEL_OPTION); if (params.ram > 0 && params.ram <= JVMHelper.RAM) { diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncherContext.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncherContext.java index 8baad567..c02fcb2c 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncherContext.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncherContext.java @@ -1,5 +1,8 @@ package ru.gravit.launcher.client; +import ru.gravit.launcher.profiles.ClientProfile; +import ru.gravit.launcher.profiles.PlayerProfile; + import java.nio.file.Path; import java.util.LinkedList; import java.util.List; @@ -9,4 +12,6 @@ public class ClientLauncherContext { public List args = new LinkedList<>(); public String pathLauncher; public ProcessBuilder builder; + public ClientProfile clientProfile; + public PlayerProfile playerProfile; } 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 63a7f593..5f55acfb 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java +++ b/Launcher/src/main/java/ru/gravit/launcher/guard/LauncherWrapperGuard.java @@ -56,16 +56,14 @@ public void addCustomEnv(ClientLauncherContext context) { Map env = context.builder.environment(); env.put("JAVA_HOME", System.getProperty("java.home")); LauncherConfig config = Launcher.getConfig(); + env.put("GUARD_USERNAME", context.playerProfile.username); + env.put("GUARD_PUBLICKEY", config.publicKey.getModulus().toString(16)); + env.put("GUARD_PROJECTNAME", config.projectname); if(config.guardLicenseName != null) env.put("GUARD_LICENSE_NAME", config.guardLicenseName); - if(config.guardLicenseKey != null && config.guardLicenseEncryptKey != null) + if(config.guardLicenseKey != 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); - } + env.put("GUARD_LICENSE_KEY", config.guardLicenseKey); } } }