small edits

This commit is contained in:
The Biggest skiddd 2023-06-20 14:15:57 +02:00
parent ebcf227887
commit 2755b1593b
91 changed files with 148 additions and 4177 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

23
pom.xml
View File

@ -19,33 +19,24 @@
<id>strezz</id>
<url>https://nexus.hexeption.dev/repository/strezz-central/</url>
</repository>
<repository>
<id>litarvan</id>
<url>https://litarvan.github.io/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>9.4.43.v20210629</version>
<groupId>fr.litarvan</groupId>
<artifactId>openauth</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.4.43.v20210629</version>
</dependency>
<dependency>
<groupId>net.minecraft</groupId>
<artifactId>minecraft</artifactId>
<version>1.8.8</version>
</dependency>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>co.gongzh.procbridge</groupId>
<artifactId>procbridge</artifactId>

View File

@ -1,130 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth;
/**
* The server Auth Points
*
* <p>
* Contains the pages url of a server
* </p>
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthPoints {
/**
* The Mojang auth server auth points
*/
public static final AuthPoints NORMAL_AUTH_POINTS = new AuthPoints("authenticate", "refresh", "validate", "signout", "invalidate");
/**
* The server authenticate point
*/
private String authenticatePoint;
/**
* The server refresh point
*/
private String refreshPoint;
/**
* The server validate point
*/
private String validatePoint;
/**
* The server signout point
*/
private String signoutPoint;
/**
* The server invalidate point
*/
private String invalidatePoint;
/**
* AuthPoints constructor
*
* @param authenticatePoint
* Authenticate point
* @param refreshPoint
* Refresh point
* @param validatePoint
* Validate point
* @param signoutPoint
* Signout point
* @param invalidatePoint
* Invalidate point
*/
public AuthPoints(String authenticatePoint, String refreshPoint, String validatePoint, String signoutPoint, String invalidatePoint) {
this.authenticatePoint = authenticatePoint;
this.refreshPoint = refreshPoint;
this.validatePoint = validatePoint;
this.signoutPoint = signoutPoint;
this.invalidatePoint = invalidatePoint;
}
/**
* Returns the server authenticate point
*
* @return The authenticate point
*/
public String getAuthenticatePoint() {
return this.authenticatePoint;
}
/**
* Returns the server refresh point
*
* @return The refresh point
*/
public String getRefreshPoint() {
return this.refreshPoint;
}
/**
* Returns the server validate point
*
* @return The validate point
*/
public String getValidatePoint() {
return this.validatePoint;
}
/**
* Returns the server signout point
*
* @return The signout point
*/
public String getSignoutPoint() {
return this.signoutPoint;
}
/**
* Returns the server invalidate point
*
* @return The invalidate point
*/
public String getInvalidatePoint() {
return this.invalidatePoint;
}
}

View File

@ -1,55 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth;
import fr.litarvan.openauth.model.AuthError;
/**
* Authentication exceptions
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthenticationException extends Exception {
/**
* The given JSON model instance of the error
*/
private AuthError model;
/**
* Create a new Authentication Exception
*
* @param model
* The given JSON model instance of the error
*/
public AuthenticationException(AuthError model) {
super(model.getErrorMessage());
this.model = model;
}
/**
* Returns the given JSON model instance of the error
*
* @return The error model
*/
public AuthError getErrorModel() {
return model;
}
}

View File

