mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] Реализация Request части и фикс ServerWrapper
This commit is contained in:
parent
5f252682f3
commit
0ce407f1c3
3 changed files with 14 additions and 22 deletions
|
@ -20,7 +20,7 @@ public final class AuthRequest extends Request<AuthRequestEvent> implements Requ
|
||||||
private final String login;
|
private final String login;
|
||||||
|
|
||||||
private final byte[] encryptedPassword;
|
private final byte[] encryptedPassword;
|
||||||
private final int auth_id;
|
private final String auth_id;
|
||||||
private final HWID hwid;
|
private final HWID hwid;
|
||||||
private final String customText;
|
private final String customText;
|
||||||
|
|
||||||
|
@ -31,20 +31,11 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw
|
||||||
this.encryptedPassword = password.clone();
|
this.encryptedPassword = password.clone();
|
||||||
this.hwid = hwid;
|
this.hwid = hwid;
|
||||||
customText = "";
|
customText = "";
|
||||||
auth_id = 0;
|
auth_id = "";
|
||||||
}
|
|
||||||
@LauncherAPI
|
|
||||||
public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, String customText) {
|
|
||||||
super(config);
|
|
||||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
|
||||||
this.encryptedPassword = password.clone();
|
|
||||||
this.hwid = hwid;
|
|
||||||
this.customText = customText;
|
|
||||||
auth_id = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, int auth_id) {
|
public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, String auth_id) {
|
||||||
super(config);
|
super(config);
|
||||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||||
this.encryptedPassword = password.clone();
|
this.encryptedPassword = password.clone();
|
||||||
|
@ -53,7 +44,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw
|
||||||
customText = "";
|
customText = "";
|
||||||
}
|
}
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, String customText, int auth_id) {
|
public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, String customText, String auth_id) {
|
||||||
super(config);
|
super(config);
|
||||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||||
this.encryptedPassword = password.clone();
|
this.encryptedPassword = password.clone();
|
||||||
|
@ -72,7 +63,7 @@ public AuthRequestEvent requestWebSockets() throws Exception
|
||||||
return (AuthRequestEvent) LegacyRequestBridge.sendRequest(this);
|
return (AuthRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||||
}
|
}
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public AuthRequest(String login, byte[] password, HWID hwid, int auth_id) {
|
public AuthRequest(String login, byte[] password, HWID hwid, String auth_id) {
|
||||||
this(null, login, password, hwid, auth_id);
|
this(null, login, password, hwid, auth_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +95,7 @@ protected AuthRequestEvent requestDo(HInput input, HOutput output) throws IOExce
|
||||||
output.writeBoolean(Launcher.profile != null);
|
output.writeBoolean(Launcher.profile != null);
|
||||||
if (Launcher.profile != null)
|
if (Launcher.profile != null)
|
||||||
output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT);
|
output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT);
|
||||||
output.writeInt(auth_id);
|
output.writeString(auth_id, SerializeLimits.MAX_QUEUE_SIZE);
|
||||||
output.writeString(hwid.getSerializeString(), 0);
|
output.writeString(hwid.getSerializeString(), 0);
|
||||||
//output.writeLong(0);
|
//output.writeLong(0);
|
||||||
//output.writeLong(0);
|
//output.writeLong(0);
|
||||||
|
|
|
@ -30,7 +30,7 @@ private Result(PlayerProfile pp, String accessToken) {
|
||||||
private final String login;
|
private final String login;
|
||||||
|
|
||||||
private final byte[] encryptedPassword;
|
private final byte[] encryptedPassword;
|
||||||
private final int auth_id;
|
private final String auth_id;
|
||||||
private final String title;
|
private final String title;
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
@ -38,12 +38,12 @@ public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPa
|
||||||
super(config);
|
super(config);
|
||||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||||
this.encryptedPassword = encryptedPassword.clone();
|
this.encryptedPassword = encryptedPassword.clone();
|
||||||
auth_id = 0;
|
auth_id = "";
|
||||||
title = "";
|
title = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword, int auth_id) {
|
public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword, String auth_id) {
|
||||||
super(config);
|
super(config);
|
||||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||||
this.encryptedPassword = encryptedPassword.clone();
|
this.encryptedPassword = encryptedPassword.clone();
|
||||||
|
@ -52,7 +52,7 @@ public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPa
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword, int auth_id, String title) {
|
public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword, String auth_id, String title) {
|
||||||
super(config);
|
super(config);
|
||||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||||
this.encryptedPassword = encryptedPassword.clone();
|
this.encryptedPassword = encryptedPassword.clone();
|
||||||
|
@ -66,7 +66,7 @@ public AuthServerRequest(String login, byte[] encryptedPassword) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public AuthServerRequest(String login, byte[] encryptedPassword, int auth_id) {
|
public AuthServerRequest(String login, byte[] encryptedPassword, String auth_id) {
|
||||||
this(null, login, encryptedPassword, auth_id);
|
this(null, login, encryptedPassword, auth_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public Integer getLegacyType() {
|
||||||
protected ClientPermissions requestDo(HInput input, HOutput output) throws IOException {
|
protected ClientPermissions requestDo(HInput input, HOutput output) throws IOException {
|
||||||
output.writeString(login, SerializeLimits.MAX_LOGIN);
|
output.writeString(login, SerializeLimits.MAX_LOGIN);
|
||||||
output.writeString(title, SerializeLimits.MAX_CLIENT);
|
output.writeString(title, SerializeLimits.MAX_CLIENT);
|
||||||
output.writeInt(auth_id);
|
output.writeString(auth_id, SerializeLimits.MAX_QUEUE_SIZE);
|
||||||
output.writeByteArray(encryptedPassword, SecurityHelper.CRYPTO_MAX_LENGTH);
|
output.writeByteArray(encryptedPassword, SecurityHelper.CRYPTO_MAX_LENGTH);
|
||||||
output.flush();
|
output.flush();
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class ServerWrapper {
|
||||||
public static boolean auth(ServerWrapper wrapper) {
|
public static boolean auth(ServerWrapper wrapper) {
|
||||||
try {
|
try {
|
||||||
LauncherConfig cfg = Launcher.getConfig();
|
LauncherConfig cfg = Launcher.getConfig();
|
||||||
ServerWrapper.permissions = new AuthServerRequest(cfg, config.login, SecurityHelper.newRSAEncryptCipher(cfg.publicKey).doFinal(IOHelper.encode(config.password)), 0, config.title).request();
|
ServerWrapper.permissions = new AuthServerRequest(cfg, config.login, SecurityHelper.newRSAEncryptCipher(cfg.publicKey).doFinal(IOHelper.encode(config.password)), config.auth_id, config.title).request();
|
||||||
ProfilesRequestEvent result = new ProfilesRequest(cfg).request();
|
ProfilesRequestEvent result = new ProfilesRequest(cfg).request();
|
||||||
for (ClientProfile p : result.profiles) {
|
for (ClientProfile p : result.profiles) {
|
||||||
LogHelper.debug("Get profile: %s", p.getTitle());
|
LogHelper.debug("Get profile: %s", p.getTitle());
|
||||||
|
@ -218,6 +218,7 @@ public static final class Config {
|
||||||
public String login;
|
public String login;
|
||||||
public String[] args;
|
public String[] args;
|
||||||
public String password;
|
public String password;
|
||||||
|
public String auth_id = "";
|
||||||
public LauncherConfig.LauncherEnvironment env;
|
public LauncherConfig.LauncherEnvironment env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue