Browse Source

Merge remote-tracking branch 'origin/dev-V1.10.0' into dev-V1.10.0

dev-V1.10.0
niujiyi 4 hours ago
parent
commit
a9b5bcaae5
  1. 4
      zdxt-modules/zdxt-system/src/main/java/org/dromara/system/controller/system/SysUserController.java
  2. 26
      zdxt-modules/zdxt-system/src/main/java/org/dromara/system/service/ICryptoSensitiveHsmService.java
  3. 38
      zdxt-modules/zdxt-system/src/main/java/org/dromara/system/service/impl/CryptoSensitiveHsmServiceImpl.java

4
zdxt-modules/zdxt-system/src/main/java/org/dromara/system/controller/system/SysUserController.java

@ -124,6 +124,10 @@ public class SysUserController extends BaseController {
if (ObjectUtil.isNull(user)) {
return R.fail("没有权限访问用户数据!");
}
// 修复: 双轨改造后 phonenumber 为 HSM 密文, 取备用字段 crypto_remark_two
// 做 AES 解密返回明文(兼容未双轨化存量行 phonenumber 仍为 AES 密文, 解密失败返回原值兜底)
user.setPhonenumber(ICryptoSensitiveHsmService.decryptPhoneForDisplay(
user.getPhonenumber(), user.getCryptoRemarkTwo()));
userInfoVo.setUser(user);
userInfoVo.setPermissions(loginUser.getMenuPermission());
userInfoVo.setRoles(loginUser.getRolePermission());

26
zdxt-modules/zdxt-system/src/main/java/org/dromara/system/service/ICryptoSensitiveHsmService.java

@ -75,6 +75,32 @@ public interface ICryptoSensitiveHsmService {
*/
String encryptWithSrnwgAes(String plainValue);
/**
* 使用 srnwg.secretKey 对 AES 密文解密, 返回明文
* <p>供 zdxt-system 模块内无法引用 IdCardCryptoUtil 的场景使用;
* 与 CommonUtil/IdCardCryptoUtil 同源密钥, 加解密链路对称</p>
*
* @param cipherText AES 密文(Base64)
* @return 明文; 入参为空或解密失败返回 null(不抛异常)
*/
String decryptWithSrnwgAes(String cipherText);
/**
* 手机号展示统一解密入口(双轨密评改造后专用)
* <ul>
* <li>空值 → 原样返回</li>
* <li>纯数字 → 明文存量, 原样返回</li>
* <li>备用字段 crypto_remark_two 非空 → AES 解密(备份存原始字段值口径)</li>
* <li>降级 → phonenumber 本身为 AES 密文的未双轨化存量</li>
* <li>全部失败 → 返回原值, 禁止抛异常中断调用方</li>
* </ul>
*
* @param phonenumber 库中 sys_user.phonenumber(明文/AES 密文/HSM 密文)
* @param cryptoRemarkTwo 库中 sys_user.crypto_remark_two 备份原始字段值(AES 密文), 可为 null
* @return 明文手机号; 无法解密时返回原值
*/
String decryptPhoneForDisplay(String phonenumber, String cryptoRemarkTwo);
/**
* 手机号归一化为确定性 AES 形态(与 crypto_remark_two 备份口径一致)
* <p>纯数字明文 → AES 加密; 密文形态(AES Base64) → 原样保留</p>

38
zdxt-modules/zdxt-system/src/main/java/org/dromara/system/service/impl/CryptoSensitiveHsmServiceImpl.java

@ -174,6 +174,44 @@ public class CryptoSensitiveHsmServiceImpl implements ICryptoSensitiveHsmService
}
}
@Override
public String decryptWithSrnwgAes(String cipherText) {
if (StrUtil.isBlank(cipherText)) {
return null;
}
try {
return decryptAes(cipherText);
} catch (Exception e) {
log.warn("srnwg AES 解密失败", e);
return null;
}
}
@Override
public String decryptPhoneForDisplay(String phonenumber, String cryptoRemarkTwo) {
if (StrUtil.isBlank(phonenumber)) {
return phonenumber;
}
// 纯数字明文存量直接返回
if (phonenumber.matches("^\\d+$")) {
return phonenumber;
}
// 备用轨道优先: crypto_remark_two 存原始字段值(AES 密文形态)
if (StrUtil.isNotBlank(cryptoRemarkTwo)) {
String decrypted = decryptWithSrnwgAes(cryptoRemarkTwo);
if (StrUtil.isNotBlank(decrypted)) {
return decrypted;
}
}
// 降级: 未双轨化存量, phonenumber 本身为 AES 密文
String fallback = decryptWithSrnwgAes(phonenumber);
if (StrUtil.isNotBlank(fallback)) {
return fallback;
}
// HSM 密文或解密全部失败, 返回原值, 不抛出
return phonenumber;
}
@Override
public String normalizePhoneToAes(String phone) {
if (StrUtil.isBlank(phone)) {

Loading…
Cancel
Save