Register forbiddenTokens in MicrosoftSession and YggdrasilSession
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user