Skip to content

Instantly share code, notes, and snippets.

@Dinnerbone
Last active October 14, 2019 03:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dinnerbone/5450488 to your computer and use it in GitHub Desktop.
Save Dinnerbone/5450488 to your computer and use it in GitHub Desktop.
package net.minecraft.launcher.authentication;
import net.minecraft.launcher.Http;
import java.io.IOException;
import java.net.Proxy;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class OldAuthentication {
private final Proxy proxy;
private Response lastSuccessfulResponse;
public OldAuthentication(Proxy proxy) {
this.proxy = proxy;
}
public Response login(String username, String password) throws IOException {
Map<String, Object> args = new HashMap<String, Object>();
args.put("user", username);
args.put("password", password);
args.put("version", 14);
String response = Http.performPost(new URL("https://login.minecraft.net"), args, proxy);
String[] split = response.split(":");
if (split.length == 5) {
lastSuccessfulResponse = new Response(null, split[3], split[2], split[4]);
return lastSuccessfulResponse;
} else {
return new Response(response, null, null, null);
}
}
public Response getLastSuccessfulResponse() {
return lastSuccessfulResponse;
}
public static class Response {
private final String errorMessage;
private final String sessionId;
private final String name;
private final String uuid;
public Response(String errorMessage, String sessionId, String name, String uuid) {
this.errorMessage = errorMessage;
this.sessionId = sessionId;
this.name = name;
this.uuid = uuid;
}
public String getErrorMessage() {
return errorMessage;
}
public String getSessionId() {
return sessionId;
}
public String getName() {
return name;
}
public String getUUID() {
return uuid;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment