From 4214f08ee41fff5d1d09d8e31f42d080ab1f3d83 Mon Sep 17 00:00:00 2001 From: awenes <1121353141@qq.com> Date: Thu, 4 Apr 2024 21:55:43 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E5=95=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alipay/filter/AlipayLoginAuthenticationFilter.java | 4 ++-- .../dingtalk/filter/DingtalkOauthAuthenticationFilter.java | 4 ++-- .../filter/DingtalkScanCodeAuthenticationFilter.java | 4 ++-- .../feishu/filter/FeiShuLoginAuthenticationFilter.java | 4 ++-- .../gitee/filter/GiteeLoginAuthenticationFilter.java | 4 ++-- .../filter/GithubOAuth2LoginAuthenticationFilter.java | 4 ++-- .../otp/mail/filter/MailOtpAuthenticationFilter.java | 6 ++++-- .../qq/filter/QqOAuth2LoginAuthenticationFilter.java | 4 ++-- .../otp/sms/filter/SmsOtpAuthenticationFilter.java | 6 ++++-- .../filter/WeChatScanCodeLoginAuthenticationFilter.java | 4 ++-- .../WeChatWorkScanCodeLoginAuthenticationFilter.java | 7 +++---- 11 files changed, 27 insertions(+), 24 deletions(-) diff --git a/eiam-authentication/eiam-authentication-alipay/src/main/java/cn/topiam/employee/authentication/alipay/filter/AlipayLoginAuthenticationFilter.java b/eiam-authentication/eiam-authentication-alipay/src/main/java/cn/topiam/employee/authentication/alipay/filter/AlipayLoginAuthenticationFilter.java index 3d950d3c..a32ef970 100644 --- a/eiam-authentication/eiam-authentication-alipay/src/main/java/cn/topiam/employee/authentication/alipay/filter/AlipayLoginAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-alipay/src/main/java/cn/topiam/employee/authentication/alipay/filter/AlipayLoginAuthenticationFilter.java @@ -49,7 +49,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos import cn.topiam.employee.core.help.ServerHelp; import cn.topiam.employee.support.exception.TopIamException; import cn.topiam.employee.support.trace.TraceUtils; -import cn.topiam.employee.support.util.HttpUrlUtils; +import cn.topiam.employee.support.util.UrlUtils; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; @@ -159,7 +159,7 @@ public class AlipayLoginAuthenticationFilter extends AbstractIdpAuthenticationPr public static String getLoginUrl(String providerId) { String url = ServerHelp.getPortalPublicBaseUrl() + ALIPAY_OAUTH.getLoginPathPrefix() + "/" + providerId; - return HttpUrlUtils.format(url); + return UrlUtils.format(url); } public static RequestMatcher getRequestMatcher() { diff --git a/eiam-authentication/eiam-authentication-dingtalk/src/main/java/cn/topiam/employee/authentication/dingtalk/filter/DingtalkOauthAuthenticationFilter.java b/eiam-authentication/eiam-authentication-dingtalk/src/main/java/cn/topiam/employee/authentication/dingtalk/filter/DingtalkOauthAuthenticationFilter.java index f8b20859..4d5ec83e 100644 --- a/eiam-authentication/eiam-authentication-dingtalk/src/main/java/cn/topiam/employee/authentication/dingtalk/filter/DingtalkOauthAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-dingtalk/src/main/java/cn/topiam/employee/authentication/dingtalk/filter/DingtalkOauthAuthenticationFilter.java @@ -55,7 +55,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos import cn.topiam.employee.core.help.ServerHelp; import cn.topiam.employee.support.exception.TopIamException; import cn.topiam.employee.support.trace.TraceUtils; -import cn.topiam.employee.support.util.HttpUrlUtils; +import cn.topiam.employee.support.util.UrlUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -208,7 +208,7 @@ public class DingtalkOauthAuthenticationFilter extends AbstractIdpAuthentication public static String getLoginUrl(String providerId) { String url = ServerHelp.getPortalPublicBaseUrl() + DINGTALK_OAUTH.getLoginPathPrefix() + "/" + providerId; - return HttpUrlUtils.format(url); + return UrlUtils.format(url); } public static RequestMatcher getRequestMatcher() { diff --git a/eiam-authentication/eiam-authentication-dingtalk/src/main/java/cn/topiam/employee/authentication/dingtalk/filter/DingtalkScanCodeAuthenticationFilter.java b/eiam-authentication/eiam-authentication-dingtalk/src/main/java/cn/topiam/employee/authentication/dingtalk/filter/DingtalkScanCodeAuthenticationFilter.java index f219cde5..a8f94761 100644 --- a/eiam-authentication/eiam-authentication-dingtalk/src/main/java/cn/topiam/employee/authentication/dingtalk/filter/DingtalkScanCodeAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-dingtalk/src/main/java/cn/topiam/employee/authentication/dingtalk/filter/DingtalkScanCodeAuthenticationFilter.java @@ -60,7 +60,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos import cn.topiam.employee.core.help.ServerHelp; import cn.topiam.employee.support.exception.TopIamException; import cn.topiam.employee.support.trace.TraceUtils; -import cn.topiam.employee.support.util.HttpUrlUtils; +import cn.topiam.employee.support.util.UrlUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -243,7 +243,7 @@ public class DingtalkScanCodeAuthenticationFilter extends public static String getLoginUrl(String providerId) { String url = ServerHelp.getPortalPublicBaseUrl() + DINGTALK_QR.getLoginPathPrefix() + "/" + providerId; - return HttpUrlUtils.format(url); + return UrlUtils.format(url); } public static RequestMatcher getRequestMatcher() { diff --git a/eiam-authentication/eiam-authentication-feishu/src/main/java/cn/topiam/employee/authentication/feishu/filter/FeiShuLoginAuthenticationFilter.java b/eiam-authentication/eiam-authentication-feishu/src/main/java/cn/topiam/employee/authentication/feishu/filter/FeiShuLoginAuthenticationFilter.java index d5cd58ab..de043834 100644 --- a/eiam-authentication/eiam-authentication-feishu/src/main/java/cn/topiam/employee/authentication/feishu/filter/FeiShuLoginAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-feishu/src/main/java/cn/topiam/employee/authentication/feishu/filter/FeiShuLoginAuthenticationFilter.java @@ -46,7 +46,7 @@ import cn.topiam.employee.common.entity.authn.IdentityProviderEntity; import cn.topiam.employee.common.repository.authentication.IdentityProviderRepository; import cn.topiam.employee.core.help.ServerHelp; import cn.topiam.employee.support.util.HttpClientUtils; -import cn.topiam.employee.support.util.HttpUrlUtils; +import cn.topiam.employee.support.util.UrlUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -149,7 +149,7 @@ public class FeiShuLoginAuthenticationFilter extends AbstractIdpAuthenticationPr public static String getLoginUrl(String providerId) { String url = ServerHelp.getPortalPublicBaseUrl() + FEISHU_OAUTH.getLoginPathPrefix() + "/" + providerId; - return HttpUrlUtils.format(url); + return UrlUtils.format(url); } public static RequestMatcher getRequestMatcher() { diff --git a/eiam-authentication/eiam-authentication-gitee/src/main/java/cn/topiam/employee/authentication/gitee/filter/GiteeLoginAuthenticationFilter.java b/eiam-authentication/eiam-authentication-gitee/src/main/java/cn/topiam/employee/authentication/gitee/filter/GiteeLoginAuthenticationFilter.java index 251bba8b..642bdecb 100644 --- a/eiam-authentication/eiam-authentication-gitee/src/main/java/cn/topiam/employee/authentication/gitee/filter/GiteeLoginAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-gitee/src/main/java/cn/topiam/employee/authentication/gitee/filter/GiteeLoginAuthenticationFilter.java @@ -45,7 +45,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos import cn.topiam.employee.core.help.ServerHelp; import cn.topiam.employee.support.exception.TopIamException; import cn.topiam.employee.support.util.HttpClientUtils; -import cn.topiam.employee.support.util.HttpUrlUtils; +import cn.topiam.employee.support.util.UrlUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -170,7 +170,7 @@ public class GiteeLoginAuthenticationFilter extends AbstractIdpAuthenticationPro public static String getLoginUrl(String providerId) { String url = ServerHelp.getPortalPublicBaseUrl() + GITEE_OAUTH.getLoginPathPrefix() + "/" + providerId; - return HttpUrlUtils.format(url); + return UrlUtils.format(url); } public static RequestMatcher getRequestMatcher() { diff --git a/eiam-authentication/eiam-authentication-github/src/main/java/cn/topiam/employee/authentication/github/filter/GithubOAuth2LoginAuthenticationFilter.java b/eiam-authentication/eiam-authentication-github/src/main/java/cn/topiam/employee/authentication/github/filter/GithubOAuth2LoginAuthenticationFilter.java index 5d006b6e..dbdd7e59 100644 --- a/eiam-authentication/eiam-authentication-github/src/main/java/cn/topiam/employee/authentication/github/filter/GithubOAuth2LoginAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-github/src/main/java/cn/topiam/employee/authentication/github/filter/GithubOAuth2LoginAuthenticationFilter.java @@ -48,7 +48,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos import cn.topiam.employee.core.help.ServerHelp; import cn.topiam.employee.support.exception.TopIamException; import cn.topiam.employee.support.trace.TraceUtils; -import cn.topiam.employee.support.util.HttpUrlUtils; +import cn.topiam.employee.support.util.UrlUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -174,7 +174,7 @@ public class GithubOAuth2LoginAuthenticationFilter extends public static String getLoginUrl(String providerId) { String url = ServerHelp.getPortalPublicBaseUrl() + "/" + GITHUB_OAUTH.getLoginPathPrefix() + "/" + providerId; - return HttpUrlUtils.format(url); + return UrlUtils.format(url); } public static RequestMatcher getRequestMatcher() { diff --git a/eiam-authentication/eiam-authentication-mail/src/main/java/cn/topiam/employee/authentication/otp/mail/filter/MailOtpAuthenticationFilter.java b/eiam-authentication/eiam-authentication-mail/src/main/java/cn/topiam/employee/authentication/otp/mail/filter/MailOtpAuthenticationFilter.java index 45be98a2..44514161 100644 --- a/eiam-authentication/eiam-authentication-mail/src/main/java/cn/topiam/employee/authentication/otp/mail/filter/MailOtpAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-mail/src/main/java/cn/topiam/employee/authentication/otp/mail/filter/MailOtpAuthenticationFilter.java @@ -17,6 +17,8 @@ */ package cn.topiam.employee.authentication.otp.mail.filter; +import java.util.Objects; + import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -86,11 +88,11 @@ public class MailOtpAuthenticationFilter extends AbstractAuthenticationProcessin "Authentication method not supported: " + request.getMethod()); } // 获取手机号/邮箱 - String recipient = StringUtils.defaultString(obtainUsername(request), "").trim(); + String recipient = Objects.toString(obtainUsername(request), "").trim(); if (StringUtils.isBlank(recipient)) { throw new MailNotExistException(); } - String code = StringUtils.defaultString(obtainCode(request), "").trim(); + String code = Objects.toString(obtainCode(request), "").trim(); if (StringUtils.isBlank(code)) { throw new CaptchaNotExistException(); } diff --git a/eiam-authentication/eiam-authentication-qq/src/main/java/cn/topiam/employee/authentication/qq/filter/QqOAuth2LoginAuthenticationFilter.java b/eiam-authentication/eiam-authentication-qq/src/main/java/cn/topiam/employee/authentication/qq/filter/QqOAuth2LoginAuthenticationFilter.java index e43eeb57..28e8be86 100644 --- a/eiam-authentication/eiam-authentication-qq/src/main/java/cn/topiam/employee/authentication/qq/filter/QqOAuth2LoginAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-qq/src/main/java/cn/topiam/employee/authentication/qq/filter/QqOAuth2LoginAuthenticationFilter.java @@ -48,7 +48,7 @@ import cn.topiam.employee.core.help.ServerHelp; import cn.topiam.employee.support.exception.TopIamException; import cn.topiam.employee.support.trace.TraceUtils; import cn.topiam.employee.support.util.HttpClientUtils; -import cn.topiam.employee.support.util.HttpUrlUtils; +import cn.topiam.employee.support.util.UrlUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -164,7 +164,7 @@ public class QqOAuth2LoginAuthenticationFilter extends AbstractIdpAuthentication public static String getLoginUrl(String providerId) { String url = ServerHelp.getPortalPublicBaseUrl() + "/" + QQ_OAUTH.getLoginPathPrefix() + "/" + providerId; - return HttpUrlUtils.format(url); + return UrlUtils.format(url); } public static RequestMatcher getRequestMatcher() { diff --git a/eiam-authentication/eiam-authentication-sms/src/main/java/cn/topiam/employee/authentication/otp/sms/filter/SmsOtpAuthenticationFilter.java b/eiam-authentication/eiam-authentication-sms/src/main/java/cn/topiam/employee/authentication/otp/sms/filter/SmsOtpAuthenticationFilter.java index 30d516e0..d1d924d9 100644 --- a/eiam-authentication/eiam-authentication-sms/src/main/java/cn/topiam/employee/authentication/otp/sms/filter/SmsOtpAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-sms/src/main/java/cn/topiam/employee/authentication/otp/sms/filter/SmsOtpAuthenticationFilter.java @@ -17,6 +17,8 @@ */ package cn.topiam.employee.authentication.otp.sms.filter; +import java.util.Objects; + import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -88,11 +90,11 @@ public class SmsOtpAuthenticationFilter extends AbstractAuthenticationProcessing "Authentication method not supported: " + request.getMethod()); } // 获取手机号/邮箱 - String recipient = StringUtils.defaultString(obtainUsername(request), "").trim(); + String recipient = Objects.toString(obtainUsername(request), "").trim(); if (StringUtils.isBlank(recipient)) { throw new PhoneNotExistException(); } - String code = StringUtils.defaultString(obtainCode(request), "").trim(); + String code = Objects.toString(obtainCode(request), "").trim(); if (StringUtils.isBlank(code)) { throw new CaptchaNotExistException(); } diff --git a/eiam-authentication/eiam-authentication-wechat/src/main/java/cn/topiam/employee/authentication/wechat/filter/WeChatScanCodeLoginAuthenticationFilter.java b/eiam-authentication/eiam-authentication-wechat/src/main/java/cn/topiam/employee/authentication/wechat/filter/WeChatScanCodeLoginAuthenticationFilter.java index 2413551f..51143654 100644 --- a/eiam-authentication/eiam-authentication-wechat/src/main/java/cn/topiam/employee/authentication/wechat/filter/WeChatScanCodeLoginAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-wechat/src/main/java/cn/topiam/employee/authentication/wechat/filter/WeChatScanCodeLoginAuthenticationFilter.java @@ -46,7 +46,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos import cn.topiam.employee.core.help.ServerHelp; import cn.topiam.employee.support.exception.TopIamException; import cn.topiam.employee.support.util.HttpClientUtils; -import cn.topiam.employee.support.util.HttpUrlUtils; +import cn.topiam.employee.support.util.UrlUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -160,7 +160,7 @@ public class WeChatScanCodeLoginAuthenticationFilter extends public static String getLoginUrl(String providerId) { String url = ServerHelp.getPortalPublicBaseUrl() + WECHAT_QR.getLoginPathPrefix() + "/" + providerId; - return HttpUrlUtils.format(url); + return UrlUtils.format(url); } public static RequestMatcher getRequestMatcher() { diff --git a/eiam-authentication/eiam-authentication-wechatwork/src/main/java/cn/topiam/employee/authentication/wechatwork/filter/WeChatWorkScanCodeLoginAuthenticationFilter.java b/eiam-authentication/eiam-authentication-wechatwork/src/main/java/cn/topiam/employee/authentication/wechatwork/filter/WeChatWorkScanCodeLoginAuthenticationFilter.java index 53e840d1..9923995a 100644 --- a/eiam-authentication/eiam-authentication-wechatwork/src/main/java/cn/topiam/employee/authentication/wechatwork/filter/WeChatWorkScanCodeLoginAuthenticationFilter.java +++ b/eiam-authentication/eiam-authentication-wechatwork/src/main/java/cn/topiam/employee/authentication/wechatwork/filter/WeChatWorkScanCodeLoginAuthenticationFilter.java @@ -50,7 +50,7 @@ import cn.topiam.employee.common.repository.authentication.IdentityProviderRepos import cn.topiam.employee.core.help.ServerHelp; import cn.topiam.employee.support.trace.TraceUtils; import cn.topiam.employee.support.util.HttpClientUtils; -import cn.topiam.employee.support.util.HttpUrlUtils; +import cn.topiam.employee.support.util.UrlUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -146,8 +146,7 @@ public class WeChatWorkScanCodeLoginAuthenticationFilter extends throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString()); } // 返回 - String userId = StringUtils.defaultString(result.getString("UserId"), - result.getString("OpenId")); + String userId = Objects.toString(result.getString("UserId"), result.getString("OpenId")); IdpUserDetails idpUserDetails = IdpUserDetails.builder().openId(userId) .providerType(WECHAT_WORK_QR).providerCode(providerCode).providerId(providerId).build(); return attemptAuthentication(request, response, idpUserDetails); @@ -192,7 +191,7 @@ public class WeChatWorkScanCodeLoginAuthenticationFilter extends public static String getLoginUrl(String providerId) { String url = ServerHelp.getPortalPublicBaseUrl() + WECHAT_WORK_QR.getLoginPathPrefix() + "/" + providerId; - return HttpUrlUtils.format(url); + return UrlUtils.format(url); }