From 69e68adebdb773a6ecc4a68b02661ffdb881e367 Mon Sep 17 00:00:00 2001 From: zhou9584 <2428499107@qq.com> Date: Wed, 17 Sep 2025 12:22:56 +0800 Subject: [PATCH 1/2] Update AuthUtil.java --- .../hydralab/center/util/AuthUtil.java | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/center/src/main/java/com/microsoft/hydralab/center/util/AuthUtil.java b/center/src/main/java/com/microsoft/hydralab/center/util/AuthUtil.java index 4b4585fdc..281900e1e 100644 --- a/center/src/main/java/com/microsoft/hydralab/center/util/AuthUtil.java +++ b/center/src/main/java/com/microsoft/hydralab/center/util/AuthUtil.java @@ -61,7 +61,7 @@ public class AuthUtil { String ignoreUri; @Value("${spring.security.oauth2.client.registration.azure-client.scope:}") String scope; - @Value("${spring.security.oauth2.client.provider.azure-ad.miseEnabled:false}") + @Value("${spring.security.oauth2.client.provider.azure-ad.mise-enabled:false}") boolean miseEnabled; Map urlMapping = null; @@ -126,28 +126,6 @@ public boolean validateTokenWithMISE(String token) { Class miseClass = Class.forName("com.microsoft.identity.service.essentials.Mise"); Object mise = miseClass.getMethod("createClient").invoke(null); - // mise.assignLogMessageCallback(new Mise.ILogCallback() {...}, null); - Class logLevelClass = Class.forName("com.microsoft.identity.service.essentials.MiseLogLevel"); - Class iLogCallbackClass = Class.forName("com.microsoft.identity.service.essentials.Mise$ILogCallback"); - - Object logCallback = java.lang.reflect.Proxy.newProxyInstance( - iLogCallbackClass.getClassLoader(), - new Class[]{iLogCallbackClass}, - (proxy, method, args) -> { - String methodName = method.getName(); - if ("callback".equals(methodName)) { - Object level = args[0]; - String message = (String) args[1]; - // Print all log levels for simplicity - LOGGER.info(message); - } - return null; - } - ); - - miseClass.getMethod("assignLogMessageCallback", iLogCallbackClass, Object.class) - .invoke(mise, logCallback, null); - // Configure MISE JSONObject config = new JSONObject(); JSONObject azureAd = new JSONObject(); From 0e6269d39f39fd6b37932701b9631701df3c4710 Mon Sep 17 00:00:00 2001 From: zhou9584 <2428499107@qq.com> Date: Wed, 17 Sep 2025 12:33:44 +0800 Subject: [PATCH 2/2] Update AuthUtil.java --- .../hydralab/center/util/AuthUtil.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/center/src/main/java/com/microsoft/hydralab/center/util/AuthUtil.java b/center/src/main/java/com/microsoft/hydralab/center/util/AuthUtil.java index 281900e1e..0ae93292b 100644 --- a/center/src/main/java/com/microsoft/hydralab/center/util/AuthUtil.java +++ b/center/src/main/java/com/microsoft/hydralab/center/util/AuthUtil.java @@ -66,6 +66,7 @@ public class AuthUtil { Map urlMapping = null; private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(AuthUtil.class); + private static Boolean isMiseLogInitialized = false; public boolean isValidToken(String token) { LOGGER.info("Starting token validation..."); @@ -118,7 +119,7 @@ private boolean validateTokenWithPublicKey(String token) { } } - public boolean validateTokenWithMISE(String token) { + private boolean validateTokenWithMISE(String token) { LOGGER.info("Starting MISE token validation..."); try { @@ -126,6 +127,31 @@ public boolean validateTokenWithMISE(String token) { Class miseClass = Class.forName("com.microsoft.identity.service.essentials.Mise"); Object mise = miseClass.getMethod("createClient").invoke(null); + if (!isMiseLogInitialized) { + LOGGER.info("Initializing MISE..."); + // mise.assignLogMessageCallback(new Mise.ILogCallback() {...}, null); + Class iLogCallbackClass = Class.forName("com.microsoft.identity.service.essentials.Mise$ILogCallback"); + + Object logCallback = java.lang.reflect.Proxy.newProxyInstance( + iLogCallbackClass.getClassLoader(), + new Class[]{iLogCallbackClass}, + (proxy, method, args) -> { + String methodName = method.getName(); + if ("callback".equals(methodName)) { + Object level = args[0]; + String message = (String) args[1]; + // Print all log levels for simplicity + LOGGER.info(message); + } + return null; + } + ); + + miseClass.getMethod("assignLogMessageCallback", iLogCallbackClass, Object.class) + .invoke(mise, logCallback, null); + isMiseLogInitialized = true; + } + // Configure MISE JSONObject config = new JSONObject(); JSONObject azureAd = new JSONObject();