@ -1,401 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth;
import com.google.gson.Gson;
import fr.litarvan.openauth.model.AuthAgent;
import fr.litarvan.openauth.model.AuthError;
import fr.litarvan.openauth.model.request.*;
import fr.litarvan.openauth.model.response.AuthResponse;
import fr.litarvan.openauth.model.response.RefreshResponse;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.nio.charset.StandardCharsets;
/**
* The Authenticator
*
* <p>
* The main class of the lib, use it to authenticate a user !
* </p>
*
* @version 1.0.4
* @author Litarvan
*/
public class Authenticator {
/**
* The Mojang official auth server
* @deprecated Should not be used since it doesn't work anymore.
*/
@Deprecated
public static final String MOJANG_AUTH_URL = "https://authserver.mojang.com/";
/**
* The auth server URL
*/
private final String authURL;
/**
* The server auth points
*/
private final AuthPoints authPoints;
/**
* Create an authenticator
*
* @param authURL
* The auth server URL
*
* @param authPoints
* The URIs of the multiple requests
*/
public Authenticator(String authURL, AuthPoints authPoints) {
this.authURL = authURL;
this.authPoints = authPoints;
}
/**
* Authenticates a user using his password.
*
* @param agent
* The auth agent (optional)
* @param username
* User account name
* @param password
* User account password
* @param clientToken
* The client token (optional, like a key for the access token)
*
* @throws AuthenticationException If the server returned an error as a JSON
*
* @return The response sent by the server (parsed from a JSON)
*/
public AuthResponse authenticate(AuthAgent agent, String username, String password, String clientToken) throws AuthenticationException {
return authenticate(agent, username, password, clientToken, Proxy.NO_PROXY);
}
/**
* Authenticates a user using his password.
*
* @param agent
* The auth agent (optional)
* @param username
* User account name
* @param password
* User account password
* @param clientToken
* The client token (optional, like a key for the access token)
* @param proxy
* The proxy to use (optional)
*
* @throws AuthenticationException If the server returned an error as a JSON
*
* @return The response sent by the server (parsed from a JSON)
*/
public AuthResponse authenticate(AuthAgent agent, String username, String password, String clientToken, Proxy proxy) throws AuthenticationException {
AuthRequest request = new AuthRequest(agent, username, password, clientToken);
return (AuthResponse) sendRequest(request, AuthResponse.class, authPoints.getAuthenticatePoint(), proxy);
}
/**
* Refresh a valid access token. It can be uses to keep a user logged in between gaming sessions
* and is preferred over storing the user's password in a file.
*
* @param accessToken
* The saved access token
* @param clientToken
* The saved client token (need to be the same used when authenticated to get the access token)
*
* @throws AuthenticationException If the server returned an error as a JSON
*
* @return The response sent by the server (parsed from a JSON)
*/
public RefreshResponse refresh(String accessToken, String clientToken) throws AuthenticationException {
return refresh(accessToken, clientToken, Proxy.NO_PROXY);
}
/**
* Refresh a valid access token. It can be uses to keep a user logged in between gaming sessions
* and is preferred over storing the user's password in a file.
*
* @param accessToken
* The saved access token
* @param clientToken
* The saved client token (need to be the same used when authenticated to get the access token)
* @param proxy
* The proxy to use (optional)
*
* @throws AuthenticationException If the server returned an error as a JSON
*
* @return The response sent by the server (parsed from a JSON)
*/
public RefreshResponse refresh(String accessToken, String clientToken, Proxy proxy) throws AuthenticationException {
RefreshRequest request = new RefreshRequest(accessToken, clientToken);
return (RefreshResponse) sendRequest(request, RefreshResponse.class, authPoints.getRefreshPoint(), proxy);
}
/**
* Check if an access token is a valid session token with a currently-active session.
* Note: this method will not respond successfully to all currently-logged-in sessions,
* just the most recently-logged-in for each user. It is intended to be used by servers to validate
* that a user should be connecting (and reject users who have logged in elsewhere since starting Minecraft),
* NOT to auth that a particular session token is valid for authentication purposes.
* To authenticate a user by session token, use the refresh verb and catch resulting errors.
*
* @param accessToken
* The access token to check
*
* @throws AuthenticationException If the server returned an error as a JSON
*/
public void validate(String accessToken) throws AuthenticationException {
validate(accessToken, Proxy.NO_PROXY);
}
/**
* Check if an access token is a valid session token with a currently-active session.
* Note: this method will not respond successfully to all currently-logged-in sessions,
* just the most recently-logged-in for each user. It is intended to be used by servers to validate
* that a user should be connecting (and reject users who have logged in elsewhere since starting Minecraft),
* NOT to auth that a particular session token is valid for authentication purposes.
* To authenticate a user by session token, use the refresh verb and catch resulting errors.
*
* @param accessToken
* The access token to check
* @param proxy
* The proxy to use (optional)
*
* @throws AuthenticationException If the server returned an error as a JSON
*/
public void validate(String accessToken, Proxy proxy) throws AuthenticationException {
ValidateRequest request = new ValidateRequest(accessToken);
sendRequest(request, null, authPoints.getValidatePoint(), proxy);
}
/**
* Invalidates accessTokens using an account's username and password
*
* @param username
* User account name
* @param password
* User account password
*
* @throws AuthenticationException If the server returned an error as a JSON
*/
public void signout(String username, String password) throws AuthenticationException {
signout(username, password, Proxy.NO_PROXY);
}
/**
* Invalidates accessTokens using an account's username and password
*
* @param username
* User account name
* @param password
* User account password
* @param proxy
* The proxy to use (optional)
*
* @throws AuthenticationException If the server returned an error as a JSON
*/
public void signout(String username, String password, Proxy proxy) throws AuthenticationException {
SignoutRequest request = new SignoutRequest(username, password);
sendRequest(request, null, authPoints.getSignoutPoint(), proxy);
}
/**
* Invalidates accessTokens using a client/access token pair
*
* @param accessToken
* Valid access token to invalidate
* @param clientToken
* Client token used when authenticated to get the access token
*
* @throws AuthenticationException If the server returned an error as a JSON
*/
public void invalidate(String accessToken, String clientToken) throws AuthenticationException {
invalidate(accessToken, clientToken, Proxy.NO_PROXY);
}
/**
* Invalidates accessTokens using a client/access token pair
*
* @param accessToken
* Valid access token to invalidate
* @param clientToken
* Client token used when authenticated to get the access token
* @param proxy
* The proxy to use (optional)
*
* @throws AuthenticationException If the server returned an error as a JSON
*/
public void invalidate(String accessToken, String clientToken, Proxy proxy) throws AuthenticationException {
InvalidateRequest request = new InvalidateRequest(accessToken, clientToken);
sendRequest(request, null, authPoints.getInvalidatePoint(), proxy);
}
/**
* Send a request to the auth server
*
* @param request
* The auth request to send
* @param model
* The model of the response
* @param authPoint
* The auth point of the request
* @throws AuthenticationException
* If it returned an error or the request failed
*
* @throws AuthenticationException If the server returned an error as a JSON
*
* @return Instance of the given response model if it not null
*/
private Object sendRequest(Object request, Class<?> model, String authPoint) throws AuthenticationException {
return sendRequest(request, model, authPoint, Proxy.NO_PROXY);
}
/**
* Send a request to the auth server
*
* @param request
* The auth request to send
* @param model
* The model of the response
* @param authPoint
* The auth point of the request
* @param proxy
* The proxy to use (optional)
* @throws AuthenticationException
* If it returned an error or the request failed
*
* @throws AuthenticationException If the server returned an error as a JSON
*
* @return Instance of the given response model if it not null
*/
private Object sendRequest(Object request, Class<?> model, String authPoint, Proxy proxy) throws AuthenticationException {
Gson gson = new Gson();
String response;
try {
response = sendPostRequest(this.authURL + authPoint, gson.toJson(request), proxy);
} catch (IOException e) {
throw new AuthenticationException(new AuthError("Can't send the request : " + e.getClass().getName(), e.getMessage(), "Unknown"));
}
if(model != null)
return gson.fromJson(response, model);
else
return null;
}
/**
* Sends a post request of a json
*
* @param url
* The url to send the request
* @param json
* The json to send
* @throws IOException
* If it failed
*
* @throws AuthenticationException If the request returned an error JSON or not a JSON
*
* @return The request response
*/
private String sendPostRequest(String url, String json) throws AuthenticationException, IOException {
return sendPostRequest(url, json, Proxy.NO_PROXY);
}
/**
* Sends a post request of a json
*
* @param url
* The url to send the request
* @param json
* The json to send
* @param proxy
* The proxy to use (optional)
* @throws IOException
* If it failed
*
* @throws AuthenticationException If the request returned an error JSON or not a JSON
*
* @return The request response
*/
private String sendPostRequest(String url, String json, Proxy proxy) throws AuthenticationException, IOException {
byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8);
URL serverURL = new URL(url);
HttpURLConnection connection = (HttpURLConnection) serverURL.openConnection(proxy != null ? proxy : Proxy.NO_PROXY);
connection.setRequestMethod("POST");
// Sending post request
connection.setDoOutput(true);
connection.setRequestProperty("Accept-Charset", "UTF-8");
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
connection.setRequestProperty("Content-Length", String.valueOf(jsonBytes.length));
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.write(jsonBytes, 0, jsonBytes.length);
wr.flush();
wr.close();
connection.connect();
int responseCode = connection.getResponseCode();
if(responseCode == 204) {
connection.disconnect();
return null;
}
InputStream is;
if(responseCode == 200)
is = connection.getInputStream();
else
is = connection.getErrorStream();
String response;
BufferedReader br = new BufferedReader(new InputStreamReader(is));
response = br.readLine();
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
connection.disconnect();
while (response != null && response.startsWith("\uFEFF"))
response = response.substring(1);
if (responseCode != 200) {
Gson gson = new Gson();
if (response != null && !response.startsWith("{"))
throw new AuthenticationException(new AuthError("Internal server error", response, "Remote"));
throw new AuthenticationException(gson.fromJson(response, AuthError.class));
}
return response;
}
}

View File

@ -1,41 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
public class AuthTokens
{
private final String accessToken;
private final String refreshToken;
public AuthTokens(String accessToken, String refreshToken)
{
this.accessToken = accessToken;
this.refreshToken = refreshToken;
}
public String getAccessToken()
{
return accessToken;
}
public String getRefreshToken()
{
return refreshToken;
}
}

View File

