|
@@ -1,31 +1,32 @@
|
|
|
package org.dromara.system.service.impl;
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import cn.hutool.crypto.SecureUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
-import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
-import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
-import org.dromara.common.encrypt.utils.EncryptUtils;
|
|
|
|
|
-import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
-import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import org.dromara.common.core.constant.CacheNames;
|
|
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
+import org.dromara.common.encrypt.utils.YcEncryptUtil;
|
|
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
+import org.dromara.common.redis.utils.RedisUtils;
|
|
|
|
|
+import org.dromara.system.domain.SysRegisterinfo;
|
|
|
|
|
+import org.dromara.system.domain.bo.SysRegisterinfoBo;
|
|
|
import org.dromara.system.domain.vo.SysRegisterInfoVo;
|
|
import org.dromara.system.domain.vo.SysRegisterInfoVo;
|
|
|
|
|
+import org.dromara.system.mapper.SysRegisterinfoMapper;
|
|
|
|
|
+import org.dromara.system.service.ISysRegisterInfoService;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.dromara.system.domain.bo.SysRegisterinfoBo;
|
|
|
|
|
-import org.dromara.system.domain.SysRegisterinfo;
|
|
|
|
|
-import org.dromara.system.mapper.SysRegisterinfoMapper;
|
|
|
|
|
-import org.dromara.system.service.ISysRegisterInfoService;
|
|
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.Base64;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Collection;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 注册信息Service业务层处理
|
|
* 注册信息Service业务层处理
|
|
@@ -47,7 +48,7 @@ public class SysRegisterInfoServiceImpl implements ISysRegisterInfoService {
|
|
|
* @return 注册信息
|
|
* @return 注册信息
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public SysRegisterInfoVo queryById(Long registerId){
|
|
|
|
|
|
|
+ public SysRegisterInfoVo queryById(Long registerId) {
|
|
|
return baseMapper.selectVoById(registerId);
|
|
return baseMapper.selectVoById(registerId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -123,7 +124,7 @@ public class SysRegisterInfoServiceImpl implements ISysRegisterInfoService {
|
|
|
/**
|
|
/**
|
|
|
* 保存前的数据校验
|
|
* 保存前的数据校验
|
|
|
*/
|
|
*/
|
|
|
- private void validEntityBeforeSave(SysRegisterinfo entity){
|
|
|
|
|
|
|
+ private void validEntityBeforeSave(SysRegisterinfo entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -136,7 +137,7 @@ public class SysRegisterInfoServiceImpl implements ISysRegisterInfoService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
|
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
@@ -150,9 +151,10 @@ public class SysRegisterInfoServiceImpl implements ISysRegisterInfoService {
|
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
|
@Override
|
|
@Override
|
|
|
public SysRegisterInfoVo queryRegisterInfo() {
|
|
public SysRegisterInfoVo queryRegisterInfo() {
|
|
|
|
|
+
|
|
|
List<SysRegisterinfo> list = baseMapper.selectList();
|
|
List<SysRegisterinfo> list = baseMapper.selectList();
|
|
|
- SysRegisterInfoVo vo = new SysRegisterInfoVo();
|
|
|
|
|
- list.stream().findFirst().ifPresent(p-> {
|
|
|
|
|
|
|
+ AtomicReference<SysRegisterInfoVo> vo = new AtomicReference<>(new SysRegisterInfoVo());
|
|
|
|
|
+ list.stream().findFirst().ifPresent(p -> {
|
|
|
|
|
|
|
|
String base64Info = p.getRegisterInfo();
|
|
String base64Info = p.getRegisterInfo();
|
|
|
byte[] result = Base64.getDecoder().decode(base64Info.getBytes());
|
|
byte[] result = Base64.getDecoder().decode(base64Info.getBytes());
|
|
@@ -162,29 +164,53 @@ public class SysRegisterInfoServiceImpl implements ISysRegisterInfoService {
|
|
|
String dealerNo = dataMap.get("dealerNo").toString();
|
|
String dealerNo = dataMap.get("dealerNo").toString();
|
|
|
// 经销商公钥(使用经销商编号对公钥进行3DES加密后的密文)
|
|
// 经销商公钥(使用经销商编号对公钥进行3DES加密后的密文)
|
|
|
String dealerPublicKey3des = dataMap.get("dealerPublicKey").toString();
|
|
String dealerPublicKey3des = dataMap.get("dealerPublicKey").toString();
|
|
|
- log.info("dealerNo={}", dealerNo);
|
|
|
|
|
|
|
+
|
|
|
// 客户公钥(使用经销商私钥对客户公钥进行RSA加密后的密文)
|
|
// 客户公钥(使用经销商私钥对客户公钥进行RSA加密后的密文)
|
|
|
String customerPublicKeyRsa = dataMap.get("customerPublicKey").toString();
|
|
String customerPublicKeyRsa = dataMap.get("customerPublicKey").toString();
|
|
|
|
|
+ // 客户私钥(使用经销商私钥对客户私钥进行RSA加密后的密文)
|
|
|
|
|
+ String customerPrivateKeyRSA = dataMap.get("customerPrivateKey").toString();
|
|
|
// 客户ID,明文
|
|
// 客户ID,明文
|
|
|
String customerId = dataMap.get("customerId").toString();
|
|
String customerId = dataMap.get("customerId").toString();
|
|
|
// 授权加密信息(使用customId对客户的授权信息进行3DES加密,再使用客户的私钥分别对数据进行RAS加密)
|
|
// 授权加密信息(使用customId对客户的授权信息进行3DES加密,再使用客户的私钥分别对数据进行RAS加密)
|
|
|
String warrantInfoRsa = dataMap.get("warrantInfo").toString();
|
|
String warrantInfoRsa = dataMap.get("warrantInfo").toString();
|
|
|
|
|
|
|
|
- // 解密授权信息
|
|
|
|
|
- String warrantInfo3DES = "";
|
|
|
|
|
// 解密经销商公钥
|
|
// 解密经销商公钥
|
|
|
- String dealerPubKey = EncryptUtils.decryptByDESede(dealerPublicKey3des,EncryptUtils.hex(dealerNo));
|
|
|
|
|
- log.info("dealerPubKey={}", dealerPubKey);
|
|
|
|
|
|
|
+ String dealerPubKey = YcEncryptUtil.decryptByDESede(dealerPublicKey3des, YcEncryptUtil.hex(dealerNo));
|
|
|
|
|
+
|
|
|
// 解密客户公钥
|
|
// 解密客户公钥
|
|
|
- String customerPublicKey = EncryptUtils.decryptByRsaPublicKey(customerPublicKeyRsa,dealerPubKey);
|
|
|
|
|
|
|
+ String customerPublicKey = null;
|
|
|
|
|
+ customerPublicKey = YcEncryptUtil.decryptByRsaPublicKeySection(customerPublicKeyRsa, dealerPubKey);
|
|
|
|
|
+
|
|
|
|
|
+ // 解密客户私钥
|
|
|
|
|
+ String customerPrivateKey = null;
|
|
|
|
|
+ if (StringUtils.isNotEmpty(customerPrivateKeyRSA)) {
|
|
|
|
|
+ customerPrivateKey = YcEncryptUtil.decryptByRsaPublicKeySection(customerPrivateKeyRSA, dealerPubKey);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 解密授权信息
|
|
|
|
|
+ String warrantInfo3DES;
|
|
|
|
|
+ warrantInfo3DES = YcEncryptUtil.decryptByRsaPublicKeySection(warrantInfoRsa, customerPublicKey);
|
|
|
|
|
+
|
|
|
|
|
+ String warrantInfo = YcEncryptUtil.decryptByDESede(warrantInfo3DES, YcEncryptUtil.hex(customerId));
|
|
|
|
|
+ SysRegisterInfoVo tempVo = JSONUtil.toBean(warrantInfo, SysRegisterInfoVo.class);
|
|
|
|
|
+ tempVo.setCustomerId(customerId);
|
|
|
|
|
+ tempVo.setDealerNo(dealerNo);
|
|
|
|
|
+ vo.set(tempVo);
|
|
|
|
|
+
|
|
|
|
|
+ RedisUtils.setCacheObject(CacheNames.CUSTOM_PUB_KEY,customerPublicKey);
|
|
|
|
|
+ RedisUtils.setCacheObject(CacheNames.CUSTOM_PRI_KEY,customerPrivateKey);
|
|
|
|
|
|
|
|
- warrantInfo3DES = EncryptUtils.decryptByRsaPublicKey(warrantInfoRsa,customerPublicKey);
|
|
|
|
|
|
|
+ //String seckey = YcEncryptUtil.getBalanceSecretKey(customerPublicKey,"20082016134101023897");
|
|
|
|
|
+ //byte[] key = YcEncryptUtil.hexToByte(StrUtil.subSuf(seckey,3));
|
|
|
|
|
+ //String cardValue = YcEncryptUtil.parseByte2HexStr("");
|
|
|
|
|
+ //String encryptValue = SecureUtil.desede(key).encryptHex("17.9", StandardCharsets.UTF_8);
|
|
|
|
|
+ //String encryptValue1 = SecureUtil.des(key).encryptHex("17.9".getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
+ //String encryptValue2 = SecureUtil.des(key).decryptStr("ea0ea7d3e6f50986");
|
|
|
|
|
+ //byte[] data = YcEncryptUtil.hexToByte("01000000827801BF2D965037ED88D46FB8A8C4C9636D8BF149BB729D");
|
|
|
|
|
+ //String encryptValue2 = SecureUtil.desede(key).decryptStr(data);
|
|
|
|
|
|
|
|
- String warrantInfo = EncryptUtils.decryptByDESede(customerId, warrantInfo3DES);
|
|
|
|
|
- log.info("warrantInfo={}", warrantInfo);
|
|
|
|
|
- vo.setDealerNo(dealerNo);
|
|
|
|
|
|
|
+ //log.info("encryptValue-{}", encryptValue.getBytes());
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
- return vo;
|
|
|
|
|
|
|
+ return vo.get();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|