From a4355d1d058924038f371ee315236fc541dd8d23 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 26 Sep 2020 01:53:44 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=98=D1=81=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20Java=2011=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LaunchServer/build.gradle | 4 +-- .../auth/provider/JsonAuthProvider.java | 6 ++--- .../launchserver/helper/SignHelper.java | 27 +------------------ .../manangers/CertificateManager.java | 2 +- LauncherCore/build.gradle | 3 +++ modules | 2 +- 6 files changed, 10 insertions(+), 34 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index c381093a..18292b0e 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -12,8 +12,8 @@ } } -sourceCompatibility = '1.8' -targetCompatibility = '1.8' +sourceCompatibility = '11' +targetCompatibility = '11' configurations { compileOnlyA diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java index 7efa2a90..01e1dcc7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.net.URL; +import java.util.Objects; public final class JsonAuthProvider extends AuthProvider { public URL url; @@ -25,10 +26,7 @@ public AuthProviderResult auth(String login, AuthRequest.AuthPasswordInterface p authResult result = Launcher.gsonManager.gson.fromJson(content, authResult.class); if (result.username != null) return new AuthProviderResult(result.username, SecurityHelper.randomStringToken(), new ClientPermissions(result.permissions, result.flags)); - else if (result.error != null) - return authError(result.error); - else - return authError("Authentication server response is malformed"); + else return authError(Objects.requireNonNullElse(result.error, "Authentication server response is malformed")); } @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/SignHelper.java b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/SignHelper.java index e36dfe73..78374ce5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/SignHelper.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/SignHelper.java @@ -27,32 +27,7 @@ public class SignHelper { - public static final OutputStream NULL = new OutputStream() { - @Override - public String toString() { - return "NullOutputStream"; - } - - /** Discards the specified byte array. */ - @Override - public void write(byte[] b) { - } - - /** Discards the specified byte array. */ - @Override - public void write(byte[] b, int off, int len) { - } - - /** Discards the specified byte. */ - @Override - public void write(int b) { - } - - /** Never closes */ - @Override - public void close() { - } - }; + public static final OutputStream NULL = OutputStream.nullOutputStream(); public static final String hashFunctionName = "SHA-256"; private SignHelper() { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java index f51d2029..c20ef7ba 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java @@ -177,7 +177,7 @@ public void readTrustStore(Path dir) throws IOException, CertificateException { } List certificates = new ArrayList<>(); CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); - IOHelper.walk(dir, new SimpleFileVisitor() { + IOHelper.walk(dir, new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (file.toFile().getName().endsWith(".crt")) { diff --git a/LauncherCore/build.gradle b/LauncherCore/build.gradle index 893510f4..c30d2be4 100644 --- a/LauncherCore/build.gradle +++ b/LauncherCore/build.gradle @@ -9,6 +9,9 @@ compileOnly group: 'org.bouncycastle', name: 'bcprov-jdk15', version: rootProject['verBcprov'] api group: 'com.google.code.gson', name: 'gson', version: rootProject['verGson'] testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit'] + testImplementation group: 'org.jline', name: 'jline', version: rootProject['verJline'] + testImplementation group: 'org.jline', name: 'jline-reader', version: rootProject['verJline'] + testImplementation group: 'org.jline', name: 'jline-terminal', version: rootProject['verJline'] } test { diff --git a/modules b/modules index 4795b7a9..71c224e4 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 4795b7a967af69ddea48116c718bb32b96e43f83 +Subproject commit 71c224e4d7a0950d3b5599ba4dec8d6fd04ededd