@ -1,215 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
import com.google.gson.Gson;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
public class HttpClient
{
public static final String MIME_TYPE_JSON = "application/json";
public static final String MIME_TYPE_URLENCODED_FORM = "application/x-www-form-urlencoded";
private final Gson gson;
private final Proxy proxy;
public HttpClient()
{
this(Proxy.NO_PROXY);
}
public HttpClient(Proxy proxy)
{
this.gson = new Gson();
this.proxy = proxy;
}
public String getText(String url, Map<String, String> params) throws MicrosoftAuthenticationException
{
return readResponse(createConnection(url + '?' + buildParams(params)));
}
public <T> T getJson(String url, String token, Class<T> responseClass) throws MicrosoftAuthenticationException
{
HttpURLConnection connection = createConnection(url);
connection.addRequestProperty("Authorization", "Bearer " + token);
connection.addRequestProperty("Accept", MIME_TYPE_JSON);
return readJson(connection, responseClass);
}
public HttpURLConnection postForm(String url, Map<String, String> params) throws MicrosoftAuthenticationException
{
return post(url, MIME_TYPE_URLENCODED_FORM, "*/*", buildParams(params));
}
public <T> T postJson(String url, Object request, Class<T> responseClass) throws MicrosoftAuthenticationException
{
HttpURLConnection connection = post(url, MIME_TYPE_JSON, MIME_TYPE_JSON, gson.toJson(request));
return readJson(connection, responseClass);
}
public <T> T postFormGetJson(String url, Map<String, String> params, Class<T> responseClass) throws MicrosoftAuthenticationException
{
return readJson(postForm(url, params), responseClass);
}
protected HttpURLConnection post(String url, String contentType, String accept, String data) throws MicrosoftAuthenticationException
{
HttpURLConnection connection = createConnection(url);
connection.setDoOutput(true);
connection.addRequestProperty("Content-Type", contentType);
connection.addRequestProperty("Accept", accept);
try {
connection.setRequestMethod("POST");
connection.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
throw new MicrosoftAuthenticationException(e);
}
return connection;
}
protected <T> T readJson(HttpURLConnection connection, Class<T> responseType) throws MicrosoftAuthenticationException
{
return gson.fromJson(readResponse(connection), responseType);
}
protected String readResponse(HttpURLConnection connection) throws MicrosoftAuthenticationException
{
String redirection = connection.getHeaderField("Location");
if (redirection != null) {
return readResponse(createConnection(redirection));
}
StringBuilder response = new StringBuilder();
try
{
InputStream inputStream = connection.getInputStream();
// check if the url corresponds to a related authentication url
if(this.checkUrl(connection.getURL()))
{
// then patch the input stream like in the old MicrosoftPatchedHttpURLConnection class.
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int n;
byte[] data = new byte[8192];
while ((n = inputStream.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, n);
}
byte[] patched = buffer
.toString("UTF-8")
.replaceAll("integrity ?=", "integrity.disabled=")
.replaceAll("setAttribute\\(\"integrity\"", "setAttribute(\"integrity.disabled\"")
.getBytes(StandardCharsets.UTF_8);
inputStream = new ByteArrayInputStream(patched);
}
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
String line;
while ((line = br.readLine()) != null) {
response.append(line).append('\n');
}
} catch (IOException e) {
throw new MicrosoftAuthenticationException(e);
}
} catch (IOException e)
{
throw new RuntimeException(e);
}
return response.toString();
}
private boolean checkUrl(URL url)
{
return (("login.microsoftonline.com".equals(url.getHost()) && url.getPath().endsWith("/oauth2/authorize"))
|| ("login.live.com".equals(url.getHost()) && "/oauth20_authorize.srf".equals(url.getPath()))
|| ("login.live.com".equals(url.getHost()) && "/ppsecure/post.srf".equals(url.getPath()))
|| ("login.microsoftonline.com".equals(url.getHost()) && "/login.srf".equals(url.getPath()))
|| ("login.microsoftonline.com".equals(url.getHost()) && url.getPath().endsWith("/login"))
|| ("login.microsoftonline.com".equals(url.getHost()) && url.getPath().endsWith("/SAS/ProcessAuth"))
|| ("login.microsoftonline.com".equals(url.getHost()) && url.getPath().endsWith("/federation/oauth2"))
|| ("login.microsoftonline.com".equals(url.getHost()) && url.getPath().endsWith("/oauth2/v2.0/authorize")));
}
protected HttpURLConnection followRedirects(HttpURLConnection connection) throws MicrosoftAuthenticationException
{
String redirection = connection.getHeaderField("Location");
if (redirection != null) {
connection = followRedirects(createConnection(redirection));
}
return connection;
}
protected String buildParams(Map<String, String> params)
{
StringBuilder query = new StringBuilder();
params.forEach((key, value) -> {
if (query.length() > 0) {
query.append('&');
}
try {
query.append(key).append('=').append(URLEncoder.encode(value, StandardCharsets.UTF_8.name()));
} catch (UnsupportedEncodingException ignored) {
// Can't happen
}
});
return query.toString();
}
protected HttpURLConnection createConnection(String url) throws MicrosoftAuthenticationException
{
HttpURLConnection connection;
try {
connection = (HttpURLConnection) new URL(url).openConnection(proxy);
} catch (IOException e) {
throw new MicrosoftAuthenticationException(e);
}
String userAgent = "Mozilla/5.0 (XboxReplay; XboxLiveAuth/3.0) " +
"AppleWebKit/537.36 (KHTML, like Gecko) " +
"Chrome/71.0.3578.98 " +
"Safari/537.36";
connection.setConnectTimeout(30 * 1000); // 30s
connection.setReadTimeout(60 * 1000); // 60s
connection.setRequestProperty("Accept-Language", "en-US");
connection.setRequestProperty("Accept-Charset", "UTF-8");
connection.setRequestProperty("User-Agent", userAgent);
return connection;
}
}

View File

@ -1,92 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.concurrent.CompletableFuture;
/*
* Had to use Swing here, JavaFX is meant to have an 'Application' but only one can exist.
* Creating one would break compatibility with JavaFX apps (which already have their own
* class), and letting the user do so would break compatibility with Swing apps.
*
* This method makes the frame compatible with pretty much everything.
*/
public class LoginFrame extends JFrame
{
private CompletableFuture<String> future;
private boolean completed;
public LoginFrame()
{
this.setTitle("Microsoft Authentication");
this.setSize(750, 750);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setContentPane(new JFXPanel());
}
public CompletableFuture<String> start(String url)
{
if (this.future != null) {
return this.future;
}
this.future = new CompletableFuture<>();
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
if(!completed)
future.complete(null);
}
});
Platform.runLater(() -> this.init(url));
return this.future;
}
protected void init(String url)
{
WebView webView = new WebView();
JFXPanel content = (JFXPanel) this.getContentPane();
content.setScene(new Scene(webView, this.getWidth(), this.getHeight()));
webView.getEngine().locationProperty().addListener((observable, oldValue, newValue) -> {
if (newValue.contains("access_token")) {
this.future.complete(newValue);
completed = true;
this.dispose();
}
});
webView.getEngine().setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36");
webView.getEngine().load(url);
this.setVisible(true);
}
}

View File

@ -1,91 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
import fr.litarvan.openauth.microsoft.model.response.MinecraftProfile;
/**
* Microsoft authentication result
*
* <p>
* This class contains the result of a successful Microsoft authentication: a player profile and its tokens (both
* access and refresh token).
* </p>
*
* @author Litarvan
* @version 1.1.5
*/
public class MicrosoftAuthResult
{
private final MinecraftProfile profile;
private final String accessToken;
private final String refreshToken;
private final String xuid;
private final String clientId;
public MicrosoftAuthResult(MinecraftProfile profile, String accessToken, String refreshToken, String xuid, String clientId)
{
this.profile = profile;
this.accessToken = accessToken;
this.refreshToken = refreshToken;
this.xuid = xuid;
this.clientId = clientId;
}
/**
* @return The player Minecraft profile (contains its UUID and username)
*/
public MinecraftProfile getProfile()
{
return profile;
}
/**
* @return The Minecraft access token
*/
public String getAccessToken()
{
return accessToken;
}
/**
* @return The Microsoft refresh token that can be used to log the user back silently using
* {@link MicrosoftAuthenticator#loginWithRefreshToken(String)}
*/
public String getRefreshToken()
{
return refreshToken;
}
/**
* @return The XUID of the player
*/
public String getXuid()
{
return this.xuid;
}
/**
* @return The client ID of the player
*/
public String getClientId()
{
return this.clientId;
}
}

View File

@ -1,39 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
import java.io.IOException;
public class MicrosoftAuthenticationException extends Exception
{
public MicrosoftAuthenticationException(String message)
{
super(message);
}
public MicrosoftAuthenticationException(IOException cause)
{
super("I/O exception thrown during Microsoft HTTP requests", cause);
}
public MicrosoftAuthenticationException(Throwable cause)
{
super(cause);
}
}

