Register forbiddenTokens in MicrosoftSession and YggdrasilSession

This commit is contained in:
Glavo
2022-03-19 19:07:33 +08:00
committed by Yuhui Huang
parent 151e7e04eb
commit 4d4864819a
4 changed files with 11 additions and 15 deletions

View File

@@ -18,6 +18,7 @@
package org.jackhuang.hmcl.auth.microsoft;
import org.jackhuang.hmcl.auth.AuthInfo;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.gson.UUIDTypeAdapter;
import java.util.Map;
@@ -43,6 +44,8 @@ public class MicrosoftSession {
this.refreshToken = refreshToken;
this.user = user;
this.profile = profile;
if (accessToken != null) Logging.registerAccessToken(accessToken);
}
public String getTokenType() {

View File

@@ -20,6 +20,7 @@ package org.jackhuang.hmcl.auth.yggdrasil;
import com.google.gson.Gson;
import org.jackhuang.hmcl.auth.AuthInfo;
import org.jackhuang.hmcl.util.Immutable;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.gson.UUIDTypeAdapter;
import org.jetbrains.annotations.Nullable;
@@ -46,6 +47,8 @@ public class YggdrasilSession {
this.selectedProfile = selectedProfile;
this.availableProfiles = availableProfiles;
this.userProperties = userProperties;
if (accessToken != null) Logging.registerAccessToken(accessToken);
}
public String getClientToken() {

View File

@@ -47,6 +47,10 @@ public final class Logging {
forbiddenTokens.put(token, replacement);
}
public static void registerAccessToken(String accessToken) {
registerForbiddenToken(accessToken, "<access token>");
}
public static String filterForbiddenToken(String message) {
for (Map.Entry<String, String> entry : forbiddenTokens.entrySet()) {
message = message.replace(entry.getKey(), entry.getValue());