[FIX] Реализация Request части и фикс ServerWrapper

This commit is contained in:
Gravit 2019-03-22 11:40:49 +07:00
parent 5f252682f3
commit 0ce407f1c3
3 changed files with 14 additions and 22 deletions

View file

@ -20,7 +20,7 @@ public final class AuthRequest extends Request<AuthRequestEvent> implements Requ
private final String login;
private final byte[] encryptedPassword;
private final int auth_id;
private final String auth_id;
private final HWID hwid;
private final String customText;
@ -31,20 +31,11 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw
this.encryptedPassword = password.clone();
this.hwid = hwid;
customText = "";
auth_id = 0;
}
@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;
auth_id = "";
}
@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);
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
this.encryptedPassword = password.clone();
@ -53,7 +44,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw
customText = "";
}
@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);
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
this.encryptedPassword = password.clone();
@ -72,7 +63,7 @@ public AuthRequestEvent requestWebSockets() throws Exception
return (AuthRequestEvent) LegacyRequestBridge.sendRequest(this);
}
@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);
}
@ -104,7 +95,7 @@ protected AuthRequestEvent requestDo(HInput input, HOutput output) throws IOExce
output.writeBoolean(Launcher.profile != null);
if (Launcher.profile != null)
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.writeLong(0);
//output.writeLong(0);

View file

@ -30,7 +30,7 @@ private Result(PlayerProfile pp, String accessToken) {
private final String login;
private final byte[] encryptedPassword;
private final int auth_id;
private final String auth_id;
private final String title;
@LauncherAPI
@ -38,12 +38,12 @@ public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPa
super(config);
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
this.encryptedPassword = encryptedPassword.clone();
auth_id = 0;
auth_id = "";
title = "";
}
@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);
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
this.encryptedPassword = encryptedPassword.clone();
@ -52,7 +52,7 @@ public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPa
}
@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);
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
this.encryptedPassword = encryptedPassword.clone();
@ -66,7 +66,7 @@ public AuthServerRequest(String login, byte[] encryptedPassword) {
}
@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);
}
@ -79,7 +79,7 @@ public Integer getLegacyType() {
protected ClientPermissions requestDo(HInput input, HOutput output) throws IOException {
output.writeString(login, SerializeLimits.MAX_LOGIN);
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.flush();

View file

@ -43,7 +43,7 @@ public class ServerWrapper {
public static boolean auth(ServerWrapper wrapper) {
try {
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();
for (ClientProfile p : result.profiles) {
LogHelper.debug("Get profile: %s", p.getTitle());
@ -218,6 +218,7 @@ public static final class Config {
public String login;
public String[] args;
public String password;
public String auth_id = "";
public LauncherConfig.LauncherEnvironment env;
}