View File

@ -1,314 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
/*
* Ported from the amazing work of Alexis Bize on @xboxreplay/xboxlive-auth
*
* https://github.com/Alexis-Bize
* https://github.com/XboxReplay/xboxlive-auth
*/
import fr.litarvan.openauth.microsoft.model.request.MinecraftLoginRequest;
import fr.litarvan.openauth.microsoft.model.request.XSTSAuthorizationProperties;
import fr.litarvan.openauth.microsoft.model.request.XboxLiveLoginProperties;
import fr.litarvan.openauth.microsoft.model.request.XboxLoginRequest;
import fr.litarvan.openauth.microsoft.model.response.*;
import java.io.UnsupportedEncodingException;
import java.net.*;
import java.util.Arrays;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Microsoft authenticator
*
* <p>
* This class can be used to authenticate a player using its Microsoft account.
* Use {@link #loginWithCredentials} to retrieve a player profile from his Microsoft credentials,
* or {@link #loginWithWebview} to use a webview with Microsoft login form.
* </p>
*
* @author Litarvan
* @version 1.1.0
*/
public class MicrosoftAuthenticator {
public static final String MICROSOFT_AUTHORIZATION_ENDPOINT = "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize";
public static final String MICROSOFT_TOKEN_ENDPOINT = "https://login.live.com/oauth20_token.srf";
public static final String MICROSOFT_REDIRECTION_ENDPOINT = "https://login.live.com/oauth20_desktop.srf";
public static final String XBOX_LIVE_AUTH_HOST = "user.auth.xboxlive.com";
public static final String XBOX_LIVE_CLIENT_ID = "000000004C12AE6F";
public static final String XBOX_LIVE_SERVICE_SCOPE = "service::user.auth.xboxlive.com::MBI_SSL";
public static final String XBOX_LIVE_AUTHORIZATION_ENDPOINT = "https://user.auth.xboxlive.com/user/authenticate";
public static final String XSTS_AUTHORIZATION_ENDPOINT = "https://xsts.auth.xboxlive.com/xsts/authorize";
public static final String MINECRAFT_AUTH_ENDPOINT = "https://api.minecraftservices.com/authentication/login_with_xbox";
public static final String XBOX_LIVE_AUTH_RELAY = "http://auth.xboxlive.com";
public static final String MINECRAFT_AUTH_RELAY = "rp://api.minecraftservices.com/";
public static final String MINECRAFT_STORE_ENDPOINT = "https://api.minecraftservices.com/entitlements/mcstore";
public static final String MINECRAFT_PROFILE_ENDPOINT = "https://api.minecraftservices.com/minecraft/profile";
public static final String MINECRAFT_STORE_IDENTIFIER = "game_minecraft";
private final HttpClient http;
public MicrosoftAuthenticator() {
this.http = new HttpClient();
}
/**
* Logs in a player using its Microsoft account credentials, and retrieve its Minecraft profile
*
* @param email Player Microsoft account e-mail
* @param password Player Microsoft account password
* @return The player Minecraft profile
* @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
*/
public MicrosoftAuthResult loginWithCredentials(String email, String password) throws MicrosoftAuthenticationException {
CookieHandler currentHandler = CookieHandler.getDefault();
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
Map<String, String> params = new HashMap<>();
params.put("login", email);
params.put("loginfmt", email);
params.put("passwd", password);
HttpURLConnection result;
try {
PreAuthData authData = preAuthRequest();
params.put("PPFT", authData.getPPFT());
result = http.followRedirects(http.postForm(authData.getUrlPost(), params));
} finally {
CookieHandler.setDefault(currentHandler);
}
try {
return loginWithTokens(extractTokens(result.getURL().toString()),true);
} catch (MicrosoftAuthenticationException e) {
if (match("(identity/confirm)", http.readResponse(result)) != null) {
throw new MicrosoftAuthenticationException(
"User has enabled double-authentication or must allow sign-in on https://account.live.com/activity"
);
}
throw e;
}
}
/**
* Logs in a player using a webview to display Microsoft login page.
* <b>This function blocks the current thread until the process is finished; this can cause your application to
* freeze. When calling from the JavaFX thread or any thread which must not be blocked, use
* {@link #loginWithAsyncWebview()}</b>
*
* @return The player Minecraft profile
* @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
*/
public MicrosoftAuthResult loginWithWebview() throws MicrosoftAuthenticationException {
try {
return loginWithAsyncWebview().get();
} catch (InterruptedException | ExecutionException e) {
throw new MicrosoftAuthenticationException(e);
}
}
/**
* Logs in a player using a webview to display Microsoft login page. This function does not block the current thread.
*
* @return A future resolved by the player Minecraft profile
*/
public CompletableFuture<MicrosoftAuthResult> loginWithAsyncWebview() {
if(!System.getProperty("java.version").startsWith("1."))
CookieHandler.setDefault(new CookieManager());
String url = String.format("%s?%s", MICROSOFT_AUTHORIZATION_ENDPOINT, http.buildParams(getLoginParams()));
LoginFrame frame = new LoginFrame();
return frame.start(url).thenApplyAsync(result -> {
try {
if(result != null)
return loginWithTokens(extractTokens(result),true);
else return null;
} catch (MicrosoftAuthenticationException e) {
throw new CompletionException(e);
}
});
}
/**
* Logs in a player using a Microsoft account refresh token retrieved earlier.
*
* @param refreshToken Player Microsoft account refresh token
* @return The player Minecraft profile
* @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
*/
public MicrosoftAuthResult loginWithRefreshToken(String refreshToken) throws MicrosoftAuthenticationException {
Map<String, String> params = getLoginParams();
params.put("refresh_token", refreshToken);
params.put("grant_type", "refresh_token");
MicrosoftRefreshResponse response = http.postFormGetJson(
MICROSOFT_TOKEN_ENDPOINT,
params, MicrosoftRefreshResponse.class
);
return loginWithTokens(new AuthTokens(response.getAccessToken(), response.getRefreshToken()),true);
}
/**
* Logs in a player using a Microsoft account tokens retrieved earlier.
* <b>If the token was retrieved using Azure AAD/MSAL, it should be prefixed with d=</b>
*
* @param tokens Player Microsoft account tokens pair
* @return The player Minecraft profile
* @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
*/
public MicrosoftAuthResult loginWithTokens(AuthTokens tokens) throws MicrosoftAuthenticationException {
return loginWithTokens(tokens,true);
}
/**
* Logs in a player using a Microsoft account tokens retrieved earlier.
* <b>If the token was retrieved using Azure AAD/MSAL, it should be prefixed with d=</b>
*
* @param tokens Player Microsoft account tokens pair
* @param retrieveProfile Whether to retrieve the player profile
* @return The player Minecraft profile
* @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
*/
public MicrosoftAuthResult loginWithTokens(AuthTokens tokens, boolean retrieveProfile) throws MicrosoftAuthenticationException {
XboxLoginResponse xboxLiveResponse = xboxLiveLogin(tokens.getAccessToken());
XboxLoginResponse xstsResponse = xstsLogin(xboxLiveResponse.getToken());
String userHash = xstsResponse.getDisplayClaims().getUsers()[0].getUserHash();
MinecraftLoginResponse minecraftResponse = minecraftLogin(userHash, xstsResponse.getToken());
MinecraftStoreResponse storeResponse = http.getJson(
MINECRAFT_STORE_ENDPOINT,
minecraftResponse.getAccessToken(),
MinecraftStoreResponse.class
);
if (Arrays.stream(storeResponse.getItems()).noneMatch(item -> item.getName().equals(MINECRAFT_STORE_IDENTIFIER))) {
throw new MicrosoftAuthenticationException("Player didn't buy Minecraft Java Edition or did not migrate its account");
}
MinecraftProfile profile = null;
if (retrieveProfile) {
profile = http.getJson(
MINECRAFT_PROFILE_ENDPOINT,
minecraftResponse.getAccessToken(),
MinecraftProfile.class
);
}
return new MicrosoftAuthResult(
profile,
minecraftResponse.getAccessToken(),
tokens.getRefreshToken(),
xboxLiveResponse.getDisplayClaims().getUsers()[0].getUserHash(),
Base64.getEncoder().encodeToString(minecraftResponse.getUsername().getBytes())
);
}
protected PreAuthData preAuthRequest() throws MicrosoftAuthenticationException {
Map<String, String> params = getLoginParams();
params.put("display", "touch");
params.put("locale", "en");
String result = http.getText(MICROSOFT_AUTHORIZATION_ENDPOINT, params);
String ppft = match("sFTTag:'.*value=\"([^\"]*)\"", result);
String urlPost = match("urlPost: ?'(.+?(?='))", result);
return new PreAuthData(ppft, urlPost);
}
protected XboxLoginResponse xboxLiveLogin(String accessToken) throws MicrosoftAuthenticationException {
XboxLiveLoginProperties properties = new XboxLiveLoginProperties("RPS", XBOX_LIVE_AUTH_HOST, accessToken);
XboxLoginRequest<XboxLiveLoginProperties> request = new XboxLoginRequest<>(
properties, XBOX_LIVE_AUTH_RELAY, "JWT"
);
return http.postJson(XBOX_LIVE_AUTHORIZATION_ENDPOINT, request, XboxLoginResponse.class);
}
protected XboxLoginResponse xstsLogin(String xboxLiveToken) throws MicrosoftAuthenticationException {
XSTSAuthorizationProperties properties = new XSTSAuthorizationProperties("RETAIL", new String[]{xboxLiveToken});
XboxLoginRequest<XSTSAuthorizationProperties> request = new XboxLoginRequest<>(
properties, MINECRAFT_AUTH_RELAY, "JWT"
);
return http.postJson(XSTS_AUTHORIZATION_ENDPOINT, request, XboxLoginResponse.class);
}
protected MinecraftLoginResponse minecraftLogin(String userHash, String xstsToken) throws MicrosoftAuthenticationException {
MinecraftLoginRequest request = new MinecraftLoginRequest(String.format("XBL3.0 x=%s;%s", userHash, xstsToken));
return http.postJson(MINECRAFT_AUTH_ENDPOINT, request, MinecraftLoginResponse.class);
}
protected Map<String, String> getLoginParams() {
Map<String, String> params = new HashMap<>();
params.put("client_id", XBOX_LIVE_CLIENT_ID);
params.put("redirect_uri", MICROSOFT_REDIRECTION_ENDPOINT);
params.put("scope", XBOX_LIVE_SERVICE_SCOPE);
params.put("response_type", "token");
return params;
}
protected AuthTokens extractTokens(String url) throws MicrosoftAuthenticationException {
return new AuthTokens(extractValue(url, "access_token"), extractValue(url, "refresh_token"));
}
protected String extractValue(String url, String key) throws MicrosoftAuthenticationException {
String matched = match(key + "=([^&]*)", url);
if (matched == null) {
throw new MicrosoftAuthenticationException("Invalid credentials or tokens");
}
try {
return URLDecoder.decode(matched, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new MicrosoftAuthenticationException(e);
}
}
protected String match(String regex, String content) {
Matcher matcher = Pattern.compile(regex).matcher(content);
if (!matcher.find()) {
return null;
}
return matcher.group(1);
}
}

View File

@ -1,41 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft;
public class PreAuthData
{
private final String ppft;
private final String urlPost;
public PreAuthData(String ppft, String urlPost)
{
this.ppft = ppft;
this.urlPost = urlPost;
}
public String getPPFT()
{
return ppft;
}
public String getUrlPost()
{
return urlPost;
}
}

View File

@ -1,34 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.request;
public class MinecraftLoginRequest
{
private final String identityToken;
public MinecraftLoginRequest(String identityToken)
{
this.identityToken = identityToken;
}
public String getIdentityToken()
{
return identityToken;
}
}

View File

@ -1,41 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.request;
public class XSTSAuthorizationProperties
{
private final String SandboxId;
private final String[] UserTokens;
public XSTSAuthorizationProperties(String SandboxId, String[] UserTokens)
{
this.SandboxId = SandboxId;
this.UserTokens = UserTokens;
}
public String getSandboxId()
{
return SandboxId;
}
public String[] getUserTokens()
{
return UserTokens;
}
}

View File

@ -1,48 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.request;
public class XboxLiveLoginProperties
{
private final String AuthMethod;
private final String SiteName;
private final String RpsTicket;
public XboxLiveLoginProperties(String AuthMethod, String SiteName, String RpsTicket)
{
this.AuthMethod = AuthMethod;
this.SiteName = SiteName;
this.RpsTicket = RpsTicket;
}
public String getAuthMethod()
{
return AuthMethod;
}
public String getSiteName()
{
return SiteName;
}
public String getRpsTicket()
{
return RpsTicket;
}
}

View File

@ -1,48 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.request;
public class XboxLoginRequest<T>
{
private final T Properties;
private final String RelyingParty;
private final String TokenType;
public XboxLoginRequest(T Properties, String RelyingParty, String TokenType)
{
this.Properties = Properties;
this.RelyingParty = RelyingParty;
this.TokenType = TokenType;
}
public T getProperties()
{
return Properties;
}
public String getSiteName()
{
return RelyingParty;
}
public String getTokenType()
{
return TokenType;
}
}

View File

@ -1,69 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.response;
public class MicrosoftRefreshResponse
{
private final String token_type;
private final long expires_in;
private final String scope;
private final String access_token;
private final String refresh_token;
private final String user_id;
public MicrosoftRefreshResponse(String token_type, long expires_in, String scope, String access_token, String refresh_token, String user_id)
{
this.token_type = token_type;
this.expires_in = expires_in;
this.scope = scope;
this.access_token = access_token;
this.refresh_token = refresh_token;
this.user_id = user_id;
}
public String getTokenType()
{
return token_type;
}
public long getExpiresIn()
{
return expires_in;
}
public String getScope()
{
return scope;
}
public String getAccessToken()
{
return access_token;
}
public String getRefreshToken()
{
return refresh_token;
}
public String getUserId()
{
return user_id;
}
}

View File

@ -1,55 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.response;
public class MinecraftLoginResponse
{
private final String username;
private final String access_token;
private final String token_type;
private final long expires_in;
public MinecraftLoginResponse(String username, String access_token, String token_type, long expires_in)
{
this.username = username;
this.access_token = access_token;
this.token_type = token_type;
this.expires_in = expires_in;
}
public String getUsername()
{
return username;
}
public String getAccessToken()
{
return access_token;
}
public String getTokenType()
{
return token_type;
}
public long getExpiresIn()
{
return expires_in;
}
}

View File

@ -1,107 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.response;
/**
* Minecraft player profile
*
* <p>
* Represents a Minecraft player profile data. UUID is {@link #id} and username is {@link #name}.
* </p>
*
* @version 1.1.0
* @author Litarvan
*/
public class MinecraftProfile
{
private final String id;
private final String name;
private final MinecraftSkin[] skins;
public MinecraftProfile(String id, String name, MinecraftSkin[] skins)
{
this.id = id;
this.name = name;
this.skins = skins;
}
/**
* @return The player Minecraft UUID
*/
public String getId()
{
return id;
}
/**
* @return The player Minecraft username
*/
public String getName()
{
return name;
}
public MinecraftSkin[] getSkins()
{
return skins;
}
public static class MinecraftSkin
{
private final String id;
private final String state;
private final String url;
private final String variant;
private final String alias;
public MinecraftSkin(String id, String state, String url, String variant, String alias)
{
this.id = id;
this.state = state;
this.url = url;
this.variant = variant;
this.alias = alias;
}
public String getId()
{
return id;
}
public String getState()
{
return state;
}
public String getUrl()
{
return url;
}
public String getVariant()
{
return variant;
}
public String getAlias()
{
return alias;
}
}
}

View File

@ -1,70 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.response;
public class MinecraftStoreResponse
{
private final StoreProduct[] items;
private final String signature;
private final String keyId;
public MinecraftStoreResponse(StoreProduct[] items, String signature, String keyId)
{
this.items = items;
this.signature = signature;
this.keyId = keyId;
}
public StoreProduct[] getItems()
{
return items;
}
public String getSignature()
{
return signature;
}
public String getKeyId()
{
return keyId;
}
public static class StoreProduct
{
private final String name;
private final String signature;
public StoreProduct(String name, String signature)
{
this.name = name;
this.signature = signature;
}
public String getName()
{
return name;
}
public String getSignature()
{
return signature;
}
}
}

View File

@ -1,85 +0,0 @@
/*
* Copyright 2015-2021 Adrien 'Litarvan' Navratil
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.microsoft.model.response;
public class XboxLoginResponse
{
private final String IssueInstant;
private final String NotAfter;
private final String Token;
private final XboxLiveLoginResponseClaims DisplayClaims;
public XboxLoginResponse(String IssueInstant, String NotAfter, String Token, XboxLiveLoginResponseClaims DisplayClaims)
{
this.IssueInstant = IssueInstant;
this.NotAfter = NotAfter;
this.Token = Token;
this.DisplayClaims = DisplayClaims;
}
public String getIssueInstant()
{
return IssueInstant;
}
public String getNotAfter()
{
return NotAfter;
}
public String getToken()
{
return Token;
}
public XboxLiveLoginResponseClaims getDisplayClaims()
{
return DisplayClaims;
}
public static class XboxLiveLoginResponseClaims
{
private final XboxLiveUserInfo[] xui;
public XboxLiveLoginResponseClaims(XboxLiveUserInfo[] xui)
{
this.xui = xui;
}
public XboxLiveUserInfo[] getUsers()
{
return xui;
}
}
public static class XboxLiveUserInfo
{
private final String uhs;
public XboxLiveUserInfo(String uhs)
{
this.uhs = uhs;
}
public String getUserHash()
{
return uhs;
}
}
}

View File

@ -1,100 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model;
/**
* JSON model of an auth agent
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthAgent {
/**
* The Minecraft auth agent
*/
public static final AuthAgent MINECRAFT = new AuthAgent("Minecraft", 1);
/**
* The Scroll auth agent
*/
public static final AuthAgent SCROLLS = new AuthAgent("Scrolls", 1);
/**
* The agent name
*/
private String name;
/**
* The agent version
*/
private int version;
/**
* Agent constructor
*
* @param name
* The name of the agent
* @param version
* The version of the agent (1 by default)
*/
public AuthAgent(String name, int version) {
this.name = name;
this.version = version;
}
/**
* Sets a new name
*
* @param name
* The new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the name of the agent
*
* @return The agent name
*/
public String getName() {
return this.name;
}
/**
* Sets a new version
*
* @param version
* The new version
*/
public void setVersion(int version) {
this.version = version;
}
/**
* Returns the version of the agent
*
* @return The agent version
*/
public int getVersion() {
return this.version;
}
}

View File

@ -1,87 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model;
/**
* JSON model of an error
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthError {
/**
* Short description of the error
*/
private String error;
/**
* Longer description wich can be shown to the user
*/
private String errorMessage;
/**
* Cause of the error (optional)
*/
private String cause;
/**
* Auth Error constructor
*
* @param error
* Short description of the error
* @param errorMessage
* Longer description wich can be shown to the user
* @param cause
* Cause of the error
*/
public AuthError(String error, String errorMessage, String cause) {
this.error = error;
this.errorMessage = errorMessage;
this.cause = cause;
}
/**
* Returns the error (Short description of the error)
*
* @return The error
*/
public String getError() {
return error;
}
/**
* Returns the error message (Longer description of the error)
*
* @return The error message
*/
public String getErrorMessage() {
return this.errorMessage;
}
/**
* Returns the cause of the error
*
* @return The cause
*/
public String getCause() {
return cause;
}
}

View File

@ -1,78 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model;
/**
* JSON model of a profile
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthProfile {
/**
* The profile name
*/
private String name;
/**
* The profile UUID
*/
private String id;
/**
* Blank auth profile
*/
public AuthProfile() {
this.name = "";
this.id = "";
}
/**
* Normal auth profile
*
* @param name
* The profile name
* @param id
* The profile UUID
*/
public AuthProfile(String name, String id) {
this.name = name;
this.id = id;
}
/**
* Returns the name of the profile
*
* @return The profile name
*/
public String getName() {
return this.name;
}
/**
* Returns the profile UUID
*
* @return The profile UUID
*/
public String getId() {
return this.id;
}
}

