mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] JsonCoreProvider: getDetails
This commit is contained in:
parent
fc33ed11d0
commit
be78caa841
1 changed files with 22 additions and 0 deletions
|
@ -2,12 +2,14 @@
|
|||
|
||||
import pro.gravit.launcher.ClientPermissions;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
||||
import pro.gravit.launcher.request.auth.AuthRequest;
|
||||
import pro.gravit.launcher.request.auth.password.AuthPlainPassword;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.auth.AuthException;
|
||||
import pro.gravit.launchserver.auth.password.PasswordVerifier;
|
||||
import pro.gravit.launchserver.manangers.AuthManager;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.auth.AuthResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -19,12 +21,14 @@
|
|||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class JsonCoreProvider extends AuthCoreProvider {
|
||||
public String getUserByUsernameUrl;
|
||||
public String getUserByUUIDUrl;
|
||||
public String getUserSessionByOAuthAccessTokenUrl;
|
||||
public String getAuthDetailsUrl;
|
||||
public String refreshAccessTokenUrl;
|
||||
public String verifyPasswordUrl;
|
||||
public String createOAuthSessionUrl;
|
||||
|
@ -125,6 +129,14 @@ public JsonGetUserSessionByOAuthTokenResponse() {
|
|||
}
|
||||
}
|
||||
|
||||
public static class JsonGetDetails {
|
||||
|
||||
}
|
||||
|
||||
public static class JsonGetDetailsResponse {
|
||||
public List<GetAvailabilityAuthRequestEvent.AuthAvailabilityDetails> details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUserByUsername(String username) {
|
||||
return jsonRequest(new JsonGetUserByUsername(username), getUserByUsernameUrl, JsonUser.class);
|
||||
|
@ -143,6 +155,16 @@ public UserSession getUserSessionByOAuthAccessToken(String accessToken) throws O
|
|||
return response.session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GetAvailabilityAuthRequestEvent.AuthAvailabilityDetails> getDetails(Client client) {
|
||||
if (getAuthDetailsUrl != null) {
|
||||
JsonGetDetailsResponse response = jsonRequest(new JsonGetDetails(), getAuthDetailsUrl, JsonGetDetailsResponse.class);
|
||||
if (response == null) return super.getDetails(client);
|
||||
return response.details;
|
||||
}
|
||||
return super.getDetails(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthManager.AuthReport refreshAccessToken(String refreshToken, AuthResponse.AuthContext context) {
|
||||
JsonAuthReportResponse response = jsonRequest(new JsonRefreshToken(refreshToken, context.ip), this.refreshAccessTokenUrl, JsonAuthReportResponse.class);
|
||||
|
|
Loading…
Reference in a new issue