Merge branch 'release/5.0.3'

This commit is contained in:
Gravit 2019-06-07 13:17:14 +07:00
commit 1e2d3ba1bd
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
389 changed files with 3515 additions and 2241 deletions

View file

@ -1,5 +1,5 @@
def mainClassName = "ru.gravit.launchserver.LaunchServer" def mainClassName = "pro.gravit.launchserver.LaunchServer"
def mainAgentName = "ru.gravit.launchserver.StarterAgent" def mainAgentName = "pro.gravit.launchserver.StarterAgent"
evaluationDependsOn(':Launcher') evaluationDependsOn(':Launcher')
@ -53,6 +53,7 @@ bundle project(':Radon')
bundle 'commons-codec:commons-codec:1.12' bundle 'commons-codec:commons-codec:1.12'
bundle 'org.javassist:javassist:3.25.0-GA' bundle 'org.javassist:javassist:3.25.0-GA'
bundle 'io.netty:netty-all:4.1.36.Final' bundle 'io.netty:netty-all:4.1.36.Final'
bundle 'org.hibernate:hibernate-core:5.4.3.Final'
bundle 'org.slf4j:slf4j-simple:1.7.25' bundle 'org.slf4j:slf4j-simple:1.7.25'
bundle 'org.slf4j:slf4j-api:1.7.25' bundle 'org.slf4j:slf4j-api:1.7.25'

View file