View File

@ -1,146 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.request;
import fr.litarvan.openauth.model.AuthAgent;
/**
* JSON Model of an authentication request
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthRequest {
/**
* The authentication agent (Optional, the game profile you want to use, Minecraft, Scrolls, etc...)
*/
private AuthAgent agent;
/**
* The username (The username of the player you want to authenticate)
*/
private String username;
/**
* The password (The password of the player you want to authenticate)
*/
private String password;
/**
* The client token (Optional, it's like a password for the access token)
*/
private String clientToken;
/**
* Authentication Request
*
* @param agent
* The authentication agent (Optional, the game you want to use, Minecraft, Scrolls, etc...)
* @param username
* The username (The username of the player you want to authenticate)
* @param password
* The password (The password of the player you want to authenticate)
* @param clientToken
* The client token (Optional, It's like a password for the access token)
*/
public AuthRequest(AuthAgent agent, String username, String password, String clientToken) {
this.agent = agent;
this.username = username;
this.password = password;
this.clientToken = clientToken;
}
/**
* Sets a new authentication agent (Optional, the game you want to use, Minecraft, Scrolls, etc...)
*
* @param agent
* The new agent
*/
public void setAgent(AuthAgent agent) {
this.agent = agent;
}
/**
* Returns the authentication agent (Given with the constructor or the setter)
*
* @return The given auth agent
*/
public AuthAgent getAgent() {
return this.agent;
}
/**
* Sets a new username (The username of the player you want to authenticate)
*
* @param username
* The new username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* Returns the username (Given with the constructor or the setter)
*
* @return The given username
*/
public String getUsername() {
return this.username;
}
/**
* Sets a new password (The password of the player you want to authenticate)
*
* @param password
* The new password
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Returns the password (Given with the constructor or the setter)
*
* @return The given password
*/
public String getPassword() {
return this.password;
}
/**
* Sets a new client token (It's like a password for the access token)
*
* @param clientToken
* The new client token
*/
public void setClientToken(String clientToken) {
this.clientToken = clientToken;
}
/**
* Returns the client token (Given with the constructor or the setter)
*
* @return The given client token
*/
public String getClientToken() {
return clientToken;
}
}

