From dfdabcbe1c4c31443eac56ef53b434b2ceeb8510dafdf42ee53a5575cc0b2c34 Mon Sep 17 00:00:00 2001 From: yanglei Date: Fri, 9 Jan 2026 10:47:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E5=90=8D=E8=AE=A4=E8=AF=81=E6=8F=90?= =?UTF-8?q?=E5=8F=96=E9=AD=94=E6=B3=95=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cdzy/common/enums/GlobalConstants.java | 2 ++ .../main/java/com/cdzy/user/utils/VerifyUtil.java | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ebike-common/src/main/java/com/cdzy/common/enums/GlobalConstants.java b/ebike-common/src/main/java/com/cdzy/common/enums/GlobalConstants.java index 5b497b0..1551edd 100644 --- a/ebike-common/src/main/java/com/cdzy/common/enums/GlobalConstants.java +++ b/ebike-common/src/main/java/com/cdzy/common/enums/GlobalConstants.java @@ -43,6 +43,8 @@ public interface GlobalConstants { String STATUS_FIVE = "5"; + String REALNAME_VERIFY_SUCCESS_CODE = "10000"; + // LONG 型常量 Long LONG_MINUS_ONE = -1L; diff --git a/ebike-user/src/main/java/com/cdzy/user/utils/VerifyUtil.java b/ebike-user/src/main/java/com/cdzy/user/utils/VerifyUtil.java index 48cd164..d4905c6 100644 --- a/ebike-user/src/main/java/com/cdzy/user/utils/VerifyUtil.java +++ b/ebike-user/src/main/java/com/cdzy/user/utils/VerifyUtil.java @@ -5,6 +5,7 @@ import com.cdp.product.security.exception.DecryptFailureException; import com.cdp.product.security.exception.EncryptFailureException; import com.cdp.product.security.exception.SignFailureException; import com.cdp.product.security.strategyImpl.SM2StrategyImpl; +import com.cdzy.common.enums.GlobalConstants; import com.cdzy.common.ex.EbikeException; import com.cdzy.common.secure.SecureComponent; import com.cdzy.common.secure.SecureSM2Component; @@ -37,7 +38,11 @@ import javax.crypto.spec.SecretKeySpec; import java.nio.charset.StandardCharsets; import java.security.Security; import java.time.LocalDateTime; -import java.util.*; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.StringJoiner; /** * 验证工具类 @@ -89,7 +94,7 @@ public class VerifyUtil { /** * 微信工具类构造函数。 */ - public VerifyUtil(){ + public VerifyUtil() { client = new OkHttpClient(); securityContext = new SecurityContext(); //设置加解密上下⽂类调⽤SM2加解密类 @@ -183,10 +188,10 @@ public class VerifyUtil { throw new EbikeException("验证用户实名失败"); } String code = result.has("code") ? result.get("code").asText() : ""; - if (!"10000".equals(code)) { + if (!GlobalConstants.REALNAME_VERIFY_SUCCESS_CODE.equals(code)) { String message = result.has("message") ? result.get("message").asText() : "未知错误"; log.error("验证用户实名失败, code: {}, message: {}", code, message); - throw new EbikeException(message.replace("(","").replace(")","")); + throw new EbikeException(message.replace("(", "").replace(")", "")); } // 3. 解密并解析结果 String data = securityContext.decrypt(result.get("data").asText(), realNameVerifyConfig.getClientPrivateKey());