Pending Microsoft Authentication changes for GeyserConnect

This commit is contained in:
Camotoy 2022-02-28 10:24:27 -05:00
parent 65b68087b8
commit 0fd903e0a0
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F

View file

@ -46,6 +46,10 @@ import java.util.concurrent.*;
* It permits user to exit the server while they authorize Geyser to access their Microsoft account.
*/
public class PendingMicrosoftAuthentication {
/**
* For GeyserConnect usage.
*/
private boolean storeServerInformation = false;
private final LoadingCache<String, AuthenticationTask> authentications;
public PendingMicrosoftAuthentication(int timeoutSeconds) {
@ -53,7 +57,8 @@ public class PendingMicrosoftAuthentication {
.build(new CacheLoader<>() {
@Override
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);
}
@SuppressWarnings("unused") // GeyserConnect
public void setStoreServerInformation() {
storeServerInformation = true;
}
public class AuthenticationTask {
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
*/