Skip to content

Commit

Permalink
Require client token when authenticating with an access token.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveice10 authored and Steveice10 committed Jun 11, 2018
1 parent 34c3504 commit 08f1ca0
Showing 1 changed file with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public class MinecraftProtocol extends PacketProtocol {
private AESEncryption encrypt;

private GameProfile profile;
private String clientToken = "";
private String accessToken = "";

@SuppressWarnings("unused")
Expand All @@ -171,16 +172,24 @@ public MinecraftProtocol(String username) {
}

public MinecraftProtocol(String username, String password) throws RequestException {
this(username, password, false);
this(username, password, Proxy.NO_PROXY);
}

public MinecraftProtocol(String username, String using, boolean token) throws RequestException {
this(username, using, token, Proxy.NO_PROXY);
public MinecraftProtocol(String username, String clientToken, String accessToken) throws RequestException {
this(username, clientToken, accessToken, Proxy.NO_PROXY);
}

public MinecraftProtocol(String username, String using, boolean token, Proxy authProxy) throws RequestException {
public MinecraftProtocol(String username, String password, Proxy proxy) throws RequestException {
this(username, UUID.randomUUID().toString(), password, false, proxy);
}

public MinecraftProtocol(String username, String clientToken, String accessToken, Proxy proxy) throws RequestException {
this(username, clientToken, accessToken, true, proxy);
}

private MinecraftProtocol(String username, String clientToken, String using, boolean token, Proxy authProxy) throws RequestException {
this(SubProtocol.LOGIN);
String clientToken = UUID.randomUUID().toString();

AuthenticationService auth = new AuthenticationService(clientToken, authProxy);
auth.setUsername(username);
if(token) {
Expand All @@ -191,19 +200,25 @@ public MinecraftProtocol(String username, String using, boolean token, Proxy aut

auth.login();
this.profile = auth.getSelectedProfile();
this.clientToken = auth.getClientToken();
this.accessToken = auth.getAccessToken();
}

public MinecraftProtocol(GameProfile profile, String accessToken) {
public MinecraftProtocol(GameProfile profile, String clientToken, String accessToken) {
this(SubProtocol.LOGIN);
this.profile = profile;
this.clientToken = clientToken;
this.accessToken = accessToken;
}

public GameProfile getProfile() {
return this.profile;
}

public String getClientToken() {
return this.clientToken;
}

public String getAccessToken() {
return this.accessToken;
}
Expand Down

0 comments on commit 08f1ca0

Please sign in to comment.