View File

@ -1,90 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.request;
/**
* JSON Model of an invalidate request
*
* @version 1.0.4
* @author Litarvan
*/
public class InvalidateRequest {
/**
* The access token you want to invalidate
*/
private String accessToken;
/**
* The client token associated with the access token
*/
private String clientToken;
/**
* Invalidate Request constructor
*
* @param accessToken
* The access token you want to invalidate
* @param clientToken
* The client token associated with the access token
*/
public InvalidateRequest(String accessToken, String clientToken) {
this.accessToken = accessToken;
this.clientToken = clientToken;
}
/**
* Sets a new access token (That you want to invalidate)
*
* @param accessToken
* The new access token
*/
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
/**
* Returns the access token (Given by the constructor or the setter)
*
* @return The given access token
*/
public String getAccessToken() {
return this.accessToken;
}
/**
* Sets a new client token (Need to be associated with the access token)
*
* @param clientToken
* The new client token
*/
public void setClientToken(String clientToken) {
this.clientToken = clientToken;
}
/**
* Returns the client token (Given by the constructor or the setter)
*
* @return The given client token
*/
public String getClientToken() {
return clientToken;
}
}

View File

@ -1,90 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.request;
/**
* JSON model of a refresh request
*
* @version 1.0.4
* @author Litarvan
*/
public class RefreshRequest {
/**
* The saved access token that you want to refresh
*/
private String accessToken;
/**
* The saved client token associated with the access token
*/
private String clientToken;
/**
* Refresh Request constructor
*
* @param accessToken
* The saved access token that you want to refresh
* @param clientToken
* The saved client token associated with the access token
*/
public RefreshRequest(String accessToken, String clientToken) {
this.accessToken = accessToken;
this.clientToken = clientToken;
}
/**
* Sets a new access token (That you want to refresh)
*
* @param accessToken
* The new access token
*/
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
/**
* Returns the access token (Given by the constructor or the setter)
*
* @return The given access token
*/
public String getAccessToken() {
return this.accessToken;
}
/**
* Sets a new client token (Need to be associated with the access token)
*
* @param clientToken
* The new client token
*/
public void setClientToken(String clientToken) {
this.clientToken = clientToken;
}
/**
* Returns the client token (Given by the constructor or the setter)
*
* @return The given client token
*/
public String getClientToken() {
return this.clientToken;
}
}

