3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Pending Microsoft Authentication changes for GeyserConnect

Dieser Commit ist enthalten in:
Camotoy 2022-02-28 10:24:27 -05:00
Ursprung 65b68087b8
Commit 0fd903e0a0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -46,6 +46,10 @@ import java.util.concurrent.*;
* It permits user to exit the server while they authorize Geyser to access their Microsoft account. * It permits user to exit the server while they authorize Geyser to access their Microsoft account.
*/ */
public class PendingMicrosoftAuthentication { public class PendingMicrosoftAuthentication {
/**
* For GeyserConnect usage.
*/
private boolean storeServerInformation = false;
private final LoadingCache<String, AuthenticationTask> authentications; private final LoadingCache<String, AuthenticationTask> authentications;
public PendingMicrosoftAuthentication(int timeoutSeconds) { public PendingMicrosoftAuthentication(int timeoutSeconds) {
@ -53,7 +57,8 @@ public class PendingMicrosoftAuthentication {
.build(new CacheLoader<>() { .build(new CacheLoader<>() {
@Override @Override
public AuthenticationTask load(@NonNull String userKey) { public AuthenticationTask load(@NonNull String userKey) {
return new AuthenticationTask(userKey, timeoutSeconds * 1000L); return storeServerInformation ? new ProxyAuthenticationTask(userKey, timeoutSeconds * 1000L)
: new AuthenticationTask(userKey, timeoutSeconds * 1000L);
} }
}); });
} }
@ -67,6 +72,11 @@ public class PendingMicrosoftAuthentication {
return authentications.get(userKey); return authentications.get(userKey);
} }
@SuppressWarnings("unused") // GeyserConnect
public void setStoreServerInformation() {
storeServerInformation = true;
}
public class AuthenticationTask { public class AuthenticationTask {
private static final Executor DELAYED_BY_ONE_SECOND = CompletableFuture.delayedExecutor(1, TimeUnit.SECONDS); private static final Executor DELAYED_BY_ONE_SECOND = CompletableFuture.delayedExecutor(1, TimeUnit.SECONDS);
@ -159,6 +169,17 @@ public class PendingMicrosoftAuthentication {
} }
} }
@Getter
@Setter
public final class ProxyAuthenticationTask extends AuthenticationTask {
private String server;
private int port;
private ProxyAuthenticationTask(String userKey, long timeoutMs) {
super(userKey, timeoutMs);
}
}
/** /**
* @see PendingMicrosoftAuthentication * @see PendingMicrosoftAuthentication
*/ */