From 1a562792cf37a5639db5f9a54f8dae571477f449 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Wed, 26 Dec 2018 15:33:49 +0300 Subject: [PATCH] Refactor with warns fix. --- .../ru/gravit/launchserver/LaunchServer.java | 71 +++++++++++++------ .../ru/gravit/launchserver/ProguardConf.java | 14 ++-- .../ru/gravit/launchserver/StarterAgent.java | 7 +- .../launchserver/asm/ClassMetadataReader.java | 11 +-- .../launchserver/asm/SafeClassWriter.java | 4 +- .../gravit/launchserver/auth/AuthLimiter.java | 6 +- .../launchserver/auth/MySQLSourceConfig.java | 10 +-- .../auth/handler/AuthHandler.java | 18 ++--- .../auth/handler/BinaryFileAuthHandler.java | 8 +-- .../auth/handler/CachedAuthHandler.java | 13 ++-- .../auth/handler/FileAuthHandler.java | 22 ++++-- .../auth/handler/MemoryAuthHandler.java | 6 +- .../auth/handler/MySQLAuthHandler.java | 4 +- .../auth/handler/NullAuthHandler.java | 6 +- .../auth/hwid/AcceptHWIDHandler.java | 4 +- .../launchserver/auth/hwid/HWIDHandler.java | 16 ++--- .../auth/hwid/JsonHWIDHandler.java | 16 ++--- .../auth/hwid/MysqlHWIDHandler.java | 12 ++-- .../permissions/ConfigPermissionsHandler.java | 1 - .../JsonFilePermissionsHandler.java | 16 ++--- .../auth/permissions/PermissionsHandler.java | 16 ++--- .../auth/provider/AcceptAuthProvider.java | 1 - .../auth/provider/AuthProvider.java | 21 +++--- .../auth/provider/JsonAuthProvider.java | 13 ++-- .../auth/provider/MojangAuthProvider.java | 11 +-- .../auth/provider/MySQLAuthProvider.java | 11 ++- .../auth/provider/NullAuthProvider.java | 4 +- .../auth/provider/RequestAuthProvider.java | 10 +-- .../launchserver/binary/BuildContext.java | 4 +- .../binary/EXEL4JLauncherBinary.java | 12 ++-- .../binary/EXELauncherBinary.java | 6 +- .../launchserver/binary/JAConfigurator.java | 11 ++- .../binary/JARLauncherBinary.java | 36 +++++----- .../launchserver/binary/LauncherBinary.java | 6 +- .../gravit/launchserver/command/Command.java | 4 +- .../command/auth/AuthCommand.java | 4 +- .../launchserver/command/auth/BanCommand.java | 4 +- .../command/auth/UUIDToUsernameCommand.java | 6 +- .../command/auth/UnbanCommand.java | 4 +- .../command/auth/UsernameToUUIDCommand.java | 6 +- .../command/basic/HelpCommand.java | 4 +- .../basic/RegenProguardDictCommand.java | 4 +- .../basic/RemoveMappingsProguardCommand.java | 6 +- .../command/basic/TestCommand.java | 5 +- .../command/dump/DumpEntryCacheCommand.java | 17 ++--- .../command/dump/DumpSessionsCommand.java | 17 +++-- .../command/handler/CommandHandler.java | 45 +++++++++--- .../command/handler/JLineCommandHandler.java | 4 +- .../command/handler/StdCommandHandler.java | 6 +- .../command/hash/DownloadAssetCommand.java | 8 +-- .../command/hash/DownloadClientCommand.java | 15 ++-- .../command/hash/IndexAssetCommand.java | 21 +++--- .../command/hash/SyncBinariesCommand.java | 4 +- .../command/hash/SyncProfilesCommand.java | 4 +- .../command/hash/SyncUpdatesCommand.java | 8 +-- .../command/hash/UnindexAssetCommand.java | 19 ++--- .../command/modules/LoadModuleCommand.java | 6 +- .../config/AuthHandlerAdapter.java | 20 ++++-- .../config/AuthProviderAdapter.java | 18 +++-- .../config/HWIDHandlerAdapter.java | 17 +++-- .../config/PermissionsHandlerAdapter.java | 17 +++-- .../config/TextureProviderAdapter.java | 17 +++-- .../ClosingChannelFutureListener.java | 4 +- .../fileserver/FileServerHandler.java | 52 ++++++++++---- .../manangers/BuildHookManager.java | 12 ++-- .../launchserver/manangers/MirrorManager.java | 4 +- .../manangers/ModulesManager.java | 6 +- .../manangers/NodeTransformer.java | 7 +- .../launchserver/manangers/ReloadManager.java | 6 +- .../manangers/SessionManager.java | 6 +- .../launchserver/response/PingResponse.java | 4 +- .../launchserver/response/Response.java | 21 ++++-- .../response/auth/AuthResponse.java | 14 ++-- .../response/auth/AuthServerResponse.java | 12 ++-- .../response/auth/CheckServerResponse.java | 6 +- .../response/auth/JoinServerResponse.java | 4 +- .../response/auth/SetProfileResponse.java | 5 +- .../BatchProfileByUsernameResponse.java | 6 +- .../profile/ProfileByUUIDResponse.java | 6 +- .../profile/ProfileByUsernameResponse.java | 6 +- .../response/update/LauncherResponse.java | 6 +- .../update/LegacyLauncherResponse.java | 4 +- .../response/update/ProfilesResponse.java | 7 +- .../response/update/UpdateListResponse.java | 6 +- .../response/update/UpdateResponse.java | 16 ++--- .../socket/NettyServerSocketHandler.java | 52 ++++++++------ .../launchserver/socket/ResponseThread.java | 10 +-- .../socket/ServerSocketHandler.java | 20 +++--- .../websocket/WebSocketFrameHandler.java | 1 + .../websocket/WebSocketIndexPageHandler.java | 25 +++++-- .../socket/websocket/WebSocketService.java | 5 +- .../websocket/json/JsonResponseAdapter.java | 14 +++- .../websocket/json/auth/AuthResponse.java | 5 +- .../json/update/LauncherResponse.java | 6 +- .../texture/NullTextureProvider.java | 6 +- .../texture/RequestTextureProvider.java | 10 ++- .../launchserver/texture/TextureProvider.java | 16 ++--- .../texture/VoidTextureProvider.java | 4 +- gradle.properties | 2 +- 99 files changed, 654 insertions(+), 479 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 666cab6a..5922dcb7 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -1,8 +1,39 @@ package ru.gravit.launchserver; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.MalformedURLException; +import java.net.SocketAddress; +import java.nio.file.DirectoryStream; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.security.KeyPair; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.InvalidKeySpecException; +import java.time.Duration; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.zip.CRC32; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.annotations.Expose; + import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.hasher.HashedDir; @@ -25,32 +56,26 @@ import ru.gravit.launchserver.command.handler.CommandHandler; import ru.gravit.launchserver.command.handler.JLineCommandHandler; import ru.gravit.launchserver.command.handler.StdCommandHandler; -import ru.gravit.launchserver.config.*; -import ru.gravit.launchserver.manangers.*; +import ru.gravit.launchserver.config.AuthHandlerAdapter; +import ru.gravit.launchserver.config.AuthProviderAdapter; +import ru.gravit.launchserver.config.HWIDHandlerAdapter; +import ru.gravit.launchserver.config.PermissionsHandlerAdapter; +import ru.gravit.launchserver.config.TextureProviderAdapter; +import ru.gravit.launchserver.manangers.BuildHookManager; +import ru.gravit.launchserver.manangers.MirrorManager; +import ru.gravit.launchserver.manangers.ModulesManager; +import ru.gravit.launchserver.manangers.ReloadManager; +import ru.gravit.launchserver.manangers.SessionManager; import ru.gravit.launchserver.response.Response; import ru.gravit.launchserver.socket.ServerSocketHandler; import ru.gravit.launchserver.texture.RequestTextureProvider; import ru.gravit.launchserver.texture.TextureProvider; -import ru.gravit.utils.helper.*; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.MalformedURLException; -import java.net.SocketAddress; -import java.nio.file.*; -import java.nio.file.attribute.BasicFileAttributes; -import java.security.KeyPair; -import java.security.interfaces.RSAPrivateKey; -import java.security.interfaces.RSAPublicKey; -import java.security.spec.InvalidKeySpecException; -import java.time.Duration; -import java.time.Instant; -import java.util.*; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.zip.CRC32; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.JVMHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public final class LaunchServer implements Runnable, AutoCloseable { public static final class Config { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java b/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java index 817acd01..29e38b60 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/ProguardConf.java @@ -1,15 +1,19 @@ package ru.gravit.launchserver; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; - -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; import java.security.SecureRandom; import java.util.ArrayList; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; + public class ProguardConf { private static final String charsFirst = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"; private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ"; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java b/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java index f0c1c091..30db3252 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/StarterAgent.java @@ -2,7 +2,12 @@ import java.io.IOException; import java.lang.instrument.Instrumentation; -import java.nio.file.*; +import java.nio.file.FileVisitOption; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.Collections; import java.util.jar.JarFile; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java index ca10e53b..53cf3e89 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/ClassMetadataReader.java @@ -1,10 +1,5 @@ package ru.gravit.launchserver.asm; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.Opcodes; -import ru.gravit.utils.helper.IOHelper; - import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -12,6 +7,12 @@ import java.util.List; import java.util.jar.JarFile; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.Opcodes; + +import ru.gravit.utils.helper.IOHelper; + /** * Позволяет искать методы внутри незагруженных классов и общие суперклассы для * чего угодно. Работает через поиск class-файлов в classpath. diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/SafeClassWriter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/SafeClassWriter.java index 34ef1b44..d49ae26a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/asm/SafeClassWriter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/asm/SafeClassWriter.java @@ -1,10 +1,10 @@ package ru.gravit.launchserver.asm; +import java.util.ArrayList; + import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; -import java.util.ArrayList; - /** * ClassWriter с другой реализацией метода getCommonSuperClass: при его * использовании не происходит загрузки классов. diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java index 40122c15..efdc5c6b 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java @@ -1,13 +1,13 @@ package ru.gravit.launchserver.auth; -import ru.gravit.launcher.NeedGarbageCollection; -import ru.gravit.launchserver.LaunchServer; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; +import ru.gravit.launcher.NeedGarbageCollection; +import ru.gravit.launchserver.LaunchServer; + public class AuthLimiter implements NeedGarbageCollection { static class AuthEntry { public int value; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/MySQLSourceConfig.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/MySQLSourceConfig.java index aff95d1d..2742bb06 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/MySQLSourceConfig.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/MySQLSourceConfig.java @@ -1,15 +1,17 @@ package ru.gravit.launchserver.auth; +import java.sql.Connection; +import java.sql.SQLException; + +import javax.sql.DataSource; + import com.mysql.cj.jdbc.MysqlDataSource; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; + import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; - public final class MySQLSourceConfig implements AutoCloseable { public static final int TIMEOUT = VerifyHelper.verifyInt( diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java index 77b568b0..22a3d473 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java @@ -1,17 +1,17 @@ package ru.gravit.launchserver.auth.handler; -import ru.gravit.launchserver.auth.AuthException; -import ru.gravit.launchserver.auth.provider.AuthProviderResult; -import ru.gravit.utils.helper.VerifyHelper; - import java.io.IOException; import java.util.Map; import java.util.Objects; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import ru.gravit.launchserver.auth.AuthException; +import ru.gravit.launchserver.auth.provider.AuthProviderResult; +import ru.gravit.utils.helper.VerifyHelper; + public abstract class AuthHandler implements AutoCloseable { - private static final Map AUTH_HANDLERS = new ConcurrentHashMap<>(4); + private static final Map> AUTH_HANDLERS = new ConcurrentHashMap<>(4); private static boolean registredHandl = false; @@ -20,18 +20,18 @@ public static UUID authError(String message) throws AuthException { } - public static void registerHandler(String name, Class adapter) { + public static void registerHandler(String name, Class adapter) { VerifyHelper.verifyIDName(name); VerifyHelper.putIfAbsent(AUTH_HANDLERS, name, Objects.requireNonNull(adapter, "adapter"), String.format("Auth handler has been already registered: '%s'", name)); } - public static Class getHandlerClass(String name) + public static Class getHandlerClass(String name) { return AUTH_HANDLERS.get(name); } - public static String getHandlerName(Class clazz) + public static String getHandlerName(Class clazz) { - for(Map.Entry e: AUTH_HANDLERS.entrySet()) + for(Map.Entry> e: AUTH_HANDLERS.entrySet()) { if(e.getValue().equals(clazz)) return e.getKey(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/BinaryFileAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/BinaryFileAuthHandler.java index 820bfd0c..14385e80 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/BinaryFileAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/BinaryFileAuthHandler.java @@ -1,14 +1,14 @@ package ru.gravit.launchserver.auth.handler; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.utils.helper.IOHelper; - import java.io.IOException; import java.util.Map; import java.util.Set; import java.util.UUID; +import ru.gravit.launcher.serialize.HInput; +import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.utils.helper.IOHelper; + public final class BinaryFileAuthHandler extends FileAuthHandler { @Override diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/CachedAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/CachedAuthHandler.java index 1784b3d0..4f0f7fa9 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/CachedAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/CachedAuthHandler.java @@ -1,18 +1,17 @@ package ru.gravit.launchserver.auth.handler; -import com.google.gson.annotations.Expose; -import ru.gravit.launcher.NeedGarbageCollection; -import ru.gravit.launchserver.auth.provider.AuthProviderResult; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; - import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.UUID; +import ru.gravit.launcher.NeedGarbageCollection; +import ru.gravit.launchserver.auth.provider.AuthProviderResult; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; + public abstract class CachedAuthHandler extends AuthHandler implements NeedGarbageCollection { public static final class Entry { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/FileAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/FileAuthHandler.java index 90dd12bf..dd114a48 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/FileAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/FileAuthHandler.java @@ -1,17 +1,25 @@ package ru.gravit.launchserver.auth.handler; +import java.io.IOException; +import java.nio.file.Path; +import java.security.SecureRandom; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.locks.ReentrantReadWriteLock; + import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.StreamObject; import ru.gravit.launchserver.auth.provider.AuthProviderResult; -import ru.gravit.utils.helper.*; - -import java.io.IOException; -import java.nio.file.Path; -import java.security.SecureRandom; -import java.util.*; -import java.util.concurrent.locks.ReentrantReadWriteLock; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.VerifyHelper; public abstract class FileAuthHandler extends AuthHandler { public static final class Entry extends StreamObject { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MemoryAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MemoryAuthHandler.java index 792900ab..ba1c350f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MemoryAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MemoryAuthHandler.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.auth.handler; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.VerifyHelper; - import java.nio.ByteBuffer; import java.util.Arrays; import java.util.UUID; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.VerifyHelper; + public final class MemoryAuthHandler extends CachedAuthHandler { private static String toUsername(UUID uuid) { byte[] bytes = ByteBuffer.allocate(16). diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java index 9b02b216..a4321f4c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/MySQLAuthHandler.java @@ -1,7 +1,5 @@ package ru.gravit.launchserver.auth.handler; -import ru.gravit.launchserver.auth.MySQLSourceConfig; - import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; @@ -9,6 +7,8 @@ import java.sql.SQLException; import java.util.UUID; +import ru.gravit.launchserver.auth.MySQLSourceConfig; + public final class MySQLAuthHandler extends CachedAuthHandler { private MySQLSourceConfig mySQLHolder; private String uuidColumn; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/NullAuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/NullAuthHandler.java index c0d5ace1..d49ee34f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/NullAuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/NullAuthHandler.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.auth.handler; -import ru.gravit.launchserver.auth.provider.AuthProviderResult; -import ru.gravit.utils.helper.VerifyHelper; - import java.io.IOException; import java.util.Objects; import java.util.UUID; +import ru.gravit.launchserver.auth.provider.AuthProviderResult; +import ru.gravit.utils.helper.VerifyHelper; + public final class NullAuthHandler extends AuthHandler { private volatile AuthHandler handler; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/AcceptHWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/AcceptHWIDHandler.java index ee657875..a83a14d3 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/AcceptHWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/AcceptHWIDHandler.java @@ -1,10 +1,10 @@ package ru.gravit.launchserver.auth.hwid; -import ru.gravit.launcher.HWID; - import java.util.ArrayList; import java.util.List; +import ru.gravit.launcher.HWID; + public class AcceptHWIDHandler extends HWIDHandler { @Override diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/HWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/HWIDHandler.java index 0dc364fb..7846807c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/HWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/HWIDHandler.java @@ -1,19 +1,19 @@ package ru.gravit.launchserver.auth.hwid; -import ru.gravit.launcher.HWID; -import ru.gravit.utils.helper.VerifyHelper; - import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; +import ru.gravit.launcher.HWID; +import ru.gravit.utils.helper.VerifyHelper; + public abstract class HWIDHandler implements AutoCloseable { - private static final Map HW_HANDLERS = new ConcurrentHashMap<>(4); + private static final Map> HW_HANDLERS = new ConcurrentHashMap<>(4); private static boolean registredHandl = false; - public static void registerHandler(String name, Class adapter) { + public static void registerHandler(String name, Class adapter) { VerifyHelper.verifyIDName(name); VerifyHelper.putIfAbsent(HW_HANDLERS, name, Objects.requireNonNull(adapter, "adapter"), String.format("HWID handler has been already registered: '%s'", name)); @@ -44,13 +44,13 @@ public void check(HWID hwid, String username) throws HWIDException { public abstract void unban(List hwid) throws HWIDException; - public static Class getHandlerClass(String name) + public static Class getHandlerClass(String name) { return HW_HANDLERS.get(name); } - public static String getHandlerName(Class clazz) + public static String getHandlerName(Class clazz) { - for(Map.Entry e: HW_HANDLERS.entrySet()) + for(Map.Entry> e: HW_HANDLERS.entrySet()) { if(e.getValue().equals(clazz)) return e.getKey(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java index a90a0139..6ee77c5b 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/JsonHWIDHandler.java @@ -1,18 +1,18 @@ package ru.gravit.launchserver.auth.hwid; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import ru.gravit.launcher.HWID; -import ru.gravit.launcher.OshiHWID; -import ru.gravit.utils.HTTPRequest; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; - import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import com.google.gson.Gson; +import com.google.gson.JsonElement; + +import ru.gravit.launcher.HWID; +import ru.gravit.launcher.OshiHWID; +import ru.gravit.utils.HTTPRequest; +import ru.gravit.utils.helper.LogHelper; + public final class JsonHWIDHandler extends HWIDHandler { private static final Gson gson = new Gson(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java index d2c6a34b..113cea07 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java @@ -1,11 +1,5 @@ package ru.gravit.launchserver.auth.hwid; -import ru.gravit.launcher.HWID; -import ru.gravit.launcher.OshiHWID; -import ru.gravit.launchserver.auth.MySQLSourceConfig; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.LogHelper; - import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -13,6 +7,12 @@ import java.util.ArrayList; import java.util.List; +import ru.gravit.launcher.HWID; +import ru.gravit.launcher.OshiHWID; +import ru.gravit.launchserver.auth.MySQLSourceConfig; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.LogHelper; + public class MysqlHWIDHandler extends HWIDHandler { private MySQLSourceConfig mySQLHolder; private String query; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/ConfigPermissionsHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/ConfigPermissionsHandler.java index 0e5ba896..6cf5a1de 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/ConfigPermissionsHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/ConfigPermissionsHandler.java @@ -1,7 +1,6 @@ package ru.gravit.launchserver.auth.permissions; import ru.gravit.launchserver.auth.ClientPermissions; -import ru.gravit.launchserver.socket.Client; public class ConfigPermissionsHandler extends PermissionsHandler { public boolean isAdmin = false; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java index fb15aa7c..bfad14ee 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java @@ -1,13 +1,5 @@ package ru.gravit.launchserver.auth.permissions; -import com.google.gson.reflect.TypeToken; -import ru.gravit.launcher.Launcher; -import ru.gravit.launchserver.Reloadable; -import ru.gravit.launchserver.auth.ClientPermissions; -import ru.gravit.launchserver.manangers.PermissionsManager; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; - import java.io.IOException; import java.io.Reader; import java.io.Writer; @@ -17,6 +9,14 @@ import java.util.HashMap; import java.util.Map; +import com.google.gson.reflect.TypeToken; + +import ru.gravit.launcher.Launcher; +import ru.gravit.launchserver.Reloadable; +import ru.gravit.launchserver.auth.ClientPermissions; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; + public class JsonFilePermissionsHandler extends PermissionsHandler implements Reloadable { public String filename = "permissions.json"; public static Map map; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/PermissionsHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/PermissionsHandler.java index 6da71307..c4333414 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/PermissionsHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/permissions/PermissionsHandler.java @@ -1,27 +1,27 @@ package ru.gravit.launchserver.auth.permissions; -import ru.gravit.launchserver.auth.ClientPermissions; -import ru.gravit.utils.helper.VerifyHelper; - import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; +import ru.gravit.launchserver.auth.ClientPermissions; +import ru.gravit.utils.helper.VerifyHelper; + public abstract class PermissionsHandler { - private static final Map PERMISSIONS_HANDLERS = new ConcurrentHashMap<>(4); + private static final Map> PERMISSIONS_HANDLERS = new ConcurrentHashMap<>(4); private static boolean registredHandl = false; - public static void registerHandler(String name, Class adapter) { + public static void registerHandler(String name, Class adapter) { VerifyHelper.verifyIDName(name); VerifyHelper.putIfAbsent(PERMISSIONS_HANDLERS, name, Objects.requireNonNull(adapter, "adapter"), String.format("Auth handler has been already registered: '%s'", name)); } - public static Class getHandlerClass(String name) + public static Class getHandlerClass(String name) { return PERMISSIONS_HANDLERS.get(name); } - public static String getHandlerName(Class clazz) + public static String getHandlerName(Class clazz) { - for(Map.Entry e: PERMISSIONS_HANDLERS.entrySet()) + for(Map.Entry> e: PERMISSIONS_HANDLERS.entrySet()) { if(e.getValue().equals(clazz)) return e.getKey(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java index 5d7fa638..ff35ba8e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java @@ -1,6 +1,5 @@ package ru.gravit.launchserver.auth.provider; -import ru.gravit.launchserver.auth.ClientPermissions; import ru.gravit.utils.helper.SecurityHelper; public final class AcceptAuthProvider extends AuthProvider { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java index 6580cd74..1d40a27d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProvider.java @@ -1,18 +1,17 @@ package ru.gravit.launchserver.auth.provider; -import com.google.gson.annotations.Expose; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.auth.AuthException; -import ru.gravit.launchserver.auth.handler.AuthHandler; -import ru.gravit.utils.helper.VerifyHelper; - import java.io.IOException; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.auth.AuthException; +import ru.gravit.launchserver.auth.handler.AuthHandler; +import ru.gravit.utils.helper.VerifyHelper; + public abstract class AuthProvider implements AutoCloseable { - private static final Map AUTH_PROVIDERS = new ConcurrentHashMap<>(8); + private static final Map> AUTH_PROVIDERS = new ConcurrentHashMap<>(8); private static boolean registredProv = false; private transient LaunchServer server = LaunchServer.server; @@ -22,7 +21,7 @@ public static AuthProviderResult authError(String message) throws AuthException } - public static void registerProvider(String name, Class adapter) { + public static void registerProvider(String name, Class adapter) { VerifyHelper.putIfAbsent(AUTH_PROVIDERS, name, Objects.requireNonNull(adapter, "adapter"), String.format("Auth provider has been already registered: '%s'", name)); } @@ -52,13 +51,13 @@ public AuthHandler getAccociateHandler(int this_position) { @Override public abstract void close() throws IOException; - public static Class getProviderClass(String name) + public static Class getProviderClass(String name) { return AUTH_PROVIDERS.get(name); } - public static String getProviderName(Class clazz) + public static String getProviderName(Class clazz) { - for(Map.Entry e: AUTH_PROVIDERS.entrySet()) + for(Map.Entry> e: AUTH_PROVIDERS.entrySet()) { if(e.getValue().equals(clazz)) return e.getKey(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java index 28ab6fb6..f43a4bb2 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/JsonAuthProvider.java @@ -1,14 +1,15 @@ package ru.gravit.launchserver.auth.provider; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import ru.gravit.launchserver.auth.ClientPermissions; -import ru.gravit.utils.HTTPRequest; -import ru.gravit.utils.helper.SecurityHelper; - import java.io.IOException; import java.net.URL; +import com.google.gson.Gson; +import com.google.gson.JsonElement; + +import ru.gravit.launchserver.auth.ClientPermissions; +import ru.gravit.utils.HTTPRequest; +import ru.gravit.utils.helper.SecurityHelper; + public final class JsonAuthProvider extends AuthProvider { private Gson gson = new Gson(); private URL url; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java index c668418e..cdb737d1 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MojangAuthProvider.java @@ -1,15 +1,16 @@ package ru.gravit.launchserver.auth.provider; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import ru.gravit.utils.HTTPRequest; - import java.net.MalformedURLException; import java.net.URL; import java.util.UUID; import java.util.regex.Pattern; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import ru.gravit.utils.HTTPRequest; + public final class MojangAuthProvider extends AuthProvider { private static final Pattern UUID_REGEX = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"); private static final URL URL; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java index 4492a189..465c09cb 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/MySQLAuthProvider.java @@ -1,16 +1,15 @@ package ru.gravit.launchserver.auth.provider; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.auth.ClientPermissions; import ru.gravit.launchserver.auth.MySQLSourceConfig; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.VerifyHelper; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; public final class MySQLAuthProvider extends AuthProvider { private MySQLSourceConfig mySQLHolder; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/NullAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/NullAuthProvider.java index 92fa8ea5..7b4819c7 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/NullAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/NullAuthProvider.java @@ -1,10 +1,10 @@ package ru.gravit.launchserver.auth.provider; -import ru.gravit.utils.helper.VerifyHelper; - import java.io.IOException; import java.util.Objects; +import ru.gravit.utils.helper.VerifyHelper; + public final class NullAuthProvider extends AuthProvider { private volatile AuthProvider provider; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java index 1cbe7e6b..efe2305e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/RequestAuthProvider.java @@ -1,15 +1,15 @@ package ru.gravit.launchserver.auth.provider; -import ru.gravit.launchserver.auth.ClientPermissions; -import ru.gravit.utils.helper.CommonHelper; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.SecurityHelper; - import java.io.IOException; import java.net.URL; import java.util.regex.Matcher; import java.util.regex.Pattern; +import ru.gravit.launchserver.auth.ClientPermissions; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.SecurityHelper; + public final class RequestAuthProvider extends AuthProvider { private String url; private Pattern response; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java index b04d42f6..8c507ae1 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/BuildContext.java @@ -1,7 +1,5 @@ package ru.gravit.launchserver.binary; -import ru.gravit.utils.helper.IOHelper; - import java.io.IOException; import java.io.InputStream; import java.util.HashSet; @@ -10,6 +8,8 @@ import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; +import ru.gravit.utils.helper.IOHelper; + public class BuildContext { public final ZipOutputStream output; public final JAConfigurator config; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java index 1169083b..5d6c5c06 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXEL4JLauncherBinary.java @@ -1,16 +1,20 @@ package ru.gravit.launchserver.binary; +import java.io.IOException; +import java.nio.file.Path; + import net.sf.launch4j.Builder; import net.sf.launch4j.Log; -import net.sf.launch4j.config.*; +import net.sf.launch4j.config.Config; +import net.sf.launch4j.config.ConfigPersister; +import net.sf.launch4j.config.Jre; +import net.sf.launch4j.config.LanguageID; +import net.sf.launch4j.config.VersionInfo; import ru.gravit.launcher.Launcher; import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; -import java.nio.file.Path; - public final class EXEL4JLauncherBinary extends LauncherBinary { private final static class Launch4JLog extends Log { private static final Launch4JLog INSTANCE = new Launch4JLog(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java index 50b13d4b..8b5b0520 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/EXELauncherBinary.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.binary; +import java.io.IOException; +import java.nio.file.Files; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; -import java.nio.file.Files; - public class EXELauncherBinary extends LauncherBinary { public EXELauncherBinary(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java index 3803b744..18296f8e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java @@ -1,10 +1,15 @@ package ru.gravit.launchserver.binary; -import javassist.*; -import ru.gravit.launcher.LauncherConfig; - import java.io.IOException; +import javassist.CannotCompileException; +import javassist.ClassPool; +import javassist.CtClass; +import javassist.CtConstructor; +import javassist.CtMethod; +import javassist.NotFoundException; +import ru.gravit.launcher.LauncherConfig; + public class JAConfigurator implements AutoCloseable { public ClassPool pool; public CtClass ctClass; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java index 1375dfde..cf427556 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -1,20 +1,6 @@ package ru.gravit.launchserver.binary; -import javassist.CannotCompileException; -import javassist.NotFoundException; -import proguard.Configuration; -import proguard.ConfigurationParser; -import proguard.ParseException; -import proguard.ProGuard; -import ru.gravit.launcher.AutogenConfig; -import ru.gravit.launcher.Launcher; -import ru.gravit.launcher.LauncherConfig; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.asm.ClassMetadataReader; -import ru.gravit.launchserver.manangers.BuildHookManager.ZipBuildHook; -import ru.gravit.utils.helper.*; -import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; +import static ru.gravit.utils.helper.IOHelper.newZipEntry; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -34,7 +20,25 @@ import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; -import static ru.gravit.utils.helper.IOHelper.newZipEntry; +import javassist.CannotCompileException; +import javassist.NotFoundException; +import proguard.Configuration; +import proguard.ConfigurationParser; +import proguard.ParseException; +import proguard.ProGuard; +import ru.gravit.launcher.AutogenConfig; +import ru.gravit.launcher.Launcher; +import ru.gravit.launcher.LauncherConfig; +import ru.gravit.launcher.serialize.HOutput; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.asm.ClassMetadataReader; +import ru.gravit.launchserver.manangers.BuildHookManager.ZipBuildHook; +import ru.gravit.utils.helper.CommonHelper; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; +import ru.gravit.utils.helper.UnpackHelper; public final class JARLauncherBinary extends LauncherBinary { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java index 2dc99d26..75429ba0 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/LauncherBinary.java @@ -1,13 +1,13 @@ package ru.gravit.launchserver.binary; +import java.io.IOException; +import java.nio.file.Path; + import ru.gravit.launcher.serialize.signed.DigestBytesHolder; import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.SecurityHelper; -import java.io.IOException; -import java.nio.file.Path; - public abstract class LauncherBinary { public final LaunchServer server; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/Command.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/Command.java index a69b023a..402444e5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/Command.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/Command.java @@ -1,10 +1,10 @@ package ru.gravit.launchserver.command; +import java.util.UUID; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.VerifyHelper; -import java.util.UUID; - public abstract class Command { protected static String parseUsername(String username) throws CommandException { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/AuthCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/AuthCommand.java index 5a34131e..c5048a5b 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/AuthCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/AuthCommand.java @@ -1,13 +1,13 @@ package ru.gravit.launchserver.command.auth; +import java.util.UUID; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.provider.AuthProvider; import ru.gravit.launchserver.auth.provider.AuthProviderResult; import ru.gravit.launchserver.command.Command; import ru.gravit.utils.helper.LogHelper; -import java.util.UUID; - public final class AuthCommand extends Command { public AuthCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/BanCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/BanCommand.java index 3cfad3be..3511028c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/BanCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/BanCommand.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.command.auth; +import java.util.List; + import ru.gravit.launcher.HWID; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; -import java.util.List; - public class BanCommand extends Command { public BanCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UUIDToUsernameCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UUIDToUsernameCommand.java index 918a5e7f..63738552 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UUIDToUsernameCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UUIDToUsernameCommand.java @@ -1,13 +1,13 @@ package ru.gravit.launchserver.command.auth; +import java.io.IOException; +import java.util.UUID; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.CommandException; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; -import java.util.UUID; - public final class UUIDToUsernameCommand extends Command { public UUIDToUsernameCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UnbanCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UnbanCommand.java index a0c801a3..edfb3602 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UnbanCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UnbanCommand.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.command.auth; +import java.util.List; + import ru.gravit.launcher.HWID; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; -import java.util.List; - public class UnbanCommand extends Command { public UnbanCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UsernameToUUIDCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UsernameToUUIDCommand.java index 24d226ac..571368a5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UsernameToUUIDCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/auth/UsernameToUUIDCommand.java @@ -1,13 +1,13 @@ package ru.gravit.launchserver.command.auth; +import java.io.IOException; +import java.util.UUID; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.CommandException; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; -import java.util.UUID; - public final class UsernameToUUIDCommand extends Command { public UsernameToUUIDCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java index 34dd6282..364de723 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/HelpCommand.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.command.basic; +import java.util.Map.Entry; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.CommandException; import ru.gravit.utils.helper.LogHelper; -import java.util.Map.Entry; - public final class HelpCommand extends Command { private static void printCommand(String name, Command command) { String args = command.getArgsDescription(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RegenProguardDictCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RegenProguardDictCommand.java index c1cdb794..047aadb7 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RegenProguardDictCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RegenProguardDictCommand.java @@ -1,10 +1,10 @@ package ru.gravit.launchserver.command.basic; +import java.io.IOException; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; -import java.io.IOException; - public class RegenProguardDictCommand extends Command { public RegenProguardDictCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RemoveMappingsProguardCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RemoveMappingsProguardCommand.java index ba069f28..a08a47f0 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RemoveMappingsProguardCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/RemoveMappingsProguardCommand.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.command.basic; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.command.Command; - import java.io.IOException; import java.nio.file.Files; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.command.Command; + public class RemoveMappingsProguardCommand extends Command { public RemoveMappingsProguardCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java index 3e7edfd1..c80a19fb 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/TestCommand.java @@ -1,6 +1,7 @@ package ru.gravit.launchserver.command.basic; -import ru.gravit.launcher.Launcher; +import java.io.Writer; + import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; @@ -8,8 +9,6 @@ import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.IOHelper; -import java.io.Writer; - public class TestCommand extends Command { public TestCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/dump/DumpEntryCacheCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/dump/DumpEntryCacheCommand.java index 9ff5d1ff..df3d81ca 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/dump/DumpEntryCacheCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/dump/DumpEntryCacheCommand.java @@ -1,22 +1,17 @@ package ru.gravit.launchserver.command.dump; -import com.google.gson.reflect.TypeToken; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.auth.handler.CachedAuthHandler; -import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.socket.Client; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; - import java.io.Reader; import java.io.Writer; -import java.lang.reflect.Type; import java.nio.file.Paths; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.UUID; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.auth.handler.CachedAuthHandler; +import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; + public class DumpEntryCacheCommand extends Command { public DumpEntryCacheCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/dump/DumpSessionsCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/dump/DumpSessionsCommand.java index 9ef36b43..63e6c158 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/dump/DumpSessionsCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/dump/DumpSessionsCommand.java @@ -1,14 +1,5 @@ package ru.gravit.launchserver.command.dump; -import com.google.gson.reflect.TypeToken; -import javafx.scene.media.MediaException; -import ru.gravit.launcher.Launcher; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.socket.Client; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; - import java.io.Reader; import java.io.Writer; import java.lang.reflect.Type; @@ -16,6 +7,14 @@ import java.util.HashSet; import java.util.Set; +import com.google.gson.reflect.TypeToken; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.command.Command; +import ru.gravit.launchserver.socket.Client; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; + public class DumpSessionsCommand extends Command { public DumpSessionsCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java index 0425987a..b910495f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java @@ -1,13 +1,46 @@ package ru.gravit.launchserver.command.handler; +import java.io.IOException; +import java.time.Duration; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.CommandException; -import ru.gravit.launchserver.command.auth.*; -import ru.gravit.launchserver.command.basic.*; +import ru.gravit.launchserver.command.auth.AuthCommand; +import ru.gravit.launchserver.command.auth.BanCommand; +import ru.gravit.launchserver.command.auth.UUIDToUsernameCommand; +import ru.gravit.launchserver.command.auth.UnbanCommand; +import ru.gravit.launchserver.command.auth.UsernameToUUIDCommand; +import ru.gravit.launchserver.command.basic.BuildCommand; +import ru.gravit.launchserver.command.basic.ClearCommand; +import ru.gravit.launchserver.command.basic.DebugCommand; +import ru.gravit.launchserver.command.basic.GCCommand; +import ru.gravit.launchserver.command.basic.HelpCommand; +import ru.gravit.launchserver.command.basic.LogConnectionsCommand; +import ru.gravit.launchserver.command.basic.ProguardCleanCommand; +import ru.gravit.launchserver.command.basic.RebindCommand; +import ru.gravit.launchserver.command.basic.RegenProguardDictCommand; +import ru.gravit.launchserver.command.basic.RemoveMappingsProguardCommand; +import ru.gravit.launchserver.command.basic.StopCommand; +import ru.gravit.launchserver.command.basic.TestCommand; +import ru.gravit.launchserver.command.basic.VersionCommand; import ru.gravit.launchserver.command.dump.DumpEntryCacheCommand; import ru.gravit.launchserver.command.dump.DumpSessionsCommand; -import ru.gravit.launchserver.command.hash.*; +import ru.gravit.launchserver.command.hash.DownloadAssetCommand; +import ru.gravit.launchserver.command.hash.DownloadClientCommand; +import ru.gravit.launchserver.command.hash.IndexAssetCommand; +import ru.gravit.launchserver.command.hash.SyncBinariesCommand; +import ru.gravit.launchserver.command.hash.SyncProfilesCommand; +import ru.gravit.launchserver.command.hash.SyncUpdatesCommand; +import ru.gravit.launchserver.command.hash.UnindexAssetCommand; import ru.gravit.launchserver.command.modules.LoadModuleCommand; import ru.gravit.launchserver.command.modules.ModulesCommand; import ru.gravit.launchserver.command.service.ReloadAllCommand; @@ -16,12 +49,6 @@ import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; -import java.io.IOException; -import java.time.Duration; -import java.time.Instant; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - public abstract class CommandHandler implements Runnable { private static String[] parse(CharSequence line) throws CommandException { boolean quoted = false; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java index 7455b026..8fdfef7e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/JLineCommandHandler.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.command.handler; +import java.io.IOException; + import jline.console.ConsoleReader; import ru.gravit.launchserver.LaunchServer; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.LogHelper.Output; -import java.io.IOException; - public final class JLineCommandHandler extends CommandHandler { private final class JLineOutput implements Output { @Override diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java index 8593cccb..9e7c6c15 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/StdCommandHandler.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.command.handler; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.utils.helper.IOHelper; - import java.io.BufferedReader; import java.io.IOException; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.utils.helper.IOHelper; + public final class StdCommandHandler extends CommandHandler { private final BufferedReader reader; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadAssetCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadAssetCommand.java index 91c0aac7..49a3770a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadAssetCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadAssetCommand.java @@ -1,5 +1,9 @@ package ru.gravit.launchserver.command.hash; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; + import ru.gravit.launcher.profiles.ClientProfile.Version; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; @@ -7,10 +11,6 @@ import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; - public final class DownloadAssetCommand extends Command { public DownloadAssetCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java index 1fc38297..4652f1a6 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java @@ -1,6 +1,12 @@ package ru.gravit.launchserver.command.hash; -import ru.gravit.launcher.Launcher; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; + import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.ClientProfile.Version; import ru.gravit.launchserver.LaunchServer; @@ -10,13 +16,6 @@ import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; - public final class DownloadClientCommand extends Command { public DownloadClientCommand(LaunchServer server) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/IndexAssetCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/IndexAssetCommand.java index 16c06595..5878a49a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/IndexAssetCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/IndexAssetCommand.java @@ -1,15 +1,5 @@ package ru.gravit.launchserver.command.hash; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.command.CommandException; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; - import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.FileVisitResult; @@ -19,6 +9,17 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.Collections; +import com.google.gson.Gson; +import com.google.gson.JsonArray; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.command.Command; +import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; +import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; + public final class IndexAssetCommand extends Command { private static Gson gson = new Gson(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncBinariesCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncBinariesCommand.java index 44326cd1..082c37ec 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncBinariesCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncBinariesCommand.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.command.hash; +import java.io.IOException; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; - public final class SyncBinariesCommand extends Command { public SyncBinariesCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncProfilesCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncProfilesCommand.java index e31269ad..423b3152 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncProfilesCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncProfilesCommand.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.command.hash; +import java.io.IOException; + import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; - public final class SyncProfilesCommand extends Command { public SyncProfilesCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncUpdatesCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncUpdatesCommand.java index 6b741c12..e4dc8996 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncUpdatesCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/SyncUpdatesCommand.java @@ -1,14 +1,14 @@ package ru.gravit.launchserver.command.hash; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.command.Command; -import ru.gravit.utils.helper.LogHelper; - import java.io.IOException; import java.util.Collections; import java.util.HashSet; import java.util.Set; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; + public final class SyncUpdatesCommand extends Command { public SyncUpdatesCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/UnindexAssetCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/UnindexAssetCommand.java index 9bb0c797..a1f8523b 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/UnindexAssetCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/UnindexAssetCommand.java @@ -1,20 +1,21 @@ package ru.gravit.launchserver.command.hash; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.command.Command; -import ru.gravit.launchserver.command.CommandException; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.LogHelper; - import java.io.BufferedReader; import java.nio.file.Files; import java.nio.file.Path; import java.util.Collections; import java.util.Map; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.command.Command; +import ru.gravit.launchserver.command.CommandException; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.LogHelper; + public final class UnindexAssetCommand extends Command { private static JsonParser parser = new JsonParser(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/modules/LoadModuleCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/modules/LoadModuleCommand.java index af69674b..1ab8a23a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/modules/LoadModuleCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/modules/LoadModuleCommand.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.command.modules; -import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.command.Command; - import java.net.URI; import java.nio.file.Paths; +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.command.Command; + public class LoadModuleCommand extends Command { public LoadModuleCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthHandlerAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthHandlerAdapter.java index e194f32d..4be07ec2 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthHandlerAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthHandlerAdapter.java @@ -1,17 +1,24 @@ package ru.gravit.launchserver.config; -import com.google.gson.*; -import ru.gravit.launchserver.auth.handler.AuthHandler; -import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface; - import java.lang.reflect.Type; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import ru.gravit.launchserver.auth.handler.AuthHandler; + public class AuthHandlerAdapter implements JsonSerializer, JsonDeserializer { private static final String PROP_NAME = "type"; @Override public AuthHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = AuthHandler.getHandlerClass(typename); + Class cls = AuthHandler.getHandlerClass(typename); return (AuthHandler) context.deserialize(json, cls); @@ -21,7 +28,8 @@ public AuthHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializati public JsonElement serialize(AuthHandler src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jo = context.serialize(src).getAsJsonObject(); - String classPath = AuthHandler.getHandlerName(src.getClass()); + @SuppressWarnings("unchecked") + String classPath = AuthHandler.getHandlerName((Class) src.getClass()); jo.add(PROP_NAME, new JsonPrimitive(classPath)); return jo; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthProviderAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthProviderAdapter.java index 26e8687e..7c0609eb 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthProviderAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/AuthProviderAdapter.java @@ -1,18 +1,24 @@ package ru.gravit.launchserver.config; -import com.google.gson.*; -import ru.gravit.launchserver.auth.handler.AuthHandler; -import ru.gravit.launchserver.auth.provider.AuthProvider; -import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface; - import java.lang.reflect.Type; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import ru.gravit.launchserver.auth.provider.AuthProvider; + public class AuthProviderAdapter implements JsonSerializer, JsonDeserializer { private static final String PROP_NAME = "type"; @Override public AuthProvider deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = AuthProvider.getProviderClass(typename); + Class cls = AuthProvider.getProviderClass(typename); return (AuthProvider) context.deserialize(json, cls); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/HWIDHandlerAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/HWIDHandlerAdapter.java index 353a87e6..07ee387d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/HWIDHandlerAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/HWIDHandlerAdapter.java @@ -1,17 +1,24 @@ package ru.gravit.launchserver.config; -import com.google.gson.*; -import ru.gravit.launchserver.auth.handler.AuthHandler; -import ru.gravit.launchserver.auth.hwid.HWIDHandler; - import java.lang.reflect.Type; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import ru.gravit.launchserver.auth.hwid.HWIDHandler; + public class HWIDHandlerAdapter implements JsonSerializer, JsonDeserializer { private static final String PROP_NAME = "type"; @Override public HWIDHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = HWIDHandler.getHandlerClass(typename); + Class cls = HWIDHandler.getHandlerClass(typename); return (HWIDHandler) context.deserialize(json, cls); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/PermissionsHandlerAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/PermissionsHandlerAdapter.java index a39b8335..d9bd985b 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/PermissionsHandlerAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/PermissionsHandlerAdapter.java @@ -1,17 +1,24 @@ package ru.gravit.launchserver.config; -import com.google.gson.*; -import ru.gravit.launchserver.auth.handler.AuthHandler; -import ru.gravit.launchserver.auth.permissions.PermissionsHandler; - import java.lang.reflect.Type; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import ru.gravit.launchserver.auth.permissions.PermissionsHandler; + public class PermissionsHandlerAdapter implements JsonSerializer, JsonDeserializer { private static final String PROP_NAME = "type"; @Override public PermissionsHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = PermissionsHandler.getHandlerClass(typename); + Class cls = PermissionsHandler.getHandlerClass(typename); return (PermissionsHandler) context.deserialize(json, cls); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/TextureProviderAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/TextureProviderAdapter.java index f4b64b8c..50277a63 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/TextureProviderAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/TextureProviderAdapter.java @@ -1,17 +1,24 @@ package ru.gravit.launchserver.config; -import com.google.gson.*; -import ru.gravit.launchserver.auth.provider.AuthProvider; -import ru.gravit.launchserver.texture.TextureProvider; - import java.lang.reflect.Type; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import ru.gravit.launchserver.texture.TextureProvider; + public class TextureProviderAdapter implements JsonSerializer, JsonDeserializer { private static final String PROP_NAME = "type"; @Override public TextureProvider deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); - Class cls = TextureProvider.getProviderClass(typename); + Class cls = TextureProvider.getProviderClass(typename); return (TextureProvider) context.deserialize(json, cls); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/ClosingChannelFutureListener.java b/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/ClosingChannelFutureListener.java index 6b29eed0..9cd22a0c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/ClosingChannelFutureListener.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/ClosingChannelFutureListener.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.fileserver; +import java.io.Closeable; + import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import ru.gravit.utils.helper.IOHelper; -import java.io.Closeable; - public class ClosingChannelFutureListener implements ChannelFutureListener { public final Closeable[] close; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileServerHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileServerHandler.java index 3b78e8ad..c626b7fc 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/fileserver/FileServerHandler.java @@ -1,14 +1,16 @@ package ru.gravit.launchserver.fileserver; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.channel.*; -import io.netty.handler.codec.http.*; -import io.netty.handler.ssl.SslHandler; -import io.netty.handler.stream.ChunkedFile; -import io.netty.util.CharsetUtil; +import static io.netty.handler.codec.http.HttpMethod.GET; +import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST; +import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; +import static io.netty.handler.codec.http.HttpResponseStatus.FOUND; +import static io.netty.handler.codec.http.HttpResponseStatus.INTERNAL_SERVER_ERROR; +import static io.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; +import static io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; +import static io.netty.handler.codec.http.HttpResponseStatus.NOT_MODIFIED; +import static io.netty.handler.codec.http.HttpResponseStatus.OK; +import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; -import javax.activation.MimetypesFileTypeMap; import java.io.File; import java.io.FileNotFoundException; import java.io.RandomAccessFile; @@ -16,12 +18,38 @@ import java.net.URLDecoder; import java.nio.file.Path; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; import java.util.regex.Pattern; -import static io.netty.handler.codec.http.HttpMethod.GET; -import static io.netty.handler.codec.http.HttpResponseStatus.*; -import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; +import javax.activation.MimetypesFileTypeMap; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelProgressiveFuture; +import io.netty.channel.ChannelProgressiveFutureListener; +import io.netty.channel.DefaultFileRegion; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.http.DefaultFullHttpResponse; +import io.netty.handler.codec.http.DefaultHttpResponse; +import io.netty.handler.codec.http.FullHttpRequest; +import io.netty.handler.codec.http.FullHttpResponse; +import io.netty.handler.codec.http.HttpChunkedInput; +import io.netty.handler.codec.http.HttpHeaderNames; +import io.netty.handler.codec.http.HttpHeaderValues; +import io.netty.handler.codec.http.HttpResponse; +import io.netty.handler.codec.http.HttpResponseStatus; +import io.netty.handler.codec.http.HttpUtil; +import io.netty.handler.codec.http.LastHttpContent; +import io.netty.handler.ssl.SslHandler; +import io.netty.handler.stream.ChunkedFile; +import io.netty.util.CharsetUtil; public class FileServerHandler extends SimpleChannelInboundHandler { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/BuildHookManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/BuildHookManager.java index 588c9e49..712a3478 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/BuildHookManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/BuildHookManager.java @@ -1,17 +1,17 @@ package ru.gravit.launchserver.manangers; -import ru.gravit.launcher.AutogenConfig; -import ru.gravit.launcher.modules.TestClientModule; -import ru.gravit.launchserver.binary.BuildContext; -import ru.gravit.launchserver.binary.JAConfigurator; -import ru.gravit.launchserver.binary.JARLauncherBinary; - import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.zip.ZipOutputStream; +import ru.gravit.launcher.AutogenConfig; +import ru.gravit.launcher.modules.TestClientModule; +import ru.gravit.launchserver.binary.BuildContext; +import ru.gravit.launchserver.binary.JAConfigurator; +import ru.gravit.launchserver.binary.JARLauncherBinary; + public class BuildHookManager { @FunctionalInterface public interface ZipBuildHook { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/MirrorManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/MirrorManager.java index d9485f64..89633b36 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/MirrorManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/MirrorManager.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.manangers; -import ru.gravit.utils.helper.IOHelper; - import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; +import ru.gravit.utils.helper.IOHelper; + public class MirrorManager { public class Mirror { URL url; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java index fe6e0e8e..3364a488 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ModulesManager.java @@ -1,14 +1,14 @@ package ru.gravit.launchserver.manangers; +import java.net.URL; +import java.util.ArrayList; + import ru.gravit.launcher.modules.SimpleModuleManager; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.modules.CoreModule; import ru.gravit.launchserver.modules.LaunchServerModuleContext; import ru.gravit.utils.PublicURLClassLoader; -import java.net.URL; -import java.util.ArrayList; - public class ModulesManager extends SimpleModuleManager { public ModulesManager(LaunchServer lsrv) { modules = new ArrayList<>(1); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java index ea8ee6ae..2b8d7a28 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/NodeTransformer.java @@ -1,15 +1,16 @@ package ru.gravit.launchserver.manangers; +import java.util.ArrayList; +import java.util.List; + import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.tree.ClassNode; + import ru.gravit.launchserver.asm.SafeClassWriter; import ru.gravit.launchserver.binary.JARLauncherBinary; import ru.gravit.launchserver.manangers.BuildHookManager.Transformer; -import java.util.ArrayList; -import java.util.List; - public class NodeTransformer implements Transformer { @FunctionalInterface public interface ClassNodeTransformer { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java index 8f0b2305..3ef953ee 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.manangers; +import java.util.HashMap; +import java.util.Objects; + import ru.gravit.launchserver.Reloadable; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; -import java.util.HashMap; -import java.util.Objects; - public class ReloadManager { private final HashMap RELOADABLES = new HashMap<>(); public void registerReloadable(String name,Reloadable reloadable) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java index c0171c38..9be9aca5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/SessionManager.java @@ -1,11 +1,11 @@ package ru.gravit.launchserver.manangers; -import ru.gravit.launcher.NeedGarbageCollection; -import ru.gravit.launchserver.socket.Client; - import java.util.HashSet; import java.util.Set; +import ru.gravit.launcher.NeedGarbageCollection; +import ru.gravit.launchserver.socket.Client; + public class SessionManager implements NeedGarbageCollection { public static final long SESSION_TIMEOUT = 10 * 60 * 1000; // 10 минут diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/PingResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/PingResponse.java index 74b78222..0982768f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/PingResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/PingResponse.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.response; +import java.io.IOException; + import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; import ru.gravit.launchserver.LaunchServer; -import java.io.IOException; - public final class PingResponse extends Response { public PingResponse(LaunchServer server, long id, HInput input, HOutput output, String ip) { super(server, id, input, output, ip); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java index b09a79e5..4abd5a2a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java @@ -1,21 +1,30 @@ package ru.gravit.launchserver.response; +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + import ru.gravit.launcher.request.RequestException; import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.response.auth.*; +import ru.gravit.launchserver.response.auth.AuthResponse; +import ru.gravit.launchserver.response.auth.AuthServerResponse; +import ru.gravit.launchserver.response.auth.ChangeServerResponse; +import ru.gravit.launchserver.response.auth.CheckServerResponse; +import ru.gravit.launchserver.response.auth.JoinServerResponse; +import ru.gravit.launchserver.response.auth.SetProfileResponse; import ru.gravit.launchserver.response.profile.BatchProfileByUsernameResponse; import ru.gravit.launchserver.response.profile.ProfileByUUIDResponse; import ru.gravit.launchserver.response.profile.ProfileByUsernameResponse; -import ru.gravit.launchserver.response.update.*; +import ru.gravit.launchserver.response.update.LauncherResponse; +import ru.gravit.launchserver.response.update.LegacyLauncherResponse; +import ru.gravit.launchserver.response.update.ProfilesResponse; +import ru.gravit.launchserver.response.update.UpdateListResponse; +import ru.gravit.launchserver.response.update.UpdateResponse; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - public abstract class Response { @FunctionalInterface public interface Factory { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java index c97838af..0d64fa62 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java @@ -1,11 +1,17 @@ package ru.gravit.launchserver.response.auth; +import java.util.Arrays; +import java.util.Collection; +import java.util.UUID; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; + import ru.gravit.launcher.OshiHWID; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; -import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.auth.hwid.HWIDException; @@ -19,12 +25,6 @@ import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import java.util.Arrays; -import java.util.Collection; -import java.util.UUID; - public final class AuthResponse extends Response { private static String echo(int length) { char[] chars = new char[length]; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java index 9fba3686..0b4cd557 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java @@ -1,10 +1,15 @@ package ru.gravit.launchserver.response.auth; +import java.util.Arrays; +import java.util.Collection; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; + import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; -import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.auth.hwid.HWIDException; @@ -17,11 +22,6 @@ import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import java.util.Arrays; -import java.util.Collection; - public final class AuthServerResponse extends Response { private static String echo(int length) { char[] chars = new char[length]; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/CheckServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/CheckServerResponse.java index 3ad7d1cf..a3b4dfa7 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/CheckServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/CheckServerResponse.java @@ -1,5 +1,8 @@ package ru.gravit.launchserver.response.auth; +import java.io.IOException; +import java.util.UUID; + import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; @@ -10,9 +13,6 @@ import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; -import java.io.IOException; -import java.util.UUID; - public final class CheckServerResponse extends Response { public CheckServerResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/JoinServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/JoinServerResponse.java index 8ae04ec4..1184654e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/JoinServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/JoinServerResponse.java @@ -1,5 +1,7 @@ package ru.gravit.launchserver.response.auth; +import java.io.IOException; + import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; @@ -10,8 +12,6 @@ import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; -import java.io.IOException; - public final class JoinServerResponse extends Response { public JoinServerResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/SetProfileResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/SetProfileResponse.java index 6da93ecd..787d5a91 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/SetProfileResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/SetProfileResponse.java @@ -1,16 +1,15 @@ package ru.gravit.launchserver.response.auth; +import java.util.Collection; + import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; -import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.response.Response; import ru.gravit.launchserver.socket.Client; -import java.util.Collection; - public class SetProfileResponse extends Response { public SetProfileResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { super(server, session, input, output, ip); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/BatchProfileByUsernameResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/BatchProfileByUsernameResponse.java index 8d9f5181..00966979 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/BatchProfileByUsernameResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/BatchProfileByUsernameResponse.java @@ -1,5 +1,8 @@ package ru.gravit.launchserver.response.profile; +import java.io.IOException; +import java.util.Arrays; + import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; @@ -7,9 +10,6 @@ import ru.gravit.launchserver.response.Response; import ru.gravit.utils.helper.VerifyHelper; -import java.io.IOException; -import java.util.Arrays; - public final class BatchProfileByUsernameResponse extends Response { public BatchProfileByUsernameResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUUIDResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUUIDResponse.java index 0aeeca44..34f0506f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUUIDResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUUIDResponse.java @@ -1,5 +1,8 @@ package ru.gravit.launchserver.response.profile; +import java.io.IOException; +import java.util.UUID; + import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.profiles.Texture; import ru.gravit.launcher.serialize.HInput; @@ -9,9 +12,6 @@ import ru.gravit.launchserver.response.Response; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; -import java.util.UUID; - public final class ProfileByUUIDResponse extends Response { public static PlayerProfile getProfile(LaunchServer server, UUID uuid, String username, String client) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUsernameResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUsernameResponse.java index 859ada26..e2b45680 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUsernameResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/profile/ProfileByUsernameResponse.java @@ -1,5 +1,8 @@ package ru.gravit.launchserver.response.profile; +import java.io.IOException; +import java.util.UUID; + import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; @@ -7,9 +10,6 @@ import ru.gravit.launchserver.response.Response; import ru.gravit.utils.helper.VerifyHelper; -import java.io.IOException; -import java.util.UUID; - public final class ProfileByUsernameResponse extends Response { public static void writeProfile(LaunchServer server, HOutput output, String username, String client) throws IOException { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LauncherResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LauncherResponse.java index 114a55d5..4edaadd5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LauncherResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LauncherResponse.java @@ -1,5 +1,8 @@ package ru.gravit.launchserver.response.update; +import java.io.IOException; +import java.util.Arrays; + import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.signed.DigestBytesHolder; @@ -7,9 +10,6 @@ import ru.gravit.launchserver.response.Response; import ru.gravit.launchserver.socket.Client; -import java.io.IOException; -import java.util.Arrays; - public final class LauncherResponse extends Response { public LauncherResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LegacyLauncherResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LegacyLauncherResponse.java index 92aba4d6..6af47d77 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LegacyLauncherResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/LegacyLauncherResponse.java @@ -1,5 +1,7 @@ package ru.gravit.launchserver.response.update; +import java.io.IOException; + import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launchserver.LaunchServer; @@ -7,8 +9,6 @@ import ru.gravit.launchserver.response.Response; import ru.gravit.utils.helper.SecurityHelper; -import java.io.IOException; - public final class LegacyLauncherResponse extends Response { public LegacyLauncherResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java index be29c45f..eb672145 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/ProfilesResponse.java @@ -1,18 +1,17 @@ package ru.gravit.launchserver.response.update; +import java.io.IOException; +import java.util.Collection; + import ru.gravit.launcher.Launcher; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.response.Response; import ru.gravit.launchserver.socket.Client; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; -import java.util.Collection; - public final class ProfilesResponse extends Response { public ProfilesResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateListResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateListResponse.java index ffb1dddf..75426575 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateListResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateListResponse.java @@ -1,5 +1,8 @@ package ru.gravit.launchserver.response.update; +import java.util.Map.Entry; +import java.util.Set; + import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; @@ -7,9 +10,6 @@ import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.response.Response; -import java.util.Map.Entry; -import java.util.Set; - public final class UpdateListResponse extends Response { public UpdateListResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateResponse.java index de273442..8199d787 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/update/UpdateResponse.java @@ -1,5 +1,13 @@ package ru.gravit.launchserver.response.update; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Path; +import java.util.Deque; +import java.util.LinkedList; +import java.util.zip.DeflaterOutputStream; + import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.hasher.HashedEntry; import ru.gravit.launcher.hasher.HashedEntry.Type; @@ -14,14 +22,6 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.utils.helper.IOHelper; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Path; -import java.util.Deque; -import java.util.LinkedList; -import java.util.zip.DeflaterOutputStream; - public final class UpdateResponse extends Response { public UpdateResponse(LaunchServer server, long session, HInput input, HOutput output, String ip) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java index 9e4542c8..0a23981d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/NettyServerSocketHandler.java @@ -1,5 +1,34 @@ package ru.gravit.launchserver.socket; +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.nio.channels.Selector; +import java.nio.channels.ServerSocketChannel; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; + +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.TrustManager; + import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelInitializer; @@ -24,29 +53,6 @@ import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLServerSocketFactory; -import javax.net.ssl.TrustManager; -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.nio.channels.Selector; -import java.nio.channels.ServerSocketChannel; -import java.security.*; -import java.security.cert.CertificateException; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; - @SuppressWarnings({"unused", "rawtypes"}) public final class NettyServerSocketHandler implements Runnable, AutoCloseable { private static final String WEBSOCKET_PATH = "/api"; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ResponseThread.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ResponseThread.java index 00f33060..e545ab8c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ResponseThread.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ResponseThread.java @@ -1,5 +1,10 @@ package ru.gravit.launchserver.socket; +import java.io.IOException; +import java.math.BigInteger; +import java.net.Socket; +import java.net.SocketException; + import ru.gravit.launcher.Launcher; import ru.gravit.launcher.request.RequestException; import ru.gravit.launcher.serialize.HInput; @@ -11,11 +16,6 @@ import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; -import java.io.IOException; -import java.math.BigInteger; -import java.net.Socket; -import java.net.SocketException; - public final class ResponseThread implements Runnable { class Handshake { int type; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java index 79f1ab52..acfdd3da 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/ServerSocketHandler.java @@ -1,19 +1,23 @@ package ru.gravit.launchserver.socket; +import java.io.IOException; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; + import ru.gravit.launcher.managers.GarbageManager; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.manangers.SessionManager; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.LogHelper; -import java.io.IOException; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; - public final class ServerSocketHandler implements Runnable, AutoCloseable { public interface Listener { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java index dc1bd5ee..7f548c8d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketFrameHandler.java @@ -1,6 +1,7 @@ package ru.gravit.launchserver.socket.websocket; import com.google.gson.GsonBuilder; + import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.group.DefaultChannelGroup; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketIndexPageHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketIndexPageHandler.java index b65f25a7..6e31a384 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketIndexPageHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketIndexPageHandler.java @@ -1,17 +1,28 @@ package ru.gravit.launchserver.socket.websocket; +import static io.netty.handler.codec.http.HttpMethod.GET; +import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST; +import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; +import static io.netty.handler.codec.http.HttpResponseStatus.OK; +import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; +import static io.netty.handler.codec.rtsp.RtspResponseStatuses.NOT_FOUND; + import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import io.netty.channel.*; -import io.netty.handler.codec.http.*; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.http.DefaultFullHttpResponse; +import io.netty.handler.codec.http.FullHttpRequest; +import io.netty.handler.codec.http.FullHttpResponse; +import io.netty.handler.codec.http.HttpHeaderNames; +import io.netty.handler.codec.http.HttpRequest; +import io.netty.handler.codec.http.HttpUtil; import io.netty.handler.ssl.SslHandler; import io.netty.util.CharsetUtil; -import static io.netty.handler.codec.http.HttpMethod.GET; -import static io.netty.handler.codec.http.HttpResponseStatus.*; -import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; -import static io.netty.handler.codec.rtsp.RtspResponseStatuses.NOT_FOUND; - public class WebSocketIndexPageHandler extends SimpleChannelInboundHandler { private final String websocketPath; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java index 31d5a726..a18ff095 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java @@ -1,7 +1,10 @@ package ru.gravit.launchserver.socket.websocket; +import java.util.HashMap; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; + import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; @@ -21,8 +24,6 @@ import ru.gravit.launchserver.socket.websocket.json.update.UpdateListResponse; import ru.gravit.utils.helper.LogHelper; -import java.util.HashMap; - @SuppressWarnings({"unused", "rawtypes"}) public class WebSocketService { public final ChannelGroup channels; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/JsonResponseAdapter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/JsonResponseAdapter.java index f967c952..2358ad31 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/JsonResponseAdapter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/JsonResponseAdapter.java @@ -1,10 +1,18 @@ package ru.gravit.launchserver.socket.websocket.json; -import com.google.gson.*; -import ru.gravit.launchserver.socket.websocket.WebSocketService; - import java.lang.reflect.Type; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import ru.gravit.launchserver.socket.websocket.WebSocketService; + public class JsonResponseAdapter implements JsonSerializer, JsonDeserializer { private final WebSocketService service; private static final String PROP_NAME = "type"; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java index 14fb7b9a..e0c8f0ae 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java @@ -1,9 +1,10 @@ package ru.gravit.launchserver.socket.websocket.json.auth; +import java.util.Collection; + import io.netty.channel.ChannelHandlerContext; import ru.gravit.launcher.HWID; import ru.gravit.launcher.profiles.ClientProfile; -import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.auth.hwid.HWIDException; @@ -15,8 +16,6 @@ import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.VerifyHelper; -import java.util.Collection; - public class AuthResponse implements JsonResponseInterface { public String login; public String client; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java index 1a63af31..a3003988 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/update/LauncherResponse.java @@ -1,5 +1,8 @@ package ru.gravit.launchserver.socket.websocket.json.update; +import java.util.Arrays; +import java.util.Base64; + import io.netty.channel.ChannelHandlerContext; import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.socket.Client; @@ -7,9 +10,6 @@ import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface; import ru.gravit.utils.Version; -import java.util.Arrays; -import java.util.Base64; - public class LauncherResponse implements JsonResponseInterface { public Version version; public String hash; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/NullTextureProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/NullTextureProvider.java index e1a855e7..a4293a41 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/NullTextureProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/NullTextureProvider.java @@ -1,12 +1,12 @@ package ru.gravit.launchserver.texture; -import ru.gravit.launcher.profiles.Texture; -import ru.gravit.utils.helper.VerifyHelper; - import java.io.IOException; import java.util.Objects; import java.util.UUID; +import ru.gravit.launcher.profiles.Texture; +import ru.gravit.utils.helper.VerifyHelper; + public final class NullTextureProvider extends TextureProvider { private volatile TextureProvider provider; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java index 55859b52..0f05a421 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/RequestTextureProvider.java @@ -1,21 +1,19 @@ package ru.gravit.launchserver.texture; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.UUID; + import ru.gravit.launcher.Launcher; import ru.gravit.launcher.profiles.Texture; import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.UUID; - public final class RequestTextureProvider extends TextureProvider { public RequestTextureProvider() { } - private static final UUID ZERO_UUID = new UUID(0, 0); - public RequestTextureProvider(String skinURL, String cloakURL) { this.skinURL = skinURL; this.cloakURL = cloakURL; diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/TextureProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/TextureProvider.java index 7f22515d..51829465 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/TextureProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/TextureProvider.java @@ -1,20 +1,20 @@ package ru.gravit.launchserver.texture; -import ru.gravit.launcher.profiles.Texture; -import ru.gravit.utils.helper.VerifyHelper; - import java.io.IOException; import java.util.Map; import java.util.Objects; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import ru.gravit.launcher.profiles.Texture; +import ru.gravit.utils.helper.VerifyHelper; + public abstract class TextureProvider implements AutoCloseable { - private static final Map TEXTURE_PROVIDERS = new ConcurrentHashMap<>(2); + private static final Map> TEXTURE_PROVIDERS = new ConcurrentHashMap<>(2); private static boolean registredProv = false; - public static void registerProvider(String name, Class adapter) { + public static void registerProvider(String name, Class adapter) { VerifyHelper.putIfAbsent(TEXTURE_PROVIDERS, name, Objects.requireNonNull(adapter, "adapter"), String.format("Texture provider has been already registered: '%s'", name)); } @@ -39,13 +39,13 @@ public static void registerProviders() { public abstract Texture getSkinTexture(UUID uuid, String username, String client) throws IOException; - public static Class getProviderClass(String name) + public static Class getProviderClass(String name) { return TEXTURE_PROVIDERS.get(name); } - public static String getProviderName(Class clazz) + public static String getProviderName(Class clazz) { - for(Map.Entry e: TEXTURE_PROVIDERS.entrySet()) + for(Map.Entry> e: TEXTURE_PROVIDERS.entrySet()) { if(e.getValue().equals(clazz)) return e.getKey(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/VoidTextureProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/VoidTextureProvider.java index 0b77312e..ed5af330 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/texture/VoidTextureProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/texture/VoidTextureProvider.java @@ -1,9 +1,9 @@ package ru.gravit.launchserver.texture; -import ru.gravit.launcher.profiles.Texture; - import java.util.UUID; +import ru.gravit.launcher.profiles.Texture; + public final class VoidTextureProvider extends TextureProvider { @Override diff --git a/gradle.properties b/gradle.properties index 45d429c7..e1833827 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ org.gradle.parallel=true org.gradle.daemon=false org.gradle.configureondemand=true -org.gradle.caching=true \ No newline at end of file +org.gradle.caching=true