View File

@ -1,90 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.request;
/**
* JSON Model of an signout request
*
* @version 1.0.4
* @author Litarvan
*/
public class SignoutRequest {
/**
* The username of the player that you want to signout
*/
private String username;
/**
* The password of the player that you want to signout
*/
private String password;
/**
* Signout Request constructor
*
* @param username
* The username of the player that you want to signout
* @param password
* The password of the player that you want to signout
*/
public SignoutRequest(String username, String password) {
this.username = username;
this.password = password;
}
/**
* Sets a new username (Of the player that you want to signout)
*
* @param username
* The new username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* Returns the username (Given by the constructor or the setter)
*
* @return The given username
*/
public String getUsername() {
return this.username;
}
/**
* Sets a new password (Of the player that you want to signout)
*
* @param password
* The new password
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Returns the password (Given by the constructor or the setter)
*
* @return The given password
*/
public String getPassword() {
return password;
}
}

View File

@ -1,63 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.request;
/**
* JSON Model of an validate request
*
* @version 1.0.4
* @author Litarvan
*/
public class ValidateRequest {
/**
* The access token that you want to validate
*/
private String accessToken;
/**
* Validate Request constructor
*
* @param accessToken
* The access token that you want to validate
*/
public ValidateRequest(String accessToken) {
this.accessToken = accessToken;
}
/**
* Sets a new access token
*
* @param accessToken
* The new access token
*/
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
/**
* Returns the access token (Given by the constructor or the setter)
*
* @return The given access token
*/
public String getAccessToken() {
return accessToken;
}
}

View File

@ -1,106 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.response;
import fr.litarvan.openauth.model.AuthProfile;
/**
* JSON Model of an authentication response
*
* @version 1.0.4
* @author Litarvan
*/
public class AuthResponse {
/**
* The access token
*/
private String accessToken;
/**
* The client token (same as the one given by the request)
*/
private String clientToken;
/**
* All available profiles
*/
private AuthProfile[] availableProfiles;
/**
* The current selected profile from the agent
*/
private AuthProfile selectedProfile;
/**
* Auth Response constructor
*
* @param accessToken
* The access token
* @param clientToken
* The client token (same as the one given by the request)
* @param availableProfiles
* All available profiles
* @param selectedProfile
* The current selected profile from the agent
*/
public AuthResponse(String accessToken, String clientToken, AuthProfile[] availableProfiles, AuthProfile selectedProfile) {
this.accessToken = accessToken;
this.clientToken = clientToken;
this.availableProfiles = availableProfiles;
this.selectedProfile = selectedProfile;
}
/**
* Returns the access token
*
* @return The access token
*/
public String getAccessToken() {
return this.accessToken;
}
/**
* Returns the client token (same as the one given by the request)
*
* @return The client token
*/
public String getClientToken() {
return this.clientToken;
}
/**
* Returns the available profiles
*
* @return The available profiles
*/
public AuthProfile[] getAvailableProfiles() {
return this.availableProfiles;
}
/**
* Returns the selected profile from the agent
*
* @return The selected profile
*/
public AuthProfile getSelectedProfile() {
return this.selectedProfile;
}
}

View File

@ -1,91 +0,0 @@
/*
* Copyright 2015 TheShark34
*
* This file is part of OpenAuth.
* OpenAuth is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with OpenAuth. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.litarvan.openauth.model.response;
import fr.litarvan.openauth.model.AuthProfile;
/**
* JSON Model of an refresh response
*
* @version 1.0.4
* @author Litarvan
*/
public class RefreshResponse {
/**
* The access token (not the same as the one given by the request)
*/
private String accessToken;
/**
* The client token (same as the one given by the request)
*/
private String clientToken;
/**
* The selected profile
*/
private AuthProfile selectedProfile;
/**
* Refresh Response constructor
*
* @param accessToken
* The access token (not the same as the one given by the request)
* @param clientToken
* The client token (same as the one given by the request)
* @param selectedProfile
* The profile selected (depending of the sent AuthAgent) containing
* more information about the agent (the game) selected, like the
* username for Minecraft
*/
public RefreshResponse(String accessToken, String clientToken, AuthProfile selectedProfile) {
this.accessToken = accessToken;
this.clientToken = clientToken;
this.selectedProfile = selectedProfile;
}
/**
* Returns the access token (not the same as the one given by the request)
*
* @return The access token
*/
public String getAccessToken() {
return accessToken;
}
/**
* Returns the client token (same as the one given by the request)
*
* @return The client token
*/
public String getClientToken() {
return clientToken;
}
/**
* Returns the selected profile
*
* @return The selected profile
*/
public AuthProfile getSelectedProfile() {
return selectedProfile;
}
}

View File

