diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java index ff86a97b..c7bc2183 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthServerResponse.java @@ -91,5 +91,6 @@ public void reply() throws Exception { } debug("ServerAuth: '%s' -> '%s', '%s'", login, result.username, result.accessToken); clientData.isAuth = true; + writeNoError(output); } } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/ServerAuthRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthServerRequest.java similarity index 76% rename from LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/ServerAuthRequest.java rename to LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthServerRequest.java index b9a0d8cc..83cb5faa 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/ServerAuthRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthServerRequest.java @@ -9,14 +9,12 @@ import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; -import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; -import ru.zaxar163.GuardBind; import java.io.IOException; -public final class ServerAuthRequest extends Request { +public final class AuthServerRequest extends Request { public static final class Result { @LauncherAPI public final PlayerProfile pp; @@ -35,14 +33,14 @@ private Result(PlayerProfile pp, String accessToken) { private final int auth_id; @LauncherAPI - public ServerAuthRequest(LauncherConfig config, String login, byte[] encryptedPassword) { + public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword) { super(config); this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); this.encryptedPassword = encryptedPassword.clone(); auth_id = 0; } @LauncherAPI - public ServerAuthRequest(LauncherConfig config, String login, byte[] encryptedPassword, int auth_id) { + public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword, int auth_id) { super(config); this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); this.encryptedPassword = encryptedPassword.clone(); @@ -50,11 +48,11 @@ public ServerAuthRequest(LauncherConfig config, String login, byte[] encryptedPa } @LauncherAPI - public ServerAuthRequest(String login, byte[] encryptedPassword) { + public AuthServerRequest(String login, byte[] encryptedPassword) { this(null, login, encryptedPassword); } @LauncherAPI - public ServerAuthRequest(String login, byte[] encryptedPassword, int auth_id) { + public AuthServerRequest(String login, byte[] encryptedPassword, int auth_id) { this(null, login, encryptedPassword,auth_id); } @@ -64,7 +62,7 @@ public Integer getType() { } @Override - protected Result requestDo(HInput input, HOutput output) throws IOException { + protected Boolean requestDo(HInput input, HOutput output) throws IOException { output.writeString(login, SerializeLimits.MAX_LOGIN); output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT); output.writeInt(auth_id); @@ -73,8 +71,6 @@ protected Result requestDo(HInput input, HOutput output) throws IOException { // Read UUID and access token readError(input); - PlayerProfile pp = new PlayerProfile(input); - String accessToken = input.readASCII(-SecurityHelper.TOKEN_STRING_LENGTH); - return new Result(pp, accessToken); + return true; } } diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java index a7beec02..046bddbc 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -13,6 +13,7 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherConfig; +import ru.gravit.launcher.request.auth.AuthServerRequest; import ru.gravit.launcher.serialize.config.ConfigObject; import ru.gravit.launcher.serialize.config.TextConfigReader; import ru.gravit.launcher.serialize.config.TextConfigWriter; @@ -24,10 +25,8 @@ import ru.gravit.utils.helper.LogHelper; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.request.update.ProfilesRequest; -import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.utils.helper.SecurityHelper; -import sun.security.rsa.RSAPublicKeyImpl; public class ServerWrapper { public static ModulesManager modulesManager; @@ -45,6 +44,8 @@ public static void main(String[] args) throws Throwable { config = new Config(TextConfigReader.read(reader, true)); } LauncherConfig cfg = new LauncherConfig(config.address, config.port, SecurityHelper.toPublicRSAKey(IOHelper.read(Paths.get("public.key"))),new HashMap<>(),config.projectname); + Boolean auth = new AuthServerRequest(cfg,config.login,SecurityHelper.newRSAEncryptCipher(cfg.publicKey).doFinal(IOHelper.encode(config.password))).request(); + ProfilesRequest.Result result = new ProfilesRequest(cfg).request(); Launcher.setConfig(cfg); for (SignedObjectHolder p : result.profiles) { @@ -100,11 +101,15 @@ public static final class Config extends ConfigObject { public boolean customClassLoader; public String classloader; public String mainclass; + public String login; + public String password; protected Config(BlockConfigEntry block) { super(block); title = block.getEntryValue("title",StringConfigEntry.class); address = block.getEntryValue("address",StringConfigEntry.class); projectname = block.getEntryValue("projectName",StringConfigEntry.class); + login = block.getEntryValue("login",StringConfigEntry.class); + password = block.getEntryValue("password",StringConfigEntry.class); port = block.getEntryValue("port", IntegerConfigEntry.class); customClassLoader = block.getEntryValue("customClassLoader", BooleanConfigEntry.class); if(customClassLoader)