From 52a0b561f9c658ea9f254c4e070ae417f3643799 Mon Sep 17 00:00:00 2001 From: chenbowen Date: Tue, 18 Nov 2025 18:47:50 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=96=B0=E5=A2=9E=E9=92=88=E5=AF=B9?= =?UTF-8?q?=E5=A4=96=E9=83=A8=E7=9A=84=E8=87=AA=E5=AE=9A=E4=B9=89=20sso=20?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=A4=96=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/sso/ExternalSsoServiceImpl.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/sso/ExternalSsoServiceImpl.java b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/sso/ExternalSsoServiceImpl.java index ac76d7a8..ba34d6dc 100644 --- a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/sso/ExternalSsoServiceImpl.java +++ b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/sso/ExternalSsoServiceImpl.java @@ -218,16 +218,27 @@ public class ExternalSsoServiceImpl implements ExternalSsoService { if (strategies == null || strategies.isEmpty()) { return null; } - return strategies.stream() - .filter(strategy -> { - try { - return strategy.supports(sourceSystem); - } catch (Exception ex) { - log.warn("判定 SSO 策略是否支持来源系统时出现异常: {}", ex.getMessage()); - return false; - } - }) - .findFirst() - .orElse(null); + ExternalSsoStrategy wildcardStrategy = null; + for (ExternalSsoStrategy strategy : strategies) { + if (supportsSafely(strategy, sourceSystem)) { + return strategy; + } + if (wildcardStrategy == null && supportsSafely(strategy, null)) { + wildcardStrategy = strategy; + } + } + return wildcardStrategy; + } + + private boolean supportsSafely(ExternalSsoStrategy strategy, String sourceSystem) { + try { + return strategy.supports(sourceSystem); + } catch (Exception ex) { + if (log.isWarnEnabled()) { + log.warn("判定 SSO 策略 [{}] 是否支持来源系统 [{}] 时出现异常: {}", + strategy.getClass().getSimpleName(), sourceSystem, ex.getMessage()); + } + return false; + } } }