mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[ANY] Remove deprecated
This commit is contained in:
parent
bf1967f32b
commit
83ae8a7e72
1 changed files with 36 additions and 52 deletions
|
@ -20,8 +20,6 @@ public abstract class Request<R extends WebSocketEvent> implements WebSocketRequ
|
|||
@Deprecated
|
||||
public static StdWebSocketService service;
|
||||
private static RequestService requestService;
|
||||
@Deprecated
|
||||
private static UUID session;
|
||||
private static AuthRequestEvent.OAuthRequestEvent oauth;
|
||||
private static Map<String, String> extendedTokens;
|
||||
private static String authId;
|
||||
|
@ -45,16 +43,6 @@ public static boolean isAvailable() {
|
|||
return requestService != null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static UUID getSession() {
|
||||
return Request.session;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void setSession(UUID session) {
|
||||
Request.session = session;
|
||||
}
|
||||
|
||||
public static void setOAuth(String authId, AuthRequestEvent.OAuthRequestEvent event) {
|
||||
oauth = event;
|
||||
Request.authId = authId;
|
||||
|
@ -146,48 +134,44 @@ public RequestRestoreReport(boolean legacySession, boolean refreshed, List<Strin
|
|||
}
|
||||
|
||||
public static RequestRestoreReport restore() throws Exception {
|
||||
if (session != null) {
|
||||
throw new UnsupportedOperationException("Legacy session system not supported");
|
||||
boolean refreshed = false;
|
||||
RestoreRequest request;
|
||||
if(oauth != null) {
|
||||
if (isTokenExpired() || oauth.accessToken == null) {
|
||||
RefreshTokenRequest refreshRequest = new RefreshTokenRequest(authId, oauth.refreshToken);
|
||||
RefreshTokenRequestEvent event = refreshRequest.request();
|
||||
setOAuth(authId, event.oauth);
|
||||
refreshed = true;
|
||||
}
|
||||
request = new RestoreRequest(authId, oauth.accessToken, extendedTokens, false);
|
||||
} else {
|
||||
boolean refreshed = false;
|
||||
RestoreRequest request;
|
||||
if(oauth != null) {
|
||||
if (isTokenExpired() || oauth.accessToken == null) {
|
||||
RefreshTokenRequest refreshRequest = new RefreshTokenRequest(authId, oauth.refreshToken);
|
||||
RefreshTokenRequestEvent event = refreshRequest.request();
|
||||
setOAuth(authId, event.oauth);
|
||||
refreshed = true;
|
||||
}
|
||||
request = new RestoreRequest(authId, oauth.accessToken, extendedTokens, false);
|
||||
} else {
|
||||
request = new RestoreRequest(authId, null, extendedTokens, false);
|
||||
}
|
||||
RestoreRequestEvent event = request.request();
|
||||
List<String> invalidTokens = null;
|
||||
if (event.invalidTokens != null && event.invalidTokens.size() > 0) {
|
||||
boolean needRequest = false;
|
||||
Map<String, String> tokens = new HashMap<>();
|
||||
for (ExtendedTokenCallback cb : extendedTokenCallbacks) {
|
||||
for (String tokenName : event.invalidTokens) {
|
||||
String newToken = cb.tryGetNewToken(tokenName);
|
||||
if (newToken != null) {
|
||||
needRequest = true;
|
||||
tokens.put(tokenName, newToken);
|
||||
addExtendedToken(tokenName, newToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (needRequest) {
|
||||
request = new RestoreRequest(authId, null, tokens, false);
|
||||
event = request.request();
|
||||
if (event.invalidTokens != null && event.invalidTokens.size() > 0) {
|
||||
LogHelper.warning("Tokens %s not restored", String.join(",", event.invalidTokens));
|
||||
}
|
||||
}
|
||||
invalidTokens = event.invalidTokens;
|
||||
}
|
||||
return new RequestRestoreReport(false, refreshed, invalidTokens);
|
||||
request = new RestoreRequest(authId, null, extendedTokens, false);
|
||||
}
|
||||
RestoreRequestEvent event = request.request();
|
||||
List<String> invalidTokens = null;
|
||||
if (event.invalidTokens != null && event.invalidTokens.size() > 0) {
|
||||
boolean needRequest = false;
|
||||
Map<String, String> tokens = new HashMap<>();
|
||||
for (ExtendedTokenCallback cb : extendedTokenCallbacks) {
|
||||
for (String tokenName : event.invalidTokens) {
|
||||
String newToken = cb.tryGetNewToken(tokenName);
|
||||
if (newToken != null) {
|
||||
needRequest = true;
|
||||
tokens.put(tokenName, newToken);
|
||||
addExtendedToken(tokenName, newToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (needRequest) {
|
||||
request = new RestoreRequest(authId, null, tokens, false);
|
||||
event = request.request();
|
||||
if (event.invalidTokens != null && event.invalidTokens.size() > 0) {
|
||||
LogHelper.warning("Tokens %s not restored", String.join(",", event.invalidTokens));
|
||||
}
|
||||
}
|
||||
invalidTokens = event.invalidTokens;
|
||||
}
|
||||
return new RequestRestoreReport(false, refreshed, invalidTokens);
|
||||
}
|
||||
|
||||
public static void requestError(String message) throws RequestException {
|
||||
|
|
Loading…
Reference in a new issue