@ -1,62 +1,95 @@
package ru.gravit.launchserver; package pro.gravit.launchserver;
import io.netty.handler.logging.LogLevel; import java.io.BufferedReader;
import ru.gravit.launcher.Launcher; import java.io.BufferedWriter;
import ru.gravit.launcher.LauncherConfig; import java.io.File;
import ru.gravit.launcher.NeedGarbageCollection; import java.io.IOException;
import ru.gravit.launcher.config.JsonConfigurable; import java.io.Writer;
import ru.gravit.launcher.hasher.HashedDir;
import ru.gravit.launcher.managers.ConfigManager;
import ru.gravit.launcher.managers.GarbageManager;
import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
import ru.gravit.launchserver.auth.AuthProviderPair;
import ru.gravit.launchserver.auth.handler.AuthHandler;
import ru.gravit.launchserver.auth.handler.MemoryAuthHandler;
import ru.gravit.launchserver.auth.hwid.AcceptHWIDHandler;
import ru.gravit.launchserver.auth.hwid.HWIDHandler;
import ru.gravit.launchserver.auth.permissions.DefaultPermissionsHandler;
import ru.gravit.launchserver.auth.permissions.JsonFilePermissionsHandler;
import ru.gravit.launchserver.auth.permissions.PermissionsHandler;
import ru.gravit.launchserver.auth.protect.NoProtectHandler;
import ru.gravit.launchserver.auth.protect.ProtectHandler;
import ru.gravit.launchserver.auth.provider.AuthProvider;
import ru.gravit.launchserver.auth.provider.RejectAuthProvider;
import ru.gravit.launchserver.auth.texture.RequestTextureProvider;
import ru.gravit.launchserver.auth.texture.TextureProvider;
import ru.gravit.launchserver.binary.*;
import ru.gravit.launchserver.components.AuthLimiterComponent;
import ru.gravit.launchserver.components.Component;
import ru.gravit.launchserver.config.LaunchServerRuntimeConfig;
import ru.gravit.launchserver.legacy.Response;
import ru.gravit.launchserver.manangers.*;
import ru.gravit.launchserver.manangers.hook.AuthHookManager;
import ru.gravit.launchserver.manangers.hook.BuildHookManager;
import ru.gravit.launchserver.manangers.hook.SocketHookManager;
import ru.gravit.launchserver.socket.ServerSocketHandler;
import ru.gravit.launchserver.websocket.NettyServerSocketHandler;
import ru.gravit.utils.Version;
import ru.gravit.utils.command.CommandHandler;
import ru.gravit.utils.command.JLineCommandHandler;
import ru.gravit.utils.command.StdCommandHandler;
import ru.gravit.utils.helper.*;
import java.io.*;
import java.lang.ProcessBuilder.Redirect; import java.lang.ProcessBuilder.Redirect;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.file.*; 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.nio.file.attribute.BasicFileAttributes;
import java.security.KeyPair; import java.security.KeyPair;
import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey; import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException; import java.security.spec.InvalidKeySpecException;
import java.util.*; import java.util.ArrayList;
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.Map.Entry;
import java.util.Set;
import java.util.Timer;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.zip.CRC32; import java.util.zip.CRC32;
import io.netty.handler.logging.LogLevel;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.LauncherConfig;
import pro.gravit.launcher.NeedGarbageCollection;
import pro.gravit.launcher.config.JsonConfigurable;
import pro.gravit.launcher.hasher.HashedDir;
import pro.gravit.launcher.managers.ConfigManager;
import pro.gravit.launcher.managers.GarbageManager;
import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.launcher.serialize.signed.SignedObjectHolder;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.auth.handler.AuthHandler;
import pro.gravit.launchserver.auth.handler.MemoryAuthHandler;
import pro.gravit.launchserver.auth.hwid.AcceptHWIDHandler;
import pro.gravit.launchserver.auth.hwid.HWIDHandler;
import pro.gravit.launchserver.auth.permissions.DefaultPermissionsHandler;
import pro.gravit.launchserver.auth.permissions.JsonFilePermissionsHandler;
import pro.gravit.launchserver.auth.permissions.PermissionsHandler;
import pro.gravit.launchserver.auth.protect.ProtectHandler;
import pro.gravit.launchserver.auth.protect.StdProtectHandler;
import pro.gravit.launchserver.auth.provider.AuthProvider;
import pro.gravit.launchserver.auth.provider.RejectAuthProvider;
import pro.gravit.launchserver.auth.texture.RequestTextureProvider;
import pro.gravit.launchserver.auth.texture.TextureProvider;
import pro.gravit.launchserver.binary.EXEL4JLauncherBinary;
import pro.gravit.launchserver.binary.EXELauncherBinary;
import pro.gravit.launchserver.binary.JARLauncherBinary;
import pro.gravit.launchserver.binary.LauncherBinary;
import pro.gravit.launchserver.binary.ProguardConf;
import pro.gravit.launchserver.components.AuthLimiterComponent;
import pro.gravit.launchserver.components.Component;
import pro.gravit.launchserver.config.LaunchServerRuntimeConfig;
import pro.gravit.launchserver.dao.UserService;
import pro.gravit.launchserver.legacy.Response;
import pro.gravit.launchserver.manangers.LaunchServerGsonManager;
import pro.gravit.launchserver.manangers.MirrorManager;
import pro.gravit.launchserver.manangers.ModulesManager;
import pro.gravit.launchserver.manangers.ReconfigurableManager;
import pro.gravit.launchserver.manangers.ReloadManager;
import pro.gravit.launchserver.manangers.SessionManager;
import pro.gravit.launchserver.manangers.hook.AuthHookManager;
import pro.gravit.launchserver.manangers.hook.BuildHookManager;
import pro.gravit.launchserver.manangers.hook.SocketHookManager;
import pro.gravit.launchserver.socket.ServerSocketHandler;
import pro.gravit.launchserver.websocket.NettyServerSocketHandler;
import pro.gravit.utils.Version;
import pro.gravit.utils.command.CommandHandler;
import pro.gravit.utils.command.JLineCommandHandler;
import pro.gravit.utils.command.StdCommandHandler;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.JVMHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.VerifyHelper;
public final class LaunchServer implements Runnable, AutoCloseable, Reloadable { public final class LaunchServer implements Runnable, AutoCloseable, Reloadable {
@Override @Override
public void reload() throws Exception { public void reload() throws Exception {
@ -65,11 +98,13 @@ public void reload() throws Exception {
try (BufferedReader reader = IOHelper.newReader(configFile)) { try (BufferedReader reader = IOHelper.newReader(configFile)) {
config = Launcher.gsonManager.gson.fromJson(reader, Config.class); config = Launcher.gsonManager.gson.fromJson(reader, Config.class);
} }
config.server = this;
config.verify(); config.verify();
config.init(); config.init();
} }
public static final class Config { public static final class Config {
private transient LaunchServer server = null;
public int legacyPort; public int legacyPort;
private String legacyAddress; private String legacyAddress;
@ -204,30 +239,30 @@ public void verify() {
public void init() { public void init() {
Launcher.applyLauncherEnv(env); Launcher.applyLauncherEnv(env);
for (AuthProviderPair provider : auth) { for (AuthProviderPair provider : auth) {
provider.init(); provider.init(server);
} }
permissionsHandler.init(); permissionsHandler.init(server);
hwidHandler.init(); hwidHandler.init();
if (protectHandler != null) { if (protectHandler != null) {
protectHandler.checkLaunchServerLicense(); protectHandler.checkLaunchServerLicense();
} }
LaunchServer.server.registerObject("permissionsHandler", permissionsHandler); server.registerObject("permissionsHandler", permissionsHandler);
for (AuthProviderPair pair : auth) { for (AuthProviderPair pair : auth) {
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider); server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler); server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
LaunchServer.server.registerObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider); server.registerObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
} }
Arrays.stream(mirrors).forEach(LaunchServer.server.mirrorManager::addMirror); Arrays.stream(mirrors).forEach(server.mirrorManager::addMirror);
} }
public void close() { public void close() {
try { try {
LaunchServer.server.unregisterObject("permissionsHandler", permissionsHandler); server.unregisterObject("permissionsHandler", permissionsHandler);
for (AuthProviderPair pair : auth) { for (AuthProviderPair pair : auth) {
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider); server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider);
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler); server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler);
LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider); server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider);
} }
} catch (Exception e) { } catch (Exception e) {
LogHelper.error(e); LogHelper.error(e);
@ -394,7 +429,7 @@ public static void main(String... args) throws Throwable {
public final Path updatesDir; public final Path updatesDir;
public static LaunchServer server = null; //public static LaunchServer server = null;
public final Path profilesDir; public final Path profilesDir;
// Server config // Server config
@ -424,6 +459,8 @@ public static void main(String... args) throws Throwable {
public final ModulesManager modulesManager; public final ModulesManager modulesManager;
public final UserService userService;
public final MirrorManager mirrorManager; public final MirrorManager mirrorManager;
public final ReloadManager reloadManager; public final ReloadManager reloadManager;
@ -477,7 +514,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
Response.registerResponses(); Response.registerResponses();
Component.registerComponents(); Component.registerComponents();
ProtectHandler.registerHandlers(); ProtectHandler.registerHandlers();
LaunchServer.server = this; //LaunchServer.server = this;
// Set command handler // Set command handler
CommandHandler localCommandHandler; CommandHandler localCommandHandler;
@ -494,7 +531,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
localCommandHandler = new StdCommandHandler(true); localCommandHandler = new StdCommandHandler(true);
LogHelper.warning("JLine2 isn't in classpath, using std"); LogHelper.warning("JLine2 isn't in classpath, using std");
} }
ru.gravit.launchserver.command.handler.CommandHandler.registerCommands(localCommandHandler); pro.gravit.launchserver.command.handler.CommandHandler.registerCommands(localCommandHandler, this);
commandHandler = localCommandHandler; commandHandler = localCommandHandler;
// Set key pair // Set key pair
@ -536,6 +573,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
try (BufferedReader reader = IOHelper.newReader(configFile)) { try (BufferedReader reader = IOHelper.newReader(configFile)) {
config = Launcher.gsonManager.gson.fromJson(reader, Config.class); config = Launcher.gsonManager.gson.fromJson(reader, Config.class);
} }
config.server = this;
if (!Files.exists(runtimeConfigFile)) { if (!Files.exists(runtimeConfigFile)) {
LogHelper.info("Reset LaunchServer runtime config file"); LogHelper.info("Reset LaunchServer runtime config file");
runtime = new LaunchServerRuntimeConfig(); runtime = new LaunchServerRuntimeConfig();
@ -550,9 +588,9 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
config.verify(); config.verify();
Launcher.applyLauncherEnv(config.env); Launcher.applyLauncherEnv(config.env);
for (AuthProviderPair provider : config.auth) { for (AuthProviderPair provider : config.auth) {
provider.init(); provider.init(this);
} }
config.permissionsHandler.init(); config.permissionsHandler.init(this);
config.hwidHandler.init(); config.hwidHandler.init();
if (config.protectHandler != null) { if (config.protectHandler != null) {
config.protectHandler.checkLaunchServerLicense(); config.protectHandler.checkLaunchServerLicense();
@ -576,6 +614,7 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
socketHookManager = new SocketHookManager(); socketHookManager = new SocketHookManager();
authHookManager = new AuthHookManager(); authHookManager = new AuthHookManager();
configManager = new ConfigManager(); configManager = new ConfigManager();
userService = new UserService(this);
GarbageManager.registerNeedGC(sessionManager); GarbageManager.registerNeedGC(sessionManager);
reloadManager.registerReloadable("launchServer", this); reloadManager.registerReloadable("launchServer", this);
registerObject("permissionsHandler", config.permissionsHandler); registerObject("permissionsHandler", config.permissionsHandler);
@ -716,7 +755,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException {
new RequestTextureProvider("http://example.com/skins/%username%.png", "http://example.com/cloaks/%username%.png") new RequestTextureProvider("http://example.com/skins/%username%.png", "http://example.com/cloaks/%username%.png")
, "std")}; , "std")};
newConfig.auth[0].displayName = "Default"; newConfig.auth[0].displayName = "Default";
newConfig.protectHandler = new NoProtectHandler(); newConfig.protectHandler = new StdProtectHandler();
if (testEnv) newConfig.permissionsHandler = new DefaultPermissionsHandler(); if (testEnv) newConfig.permissionsHandler = new DefaultPermissionsHandler();
else newConfig.permissionsHandler = new JsonFilePermissionsHandler(); else newConfig.permissionsHandler = new JsonFilePermissionsHandler();
newConfig.legacyPort = 7240; newConfig.legacyPort = 7240;

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver; package pro.gravit.launchserver;
public interface Reconfigurable { public interface Reconfigurable {
void reconfig(String action, String[] args); void reconfig(String action, String[] args);

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver; package pro.gravit.launchserver;
@FunctionalInterface @FunctionalInterface
public interface Reloadable { public interface Reloadable {

View file

@ -1,8 +1,13 @@
package ru.gravit.launchserver; package pro.gravit.launchserver;
import java.io.IOException; import java.io.IOException;
import java.lang.instrument.Instrumentation; 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.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.PosixFileAttributeView; import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermission;

View file

@ -1,9 +1,4 @@
package ru.gravit.launchserver.asm; package pro.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.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
@ -13,6 +8,12 @@
import java.util.List; import java.util.List;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;
import pro.gravit.utils.helper.IOHelper;
/** /**
* Позволяет искать методы внутри незагруженных классов и общие суперклассы для * Позволяет искать методы внутри незагруженных классов и общие суперклассы для
* чего угодно. Работает через поиск class-файлов в classpath. * чего угодно. Работает через поиск class-файлов в classpath.

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.asm; package pro.gravit.launchserver.asm;
import java.util.ArrayList;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
import java.util.ArrayList;
/** /**
* ClassWriter с другой реализацией метода getCommonSuperClass: при его * ClassWriter с другой реализацией метода getCommonSuperClass: при его
* использовании не происходит загрузки классов. * использовании не происходит загрузки классов.

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver.auth; package pro.gravit.launchserver.auth;
import java.io.IOException; import java.io.IOException;

View file

@ -1,11 +1,12 @@
package ru.gravit.launchserver.auth; package pro.gravit.launchserver.auth;
import ru.gravit.launchserver.auth.handler.AuthHandler;
import ru.gravit.launchserver.auth.provider.AuthProvider;
import ru.gravit.launchserver.auth.texture.TextureProvider;
import java.io.IOException; import java.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.handler.AuthHandler;
import pro.gravit.launchserver.auth.provider.AuthProvider;
import pro.gravit.launchserver.auth.texture.TextureProvider;
public class AuthProviderPair { public class AuthProviderPair {
public AuthProvider provider; public AuthProvider provider;
public AuthHandler handler; public AuthHandler handler;
@ -21,9 +22,9 @@ public AuthProviderPair(AuthProvider provider, AuthHandler handler, TextureProvi
this.name = name; this.name = name;
} }
public void init() { public void init(LaunchServer srv) {
provider.init(); provider.init(srv);
handler.init(); handler.init(srv);
} }
public void close() throws IOException { public void close() throws IOException {

View file

@ -1,14 +1,16 @@
package ru.gravit.launchserver.auth; package pro.gravit.launchserver.auth;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import com.mysql.cj.jdbc.MysqlDataSource; import com.mysql.cj.jdbc.MysqlDataSource;
import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.HikariDataSource;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.VerifyHelper;
import javax.sql.DataSource; import pro.gravit.utils.helper.LogHelper;
import java.sql.Connection; import pro.gravit.utils.helper.VerifyHelper;
import java.sql.SQLException;
public final class MySQLSourceConfig implements AutoCloseable { public final class MySQLSourceConfig implements AutoCloseable {

View file

@ -1,12 +1,14 @@
package ru.gravit.launchserver.auth.handler; package pro.gravit.launchserver.auth.handler;
import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
import ru.gravit.utils.ProviderMap;
import java.io.IOException; import java.io.IOException;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
import pro.gravit.utils.ProviderMap;
public abstract class AuthHandler implements AutoCloseable { public abstract class AuthHandler implements AutoCloseable {
public static ProviderMap<AuthHandler> providers = new ProviderMap<>("AuthHandler"); public static ProviderMap<AuthHandler> providers = new ProviderMap<>("AuthHandler");
private static boolean registredHandl = false; private static boolean registredHandl = false;
@ -23,10 +25,13 @@ public static void registerHandlers() {
providers.register("memory", MemoryAuthHandler.class); providers.register("memory", MemoryAuthHandler.class);
providers.register("mysql", MySQLAuthHandler.class); providers.register("mysql", MySQLAuthHandler.class);
providers.register("request", RequestAuthHandler.class); providers.register("request", RequestAuthHandler.class);
providers.register("hibernate", HibernateAuthHandler.class);
registredHandl = true; registredHandl = true;
} }
} }
protected transient LaunchServer srv;
public abstract UUID auth(AuthProviderResult authResult) throws IOException; public abstract UUID auth(AuthProviderResult authResult) throws IOException;
public abstract UUID checkServer(String username, String serverID) throws IOException; public abstract UUID checkServer(String username, String serverID) throws IOException;
@ -43,7 +48,7 @@ public static void registerHandlers() {
public abstract String uuidToUsername(UUID uuid) throws IOException; public abstract String uuidToUsername(UUID uuid) throws IOException;
public void init() { public void init(LaunchServer srv) {
this.srv = srv;
} }
} }

View file

@ -1,10 +1,4 @@
package ru.gravit.launchserver.auth.handler; package pro.gravit.launchserver.auth.handler;
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.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -12,6 +6,12 @@
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launcher.NeedGarbageCollection;
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.VerifyHelper;
public abstract class CachedAuthHandler extends AuthHandler implements NeedGarbageCollection { public abstract class CachedAuthHandler extends AuthHandler implements NeedGarbageCollection {
public static final class Entry { public static final class Entry {

View file

@ -0,0 +1,43 @@
package pro.gravit.launchserver.auth.handler;
import java.io.IOException;
import java.util.UUID;
import pro.gravit.launchserver.dao.User;
public class HibernateAuthHandler extends CachedAuthHandler {
@Override
protected Entry fetchEntry(String username) throws IOException {
User user = srv.userService.findUserByUsername(username);
if(user == null) return null;
return new Entry(user.uuid, username, user.getAccessToken(), user.serverID);
}
@Override
protected Entry fetchEntry(UUID uuid) throws IOException {
User user = srv.userService.findUserByUUID(uuid);
if(user == null) return null;
return new Entry(user.uuid, user.username, user.getAccessToken(), user.serverID);
}
@Override
protected boolean updateAuth(UUID uuid, String username, String accessToken) throws IOException {
User user = srv.userService.findUserByUUID(uuid);
user.setAccessToken(accessToken);
srv.userService.updateUser(user);
return true;
}
@Override
protected boolean updateServerID(UUID uuid, String serverID) throws IOException {
User user = srv.userService.findUserByUUID(uuid);
user.serverID = serverID;
srv.userService.updateUser(user);
return true;
}
@Override
public void close() throws IOException {
}
}

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.handler; package pro.gravit.launchserver.auth.handler;
import ru.gravit.launcher.Launcher;
import ru.gravit.utils.HTTPRequest;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launcher.Launcher;
import pro.gravit.utils.HTTPRequest;
public class JsonAuthHandler extends CachedAuthHandler { public class JsonAuthHandler extends CachedAuthHandler {
public URL getUrl; public URL getUrl;
public URL updateAuthUrl; public URL updateAuthUrl;

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.handler; package pro.gravit.launchserver.auth.handler;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.VerifyHelper;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.VerifyHelper;
public final class MemoryAuthHandler extends CachedAuthHandler { public final class MemoryAuthHandler extends CachedAuthHandler {
private static String toUsername(UUID uuid) { private static String toUsername(UUID uuid) {
byte[] bytes = ByteBuffer.allocate(16). byte[] bytes = ByteBuffer.allocate(16).

View file

@ -1,7 +1,4 @@
package ru.gravit.launchserver.auth.handler; package pro.gravit.launchserver.auth.handler;
import ru.gravit.launchserver.auth.MySQLSourceConfig;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
@ -10,6 +7,10 @@
import java.sql.SQLException; import java.sql.SQLException;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.MySQLSourceConfig;
import pro.gravit.utils.helper.LogHelper;
public final class MySQLAuthHandler extends CachedAuthHandler { public final class MySQLAuthHandler extends CachedAuthHandler {
private MySQLSourceConfig mySQLHolder; private MySQLSourceConfig mySQLHolder;
private String uuidColumn; private String uuidColumn;
@ -25,7 +26,8 @@ public final class MySQLAuthHandler extends CachedAuthHandler {
private transient String updateServerIDSQL; private transient String updateServerIDSQL;
@Override @Override
public void init() { public void init(LaunchServer srv) {
super.init(srv);
//Verify //Verify
if (mySQLHolder == null) LogHelper.error("[Verify][AuthHandler] mySQLHolder cannot be null"); if (mySQLHolder == null) LogHelper.error("[Verify][AuthHandler] mySQLHolder cannot be null");
if (uuidColumn == null) LogHelper.error("[Verify][AuthHandler] uuidColumn cannot be null"); if (uuidColumn == null) LogHelper.error("[Verify][AuthHandler] uuidColumn cannot be null");

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.handler; package pro.gravit.launchserver.auth.handler;
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
import ru.gravit.utils.helper.VerifyHelper;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
import pro.gravit.utils.helper.VerifyHelper;
public final class NullAuthHandler extends AuthHandler { public final class NullAuthHandler extends AuthHandler {
private volatile AuthHandler handler; private volatile AuthHandler handler;

View file

@ -1,13 +1,14 @@
package ru.gravit.launchserver.auth.handler; package pro.gravit.launchserver.auth.handler;
import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class RequestAuthHandler extends CachedAuthHandler { public final class RequestAuthHandler extends CachedAuthHandler {
private String usernameFetch; private String usernameFetch;
private String uuidFetch; private String uuidFetch;
@ -19,7 +20,8 @@ public final class RequestAuthHandler extends CachedAuthHandler {
private String goodResponse = "OK"; private String goodResponse = "OK";
@Override @Override
public void init() { public void init(LaunchServer srv) {
super.init(srv);
if (usernameFetch == null) if (usernameFetch == null)
LogHelper.error("[Verify][AuthHandler] usernameFetch cannot be null"); LogHelper.error("[Verify][AuthHandler] usernameFetch cannot be null");
if (uuidFetch == null) if (uuidFetch == null)

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.auth.hwid; package pro.gravit.launchserver.auth.hwid;
import ru.gravit.launcher.HWID;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import pro.gravit.launcher.HWID;
public class AcceptHWIDHandler extends HWIDHandler { public class AcceptHWIDHandler extends HWIDHandler {
@Override @Override

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver.auth.hwid; package pro.gravit.launchserver.auth.hwid;
public class HWIDException extends Exception { public class HWIDException extends Exception {
/** /**

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.auth.hwid; package pro.gravit.launchserver.auth.hwid;
import ru.gravit.launcher.HWID;
import ru.gravit.utils.ProviderMap;
import java.util.List; import java.util.List;
import pro.gravit.launcher.HWID;
import pro.gravit.utils.ProviderMap;
public abstract class HWIDHandler implements AutoCloseable { public abstract class HWIDHandler implements AutoCloseable {
public static ProviderMap<HWIDHandler> providers = new ProviderMap<>("HWIDHandler"); public static ProviderMap<HWIDHandler> providers = new ProviderMap<>("HWIDHandler");
private static boolean registredHandl = false; private static boolean registredHandl = false;
@ -15,6 +15,7 @@ public static void registerHandlers() {
providers.register("accept", AcceptHWIDHandler.class); providers.register("accept", AcceptHWIDHandler.class);
providers.register("mysql", MysqlHWIDHandler.class); providers.register("mysql", MysqlHWIDHandler.class);
providers.register("json", JsonHWIDHandler.class); providers.register("json", JsonHWIDHandler.class);
providers.register("jsonfile", JsonFileHWIDHandler.class);
providers.register("memory", MemoryHWIDHandler.class); providers.register("memory", MemoryHWIDHandler.class);
registredHandl = true; registredHandl = true;
} }

View file

@ -1,10 +1,4 @@
package ru.gravit.launchserver.auth.hwid; package pro.gravit.launchserver.auth.hwid;
import com.google.gson.reflect.TypeToken;
import ru.gravit.launcher.HWID;
import ru.gravit.launcher.Launcher;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
@ -16,6 +10,13 @@
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import com.google.gson.reflect.TypeToken;
import pro.gravit.launcher.HWID;
import pro.gravit.launcher.Launcher;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class JsonFileHWIDHandler extends HWIDHandler { public class JsonFileHWIDHandler extends HWIDHandler {
public class Entry { public class Entry {
public HWID hwid; public HWID hwid;

View file

@ -1,11 +1,4 @@
package ru.gravit.launchserver.auth.hwid; package pro.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.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
@ -13,6 +6,14 @@
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import pro.gravit.launcher.HWID;
import pro.gravit.launcher.OshiHWID;
import pro.gravit.utils.HTTPRequest;
import pro.gravit.utils.helper.LogHelper;
public final class JsonHWIDHandler extends HWIDHandler { public final class JsonHWIDHandler extends HWIDHandler {
private static final Gson gson = new Gson(); private static final Gson gson = new Gson();

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.auth.hwid; package pro.gravit.launchserver.auth.hwid;
import ru.gravit.launcher.HWID;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import pro.gravit.launcher.HWID;
public class MemoryHWIDHandler extends HWIDHandler { public class MemoryHWIDHandler extends HWIDHandler {
public class Entry { public class Entry {
public HWID hwid; public HWID hwid;

View file

@ -1,10 +1,4 @@
package ru.gravit.launchserver.auth.hwid; package pro.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.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -13,6 +7,12 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import pro.gravit.launcher.HWID;
import pro.gravit.launcher.OshiHWID;
import pro.gravit.launchserver.auth.MySQLSourceConfig;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.LogHelper;
public class MysqlHWIDHandler extends HWIDHandler { public class MysqlHWIDHandler extends HWIDHandler {
private MySQLSourceConfig mySQLHolder; private MySQLSourceConfig mySQLHolder;

View file

@ -1,16 +1,11 @@
package ru.gravit.launchserver.auth.permissions; package pro.gravit.launchserver.auth.permissions;
import ru.gravit.launcher.ClientPermissions; import pro.gravit.launcher.ClientPermissions;
public class ConfigPermissionsHandler extends PermissionsHandler { public class ConfigPermissionsHandler extends PermissionsHandler {
public boolean isAdmin = false; public boolean isAdmin = false;
public boolean isServer = false; public boolean isServer = false;
@Override
public void init() {
}
@Override @Override
public ClientPermissions getPermissions(String username) { public ClientPermissions getPermissions(String username) {
ClientPermissions permissions = new ClientPermissions(); ClientPermissions permissions = new ClientPermissions();

View file

@ -1,12 +1,8 @@
package ru.gravit.launchserver.auth.permissions; package pro.gravit.launchserver.auth.permissions;
import ru.gravit.launcher.ClientPermissions; import pro.gravit.launcher.ClientPermissions;
public class DefaultPermissionsHandler extends PermissionsHandler { public class DefaultPermissionsHandler extends PermissionsHandler {
@Override
public void init() {
}
@Override @Override
public ClientPermissions getPermissions(String username) { public ClientPermissions getPermissions(String username) {

View file

@ -0,0 +1,27 @@
package pro.gravit.launchserver.auth.permissions;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launchserver.dao.User;
public class HibernatePermissionsHandler extends PermissionsHandler {
@Override
public ClientPermissions getPermissions(String username) {
User user = srv.userService.findUserByUsername(username);
if(user == null) return ClientPermissions.DEFAULT;
return user.getPermissions();
}
@Override
public void setPermissions(String username, ClientPermissions permissions) {
User user = srv.userService.findUserByUsername(username);
if(user == null) return;
user.setPermissions(permissions);
srv.userService.updateUser(user);
}
@Override
public void close() throws Exception {
}
}

View file

@ -1,11 +1,4 @@
package ru.gravit.launchserver.auth.permissions; package pro.gravit.launchserver.auth.permissions;
import com.google.gson.reflect.TypeToken;
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.launcher.Launcher;
import ru.gravit.launchserver.Reloadable;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
@ -16,6 +9,15 @@
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.google.gson.reflect.TypeToken;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launcher.Launcher;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.Reloadable;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class JsonFilePermissionsHandler extends PermissionsHandler implements Reloadable { public class JsonFilePermissionsHandler extends PermissionsHandler implements Reloadable {
public String filename = "permissions.json"; public String filename = "permissions.json";
public static Map<String, ClientPermissions> map; public static Map<String, ClientPermissions> map;
@ -44,7 +46,8 @@ public static class Enity {
} }
@Override @Override
public void init() { public void init(LaunchServer server) {
super.init(server);
Type type = new TypeToken<Map<String, ClientPermissions>>() { Type type = new TypeToken<Map<String, ClientPermissions>>() {
}.getType(); }.getType();
Path path = Paths.get(filename); Path path = Paths.get(filename);

View file

@ -1,11 +1,4 @@
package ru.gravit.launchserver.auth.permissions; package pro.gravit.launchserver.auth.permissions;
import com.google.gson.reflect.TypeToken;
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.launcher.Launcher;
import ru.gravit.launchserver.Reloadable;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
@ -16,6 +9,15 @@
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.google.gson.reflect.TypeToken;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launcher.Launcher;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.Reloadable;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class JsonLongFilePermissionsHandler extends PermissionsHandler implements Reloadable { public class JsonLongFilePermissionsHandler extends PermissionsHandler implements Reloadable {
public String filename = "permissions.json"; public String filename = "permissions.json";
public long defaultPerms = 0L; public long defaultPerms = 0L;
@ -45,7 +47,8 @@ public static class Enity {
} }
@Override @Override
public void init() { public void init(LaunchServer server) {
super.init(server);
Type type = new TypeToken<Map<String, ClientPermissions>>() { Type type = new TypeToken<Map<String, ClientPermissions>>() {
}.getType(); }.getType();
Path path = Paths.get(filename); Path path = Paths.get(filename);

View file

@ -1,10 +1,12 @@
package ru.gravit.launchserver.auth.permissions; package pro.gravit.launchserver.auth.permissions;
import ru.gravit.launcher.ClientPermissions; import pro.gravit.launcher.ClientPermissions;
import ru.gravit.utils.ProviderMap; import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.ProviderMap;
public abstract class PermissionsHandler implements AutoCloseable { public abstract class PermissionsHandler implements AutoCloseable {
public static ProviderMap<PermissionsHandler> providers = new ProviderMap<>("PermissionsHandler"); public static ProviderMap<PermissionsHandler> providers = new ProviderMap<>("PermissionsHandler");
protected transient LaunchServer srv;
private static boolean registredHandl = false; private static boolean registredHandl = false;
public static void registerHandlers() { public static void registerHandlers() {
@ -13,11 +15,15 @@ public static void registerHandlers() {
providers.register("json-long", JsonLongFilePermissionsHandler.class); providers.register("json-long", JsonLongFilePermissionsHandler.class);
providers.register("config", ConfigPermissionsHandler.class); providers.register("config", ConfigPermissionsHandler.class);
providers.register("default", DefaultPermissionsHandler.class); providers.register("default", DefaultPermissionsHandler.class);
providers.register("hibernate", HibernatePermissionsHandler.class);
registredHandl = true; registredHandl = true;
} }
} }
public abstract void init(); public void init(LaunchServer server)
{
this.srv = server;
}
public abstract ClientPermissions getPermissions(String username); public abstract ClientPermissions getPermissions(String username);

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.auth.protect; package pro.gravit.launchserver.auth.protect;
import ru.gravit.launchserver.websocket.json.auth.AuthResponse; import pro.gravit.launchserver.websocket.json.auth.AuthResponse;
import ru.gravit.utils.helper.SecurityHelper; import pro.gravit.utils.helper.SecurityHelper;
public class NoProtectHandler extends ProtectHandler { public class NoProtectHandler extends ProtectHandler {
@Override @Override

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.auth.protect; package pro.gravit.launchserver.auth.protect;
import ru.gravit.launchserver.websocket.json.auth.AuthResponse; import pro.gravit.launchserver.websocket.json.auth.AuthResponse;
import ru.gravit.utils.ProviderMap; import pro.gravit.utils.ProviderMap;
public abstract class ProtectHandler { public abstract class ProtectHandler {
public static ProviderMap<ProtectHandler> providers = new ProviderMap<>("ProtectHandler"); public static ProviderMap<ProtectHandler> providers = new ProviderMap<>("ProtectHandler");
@ -11,6 +11,7 @@ public abstract class ProtectHandler {
public static void registerHandlers() { public static void registerHandlers() {
if (!registredHandl) { if (!registredHandl) {
providers.register("none", NoProtectHandler.class); providers.register("none", NoProtectHandler.class);
providers.register("std", StdProtectHandler.class);
registredHandl = true; registredHandl = true;
} }
} }

View file

@ -0,0 +1,31 @@
package pro.gravit.launchserver.auth.protect;
import pro.gravit.launchserver.websocket.json.auth.AuthResponse;
import pro.gravit.utils.helper.SecurityHelper;
public class StdProtectHandler extends ProtectHandler {
@Override
public String generateSecureToken(AuthResponse.AuthContext context) {
return SecurityHelper.randomStringToken();
}
@Override
public String generateClientSecureToken() {
return SecurityHelper.randomStringToken();
}
@Override
public boolean verifyClientSecureToken(String token, String secureKey) {
return true;
}
@Override
public boolean allowGetAccessToken(AuthResponse.AuthContext context) {
return !(context.authType == AuthResponse.ConnectTypes.CLIENT);
}
@Override
public void checkLaunchServerLicense() {
}
}

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.provider; package pro.gravit.launchserver.auth.provider;
import ru.gravit.utils.helper.SecurityHelper; import pro.gravit.utils.helper.SecurityHelper;
public final class AcceptAuthProvider extends AuthProvider { public final class AcceptAuthProvider extends AuthProvider {
@Override @Override
public AuthProviderResult auth(String login, String password, String ip) { public AuthProviderResult auth(String login, String password, String ip) {
return new AuthProviderResult(login, SecurityHelper.randomStringToken()); // Same as login return new AuthProviderResult(login, SecurityHelper.randomStringToken(), srv); // Same as login
} }
@Override @Override

View file

@ -1,14 +1,15 @@
package ru.gravit.launchserver.auth.provider; package pro.gravit.launchserver.auth.provider;
import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.utils.ProviderMap;
import java.io.IOException; import java.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.utils.ProviderMap;
public abstract class AuthProvider implements AutoCloseable { public abstract class AuthProvider implements AutoCloseable {
public static ProviderMap<AuthProvider> providers = new ProviderMap<>("AuthProvider"); public static ProviderMap<AuthProvider> providers = new ProviderMap<>("AuthProvider");
private static boolean registredProv = false; private static boolean registredProv = false;
protected transient LaunchServer srv = null;
public static AuthProviderResult authError(String message) throws AuthException { public static AuthProviderResult authError(String message) throws AuthException {
throw new AuthException(message); throw new AuthException(message);
} }
@ -21,6 +22,7 @@ public static void registerProviders() {
providers.register("mysql", MySQLAuthProvider.class); providers.register("mysql", MySQLAuthProvider.class);
providers.register("request", RequestAuthProvider.class); providers.register("request", RequestAuthProvider.class);
providers.register("json", JsonAuthProvider.class); providers.register("json", JsonAuthProvider.class);
providers.register("hibernate", HibernateAuthProvider.class);
registredProv = true; registredProv = true;
} }
} }
@ -34,7 +36,7 @@ public void preAuth(String login, String password, String customText, String ip)
@Override @Override
public abstract void close() throws IOException; public abstract void close() throws IOException;
public void init() { public void init(LaunchServer srv) {
this.srv = srv;
} }
} }

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.auth.provider; package pro.gravit.launchserver.auth.provider;
import ru.gravit.launcher.ClientPermissions; import pro.gravit.launcher.ClientPermissions;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
public class AuthProviderResult { public class AuthProviderResult {
@ -9,10 +9,10 @@ public class AuthProviderResult {
public final String accessToken; public final String accessToken;
public final ClientPermissions permissions; public final ClientPermissions permissions;
public AuthProviderResult(String username, String accessToken) { public AuthProviderResult(String username, String accessToken, LaunchServer server) {
this.username = username; this.username = username;
this.accessToken = accessToken; this.accessToken = accessToken;
permissions = LaunchServer.server.config.permissionsHandler.getPermissions(username); permissions = server.config.permissionsHandler.getPermissions(username);
} }
public AuthProviderResult(String username, String accessToken, ClientPermissions permissions) { public AuthProviderResult(String username, String accessToken, ClientPermissions permissions) {

View file

@ -1,8 +1,8 @@
package ru.gravit.launchserver.auth.provider; package pro.gravit.launchserver.auth.provider;
import ru.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.auth.AuthException;
import ru.gravit.utils.helper.SecurityHelper; import pro.gravit.utils.helper.SecurityHelper;
import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; import pro.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
public abstract class DigestAuthProvider extends AuthProvider { public abstract class DigestAuthProvider extends AuthProvider {
private DigestAlgorithm digest; private DigestAlgorithm digest;

View file

@ -0,0 +1,25 @@
package pro.gravit.launchserver.auth.provider;
import java.io.IOException;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.dao.User;
import pro.gravit.utils.helper.SecurityHelper;
public class HibernateAuthProvider extends AuthProvider {
@Override
public AuthProviderResult auth(String login, String password, String ip) throws Exception {
User user = srv.userService.findUserByUsername(login);
if(user == null || !user.verifyPassword(password))
{
if(user ==null) throw new AuthException("Username incorrect");
else throw new AuthException("Username or password incorrect");
}
return new AuthProviderResult(login, SecurityHelper.randomStringToken(), srv);
}
@Override
public void close() throws IOException {
}
}

View file

@ -1,14 +1,15 @@
package ru.gravit.launchserver.auth.provider; package pro.gravit.launchserver.auth.provider;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.utils.HTTPRequest;
import ru.gravit.utils.helper.SecurityHelper;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.utils.HTTPRequest;
import pro.gravit.utils.helper.SecurityHelper;
public final class JsonAuthProvider extends AuthProvider { public final class JsonAuthProvider extends AuthProvider {
private static Gson gson = new Gson(); private static Gson gson = new Gson();
private URL url; private URL url;

View file

@ -1,18 +1,18 @@
package ru.gravit.launchserver.auth.provider; package pro.gravit.launchserver.auth.provider;
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.launchserver.auth.MySQLSourceConfig;
import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.launchserver.auth.MySQLSourceConfig;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
public final class MySQLAuthProvider extends AuthProvider { public final class MySQLAuthProvider extends AuthProvider {
private MySQLSourceConfig mySQLHolder; private MySQLSourceConfig mySQLHolder;
private String query; private String query;
@ -21,7 +21,8 @@ public final class MySQLAuthProvider extends AuthProvider {
private boolean usePermission; private boolean usePermission;
@Override @Override
public void init() { public void init(LaunchServer srv) {
super.init(srv);
if (query == null) LogHelper.error("[Verify][AuthProvider] query cannot be null"); if (query == null) LogHelper.error("[Verify][AuthProvider] query cannot be null");
if (message == null) LogHelper.error("[Verify][AuthProvider] message cannot be null"); if (message == null) LogHelper.error("[Verify][AuthProvider] message cannot be null");
if (mySQLHolder == null) LogHelper.error("[Verify][AuthProvider] mySQLHolder cannot be null"); if (mySQLHolder == null) LogHelper.error("[Verify][AuthProvider] mySQLHolder cannot be null");
@ -38,7 +39,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws
// Execute SQL query // Execute SQL query
s.setQueryTimeout(MySQLSourceConfig.TIMEOUT); s.setQueryTimeout(MySQLSourceConfig.TIMEOUT);
try (ResultSet set = s.executeQuery()) { try (ResultSet set = s.executeQuery()) {
return set.next() ? new AuthProviderResult(set.getString(1), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(set.getLong(2)) : LaunchServer.server.config.permissionsHandler.getPermissions(set.getString(1))) : authError(message); return set.next() ? new AuthProviderResult(set.getString(1), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(set.getLong(2)) : srv.config.permissionsHandler.getPermissions(set.getString(1))) : authError(message);
} }
} }

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.auth.provider; package pro.gravit.launchserver.auth.provider;
import ru.gravit.utils.helper.VerifyHelper;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import pro.gravit.utils.helper.VerifyHelper;
public final class NullAuthProvider extends AuthProvider { public final class NullAuthProvider extends AuthProvider {
private volatile AuthProvider provider; private volatile AuthProvider provider;

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.provider; package pro.gravit.launchserver.auth.provider;
import ru.gravit.launchserver.Reconfigurable;
import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
import java.util.ArrayList; import java.util.ArrayList;
import pro.gravit.launchserver.Reconfigurable;
import pro.gravit.launchserver.auth.AuthException;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
public final class RejectAuthProvider extends AuthProvider implements Reconfigurable { public final class RejectAuthProvider extends AuthProvider implements Reconfigurable {
public RejectAuthProvider() { public RejectAuthProvider() {
} }
@ -23,7 +23,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws
if (whitelist != null) { if (whitelist != null) {
for (String username : whitelist) { for (String username : whitelist) {
if (login.equals(username)) { if (login.equals(username)) {
return new AuthProviderResult(login, SecurityHelper.randomStringToken()); return new AuthProviderResult(login, SecurityHelper.randomStringToken(), srv);
} }
} }
} }

View file

@ -1,17 +1,17 @@
package ru.gravit.launchserver.auth.provider; package pro.gravit.launchserver.auth.provider;
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.launchserver.LaunchServer;
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 java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import pro.gravit.launcher.ClientPermissions;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
public final class RequestAuthProvider extends AuthProvider { public final class RequestAuthProvider extends AuthProvider {
private String url; private String url;
private transient Pattern pattern; private transient Pattern pattern;
@ -19,7 +19,8 @@ public final class RequestAuthProvider extends AuthProvider {
private boolean usePermission; private boolean usePermission;
@Override @Override
public void init() { public void init(LaunchServer srv) {
super.init(srv);
if (url == null) LogHelper.error("[Verify][AuthProvider] url cannot be null"); if (url == null) LogHelper.error("[Verify][AuthProvider] url cannot be null");
if (response == null) LogHelper.error("[Verify][AuthProvider] response cannot be null"); if (response == null) LogHelper.error("[Verify][AuthProvider] response cannot be null");
pattern = Pattern.compile(response); pattern = Pattern.compile(response);
@ -32,7 +33,7 @@ public AuthProviderResult auth(String login, String password, String ip) throws
// Match username // Match username
Matcher matcher = pattern.matcher(currentResponse); Matcher matcher = pattern.matcher(currentResponse);
return matcher.matches() && matcher.groupCount() >= 1 ? return matcher.matches() && matcher.groupCount() >= 1 ?
new AuthProviderResult(matcher.group("username"), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(Long.getLong(matcher.group("permission"))) : LaunchServer.server.config.permissionsHandler.getPermissions(login)) : new AuthProviderResult(matcher.group("username"), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(Long.getLong(matcher.group("permission"))) : srv.config.permissionsHandler.getPermissions(login)) :
authError(currentResponse); authError(currentResponse);
} }

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.auth.texture; package pro.gravit.launchserver.auth.texture;
import ru.gravit.launcher.profiles.Texture;
import ru.gravit.utils.helper.VerifyHelper;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launcher.profiles.Texture;
import pro.gravit.utils.helper.VerifyHelper;
public final class NullTextureProvider extends TextureProvider { public final class NullTextureProvider extends TextureProvider {
private volatile TextureProvider provider; private volatile TextureProvider provider;

View file

@ -1,15 +1,15 @@
package ru.gravit.launchserver.auth.texture; package pro.gravit.launchserver.auth.texture;
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.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.profiles.Texture;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class RequestTextureProvider extends TextureProvider { public final class RequestTextureProvider extends TextureProvider {
public RequestTextureProvider() { public RequestTextureProvider() {
} }

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.auth.texture; package pro.gravit.launchserver.auth.texture;
import ru.gravit.launcher.profiles.Texture;
import ru.gravit.utils.ProviderMap;
import java.io.IOException; import java.io.IOException;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launcher.profiles.Texture;
import pro.gravit.utils.ProviderMap;
public abstract class TextureProvider implements AutoCloseable { public abstract class TextureProvider implements AutoCloseable {
public static ProviderMap<TextureProvider> providers = new ProviderMap<>("TextureProvider"); public static ProviderMap<TextureProvider> providers = new ProviderMap<>("TextureProvider");
private static boolean registredProv = false; private static boolean registredProv = false;

View file

@ -1,9 +1,9 @@
package ru.gravit.launchserver.auth.texture; package pro.gravit.launchserver.auth.texture;
import ru.gravit.launcher.profiles.Texture;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launcher.profiles.Texture;
public final class VoidTextureProvider extends TextureProvider { public final class VoidTextureProvider extends TextureProvider {
@Override @Override

View file

@ -1,7 +1,4 @@
package ru.gravit.launchserver.binary; package pro.gravit.launchserver.binary;
import ru.gravit.launchserver.binary.tasks.MainBuildTask;
import ru.gravit.utils.helper.IOHelper;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -11,6 +8,9 @@
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import pro.gravit.launchserver.binary.tasks.MainBuildTask;
import pro.gravit.utils.helper.IOHelper;
public class BuildContext { public class BuildContext {
public final ZipOutputStream output; public final ZipOutputStream output;
public final JAConfigurator config; public final JAConfigurator config;

View file

@ -1,16 +1,20 @@
package ru.gravit.launchserver.binary; package pro.gravit.launchserver.binary;
import net.sf.launch4j.Builder;
import net.sf.launch4j.Log;
import net.sf.launch4j.config.*;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.Version;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import net.sf.launch4j.Builder;
import net.sf.launch4j.Log;
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 pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.Version;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class EXEL4JLauncherBinary extends LauncherBinary { public final class EXEL4JLauncherBinary extends LauncherBinary {
private final static class Launch4JLog extends Log { private final static class Launch4JLog extends Log {
private static final Launch4JLog INSTANCE = new Launch4JLog(); private static final Launch4JLog INSTANCE = new Launch4JLog();

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.binary; package pro.gravit.launchserver.binary;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class EXELauncherBinary extends LauncherBinary { public class EXELauncherBinary extends LauncherBinary {
public EXELauncherBinary(LaunchServer server) { public EXELauncherBinary(LaunchServer server) {

View file

@ -1,11 +1,16 @@
package ru.gravit.launchserver.binary; package pro.gravit.launchserver.binary;
import javassist.*;
import ru.gravit.launcher.LauncherConfig;
import ru.gravit.launchserver.binary.tasks.MainBuildTask;
import java.io.IOException; import java.io.IOException;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtConstructor;
import javassist.CtMethod;
import javassist.NotFoundException;
import pro.gravit.launcher.LauncherConfig;
import pro.gravit.launchserver.binary.tasks.MainBuildTask;
public class JAConfigurator implements AutoCloseable { public class JAConfigurator implements AutoCloseable {
public ClassPool pool; public ClassPool pool;
public CtClass ctClass; public CtClass ctClass;
@ -29,12 +34,12 @@ public JAConfigurator(String configclass, MainBuildTask jarLauncherBinary) throw
} }
public void addModuleClass(String fullName) { public void addModuleClass(String fullName) {
moduleBody.append("ru.gravit.launcher.modules.Module mod"); moduleBody.append("pro.gravit.launcher.modules.Module mod");
moduleBody.append(autoincrement); moduleBody.append(autoincrement);
moduleBody.append(" = new "); moduleBody.append(" = new ");
moduleBody.append(fullName); moduleBody.append(fullName);
moduleBody.append("();"); moduleBody.append("();");
moduleBody.append("ru.gravit.launcher.Launcher.modulesManager.registerModule( mod"); moduleBody.append("pro.gravit.launcher.Launcher.modulesManager.registerModule( mod");
moduleBody.append(autoincrement); moduleBody.append(autoincrement);
moduleBody.append(");"); moduleBody.append(");");
autoincrement++; autoincrement++;

View file

@ -1,11 +1,4 @@
package ru.gravit.launchserver.binary; package pro.gravit.launchserver.binary;
import ru.gravit.launcher.Launcher;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.binary.tasks.*;
import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@ -14,6 +7,19 @@
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import pro.gravit.launcher.Launcher;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.binary.tasks.AdditionalFixesApplyTask;
import pro.gravit.launchserver.binary.tasks.AttachJarsTask;
import pro.gravit.launchserver.binary.tasks.LauncherBuildTask;
import pro.gravit.launchserver.binary.tasks.MainBuildTask;
import pro.gravit.launchserver.binary.tasks.PrepareBuildTask;
import pro.gravit.launchserver.binary.tasks.ProGuardBuildTask;
import pro.gravit.launchserver.binary.tasks.RadonBuildTask;
import pro.gravit.utils.helper.CommonHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class JARLauncherBinary extends LauncherBinary { public final class JARLauncherBinary extends LauncherBinary {
public final AtomicLong count; public final AtomicLong count;
public final Path runtimeDir; public final Path runtimeDir;
@ -24,7 +30,7 @@ public final class JARLauncherBinary extends LauncherBinary {
public List<Path> addonLibs; public List<Path> addonLibs;
public JARLauncherBinary(LaunchServer server) throws IOException { public JARLauncherBinary(LaunchServer server) throws IOException {
super(server, LauncherBinary.resolve(server, ".jar")); super(server, resolve(server, ".jar"));
count = new AtomicLong(0); count = new AtomicLong(0);
runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
guardDir = server.dir.resolve(Launcher.GUARD_DIR); guardDir = server.dir.resolve(Launcher.GUARD_DIR);

View file

@ -1,13 +1,13 @@
package ru.gravit.launchserver.binary; package pro.gravit.launchserver.binary;
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.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import pro.gravit.launcher.serialize.signed.DigestBytesHolder;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.SecurityHelper;
public abstract class LauncherBinary { public abstract class LauncherBinary {
public final LaunchServer server; public final LaunchServer server;
public final Path syncBinaryFile; public final Path syncBinaryFile;

View file

@ -1,10 +1,4 @@
package ru.gravit.launchserver.binary; package pro.gravit.launchserver.binary;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
import ru.gravit.utils.helper.UnpackHelper;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
@ -15,6 +9,12 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.UnpackHelper;
public class ProguardConf { public class ProguardConf {
private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ"; private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ";
@ -62,7 +62,7 @@ public String[] buildConfig(Path inputJar, Path outputJar) {
private void genConfig(boolean force) throws IOException { private void genConfig(boolean force) throws IOException {
if (IOHelper.exists(config) && !force) return; if (IOHelper.exists(config) && !force) return;
Files.deleteIfExists(config); Files.deleteIfExists(config);
UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"), config); UnpackHelper.unpack(IOHelper.getResourceURL("pro/gravit/launchserver/defaults/proguard.cfg"), config);
} }
public void genWords(boolean force) throws IOException { public void genWords(boolean force) throws IOException {
@ -71,7 +71,7 @@ public void genWords(boolean force) throws IOException {
SecureRandom rand = SecurityHelper.newRandom(); SecureRandom rand = SecurityHelper.newRandom();
rand.setSeed(SecureRandom.getSeed(32)); rand.setSeed(SecureRandom.getSeed(32));
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(IOHelper.newOutput(words), IOHelper.UNICODE_CHARSET))) { try (PrintWriter out = new PrintWriter(new OutputStreamWriter(IOHelper.newOutput(words), IOHelper.UNICODE_CHARSET))) {
String projectName = LaunchServer.server.config.projectName.replaceAll("\\W", ""); String projectName = srv.config.projectName.replaceAll("\\W", "");
String lowName = projectName.toLowerCase(); String lowName = projectName.toLowerCase();
String upName = projectName.toUpperCase(); String upName = projectName.toUpperCase();
for (int i = 0; i < Short.MAX_VALUE; i++) out.println(generateString(rand, lowName, upName, 3)); for (int i = 0; i < Short.MAX_VALUE; i++) out.println(generateString(rand, lowName, upName, 3));

View file

@ -1,12 +1,4 @@
package ru.gravit.launchserver.binary.tasks; package pro.gravit.launchserver.binary.tasks;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.asm.ClassMetadataReader;
import ru.gravit.launchserver.asm.SafeClassWriter;
import ru.gravit.utils.helper.IOHelper;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -19,6 +11,15 @@
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.asm.ClassMetadataReader;
import pro.gravit.launchserver.asm.SafeClassWriter;
import pro.gravit.utils.helper.IOHelper;
public class AdditionalFixesApplyTask implements LauncherBuildTask { public class AdditionalFixesApplyTask implements LauncherBuildTask {
private final LaunchServer server; private final LaunchServer server;

View file

@ -1,8 +1,4 @@
package ru.gravit.launchserver.binary.tasks; package pro.gravit.launchserver.binary.tasks;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
@ -12,6 +8,10 @@
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class AttachJarsTask implements LauncherBuildTask { public class AttachJarsTask implements LauncherBuildTask {
private final LaunchServer srv; private final LaunchServer srv;
private final List<Path> jars; private final List<Path> jars;
@ -22,6 +22,9 @@ public AttachJarsTask(LaunchServer srv) {
jars = new ArrayList<>(); jars = new ArrayList<>();
exclusions = new ArrayList<>(); exclusions = new ArrayList<>();
exclusions.add("META-INF"); exclusions.add("META-INF");
exclusions.add("module-info.class");
exclusions.add("LICENSE");
exclusions.add("LICENSE.txt");
} }
@Override @Override

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver.binary.tasks; package pro.gravit.launchserver.binary.tasks;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;

View file

@ -1,18 +1,6 @@
package ru.gravit.launchserver.binary.tasks; package pro.gravit.launchserver.binary.tasks;
import javassist.CannotCompileException; import static pro.gravit.utils.helper.IOHelper.newZipEntry;
import javassist.NotFoundException;
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.binary.BuildContext;
import ru.gravit.launchserver.binary.JAConfigurator;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -28,7 +16,19 @@
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import static ru.gravit.utils.helper.IOHelper.newZipEntry; import javassist.CannotCompileException;
import javassist.NotFoundException;
import pro.gravit.launcher.AutogenConfig;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.LauncherConfig;
import pro.gravit.launcher.serialize.HOutput;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.asm.ClassMetadataReader;
import pro.gravit.launchserver.binary.BuildContext;
import pro.gravit.launchserver.binary.JAConfigurator;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
public class MainBuildTask implements LauncherBuildTask { public class MainBuildTask implements LauncherBuildTask {
private final LaunchServer server; private final LaunchServer server;

View file

@ -1,9 +1,4 @@
package ru.gravit.launchserver.binary.tasks; package pro.gravit.launchserver.binary.tasks;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.UnpackHelper;
import java.io.IOException; import java.io.IOException;
import java.nio.file.FileVisitResult; import java.nio.file.FileVisitResult;
@ -13,6 +8,11 @@
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.util.List; import java.util.List;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.UnpackHelper;
public class PrepareBuildTask implements LauncherBuildTask { public class PrepareBuildTask implements LauncherBuildTask {
private final LaunchServer server; private final LaunchServer server;
private final Path result; private final Path result;

View file

@ -1,15 +1,15 @@
package ru.gravit.launchserver.binary.tasks; package pro.gravit.launchserver.binary.tasks;
import java.io.IOException;
import java.nio.file.Path;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import proguard.Configuration; import proguard.Configuration;
import proguard.ConfigurationParser; import proguard.ConfigurationParser;
import proguard.ParseException; import proguard.ParseException;
import proguard.ProGuard; import proguard.ProGuard;
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 class ProGuardBuildTask implements LauncherBuildTask { public class ProGuardBuildTask implements LauncherBuildTask {
private final LaunchServer server; private final LaunchServer server;

View file

@ -1,11 +1,4 @@
package ru.gravit.launchserver.binary.tasks; package pro.gravit.launchserver.binary.tasks;
import me.itzsomebody.radon.Radon;
import me.itzsomebody.radon.SessionInfo;
import me.itzsomebody.radon.config.ConfigurationParser;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.UnpackHelper;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -14,6 +7,13 @@
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import me.itzsomebody.radon.Radon;
import me.itzsomebody.radon.SessionInfo;
import me.itzsomebody.radon.config.ConfigurationParser;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.UnpackHelper;
public class RadonBuildTask implements LauncherBuildTask { public class RadonBuildTask implements LauncherBuildTask {
private final LaunchServer srv; private final LaunchServer srv;
public final Path config; public final Path config;
@ -35,7 +35,7 @@ public Path process(Path inputFile) throws IOException {
Files.deleteIfExists(outputFile); Files.deleteIfExists(outputFile);
if (srv.config.enabledRadon) { if (srv.config.enabledRadon) {
if (!IOHelper.isFile(config)) if (!IOHelper.isFile(config))
UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/radon.cfg"), config); UnpackHelper.unpack(IOHelper.getResourceURL("pro/gravit/launchserver/defaults/radon.cfg"), config);
ConfigurationParser p = new ConfigurationParser(IOHelper.newInput(config)); ConfigurationParser p = new ConfigurationParser(IOHelper.newInput(config));
SessionInfo info = p.createSessionFromConfig(); SessionInfo info = p.createSessionFromConfig();
info.setInput(inputFile.toFile()); info.setInput(inputFile.toFile());

View file

@ -1,4 +1,4 @@
package ru.gravit.launchserver.binary.tasks; package pro.gravit.launchserver.binary.tasks;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -0,0 +1,14 @@
package pro.gravit.launchserver.command;
import pro.gravit.launchserver.LaunchServer;
public abstract class Command extends pro.gravit.utils.command.Command {
protected final LaunchServer server;
protected Command(LaunchServer server) {
this.server = server;
}
}

View file

@ -1,14 +1,14 @@
package ru.gravit.launchserver.command.auth; package pro.gravit.launchserver.command.auth;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthProviderPair;
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; import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.auth.provider.AuthProvider;
import pro.gravit.launchserver.auth.provider.AuthProviderResult;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public final class AuthCommand extends Command { public final class AuthCommand extends Command {
public AuthCommand(LaunchServer server) { public AuthCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.auth; package pro.gravit.launchserver.command.auth;
import ru.gravit.launcher.HWID;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import java.util.List; import java.util.List;
import pro.gravit.launcher.HWID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class BanCommand extends Command { public class BanCommand extends Command {
public BanCommand(LaunchServer server) { public BanCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,12 +1,12 @@
package ru.gravit.launchserver.command.auth; package pro.gravit.launchserver.command.auth;
import ru.gravit.launcher.HWID;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.LogHelper;
import java.util.List; import java.util.List;
import pro.gravit.launcher.HWID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public class GetHWIDCommand extends Command { public class GetHWIDCommand extends Command {
public GetHWIDCommand(LaunchServer server) { public GetHWIDCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,14 +1,14 @@
package ru.gravit.launchserver.command.auth; package pro.gravit.launchserver.command.auth;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthProviderPair;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.command.CommandException;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.LogHelper;
public final class UUIDToUsernameCommand extends Command { public final class UUIDToUsernameCommand extends Command {
public UUIDToUsernameCommand(LaunchServer server) { public UUIDToUsernameCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.auth; package pro.gravit.launchserver.command.auth;
import ru.gravit.launcher.HWID;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import java.util.List; import java.util.List;
import pro.gravit.launcher.HWID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class UnbanCommand extends Command { public class UnbanCommand extends Command {
public UnbanCommand(LaunchServer server) { public UnbanCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,14 +1,14 @@
package ru.gravit.launchserver.command.auth; package pro.gravit.launchserver.command.auth;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthProviderPair;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.command.CommandException;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.LogHelper;
public final class UsernameToUUIDCommand extends Command { public final class UsernameToUUIDCommand extends Command {
public UsernameToUUIDCommand(LaunchServer server) { public UsernameToUUIDCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.command.basic; package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
public final class BuildCommand extends Command { public final class BuildCommand extends Command {
public BuildCommand(LaunchServer server) { public BuildCommand(LaunchServer server) {

View file

@ -1,8 +1,8 @@
package ru.gravit.launchserver.command.basic; package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
public final class LogConnectionsCommand extends Command { public final class LogConnectionsCommand extends Command {
public LogConnectionsCommand(LaunchServer server) { public LogConnectionsCommand(LaunchServer server) {

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.basic; package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class ProguardCleanCommand extends Command { public class ProguardCleanCommand extends Command {
public ProguardCleanCommand(LaunchServer server) { public ProguardCleanCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.command.basic; package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
public final class RebindCommand extends Command { public final class RebindCommand extends Command {
public RebindCommand(LaunchServer server) { public RebindCommand(LaunchServer server) {

View file

@ -1,10 +1,10 @@
package ru.gravit.launchserver.command.basic; package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import java.io.IOException; import java.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class RegenProguardDictCommand extends Command { public class RegenProguardDictCommand extends Command {
public RegenProguardDictCommand(LaunchServer server) { public RegenProguardDictCommand(LaunchServer server) {

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.basic; package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class RemoveMappingsProguardCommand extends Command { public class RemoveMappingsProguardCommand extends Command {
public RemoveMappingsProguardCommand(LaunchServer server) { public RemoveMappingsProguardCommand(LaunchServer server) {

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.command.basic; package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
public final class RestartCommand extends Command { public final class RestartCommand extends Command {
public RestartCommand(LaunchServer server) { public RestartCommand(LaunchServer server) {

View file

@ -1,8 +1,8 @@
package ru.gravit.launchserver.command.basic; package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.JVMHelper;
public final class StopCommand extends Command { public final class StopCommand extends Command {
public StopCommand(LaunchServer server) { public StopCommand(LaunchServer server) {

View file

@ -1,11 +1,10 @@
package ru.gravit.launchserver.command.basic; package pro.gravit.launchserver.command.basic;
import ru.gravit.launcher.events.PingEvent; import pro.gravit.launcher.events.PingEvent;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
import ru.gravit.launchserver.websocket.NettyServerSocketHandler; import pro.gravit.launchserver.websocket.NettyServerSocketHandler;
import ru.gravit.launchserver.websocket.WebSocketFrameHandler; import pro.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.CommonHelper;
public class TestCommand extends Command { public class TestCommand extends Command {
public TestCommand(LaunchServer server) { public TestCommand(LaunchServer server) {
@ -36,7 +35,7 @@ public void invoke(String... args) throws Exception {
handler.close(); handler.close();
} }
if (args[0].equals("eventAll")) { if (args[0].equals("eventAll")) {
WebSocketFrameHandler.service.sendObjectAll(new PingEvent()); handler.nettyServer.frameHandler.service.sendObjectAll(new PingEvent());
} }
} }
} }

View file

@ -1,9 +1,9 @@
package ru.gravit.launchserver.command.basic; package pro.gravit.launchserver.command.basic;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
import ru.gravit.utils.Version; import pro.gravit.utils.Version;
import ru.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
public final class VersionCommand extends Command { public final class VersionCommand extends Command {
public VersionCommand(LaunchServer server) { public VersionCommand(LaunchServer server) {

View file

@ -0,0 +1,33 @@
package pro.gravit.launchserver.command.dao;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.dao.User;
import pro.gravit.utils.helper.LogHelper;
public class GetAllUsersCommand extends Command {
public GetAllUsersCommand(LaunchServer server) {
super(server);
}
@Override
public String getArgsDescription() {
return "";
}
@Override
public String getUsageDescription() {
return "get all users information";
}
@Override
public void invoke(String... args) throws Exception {
int count = 0;
for(User user : server.userService.findAllUsers())
{
LogHelper.subInfo("[%s] UUID: %s", user.username, user.uuid.toString());
count++;
}
LogHelper.info("Print %d users", count);
}
}

View file

@ -0,0 +1,39 @@
package pro.gravit.launchserver.command.dao;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.dao.User;
import pro.gravit.launchserver.dao.UserHWID;
import pro.gravit.utils.helper.LogHelper;
public class GetUserCommand extends Command {
public GetUserCommand(LaunchServer server) {
super(server);
}
@Override
public String getArgsDescription() {
return "[username]";
}
@Override
public String getUsageDescription() {
return "get user information";
}
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 1);
User user = server.userService.findUserByUsername(args[0]);
if(user == null)
{
LogHelper.error("User %s not found", args[0]);
return;
}
LogHelper.info("[%s] UUID: %s", user.username, user.uuid.toString());
for(UserHWID hwid : user.hwids)
{
LogHelper.info("[%s] HWID: memory: %d | serial %s | hwdiskserial: %s | processorID %s | macAddr %s", user.username, hwid.totalMemory, hwid.serialNumber, hwid.HWDiskSerial, hwid.processorID, hwid.macAddr);
}
}
}

View file

@ -0,0 +1,35 @@
package pro.gravit.launchserver.command.dao;
import java.util.UUID;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.dao.User;
import pro.gravit.utils.helper.LogHelper;
public class RegisterCommand extends Command {
public RegisterCommand(LaunchServer server) {
super(server);
}
@Override
public String getArgsDescription() {
return "[login] [password]";
}
@Override
public String getUsageDescription() {
return "Register new user";
}
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 2);
User user = new User();
user.username = args[0];
user.setPassword(args[1]);
user.uuid = UUID.randomUUID();
server.userService.saveUser(user);
LogHelper.info("User %s registered. UUID: %s", user.username, user.uuid.toString());
}
}

View file

@ -0,0 +1,37 @@
package pro.gravit.launchserver.command.dao;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.dao.User;
import pro.gravit.utils.helper.LogHelper;
public class SetUserPasswordCommand extends Command {
public SetUserPasswordCommand(LaunchServer server) {
super(server);
}
@Override
public String getArgsDescription() {
return "[username] [new password]";
}
@Override
public String getUsageDescription() {
return "Set user password";
}
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 2);
User user = server.userService.findUserByUsername(args[0]);
if(user == null)
{
LogHelper.error("User %s not found", args[1]);
return;
}
user.setPassword(args[1]);
server.userService.updateUser(user);
LogHelper.info("[%s] UUID: %s | New Password: %s", user.username, user.uuid.toString(), args[1]);
}
}

View file

@ -1,12 +1,4 @@
package ru.gravit.launchserver.command.dump; package pro.gravit.launchserver.command.dump;
import ru.gravit.launcher.Launcher;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthProviderPair;
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;
import java.io.Reader; import java.io.Reader;
import java.io.Writer; import java.io.Writer;
@ -14,6 +6,14 @@
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import pro.gravit.launcher.Launcher;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.auth.AuthProviderPair;
import pro.gravit.launchserver.auth.handler.CachedAuthHandler;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class DumpEntryCacheCommand extends Command { public class DumpEntryCacheCommand extends Command {
public DumpEntryCacheCommand(LaunchServer server) { public DumpEntryCacheCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,12 +1,4 @@
package ru.gravit.launchserver.command.dump; package pro.gravit.launchserver.command.dump;
import com.google.gson.reflect.TypeToken;
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.Reader;
import java.io.Writer; import java.io.Writer;
@ -15,6 +7,15 @@
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import com.google.gson.reflect.TypeToken;
import pro.gravit.launcher.Launcher;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.socket.Client;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class DumpSessionsCommand extends Command { public class DumpSessionsCommand extends Command {
public DumpSessionsCommand(LaunchServer server) { public DumpSessionsCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,25 +1,58 @@
package ru.gravit.launchserver.command.handler; package pro.gravit.launchserver.command.handler;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.auth.*; import pro.gravit.launchserver.command.auth.AuthCommand;
import ru.gravit.launchserver.command.basic.*; import pro.gravit.launchserver.command.auth.BanCommand;
import ru.gravit.launchserver.command.dump.DumpEntryCacheCommand; import pro.gravit.launchserver.command.auth.GetHWIDCommand;
import ru.gravit.launchserver.command.dump.DumpSessionsCommand; import pro.gravit.launchserver.command.auth.UUIDToUsernameCommand;
import ru.gravit.launchserver.command.hash.*; import pro.gravit.launchserver.command.auth.UnbanCommand;
import ru.gravit.launchserver.command.install.CheckInstallCommand; import pro.gravit.launchserver.command.auth.UsernameToUUIDCommand;
import ru.gravit.launchserver.command.install.MultiCommand; import pro.gravit.launchserver.command.basic.BuildCommand;
import ru.gravit.launchserver.command.modules.LoadModuleCommand; import pro.gravit.launchserver.command.basic.LogConnectionsCommand;
import ru.gravit.launchserver.command.modules.ModulesCommand; import pro.gravit.launchserver.command.basic.ProguardCleanCommand;
import ru.gravit.launchserver.command.service.*; import pro.gravit.launchserver.command.basic.RebindCommand;
import ru.gravit.utils.command.BaseCommandCategory; import pro.gravit.launchserver.command.basic.RegenProguardDictCommand;
import ru.gravit.utils.command.basic.ClearCommand; import pro.gravit.launchserver.command.basic.RemoveMappingsProguardCommand;
import ru.gravit.utils.command.basic.DebugCommand; import pro.gravit.launchserver.command.basic.RestartCommand;
import ru.gravit.utils.command.basic.GCCommand; import pro.gravit.launchserver.command.basic.StopCommand;
import ru.gravit.utils.command.basic.HelpCommand; import pro.gravit.launchserver.command.basic.TestCommand;
import pro.gravit.launchserver.command.basic.VersionCommand;
import pro.gravit.launchserver.command.dao.GetAllUsersCommand;
import pro.gravit.launchserver.command.dao.GetUserCommand;
import pro.gravit.launchserver.command.dao.RegisterCommand;
import pro.gravit.launchserver.command.dao.SetUserPasswordCommand;
import pro.gravit.launchserver.command.dump.DumpEntryCacheCommand;
import pro.gravit.launchserver.command.dump.DumpSessionsCommand;
import pro.gravit.launchserver.command.hash.DownloadAssetCommand;
import pro.gravit.launchserver.command.hash.DownloadClientCommand;
import pro.gravit.launchserver.command.hash.IndexAssetCommand;
import pro.gravit.launchserver.command.hash.SyncBinariesCommand;
import pro.gravit.launchserver.command.hash.SyncProfilesCommand;
import pro.gravit.launchserver.command.hash.SyncUpdatesCommand;
import pro.gravit.launchserver.command.hash.UnindexAssetCommand;
import pro.gravit.launchserver.command.install.CheckInstallCommand;
import pro.gravit.launchserver.command.install.MultiCommand;
import pro.gravit.launchserver.command.modules.LoadModuleCommand;
import pro.gravit.launchserver.command.modules.ModulesCommand;
import pro.gravit.launchserver.command.service.ComponentCommand;
import pro.gravit.launchserver.command.service.ConfigCommand;
import pro.gravit.launchserver.command.service.ConfigHelpCommand;
import pro.gravit.launchserver.command.service.ConfigListCommand;
import pro.gravit.launchserver.command.service.GetModulusCommand;
import pro.gravit.launchserver.command.service.GetPermissionsCommand;
import pro.gravit.launchserver.command.service.GivePermissionsCommand;
import pro.gravit.launchserver.command.service.ReloadAllCommand;
import pro.gravit.launchserver.command.service.ReloadCommand;
import pro.gravit.launchserver.command.service.ReloadListCommand;
import pro.gravit.launchserver.command.service.ServerStatusCommand;
import pro.gravit.utils.command.BaseCommandCategory;
import pro.gravit.utils.command.basic.ClearCommand;
import pro.gravit.utils.command.basic.DebugCommand;
import pro.gravit.utils.command.basic.GCCommand;
import pro.gravit.utils.command.basic.HelpCommand;
public abstract class CommandHandler extends ru.gravit.utils.command.CommandHandler { public abstract class CommandHandler extends pro.gravit.utils.command.CommandHandler {
public static void registerCommands(ru.gravit.utils.command.CommandHandler handler) { public static void registerCommands(pro.gravit.utils.command.CommandHandler handler, LaunchServer server) {
LaunchServer server = LaunchServer.server;
BaseCommandCategory basic = new BaseCommandCategory(); BaseCommandCategory basic = new BaseCommandCategory();
// Register basic commands // Register basic commands
basic.registerCommand("help", new HelpCommand(handler)); basic.registerCommand("help", new HelpCommand(handler));
@ -53,6 +86,15 @@ public static void registerCommands(ru.gravit.utils.command.CommandHandler handl
Category updatesCategory = new Category(updates, "updates", "Update and Sync Management"); Category updatesCategory = new Category(updates, "updates", "Update and Sync Management");
handler.registerCategory(updatesCategory); handler.registerCategory(updatesCategory);
//Register dao commands
BaseCommandCategory dao = new BaseCommandCategory();
dao.registerCommand("register", new RegisterCommand(server));
dao.registerCommand("setUserPassword", new SetUserPasswordCommand(server));
dao.registerCommand("getUser", new GetUserCommand(server));
dao.registerCommand("getAllUsers", new GetAllUsersCommand(server));
Category daoCategory = new Category(dao, "DAO", "Data Management");
handler.registerCategory(daoCategory);
// Register auth commands // Register auth commands
BaseCommandCategory auth = new BaseCommandCategory(); BaseCommandCategory auth = new BaseCommandCategory();
auth.registerCommand("auth", new AuthCommand(server)); auth.registerCommand("auth", new AuthCommand(server));

View file

@ -1,16 +1,16 @@
package ru.gravit.launchserver.command.hash; package pro.gravit.launchserver.command.hash;
import ru.gravit.launcher.profiles.ClientProfile.Version;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.HttpDownloader;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Collections; import java.util.Collections;
import pro.gravit.launcher.profiles.ClientProfile.Version;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.HttpDownloader;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class DownloadAssetCommand extends Command { public final class DownloadAssetCommand extends Command {
public DownloadAssetCommand(LaunchServer server) { public DownloadAssetCommand(LaunchServer server) {

View file

@ -1,14 +1,4 @@
package ru.gravit.launchserver.command.hash; package pro.gravit.launchserver.command.hash;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.profiles.ClientProfile.Version;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.HttpDownloader;
import ru.gravit.utils.command.CommandException;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -17,6 +7,16 @@
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Collections; import java.util.Collections;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.launcher.profiles.ClientProfile.Version;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.HttpDownloader;
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class DownloadClientCommand extends Command { public final class DownloadClientCommand extends Command {
public DownloadClientCommand(LaunchServer server) { public DownloadClientCommand(LaunchServer server) {
@ -51,7 +51,7 @@ public void invoke(String... args) throws IOException, CommandException {
// Create profile file // Create profile file
LogHelper.subInfo("Creaing profile file: '%s'", dirName); LogHelper.subInfo("Creaing profile file: '%s'", dirName);
ClientProfile client; ClientProfile client;
String profilePath = String.format("ru/gravit/launchserver/defaults/profile%s.cfg", version.name); String profilePath = String.format("pro/gravit/launchserver/defaults/profile%s.cfg", version.name);
try (BufferedReader reader = IOHelper.newReader(IOHelper.getResourceURL(profilePath))) { try (BufferedReader reader = IOHelper.newReader(IOHelper.getResourceURL(profilePath))) {
client = Launcher.gsonManager.configGson.fromJson(reader, ClientProfile.class); client = Launcher.gsonManager.configGson.fromJson(reader, ClientProfile.class);
} }

View file

@ -1,14 +1,4 @@
package ru.gravit.launchserver.command.hash; package pro.gravit.launchserver.command.hash;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.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.BufferedWriter;
import java.io.IOException; import java.io.IOException;
@ -19,6 +9,17 @@
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collections; import java.util.Collections;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
import pro.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
public final class IndexAssetCommand extends Command { public final class IndexAssetCommand extends Command {
private static Gson gson = new Gson(); private static Gson gson = new Gson();

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.hash; package pro.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.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public final class SyncBinariesCommand extends Command { public final class SyncBinariesCommand extends Command {
public SyncBinariesCommand(LaunchServer server) { public SyncBinariesCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.hash; package pro.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.io.IOException;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public final class SyncProfilesCommand extends Command { public final class SyncProfilesCommand extends Command {
public SyncProfilesCommand(LaunchServer server) { public SyncProfilesCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,14 +1,14 @@
package ru.gravit.launchserver.command.hash; package pro.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.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public final class SyncUpdatesCommand extends Command { public final class SyncUpdatesCommand extends Command {
public SyncUpdatesCommand(LaunchServer server) { public SyncUpdatesCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,13 +1,4 @@
package ru.gravit.launchserver.command.hash; package pro.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.utils.command.CommandException;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.nio.file.Files; import java.nio.file.Files;
@ -15,6 +6,16 @@
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.command.CommandException;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public final class UnindexAssetCommand extends Command { public final class UnindexAssetCommand extends Command {
private static JsonParser parser = new JsonParser(); private static JsonParser parser = new JsonParser();

View file

@ -1,9 +1,9 @@
package ru.gravit.launchserver.command.install; package pro.gravit.launchserver.command.install;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.JVMHelper;
import ru.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
public class CheckInstallCommand extends Command { public class CheckInstallCommand extends Command {
public CheckInstallCommand(LaunchServer server) { public CheckInstallCommand(LaunchServer server) {

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.command.install; package pro.gravit.launchserver.command.install;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
public class MultiCommand extends Command { public class MultiCommand extends Command {
public MultiCommand(LaunchServer server) { public MultiCommand(LaunchServer server) {

View file

@ -1,11 +1,11 @@
package ru.gravit.launchserver.command.modules; package pro.gravit.launchserver.command.modules;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import java.net.URI; import java.net.URI;
import java.nio.file.Paths; import java.nio.file.Paths;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
public class LoadModuleCommand extends Command { public class LoadModuleCommand extends Command {
public LoadModuleCommand(LaunchServer server) { public LoadModuleCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.command.modules; package pro.gravit.launchserver.command.modules;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
public class ModulesCommand extends Command { public class ModulesCommand extends Command {
public ModulesCommand(LaunchServer server) { public ModulesCommand(LaunchServer server) {

View file

@ -1,16 +1,16 @@
package ru.gravit.launchserver.command.service; package pro.gravit.launchserver.command.service;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.NeedGarbageCollection;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.launchserver.components.Component;
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.Reader; import java.io.Reader;
import java.nio.file.Paths; import java.nio.file.Paths;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.NeedGarbageCollection;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.launchserver.components.Component;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
public class ComponentCommand extends Command { public class ComponentCommand extends Command {
public ComponentCommand(LaunchServer server) { public ComponentCommand(LaunchServer server) {
super(server); super(server);

View file

@ -1,8 +1,8 @@
package ru.gravit.launchserver.command.service; package pro.gravit.launchserver.command.service;
import ru.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import pro.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
public class ConfigCommand extends Command { public class ConfigCommand extends Command {
public ConfigCommand(LaunchServer server) { public ConfigCommand(LaunchServer server) {

Some files were not shown because too many files have changed in this diff Show more