mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
Исправления формата ответа и реализация в ServerWrapper
This commit is contained in:
parent
20cb561b3e
commit
f7bd4a5941
3 changed files with 15 additions and 13 deletions
|
@ -91,5 +91,6 @@ public void reply() throws Exception {
|
|||
}
|
||||
debug("ServerAuth: '%s' -> '%s', '%s'", login, result.username, result.accessToken);
|
||||
clientData.isAuth = true;
|
||||
writeNoError(output);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ServerAuthRequest.Result> {
|
||||
public final class AuthServerRequest extends Request<Boolean> {
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<ClientProfile> 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)
|
||||
|
|
Loading…
Reference in a new issue