From 0b6f4e516b8bdbeef0e1261a1d82b4a3f2c05f70 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Tue, 11 Jun 2019 12:14:08 +0300 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=BA=D0=BE=D1=81=D1=82=D1=8B=D0=BB=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/binary/LauncherBinary.java | 14 ++----------- .../pro/gravit/utils/helper/CommonHelper.java | 21 +++---------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java index 238e9de3..c63ffd18 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java @@ -5,7 +5,6 @@ import pro.gravit.launcher.serialize.signed.DigestBytesHolder; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.utils.helper.CommonHelper; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.SecurityHelper; @@ -41,19 +40,10 @@ public void init() { public final boolean sync() throws IOException { boolean exists = exists(); - CommonHelper.removeExc(sign); - if (binary != null) { - CommonHelper.removeExc(binary.getBytes()); - CommonHelper.removeExc(binary.getDigest()); - } binary = exists ? new DigestBytesHolder(IOHelper.read(syncBinaryFile), SecurityHelper.DigestAlgorithm.SHA512) : null; sign = exists ? SecurityHelper.sign(IOHelper.read(syncBinaryFile), server.privateKey) : null; - CommonHelper.addExc(sign); - if (binary != null) { - CommonHelper.addExc(binary.getBytes()); - CommonHelper.addExc(binary.getDigest()); - } - return exists; + + return exists; } public static Path resolve(LaunchServer server, String ext) { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index b0000ead..7c546ae2 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -5,8 +5,6 @@ import java.util.Collection; import java.util.LinkedList; import java.util.Locale; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -142,23 +140,10 @@ public static GsonBuilder newBuilder() { ByteArrayToBase64TypeAdapter.INSTANCE); } - public static void addExc(byte[] exclusion) { - if (exclusion == null) return; - JsonArray add = new JsonArray(exclusion.length); - for (byte b : exclusion) add.add(new JsonPrimitive(b)); - ByteArrayToBase64TypeAdapter.exclusions.put(exclusion, add); - } - - public static void removeExc(byte[] exclusion) { - if (exclusion == null) return; - ByteArrayToBase64TypeAdapter.exclusions.remove(exclusion); - } - private static class ByteArrayToBase64TypeAdapter implements JsonSerializer, JsonDeserializer { private static final ByteArrayToBase64TypeAdapter INSTANCE = new ByteArrayToBase64TypeAdapter(); - private static final Map exclusions = new ConcurrentHashMap<>(); - private final Base64.Decoder decoder = Base64.getUrlDecoder(); - private final Base64.Encoder encoder = Base64.getUrlEncoder(); + private Base64.Decoder decoder = Base64.getUrlDecoder(); + private Base64.Encoder encoder = Base64.getUrlEncoder(); public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { if (json.isJsonArray()) { JsonArray byteArr = json.getAsJsonArray(); @@ -172,7 +157,7 @@ public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationCon } public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) { - return exclusions.getOrDefault(src, new JsonPrimitive(encoder.encodeToString(src))); + return new JsonPrimitive(encoder.encodeToString(src)); } } }