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; + } } }