@ -25,6 +25,7 @@ import optifine.Config;
import org.lwjgl.opengl.GL11;
import rip.athena.client.Athena;
import rip.athena.client.modules.impl.other.NickHider;
import rip.athena.client.modules.impl.other.Settings;
import rip.athena.client.socket.SocketClient;
import shadersmod.client.Shaders;
@ -375,41 +376,43 @@ public abstract class Render<T extends Entity>
if (entityIn instanceof AbstractClientPlayer) {
String username = ((AbstractClientPlayer) entityIn).getGameProfile().getId().toString();
if (SocketClient.isUser(username) && entityIn.ticksExisted > 20) {
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("Athena/logo/Athena.png"));
if (Settings.socketLogo) {
if (SocketClient.isUser(username) && entityIn.ticksExisted > 20) {
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("Athena/logo/Athena.png"));
String rank = SocketClient.getRank(username).toString();
ResourceLocation rankTexture = null;
switch (rank) {
case "OWNER":
case "MANAGER":
rankTexture = new ResourceLocation("Athena/ranks/owner.png");
break;
case "DEVELOPER":
rankTexture = new ResourceLocation("Athena/ranks/developer.png");
break;
case "ADMIN":
rankTexture = new ResourceLocation("Athena/ranks/admin.png");
break;
case "MOD":
rankTexture = new ResourceLocation("Athena/ranks/mod.png");
break;
case "PARTNER":
rankTexture = new ResourceLocation("Athena/ranks/partner.png");
break;
case "PREMIUM":
rankTexture = new ResourceLocation("Athena/ranks/premium.png");
break;
case "USER":
rankTexture = new ResourceLocation("Athena/ranks/user.png");
break;
default:
break;
}
String rank = SocketClient.getRank(username).toString();
ResourceLocation rankTexture = null;
switch (rank) {
case "OWNER":
case "MANAGER":
rankTexture = new ResourceLocation("Athena/ranks/owner.png");
break;
case "DEVELOPER":
rankTexture = new ResourceLocation("Athena/ranks/developer.png");
break;
case "ADMIN":
rankTexture = new ResourceLocation("Athena/ranks/admin.png");
break;
case "MOD":
rankTexture = new ResourceLocation("Athena/ranks/mod.png");
break;
case "PARTNER":
rankTexture = new ResourceLocation("Athena/ranks/partner.png");
break;
case "PREMIUM":
rankTexture = new ResourceLocation("Athena/ranks/premium.png");
break;
case "USER":
rankTexture = new ResourceLocation("Athena/ranks/user.png");
break;
default:
break;
}
if (rankTexture != null) {
Minecraft.getMinecraft().getTextureManager().bindTexture(rankTexture);
Gui.drawModalRectWithCustomSizedTexture(-fontrenderer.getStringWidth(entityIn.getDisplayName().getFormattedText()) / 2 - 12, (int) -2, 11, 11, 11, 11, 11, 11);
if (rankTexture != null) {
Minecraft.getMinecraft().getTextureManager().bindTexture(rankTexture);
Gui.drawModalRectWithCustomSizedTexture(-fontrenderer.getStringWidth(entityIn.getDisplayName().getFormattedText()) / 2 - 12, (int) -2, 11, 11, 11, 11, 11, 11);
}
}
}
}

View File

@ -18,7 +18,6 @@ import rip.athena.client.modules.impl.other.AimTrainer;
import rip.athena.client.requests.ContentType;
import rip.athena.client.requests.WebRequest;
import rip.athena.client.requests.WebRequestResult;
import rip.athena.client.server.CosmeticsClient;
import rip.athena.client.socket.SocketClient;
import rip.athena.client.theme.ThemeManager;
import rip.athena.client.utils.PrefixedLogger;
@ -58,8 +57,8 @@ public class Athena {
private final PrefixedLogger log = new PrefixedLogger("Athena");
private final String clientName = "Athena";
private final String clientVersion = "1.0.0";
private final String clientBuild = "230601";
private final String clientVersion = "0.0.1";
private final String clientBuild = "061723";
private NotificationManager notificationManager;
private AccountManager accountManager;
@ -167,8 +166,6 @@ public class Athena {
}
}
/**
* Cleans up and shuts down the client.
* This method is responsible for any necessary cleanup tasks,
@ -177,4 +174,16 @@ public class Athena {
public void shutdownClient() {
log.info("Shutting down client");
}
public String getClientBuild() {
return clientBuild;
}
public String getClientName() {
return clientName;
}
public String getClientVersion() {
return clientVersion;
}
}

View File

@ -9,8 +9,8 @@ public class Settings extends Module {
@ConfigValue.Boolean(name = "F5 Nametags", description = "Shows your own nametags in f5 mode")
public boolean F5Nametags = true;
@ConfigValue.Boolean(name = "Show Logo On Tab")
public boolean showLogoOnTab = true;
@ConfigValue.Boolean(name = "Render Socket Logo")
public static boolean socketLogo = true;
@ConfigValue.Boolean(name = "Custom GUI Font")
public static boolean customGuiFont = true;

View File

@ -1,60 +0,0 @@
package rip.athena.client.server;
import com.google.gson.Gson;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
/**
* @author Athena Development
* @project Athena-Client
* @date 6/12/2023
*/
@WebSocket
public class CosmeticsClient {
private Session session;
public void connect(String serverUri) throws URISyntaxException {
WebSocketClient client = new WebSocketClient();
try {
client.start();
URI uri = new URI(serverUri);
client.connect(this, uri);
} catch (Exception e) {
e.printStackTrace();
}
}
@OnWebSocketConnect
public void onConnect(Session session) {
System.out.println("Connected to server");
this.session = session;
}
@OnWebSocketMessage
public void onMessage(String message) {
System.out.println("Received message from server: " + message);
}
@OnWebSocketClose
public void onClose(int statusCode, String reason) {
System.out.println("Connection closed: " + reason);
}
public void sendMessage(String message) {
try {
session.getRemote().sendString(message);
} catch (IOException e) {
e.printStackTrace();
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
{"stat.walkOneCm":4352,"stat.leaveGame":3,"stat.mobKills":1,"stat.useItem.minecraft.diamond_sword":4,"stat.flyOneCm":1063,"stat.jump":8,"stat.playOneMinute":30933,"stat.damageDealt":370,"stat.killEntity.Zombie":1,"stat.timeSinceDeath":30933,"stat.sprintOneCm":1702,"stat.useItem.minecraft.spawn_egg":1,"achievement.exploreAllBiomes":{"value":0,"progress":["DesertHills"]}}
{"stat.walkOneCm":4352,"stat.leaveGame":4,"stat.mobKills":1,"stat.useItem.minecraft.diamond_sword":4,"stat.flyOneCm":1063,"stat.jump":8,"stat.playOneMinute":31238,"stat.damageDealt":370,"stat.killEntity.Zombie":1,"stat.timeSinceDeath":31238,"stat.sprintOneCm":1702,"stat.useItem.minecraft.spawn_egg":1,"achievement.exploreAllBiomes":{"value":0,"progress":["DesertHills","Desert"]}}

View File

@ -0,0 +1,3 @@
Account:CRACKED:t:0:0
Account:MICROSOFT:ziue:74e897386c9e4f5983efd365849e6049:M.C107_BL2.-CYIxeKF*QQ5SaDfkCjXtB7w63z4jGDwTp6AxR9Jp5JvEZ7Bm9muXbEDR47!n8m9Zwyzeq95!*8g9Xyvvkg8cZHzR44lYjk04zMKx5xEk2V4eZdi5y9Zsob1Qzrg1BvoWiF0Erk3AIFiAUhnbGeONv6UMKQ*VTYpAQADACC8pNa4TIgyqTqlDiQiGZDwbMAphYcfhe7ZEEf8bblcyKILbgkEJrmkjV1OTtPA0XnsYBhe57iZWVpcRFHfmSbPfMibmeqMOz*9X4Zr45hJZi3cScc4$
Current:ziue

File diff suppressed because one or more lines are too long