Исправление title при AuthServerRequest

This commit is contained in:
Gravit 2018-09-27 05:00:46 +07:00
parent f7bd4a5941
commit dab963a2eb
3 changed files with 13 additions and 3 deletions

View file

@ -52,7 +52,6 @@ public void reply() throws Exception {
requestError("ServerPassword decryption error"); requestError("ServerPassword decryption error");
return; return;
} }
if(client.length() == 0) requestError("Request error. You is cheater?");
// Authenticate // Authenticate
debug("ServerLogin: '%s', Password: '%s'", login, echo(password.length())); debug("ServerLogin: '%s', Password: '%s'", login, echo(password.length()));
AuthProviderResult result; AuthProviderResult result;

View file

@ -31,6 +31,7 @@ private Result(PlayerProfile pp, String accessToken) {
private final byte[] encryptedPassword; private final byte[] encryptedPassword;
private final int auth_id; private final int auth_id;
private final String title;
@LauncherAPI @LauncherAPI
public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword) { public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword) {
@ -38,6 +39,7 @@ public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPa
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 = 0;
title = "";
} }
@LauncherAPI @LauncherAPI
public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword, int auth_id) { public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword, int auth_id) {
@ -45,6 +47,15 @@ public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPa
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();
this.auth_id = auth_id; this.auth_id = auth_id;
title = "";
}
@LauncherAPI
public AuthServerRequest(LauncherConfig config, String login, byte[] encryptedPassword, int auth_id,String title) {
super(config);
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
this.encryptedPassword = encryptedPassword.clone();
this.auth_id = auth_id;
this.title = title;
} }
@LauncherAPI @LauncherAPI
@ -64,7 +75,7 @@ public Integer getType() {
@Override @Override
protected Boolean requestDo(HInput input, HOutput output) throws IOException { protected Boolean requestDo(HInput input, HOutput output) throws IOException {
output.writeString(login, SerializeLimits.MAX_LOGIN); output.writeString(login, SerializeLimits.MAX_LOGIN);
output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT); output.writeString(title, SerializeLimits.MAX_CLIENT);
output.writeInt(auth_id); output.writeInt(auth_id);
output.writeByteArray(encryptedPassword, SecurityHelper.CRYPTO_MAX_LENGTH); output.writeByteArray(encryptedPassword, SecurityHelper.CRYPTO_MAX_LENGTH);
output.flush(); output.flush();

View file

@ -44,7 +44,7 @@ public static void main(String[] args) throws Throwable {
config = new Config(TextConfigReader.read(reader, true)); 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); 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(); Boolean auth = new AuthServerRequest(cfg,config.login,SecurityHelper.newRSAEncryptCipher(cfg.publicKey).doFinal(IOHelper.encode(config.password)),0,config.title).request();
ProfilesRequest.Result result = new ProfilesRequest(cfg).request(); ProfilesRequest.Result result = new ProfilesRequest(cfg).request();
Launcher.setConfig(cfg); Launcher.setConfig(cfg);