start(String url)
55 | {
56 | if (this.future != null) {
57 | return this.future;
58 | }
59 |
60 | this.future = new CompletableFuture<>();
61 | this.addWindowListener(new WindowAdapter() {
62 | @Override
63 | public void windowClosing(WindowEvent e) {
64 | if(!completed)
65 | future.complete(null);
66 | }
67 | });
68 |
69 | Platform.runLater(() -> this.init(url));
70 | return this.future;
71 | }
72 |
73 | protected void init(String url)
74 | {
75 | WebView webView = new WebView();
76 | JFXPanel content = (JFXPanel) this.getContentPane();
77 |
78 | content.setScene(new Scene(webView, this.getWidth(), this.getHeight()));
79 |
80 | webView.getEngine().locationProperty().addListener((observable, oldValue, newValue) -> {
81 | if (newValue.contains("access_token")) {
82 | this.future.complete(newValue);
83 | completed = true;
84 | this.dispose();
85 | }
86 | });
87 | 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");
88 | webView.getEngine().load(url);
89 |
90 | this.setVisible(true);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/MicrosoftAuthResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft;
20 |
21 | import fr.litarvan.openauth.microsoft.model.response.MinecraftProfile;
22 |
23 | /**
24 | * Microsoft authentication result
25 | *
26 | *
27 | * This class contains the result of a successful Microsoft authentication: a player profile and its tokens (both
28 | * access and refresh token).
29 | *
30 | *
31 | * @author Litarvan
32 | * @version 1.1.5
33 | */
34 | public class MicrosoftAuthResult
35 | {
36 | private final MinecraftProfile profile;
37 | private final String accessToken;
38 | private final String refreshToken;
39 | private final String xuid;
40 | private final String clientId;
41 |
42 | public MicrosoftAuthResult(MinecraftProfile profile, String accessToken, String refreshToken, String xuid, String clientId)
43 | {
44 | this.profile = profile;
45 | this.accessToken = accessToken;
46 | this.refreshToken = refreshToken;
47 | this.xuid = xuid;
48 | this.clientId = clientId;
49 | }
50 |
51 | /**
52 | * @return The player Minecraft profile (contains its UUID and username)
53 | */
54 | public MinecraftProfile getProfile()
55 | {
56 | return profile;
57 | }
58 |
59 | /**
60 | * @return The Minecraft access token
61 | */
62 | public String getAccessToken()
63 | {
64 | return accessToken;
65 | }
66 |
67 | /**
68 | * @return The Microsoft refresh token that can be used to log the user back silently using
69 | * {@link MicrosoftAuthenticator#loginWithRefreshToken(String)}
70 | */
71 | public String getRefreshToken()
72 | {
73 | return refreshToken;
74 | }
75 |
76 | /**
77 | * @return The XUID of the player
78 | */
79 | public String getXuid()
80 | {
81 | return this.xuid;
82 | }
83 |
84 | /**
85 | * @return The client ID of the player
86 | */
87 | public String getClientId()
88 | {
89 | return this.clientId;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/MicrosoftAuthenticationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft;
20 |
21 | import java.io.IOException;
22 |
23 | public class MicrosoftAuthenticationException extends Exception
24 | {
25 | public MicrosoftAuthenticationException(String message)
26 | {
27 | super(message);
28 | }
29 |
30 | public MicrosoftAuthenticationException(IOException cause)
31 | {
32 | super("I/O exception thrown during Microsoft HTTP requests", cause);
33 | }
34 |
35 | public MicrosoftAuthenticationException(Throwable cause)
36 | {
37 | super(cause);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/MicrosoftAuthenticator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft;
20 |
21 | /*
22 | * Ported from the amazing work of Alexis Bize on @xboxreplay/xboxlive-auth
23 | *
24 | * https://github.com/Alexis-Bize
25 | * https://github.com/XboxReplay/xboxlive-auth
26 | */
27 |
28 | import fr.litarvan.openauth.microsoft.model.request.MinecraftLoginRequest;
29 | import fr.litarvan.openauth.microsoft.model.request.XSTSAuthorizationProperties;
30 | import fr.litarvan.openauth.microsoft.model.request.XboxLiveLoginProperties;
31 | import fr.litarvan.openauth.microsoft.model.request.XboxLoginRequest;
32 | import fr.litarvan.openauth.microsoft.model.response.*;
33 |
34 | import java.io.UnsupportedEncodingException;
35 | import java.net.*;
36 | import java.util.Arrays;
37 | import java.util.Base64;
38 | import java.util.HashMap;
39 | import java.util.Map;
40 | import java.util.concurrent.CompletableFuture;
41 | import java.util.concurrent.CompletionException;
42 | import java.util.concurrent.ExecutionException;
43 | import java.util.regex.Matcher;
44 | import java.util.regex.Pattern;
45 |
46 | /**
47 | * Microsoft authenticator
48 | *
49 | *
50 | * This class can be used to authenticate a player using its Microsoft account.
51 | * Use {@link #loginWithCredentials} to retrieve a player profile from his Microsoft credentials,
52 | * or {@link #loginWithWebview} to use a webview with Microsoft login form.
53 | *
54 | *
55 | * @author Litarvan
56 | * @version 1.1.0
57 | */
58 | public class MicrosoftAuthenticator {
59 | public static final String MICROSOFT_AUTHORIZATION_ENDPOINT = "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize";
60 | public static final String MICROSOFT_TOKEN_ENDPOINT = "https://login.live.com/oauth20_token.srf";
61 | public static final String MICROSOFT_REDIRECTION_ENDPOINT = "https://login.live.com/oauth20_desktop.srf";
62 |
63 | public static final String XBOX_LIVE_AUTH_HOST = "user.auth.xboxlive.com";
64 | public static final String XBOX_LIVE_CLIENT_ID = "000000004C12AE6F";
65 | public static final String XBOX_LIVE_SERVICE_SCOPE = "service::user.auth.xboxlive.com::MBI_SSL";
66 |
67 | public static final String XBOX_LIVE_AUTHORIZATION_ENDPOINT = "https://user.auth.xboxlive.com/user/authenticate";
68 | public static final String XSTS_AUTHORIZATION_ENDPOINT = "https://xsts.auth.xboxlive.com/xsts/authorize";
69 | public static final String MINECRAFT_AUTH_ENDPOINT = "https://api.minecraftservices.com/authentication/login_with_xbox";
70 |
71 | public static final String XBOX_LIVE_AUTH_RELAY = "http://auth.xboxlive.com";
72 | public static final String MINECRAFT_AUTH_RELAY = "rp://api.minecraftservices.com/";
73 |
74 | public static final String MINECRAFT_STORE_ENDPOINT = "https://api.minecraftservices.com/entitlements/mcstore";
75 | public static final String MINECRAFT_PROFILE_ENDPOINT = "https://api.minecraftservices.com/minecraft/profile";
76 |
77 | public static final String MINECRAFT_STORE_IDENTIFIER = "game_minecraft";
78 |
79 |
80 | private final HttpClient http;
81 |
82 | public MicrosoftAuthenticator() {
83 | this.http = new HttpClient();
84 | }
85 |
86 | /**
87 | * Logs in a player using its Microsoft account credentials, and retrieve its Minecraft profile
88 | *
89 | * @param email Player Microsoft account e-mail
90 | * @param password Player Microsoft account password
91 | * @return The player Minecraft profile
92 | * @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
93 | */
94 | public MicrosoftAuthResult loginWithCredentials(String email, String password) throws MicrosoftAuthenticationException {
95 | CookieHandler currentHandler = CookieHandler.getDefault();
96 | CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
97 |
98 | Map params = new HashMap<>();
99 | params.put("login", email);
100 | params.put("loginfmt", email);
101 | params.put("passwd", password);
102 |
103 | HttpURLConnection result;
104 |
105 | try {
106 | PreAuthData authData = preAuthRequest();
107 | params.put("PPFT", authData.getPPFT());
108 |
109 | result = http.followRedirects(http.postForm(authData.getUrlPost(), params));
110 | } finally {
111 | CookieHandler.setDefault(currentHandler);
112 | }
113 |
114 | try {
115 | return loginWithTokens(extractTokens(result.getURL().toString()),true);
116 | } catch (MicrosoftAuthenticationException e) {
117 | if (match("(identity/confirm)", http.readResponse(result)) != null) {
118 | throw new MicrosoftAuthenticationException(
119 | "User has enabled double-authentication or must allow sign-in on https://account.live.com/activity"
120 | );
121 | }
122 |
123 | throw e;
124 | }
125 | }
126 |
127 | /**
128 | * Logs in a player using a webview to display Microsoft login page.
129 | * This function blocks the current thread until the process is finished; this can cause your application to
130 | * freeze. When calling from the JavaFX thread or any thread which must not be blocked, use
131 | * {@link #loginWithAsyncWebview()}
132 | *
133 | * @return The player Minecraft profile
134 | * @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
135 | */
136 | public MicrosoftAuthResult loginWithWebview() throws MicrosoftAuthenticationException {
137 | try {
138 | return loginWithAsyncWebview().get();
139 | } catch (InterruptedException | ExecutionException e) {
140 | throw new MicrosoftAuthenticationException(e);
141 | }
142 | }
143 |
144 | /**
145 | * Logs in a player using a webview to display Microsoft login page. This function does not block the current thread.
146 | *
147 | * @return A future resolved by the player Minecraft profile
148 | */
149 | public CompletableFuture loginWithAsyncWebview() {
150 | if(!System.getProperty("java.version").startsWith("1."))
151 | CookieHandler.setDefault(new CookieManager());
152 |
153 | String url = String.format("%s?%s", MICROSOFT_AUTHORIZATION_ENDPOINT, http.buildParams(getLoginParams()));
154 | LoginFrame frame = new LoginFrame();
155 |
156 | return frame.start(url).thenApplyAsync(result -> {
157 | try {
158 | if(result != null)
159 | return loginWithTokens(extractTokens(result),true);
160 | else return null;
161 | } catch (MicrosoftAuthenticationException e) {
162 | throw new CompletionException(e);
163 | }
164 | });
165 | }
166 |
167 | /**
168 | * Logs in a player using a Microsoft account refresh token retrieved earlier.
169 | *
170 | * @param refreshToken Player Microsoft account refresh token
171 | * @return The player Minecraft profile
172 | * @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
173 | */
174 | public MicrosoftAuthResult loginWithRefreshToken(String refreshToken) throws MicrosoftAuthenticationException {
175 | Map params = getLoginParams();
176 | params.put("refresh_token", refreshToken);
177 | params.put("grant_type", "refresh_token");
178 |
179 | MicrosoftRefreshResponse response = http.postFormGetJson(
180 | MICROSOFT_TOKEN_ENDPOINT,
181 | params, MicrosoftRefreshResponse.class
182 | );
183 |
184 | return loginWithTokens(new AuthTokens(response.getAccessToken(), response.getRefreshToken()),true);
185 | }
186 |
187 | /**
188 | * Logs in a player using a Microsoft account tokens retrieved earlier.
189 | * If the token was retrieved using Azure AAD/MSAL, it should be prefixed with d=
190 | *
191 | * @param tokens Player Microsoft account tokens pair
192 | * @return The player Minecraft profile
193 | * @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
194 | */
195 | public MicrosoftAuthResult loginWithTokens(AuthTokens tokens) throws MicrosoftAuthenticationException {
196 | return loginWithTokens(tokens,true);
197 | }
198 |
199 | /**
200 | * Logs in a player using a Microsoft account tokens retrieved earlier.
201 | * If the token was retrieved using Azure AAD/MSAL, it should be prefixed with d=
202 | *
203 | * @param tokens Player Microsoft account tokens pair
204 | * @param retrieveProfile Whether to retrieve the player profile
205 | * @return The player Minecraft profile
206 | * @throws MicrosoftAuthenticationException Thrown if one of the several HTTP requests failed at some point
207 | */
208 | public MicrosoftAuthResult loginWithTokens(AuthTokens tokens, boolean retrieveProfile) throws MicrosoftAuthenticationException {
209 | XboxLoginResponse xboxLiveResponse = xboxLiveLogin(tokens.getAccessToken());
210 | XboxLoginResponse xstsResponse = xstsLogin(xboxLiveResponse.getToken());
211 |
212 | String userHash = xstsResponse.getDisplayClaims().getUsers()[0].getUserHash();
213 | MinecraftLoginResponse minecraftResponse = minecraftLogin(userHash, xstsResponse.getToken());
214 | MinecraftStoreResponse storeResponse = http.getJson(
215 | MINECRAFT_STORE_ENDPOINT,
216 | minecraftResponse.getAccessToken(),
217 | MinecraftStoreResponse.class
218 | );
219 |
220 | if (Arrays.stream(storeResponse.getItems()).noneMatch(item -> item.getName().equals(MINECRAFT_STORE_IDENTIFIER))) {
221 | throw new MicrosoftAuthenticationException("Player didn't buy Minecraft Java Edition or did not migrate its account");
222 | }
223 | MinecraftProfile profile = null;
224 | if (retrieveProfile) {
225 | profile = http.getJson(
226 | MINECRAFT_PROFILE_ENDPOINT,
227 | minecraftResponse.getAccessToken(),
228 | MinecraftProfile.class
229 | );
230 | }
231 |
232 | return new MicrosoftAuthResult(
233 | profile,
234 | minecraftResponse.getAccessToken(),
235 | tokens.getRefreshToken(),
236 | xboxLiveResponse.getDisplayClaims().getUsers()[0].getUserHash(),
237 | Base64.getEncoder().encodeToString(minecraftResponse.getUsername().getBytes())
238 | );
239 | }
240 |
241 |
242 | protected PreAuthData preAuthRequest() throws MicrosoftAuthenticationException {
243 | Map params = getLoginParams();
244 | params.put("display", "touch");
245 | params.put("locale", "en");
246 |
247 | String result = http.getText(MICROSOFT_AUTHORIZATION_ENDPOINT, params);
248 |
249 | String ppft = match("sFTTag:'.*value=\"([^\"]*)\"", result);
250 | String urlPost = match("urlPost: ?'(.+?(?='))", result);
251 |
252 | return new PreAuthData(ppft, urlPost);
253 | }
254 |
255 | protected XboxLoginResponse xboxLiveLogin(String accessToken) throws MicrosoftAuthenticationException {
256 | XboxLiveLoginProperties properties = new XboxLiveLoginProperties("RPS", XBOX_LIVE_AUTH_HOST, accessToken);
257 | XboxLoginRequest request = new XboxLoginRequest<>(
258 | properties, XBOX_LIVE_AUTH_RELAY, "JWT"
259 | );
260 |
261 | return http.postJson(XBOX_LIVE_AUTHORIZATION_ENDPOINT, request, XboxLoginResponse.class);
262 | }
263 |
264 | protected XboxLoginResponse xstsLogin(String xboxLiveToken) throws MicrosoftAuthenticationException {
265 | XSTSAuthorizationProperties properties = new XSTSAuthorizationProperties("RETAIL", new String[]{xboxLiveToken});
266 | XboxLoginRequest request = new XboxLoginRequest<>(
267 | properties, MINECRAFT_AUTH_RELAY, "JWT"
268 | );
269 |
270 | return http.postJson(XSTS_AUTHORIZATION_ENDPOINT, request, XboxLoginResponse.class);
271 | }
272 |
273 | protected MinecraftLoginResponse minecraftLogin(String userHash, String xstsToken) throws MicrosoftAuthenticationException {
274 | MinecraftLoginRequest request = new MinecraftLoginRequest(String.format("XBL3.0 x=%s;%s", userHash, xstsToken));
275 | return http.postJson(MINECRAFT_AUTH_ENDPOINT, request, MinecraftLoginResponse.class);
276 | }
277 |
278 |
279 | protected Map getLoginParams() {
280 | Map params = new HashMap<>();
281 | params.put("client_id", XBOX_LIVE_CLIENT_ID);
282 | params.put("redirect_uri", MICROSOFT_REDIRECTION_ENDPOINT);
283 | params.put("scope", XBOX_LIVE_SERVICE_SCOPE);
284 | params.put("response_type", "token");
285 |
286 | return params;
287 | }
288 |
289 | protected AuthTokens extractTokens(String url) throws MicrosoftAuthenticationException {
290 | return new AuthTokens(extractValue(url, "access_token"), extractValue(url, "refresh_token"));
291 | }
292 |
293 | protected String extractValue(String url, String key) throws MicrosoftAuthenticationException {
294 | String matched = match(key + "=([^&]*)", url);
295 | if (matched == null) {
296 | throw new MicrosoftAuthenticationException("Invalid credentials or tokens");
297 | }
298 |
299 | try {
300 | return URLDecoder.decode(matched, "UTF-8");
301 | } catch (UnsupportedEncodingException e) {
302 | throw new MicrosoftAuthenticationException(e);
303 | }
304 | }
305 |
306 | protected String match(String regex, String content) {
307 | Matcher matcher = Pattern.compile(regex).matcher(content);
308 | if (!matcher.find()) {
309 | return null;
310 | }
311 |
312 | return matcher.group(1);
313 | }
314 | }
315 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/PreAuthData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft;
20 |
21 | public class PreAuthData
22 | {
23 | private final String ppft;
24 | private final String urlPost;
25 |
26 | public PreAuthData(String ppft, String urlPost)
27 | {
28 | this.ppft = ppft;
29 | this.urlPost = urlPost;
30 | }
31 |
32 | public String getPPFT()
33 | {
34 | return ppft;
35 | }
36 |
37 | public String getUrlPost()
38 | {
39 | return urlPost;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/model/request/MinecraftLoginRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft.model.request;
20 |
21 | public class MinecraftLoginRequest
22 | {
23 | private final String identityToken;
24 |
25 | public MinecraftLoginRequest(String identityToken)
26 | {
27 | this.identityToken = identityToken;
28 | }
29 |
30 | public String getIdentityToken()
31 | {
32 | return identityToken;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/model/request/XSTSAuthorizationProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft.model.request;
20 |
21 | public class XSTSAuthorizationProperties
22 | {
23 | private final String SandboxId;
24 | private final String[] UserTokens;
25 |
26 | public XSTSAuthorizationProperties(String SandboxId, String[] UserTokens)
27 | {
28 | this.SandboxId = SandboxId;
29 | this.UserTokens = UserTokens;
30 | }
31 |
32 | public String getSandboxId()
33 | {
34 | return SandboxId;
35 | }
36 |
37 | public String[] getUserTokens()
38 | {
39 | return UserTokens;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/model/request/XboxLiveLoginProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft.model.request;
20 |
21 | public class XboxLiveLoginProperties
22 | {
23 | private final String AuthMethod;
24 | private final String SiteName;
25 | private final String RpsTicket;
26 |
27 | public XboxLiveLoginProperties(String AuthMethod, String SiteName, String RpsTicket)
28 | {
29 | this.AuthMethod = AuthMethod;
30 | this.SiteName = SiteName;
31 | this.RpsTicket = RpsTicket;
32 | }
33 |
34 | public String getAuthMethod()
35 | {
36 | return AuthMethod;
37 | }
38 |
39 | public String getSiteName()
40 | {
41 | return SiteName;
42 | }
43 |
44 | public String getRpsTicket()
45 | {
46 | return RpsTicket;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/model/request/XboxLoginRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft.model.request;
20 |
21 | public class XboxLoginRequest
22 | {
23 | private final T Properties;
24 | private final String RelyingParty;
25 | private final String TokenType;
26 |
27 | public XboxLoginRequest(T Properties, String RelyingParty, String TokenType)
28 | {
29 | this.Properties = Properties;
30 | this.RelyingParty = RelyingParty;
31 | this.TokenType = TokenType;
32 | }
33 |
34 | public T getProperties()
35 | {
36 | return Properties;
37 | }
38 |
39 | public String getSiteName()
40 | {
41 | return RelyingParty;
42 | }
43 |
44 | public String getTokenType()
45 | {
46 | return TokenType;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/model/response/MicrosoftRefreshResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft.model.response;
20 |
21 | public class MicrosoftRefreshResponse
22 | {
23 | private final String token_type;
24 | private final long expires_in;
25 | private final String scope;
26 | private final String access_token;
27 | private final String refresh_token;
28 | private final String user_id;
29 |
30 | public MicrosoftRefreshResponse(String token_type, long expires_in, String scope, String access_token, String refresh_token, String user_id)
31 | {
32 | this.token_type = token_type;
33 | this.expires_in = expires_in;
34 | this.scope = scope;
35 | this.access_token = access_token;
36 | this.refresh_token = refresh_token;
37 | this.user_id = user_id;
38 | }
39 |
40 | public String getTokenType()
41 | {
42 | return token_type;
43 | }
44 |
45 | public long getExpiresIn()
46 | {
47 | return expires_in;
48 | }
49 |
50 | public String getScope()
51 | {
52 | return scope;
53 | }
54 |
55 | public String getAccessToken()
56 | {
57 | return access_token;
58 | }
59 |
60 | public String getRefreshToken()
61 | {
62 | return refresh_token;
63 | }
64 |
65 | public String getUserId()
66 | {
67 | return user_id;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/model/response/MinecraftLoginResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft.model.response;
20 |
21 | public class MinecraftLoginResponse
22 | {
23 | private final String username;
24 | private final String access_token;
25 | private final String token_type;
26 | private final long expires_in;
27 |
28 | public MinecraftLoginResponse(String username, String access_token, String token_type, long expires_in)
29 | {
30 | this.username = username;
31 | this.access_token = access_token;
32 | this.token_type = token_type;
33 | this.expires_in = expires_in;
34 | }
35 |
36 | public String getUsername()
37 | {
38 | return username;
39 | }
40 |
41 | public String getAccessToken()
42 | {
43 | return access_token;
44 | }
45 |
46 | public String getTokenType()
47 | {
48 | return token_type;
49 | }
50 |
51 | public long getExpiresIn()
52 | {
53 | return expires_in;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/model/response/MinecraftProfile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft.model.response;
20 |
21 | /**
22 | * Minecraft player profile
23 | *
24 | *
25 | * Represents a Minecraft player profile data. UUID is {@link #id} and username is {@link #name}.
26 | *
27 | *
28 | * @version 1.1.0
29 | * @author Litarvan
30 | */
31 | public class MinecraftProfile
32 | {
33 | private final String id;
34 | private final String name;
35 | private final MinecraftSkin[] skins;
36 |
37 | public MinecraftProfile(String id, String name, MinecraftSkin[] skins)
38 | {
39 | this.id = id;
40 | this.name = name;
41 | this.skins = skins;
42 | }
43 |
44 | /**
45 | * @return The player Minecraft UUID
46 | */
47 | public String getId()
48 | {
49 | return id;
50 | }
51 |
52 | /**
53 | * @return The player Minecraft username
54 | */
55 | public String getName()
56 | {
57 | return name;
58 | }
59 |
60 | public MinecraftSkin[] getSkins()
61 | {
62 | return skins;
63 | }
64 |
65 | public static class MinecraftSkin
66 | {
67 | private final String id;
68 | private final String state;
69 | private final String url;
70 | private final String variant;
71 | private final String alias;
72 |
73 | public MinecraftSkin(String id, String state, String url, String variant, String alias)
74 | {
75 | this.id = id;
76 | this.state = state;
77 | this.url = url;
78 | this.variant = variant;
79 | this.alias = alias;
80 | }
81 |
82 | public String getId()
83 | {
84 | return id;
85 | }
86 |
87 | public String getState()
88 | {
89 | return state;
90 | }
91 |
92 | public String getUrl()
93 | {
94 | return url;
95 | }
96 |
97 | public String getVariant()
98 | {
99 | return variant;
100 | }
101 |
102 | public String getAlias()
103 | {
104 | return alias;
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/model/response/MinecraftStoreResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft.model.response;
20 |
21 | public class MinecraftStoreResponse
22 | {
23 | private final StoreProduct[] items;
24 | private final String signature;
25 | private final String keyId;
26 |
27 | public MinecraftStoreResponse(StoreProduct[] items, String signature, String keyId)
28 | {
29 | this.items = items;
30 | this.signature = signature;
31 | this.keyId = keyId;
32 | }
33 |
34 | public StoreProduct[] getItems()
35 | {
36 | return items;
37 | }
38 |
39 | public String getSignature()
40 | {
41 | return signature;
42 | }
43 |
44 | public String getKeyId()
45 | {
46 | return keyId;
47 | }
48 |
49 | public static class StoreProduct
50 | {
51 | private final String name;
52 | private final String signature;
53 |
54 | public StoreProduct(String name, String signature)
55 | {
56 | this.name = name;
57 | this.signature = signature;
58 | }
59 |
60 | public String getName()
61 | {
62 | return name;
63 | }
64 |
65 | public String getSignature()
66 | {
67 | return signature;
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/microsoft/model/response/XboxLoginResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 Adrien 'Litarvan' Navratil
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.microsoft.model.response;
20 |
21 | public class XboxLoginResponse
22 | {
23 | private final String IssueInstant;
24 | private final String NotAfter;
25 | private final String Token;
26 | private final XboxLiveLoginResponseClaims DisplayClaims;
27 |
28 | public XboxLoginResponse(String IssueInstant, String NotAfter, String Token, XboxLiveLoginResponseClaims DisplayClaims)
29 | {
30 | this.IssueInstant = IssueInstant;
31 | this.NotAfter = NotAfter;
32 | this.Token = Token;
33 | this.DisplayClaims = DisplayClaims;
34 | }
35 |
36 | public String getIssueInstant()
37 | {
38 | return IssueInstant;
39 | }
40 |
41 | public String getNotAfter()
42 | {
43 | return NotAfter;
44 | }
45 |
46 | public String getToken()
47 | {
48 | return Token;
49 | }
50 |
51 | public XboxLiveLoginResponseClaims getDisplayClaims()
52 | {
53 | return DisplayClaims;
54 | }
55 |
56 | public static class XboxLiveLoginResponseClaims
57 | {
58 | private final XboxLiveUserInfo[] xui;
59 |
60 | public XboxLiveLoginResponseClaims(XboxLiveUserInfo[] xui)
61 | {
62 | this.xui = xui;
63 | }
64 |
65 | public XboxLiveUserInfo[] getUsers()
66 | {
67 | return xui;
68 | }
69 | }
70 |
71 | public static class XboxLiveUserInfo
72 | {
73 | private final String uhs;
74 |
75 | public XboxLiveUserInfo(String uhs)
76 | {
77 | this.uhs = uhs;
78 | }
79 |
80 | public String getUserHash()
81 | {
82 | return uhs;
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/model/AuthAgent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 TheShark34
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.model;
20 |
21 | /**
22 | * JSON model of an auth agent
23 | *
24 | * @version 1.0.4
25 | * @author Litarvan
26 | */
27 | public class AuthAgent {
28 |
29 | /**
30 | * The Minecraft auth agent
31 | */
32 | public static final AuthAgent MINECRAFT = new AuthAgent("Minecraft", 1);
33 |
34 | /**
35 | * The Scroll auth agent
36 | */
37 | public static final AuthAgent SCROLLS = new AuthAgent("Scrolls", 1);
38 |
39 | /**
40 | * The agent name
41 | */
42 | private String name;
43 |
44 | /**
45 | * The agent version
46 | */
47 | private int version;
48 |
49 | /**
50 | * Agent constructor
51 | *
52 | * @param name
53 | * The name of the agent
54 | * @param version
55 | * The version of the agent (1 by default)
56 | */
57 | public AuthAgent(String name, int version) {
58 | this.name = name;
59 | this.version = version;
60 | }
61 |
62 | /**
63 | * Sets a new name
64 | *
65 | * @param name
66 | * The new name
67 | */
68 | public void setName(String name) {
69 | this.name = name;
70 | }
71 |
72 | /**
73 | * Returns the name of the agent
74 | *
75 | * @return The agent name
76 | */
77 | public String getName() {
78 | return this.name;
79 | }
80 |
81 | /**
82 | * Sets a new version
83 | *
84 | * @param version
85 | * The new version
86 | */
87 | public void setVersion(int version) {
88 | this.version = version;
89 | }
90 |
91 | /**
92 | * Returns the version of the agent
93 | *
94 | * @return The agent version
95 | */
96 | public int getVersion() {
97 | return this.version;
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/model/AuthError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 TheShark34
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.model;
20 |
21 | /**
22 | * JSON model of an error
23 | *
24 | * @version 1.0.4
25 | * @author Litarvan
26 | */
27 | public class AuthError {
28 |
29 | /**
30 | * Short description of the error
31 | */
32 | private String error;
33 |
34 | /**
35 | * Longer description wich can be shown to the user
36 | */
37 | private String errorMessage;
38 |
39 | /**
40 | * Cause of the error (optional)
41 | */
42 | private String cause;
43 |
44 | /**
45 | * Auth Error constructor
46 | *
47 | * @param error
48 | * Short description of the error
49 | * @param errorMessage
50 | * Longer description wich can be shown to the user
51 | * @param cause
52 | * Cause of the error
53 | */
54 | public AuthError(String error, String errorMessage, String cause) {
55 | this.error = error;
56 | this.errorMessage = errorMessage;
57 | this.cause = cause;
58 | }
59 |
60 | /**
61 | * Returns the error (Short description of the error)
62 | *
63 | * @return The error
64 | */
65 | public String getError() {
66 | return error;
67 | }
68 |
69 | /**
70 | * Returns the error message (Longer description of the error)
71 | *
72 | * @return The error message
73 | */
74 | public String getErrorMessage() {
75 | return this.errorMessage;
76 | }
77 |
78 | /**
79 | * Returns the cause of the error
80 | *
81 | * @return The cause
82 | */
83 | public String getCause() {
84 | return cause;
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/model/AuthProfile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 TheShark34
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.model;
20 |
21 | /**
22 | * JSON model of a profile
23 | *
24 | * @version 1.0.4
25 | * @author Litarvan
26 | */
27 | public class AuthProfile {
28 |
29 | /**
30 | * The profile name
31 | */
32 | private String name;
33 |
34 | /**
35 | * The profile UUID
36 | */
37 | private String id;
38 |
39 | /**
40 | * Blank auth profile
41 | */
42 | public AuthProfile() {
43 | this.name = "";
44 | this.id = "";
45 | }
46 |
47 | /**
48 | * Normal auth profile
49 | *
50 | * @param name
51 | * The profile name
52 | * @param id
53 | * The profile UUID
54 | */
55 | public AuthProfile(String name, String id) {
56 | this.name = name;
57 | this.id = id;
58 | }
59 |
60 | /**
61 | * Returns the name of the profile
62 | *
63 | * @return The profile name
64 | */
65 | public String getName() {
66 | return this.name;
67 | }
68 |
69 | /**
70 | * Returns the profile UUID
71 | *
72 | * @return The profile UUID
73 | */
74 | public String getId() {
75 | return this.id;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/model/request/AuthRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 TheShark34
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.model.request;
20 |
21 | import fr.litarvan.openauth.model.AuthAgent;
22 |
23 | /**
24 | * JSON Model of an authentication request
25 | *
26 | * @version 1.0.4
27 | * @author Litarvan
28 | */
29 | public class AuthRequest {
30 |
31 | /**
32 | * The authentication agent (Optional, the game profile you want to use, Minecraft, Scrolls, etc...)
33 | */
34 | private AuthAgent agent;
35 |
36 | /**
37 | * The username (The username of the player you want to authenticate)
38 | */
39 | private String username;
40 |
41 | /**
42 | * The password (The password of the player you want to authenticate)
43 | */
44 | private String password;
45 |
46 | /**
47 | * The client token (Optional, it's like a password for the access token)
48 | */
49 | private String clientToken;
50 |
51 | /**
52 | * Authentication Request
53 | *
54 | * @param agent
55 | * The authentication agent (Optional, the game you want to use, Minecraft, Scrolls, etc...)
56 | * @param username
57 | * The username (The username of the player you want to authenticate)
58 | * @param password
59 | * The password (The password of the player you want to authenticate)
60 | * @param clientToken
61 | * The client token (Optional, It's like a password for the access token)
62 | */
63 | public AuthRequest(AuthAgent agent, String username, String password, String clientToken) {
64 | this.agent = agent;
65 | this.username = username;
66 | this.password = password;
67 | this.clientToken = clientToken;
68 | }
69 |
70 | /**
71 | * Sets a new authentication agent (Optional, the game you want to use, Minecraft, Scrolls, etc...)
72 | *
73 | * @param agent
74 | * The new agent
75 | */
76 | public void setAgent(AuthAgent agent) {
77 | this.agent = agent;
78 | }
79 |
80 | /**
81 | * Returns the authentication agent (Given with the constructor or the setter)
82 | *
83 | * @return The given auth agent
84 | */
85 | public AuthAgent getAgent() {
86 | return this.agent;
87 | }
88 |
89 | /**
90 | * Sets a new username (The username of the player you want to authenticate)
91 | *
92 | * @param username
93 | * The new username
94 | */
95 | public void setUsername(String username) {
96 | this.username = username;
97 | }
98 |
99 | /**
100 | * Returns the username (Given with the constructor or the setter)
101 | *
102 | * @return The given username
103 | */
104 | public String getUsername() {
105 | return this.username;
106 | }
107 |
108 | /**
109 | * Sets a new password (The password of the player you want to authenticate)
110 | *
111 | * @param password
112 | * The new password
113 | */
114 | public void setPassword(String password) {
115 | this.password = password;
116 | }
117 |
118 | /**
119 | * Returns the password (Given with the constructor or the setter)
120 | *
121 | * @return The given password
122 | */
123 | public String getPassword() {
124 | return this.password;
125 | }
126 |
127 | /**
128 | * Sets a new client token (It's like a password for the access token)
129 | *
130 | * @param clientToken
131 | * The new client token
132 | */
133 | public void setClientToken(String clientToken) {
134 | this.clientToken = clientToken;
135 | }
136 |
137 | /**
138 | * Returns the client token (Given with the constructor or the setter)
139 | *
140 | * @return The given client token
141 | */
142 | public String getClientToken() {
143 | return clientToken;
144 | }
145 |
146 | }
147 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/model/request/InvalidateRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 TheShark34
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.model.request;
20 |
21 | /**
22 | * JSON Model of an invalidate request
23 | *
24 | * @version 1.0.4
25 | * @author Litarvan
26 | */
27 | public class InvalidateRequest {
28 |
29 | /**
30 | * The access token you want to invalidate
31 | */
32 | private String accessToken;
33 |
34 | /**
35 | * The client token associated with the access token
36 | */
37 | private String clientToken;
38 |
39 | /**
40 | * Invalidate Request constructor
41 | *
42 | * @param accessToken
43 | * The access token you want to invalidate
44 | * @param clientToken
45 | * The client token associated with the access token
46 | */
47 | public InvalidateRequest(String accessToken, String clientToken) {
48 | this.accessToken = accessToken;
49 | this.clientToken = clientToken;
50 | }
51 |
52 | /**
53 | * Sets a new access token (That you want to invalidate)
54 | *
55 | * @param accessToken
56 | * The new access token
57 | */
58 | public void setAccessToken(String accessToken) {
59 | this.accessToken = accessToken;
60 | }
61 |
62 | /**
63 | * Returns the access token (Given by the constructor or the setter)
64 | *
65 | * @return The given access token
66 | */
67 | public String getAccessToken() {
68 | return this.accessToken;
69 | }
70 |
71 | /**
72 | * Sets a new client token (Need to be associated with the access token)
73 | *
74 | * @param clientToken
75 | * The new client token
76 | */
77 | public void setClientToken(String clientToken) {
78 | this.clientToken = clientToken;
79 | }
80 |
81 | /**
82 | * Returns the client token (Given by the constructor or the setter)
83 | *
84 | * @return The given client token
85 | */
86 | public String getClientToken() {
87 | return clientToken;
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/model/request/RefreshRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 TheShark34
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.model.request;
20 |
21 | /**
22 | * JSON model of a refresh request
23 | *
24 | * @version 1.0.4
25 | * @author Litarvan
26 | */
27 | public class RefreshRequest {
28 |
29 | /**
30 | * The saved access token that you want to refresh
31 | */
32 | private String accessToken;
33 |
34 | /**
35 | * The saved client token associated with the access token
36 | */
37 | private String clientToken;
38 |
39 | /**
40 | * Refresh Request constructor
41 | *
42 | * @param accessToken
43 | * The saved access token that you want to refresh
44 | * @param clientToken
45 | * The saved client token associated with the access token
46 | */
47 | public RefreshRequest(String accessToken, String clientToken) {
48 | this.accessToken = accessToken;
49 | this.clientToken = clientToken;
50 | }
51 |
52 | /**
53 | * Sets a new access token (That you want to refresh)
54 | *
55 | * @param accessToken
56 | * The new access token
57 | */
58 | public void setAccessToken(String accessToken) {
59 | this.accessToken = accessToken;
60 | }
61 |
62 | /**
63 | * Returns the access token (Given by the constructor or the setter)
64 | *
65 | * @return The given access token
66 | */
67 | public String getAccessToken() {
68 | return this.accessToken;
69 | }
70 |
71 | /**
72 | * Sets a new client token (Need to be associated with the access token)
73 | *
74 | * @param clientToken
75 | * The new client token
76 | */
77 | public void setClientToken(String clientToken) {
78 | this.clientToken = clientToken;
79 | }
80 |
81 | /**
82 | * Returns the client token (Given by the constructor or the setter)
83 | *
84 | * @return The given client token
85 | */
86 | public String getClientToken() {
87 | return this.clientToken;
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/model/request/SignoutRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 TheShark34
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.model.request;
20 |
21 | /**
22 | * JSON Model of an signout request
23 | *
24 | * @version 1.0.4
25 | * @author Litarvan
26 | */
27 | public class SignoutRequest {
28 |
29 | /**
30 | * The username of the player that you want to signout
31 | */
32 | private String username;
33 |
34 | /**
35 | * The password of the player that you want to signout
36 | */
37 | private String password;
38 |
39 | /**
40 | * Signout Request constructor
41 | *
42 | * @param username
43 | * The username of the player that you want to signout
44 | * @param password
45 | * The password of the player that you want to signout
46 | */
47 | public SignoutRequest(String username, String password) {
48 | this.username = username;
49 | this.password = password;
50 | }
51 |
52 | /**
53 | * Sets a new username (Of the player that you want to signout)
54 | *
55 | * @param username
56 | * The new username
57 | */
58 | public void setUsername(String username) {
59 | this.username = username;
60 | }
61 |
62 | /**
63 | * Returns the username (Given by the constructor or the setter)
64 | *
65 | * @return The given username
66 | */
67 | public String getUsername() {
68 | return this.username;
69 | }
70 |
71 | /**
72 | * Sets a new password (Of the player that you want to signout)
73 | *
74 | * @param password
75 | * The new password
76 | */
77 | public void setPassword(String password) {
78 | this.password = password;
79 | }
80 |
81 | /**
82 | * Returns the password (Given by the constructor or the setter)
83 | *
84 | * @return The given password
85 | */
86 | public String getPassword() {
87 | return password;
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/model/request/ValidateRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 TheShark34
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.model.request;
20 |
21 | /**
22 | * JSON Model of an validate request
23 | *
24 | * @version 1.0.4
25 | * @author Litarvan
26 | */
27 | public class ValidateRequest {
28 |
29 | /**
30 | * The access token that you want to validate
31 | */
32 | private String accessToken;
33 |
34 | /**
35 | * Validate Request constructor
36 | *
37 | * @param accessToken
38 | * The access token that you want to validate
39 | */
40 | public ValidateRequest(String accessToken) {
41 | this.accessToken = accessToken;
42 | }
43 |
44 | /**
45 | * Sets a new access token
46 | *
47 | * @param accessToken
48 | * The new access token
49 | */
50 | public void setAccessToken(String accessToken) {
51 | this.accessToken = accessToken;
52 | }
53 |
54 | /**
55 | * Returns the access token (Given by the constructor or the setter)
56 | *
57 | * @return The given access token
58 | */
59 | public String getAccessToken() {
60 | return accessToken;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/model/response/AuthResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 TheShark34
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.model.response;
20 |
21 | import fr.litarvan.openauth.model.AuthProfile;
22 |
23 | /**
24 | * JSON Model of an authentication response
25 | *
26 | * @version 1.0.4
27 | * @author Litarvan
28 | */
29 | public class AuthResponse {
30 |
31 | /**
32 | * The access token
33 | */
34 | private String accessToken;
35 |
36 | /**
37 | * The client token (same as the one given by the request)
38 | */
39 | private String clientToken;
40 |
41 | /**
42 | * All available profiles
43 | */
44 | private AuthProfile[] availableProfiles;
45 |
46 | /**
47 | * The current selected profile from the agent
48 | */
49 | private AuthProfile selectedProfile;
50 |
51 | /**
52 | * Auth Response constructor
53 | *
54 | * @param accessToken
55 | * The access token
56 | * @param clientToken
57 | * The client token (same as the one given by the request)
58 | * @param availableProfiles
59 | * All available profiles
60 | * @param selectedProfile
61 | * The current selected profile from the agent
62 | */
63 | public AuthResponse(String accessToken, String clientToken, AuthProfile[] availableProfiles, AuthProfile selectedProfile) {
64 | this.accessToken = accessToken;
65 | this.clientToken = clientToken;
66 | this.availableProfiles = availableProfiles;
67 | this.selectedProfile = selectedProfile;
68 | }
69 |
70 | /**
71 | * Returns the access token
72 | *
73 | * @return The access token
74 | */
75 | public String getAccessToken() {
76 | return this.accessToken;
77 | }
78 |
79 | /**
80 | * Returns the client token (same as the one given by the request)
81 | *
82 | * @return The client token
83 | */
84 | public String getClientToken() {
85 | return this.clientToken;
86 | }
87 |
88 | /**
89 | * Returns the available profiles
90 | *
91 | * @return The available profiles
92 | */
93 | public AuthProfile[] getAvailableProfiles() {
94 | return this.availableProfiles;
95 | }
96 |
97 | /**
98 | * Returns the selected profile from the agent
99 | *
100 | * @return The selected profile
101 | */
102 | public AuthProfile getSelectedProfile() {
103 | return this.selectedProfile;
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/main/java/fr/litarvan/openauth/model/response/RefreshResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 TheShark34
3 | *
4 | * This file is part of OpenAuth.
5 |
6 | * OpenAuth is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * OpenAuth is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with OpenAuth. If not, see .
18 | */
19 | package fr.litarvan.openauth.model.response;
20 |
21 | import fr.litarvan.openauth.model.AuthProfile;
22 |
23 | /**
24 | * JSON Model of an refresh response
25 | *
26 | * @version 1.0.4
27 | * @author Litarvan
28 | */
29 | public class RefreshResponse {
30 |
31 | /**
32 | * The access token (not the same as the one given by the request)
33 | */
34 | private String accessToken;
35 |
36 | /**
37 | * The client token (same as the one given by the request)
38 | */
39 | private String clientToken;
40 |
41 | /**
42 | * The selected profile
43 | */
44 | private AuthProfile selectedProfile;
45 |
46 | /**
47 | * Refresh Response constructor
48 | *
49 | * @param accessToken
50 | * The access token (not the same as the one given by the request)
51 | * @param clientToken
52 | * The client token (same as the one given by the request)
53 | * @param selectedProfile
54 | * The profile selected (depending of the sent AuthAgent) containing
55 | * more information about the agent (the game) selected, like the
56 | * username for Minecraft
57 | */
58 | public RefreshResponse(String accessToken, String clientToken, AuthProfile selectedProfile) {
59 | this.accessToken = accessToken;
60 | this.clientToken = clientToken;
61 | this.selectedProfile = selectedProfile;
62 | }
63 |
64 | /**
65 | * Returns the access token (not the same as the one given by the request)
66 | *
67 | * @return The access token
68 | */
69 | public String getAccessToken() {
70 | return accessToken;
71 | }
72 |
73 | /**
74 | * Returns the client token (same as the one given by the request)
75 | *
76 | * @return The client token
77 | */
78 | public String getClientToken() {
79 | return clientToken;
80 | }
81 |
82 | /**
83 | * Returns the selected profile
84 | *
85 | * @return The selected profile
86 | */
87 | public AuthProfile getSelectedProfile() {
88 | return selectedProfile;
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------