diff --git a/chsm-common/pom.xml b/chsm-common/pom.xml
index b148e70..a92567f 100644
--- a/chsm-common/pom.xml
+++ b/chsm-common/pom.xml
@@ -45,6 +45,10 @@
org.apache.commons
commons-pool2
+
+ org.apache.commons
+ commons-lang3
+
net.java.dev.jna
jna
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/CertDTO.java b/chsm-common/src/main/java/com/sunyard/chsm/model/dto/CertDTO.java
similarity index 98%
rename from chsm-web-manage/src/main/java/com/sunyard/chsm/dto/CertDTO.java
rename to chsm-common/src/main/java/com/sunyard/chsm/model/dto/CertDTO.java
index 7e291cf..bf42672 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/CertDTO.java
+++ b/chsm-common/src/main/java/com/sunyard/chsm/model/dto/CertDTO.java
@@ -1,4 +1,4 @@
-package com.sunyard.chsm.dto;
+package com.sunyard.chsm.model.dto;
import com.sunyard.chsm.model.PageQuery;
import lombok.Data;
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/KeyInfoDTO.java b/chsm-common/src/main/java/com/sunyard/chsm/model/dto/KeyInfoDTO.java
similarity index 98%
rename from chsm-web-manage/src/main/java/com/sunyard/chsm/dto/KeyInfoDTO.java
rename to chsm-common/src/main/java/com/sunyard/chsm/model/dto/KeyInfoDTO.java
index bf7c5eb..f522bb5 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/dto/KeyInfoDTO.java
+++ b/chsm-common/src/main/java/com/sunyard/chsm/model/dto/KeyInfoDTO.java
@@ -1,4 +1,4 @@
-package com.sunyard.chsm.dto;
+package com.sunyard.chsm.model.dto;
import com.sunyard.chsm.model.PageQuery;
import com.sunyard.chsm.model.Subject;
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/AppCertService.java b/chsm-common/src/main/java/com/sunyard/chsm/service/AppCertService.java
similarity index 87%
rename from chsm-web-manage/src/main/java/com/sunyard/chsm/service/AppCertService.java
rename to chsm-common/src/main/java/com/sunyard/chsm/service/AppCertService.java
index 720d634..17a0fce 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/AppCertService.java
+++ b/chsm-common/src/main/java/com/sunyard/chsm/service/AppCertService.java
@@ -1,7 +1,7 @@
package com.sunyard.chsm.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sunyard.chsm.dto.CertDTO;
+import com.sunyard.chsm.model.dto.CertDTO;
/**
* @author liulu
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/CaCertService.java b/chsm-common/src/main/java/com/sunyard/chsm/service/CaCertService.java
similarity index 89%
rename from chsm-web-manage/src/main/java/com/sunyard/chsm/service/CaCertService.java
rename to chsm-common/src/main/java/com/sunyard/chsm/service/CaCertService.java
index ead4a6f..fda276d 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/CaCertService.java
+++ b/chsm-common/src/main/java/com/sunyard/chsm/service/CaCertService.java
@@ -1,7 +1,7 @@
package com.sunyard.chsm.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sunyard.chsm.dto.CertDTO;
+import com.sunyard.chsm.model.dto.CertDTO;
/**
* @author liulu
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/KeyInfoService.java b/chsm-common/src/main/java/com/sunyard/chsm/service/KeyInfoService.java
similarity index 93%
rename from chsm-web-manage/src/main/java/com/sunyard/chsm/service/KeyInfoService.java
rename to chsm-common/src/main/java/com/sunyard/chsm/service/KeyInfoService.java
index a265bae..9fcbd40 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/KeyInfoService.java
+++ b/chsm-common/src/main/java/com/sunyard/chsm/service/KeyInfoService.java
@@ -1,7 +1,7 @@
package com.sunyard.chsm.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sunyard.chsm.dto.KeyInfoDTO;
+import com.sunyard.chsm.model.dto.KeyInfoDTO;
import java.io.InputStream;
import java.util.List;
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/AppCertServiceImpl.java b/chsm-common/src/main/java/com/sunyard/chsm/service/impl/AppCertServiceImpl.java
similarity index 97%
rename from chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/AppCertServiceImpl.java
rename to chsm-common/src/main/java/com/sunyard/chsm/service/impl/AppCertServiceImpl.java
index a546ece..611a738 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/AppCertServiceImpl.java
+++ b/chsm-common/src/main/java/com/sunyard/chsm/service/impl/AppCertServiceImpl.java
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sunyard.chsm.dto.CertDTO;
import com.sunyard.chsm.enums.KeyCategory;
import com.sunyard.chsm.enums.KeyStatus;
import com.sunyard.chsm.enums.KeyUsage;
@@ -12,6 +11,7 @@ import com.sunyard.chsm.mapper.AppCertMapper;
import com.sunyard.chsm.mapper.ApplicationMapper;
import com.sunyard.chsm.mapper.KeyInfoMapper;
import com.sunyard.chsm.mapper.SpKeyRecordMapper;
+import com.sunyard.chsm.model.dto.CertDTO;
import com.sunyard.chsm.model.entity.AppCert;
import com.sunyard.chsm.model.entity.Application;
import com.sunyard.chsm.model.entity.KeyInfo;
@@ -23,6 +23,7 @@ import com.sunyard.chsm.utils.gm.BCSM2Utils;
import com.sunyard.chsm.utils.gm.BCSM4Utils;
import com.sunyard.chsm.utils.gm.cert.BCSM2CertUtils;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.tuple.Pair;
import org.bouncycastle.asn1.ASN1BitString;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
@@ -36,7 +37,6 @@ import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
import org.bouncycastle.util.BigIntegers;
import org.bouncycastle.util.encoders.Hex;
import org.springframework.beans.BeanUtils;
-import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
@@ -192,7 +192,7 @@ public class AppCertServiceImpl implements AppCertService {
log.error("解密加密密钥信封异常", ex);
throw new IllegalArgumentException("加密密钥信封格式错误,解密失败");
}
- Assert.isTrue(Objects.equals(encPkHex, keys.getFirst()), "加密证书和私钥不匹配");
+ Assert.isTrue(Objects.equals(encPkHex, keys.getLeft()), "加密证书和私钥不匹配");
AppCert exist = appCertMapper.selectBySN(signCert.getSerialNumber().toString());
Assert.isNull(exist, "签名证书已经存在");
@@ -207,8 +207,8 @@ public class AppCertServiceImpl implements AppCertService {
importCert.setCertType(KeyUsage.ENCRYPT_DECRYPT.getCode());
importCert.setCertText(importCert.getEncCertText());
AppCert enc = genCert(encCert, keyInfo.getApplicationId(), record, importCert);
- enc.setPubKey(keys.getFirst());
- byte[] encPri = sdfApiService.encryptByTMK(keys.getSecond());
+ enc.setPubKey(keys.getLeft());
+ byte[] encPri = sdfApiService.encryptByTMK(keys.getRight());
enc.setEncPriKey(Hex.toHexString(encPri));
appCertMapper.insert(enc);
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/CaCertServiceImpl.java b/chsm-common/src/main/java/com/sunyard/chsm/service/impl/CaCertServiceImpl.java
similarity index 99%
rename from chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/CaCertServiceImpl.java
rename to chsm-common/src/main/java/com/sunyard/chsm/service/impl/CaCertServiceImpl.java
index 2929dd8..9897c2e 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/CaCertServiceImpl.java
+++ b/chsm-common/src/main/java/com/sunyard/chsm/service/impl/CaCertServiceImpl.java
@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sunyard.chsm.dto.CertDTO;
import com.sunyard.chsm.mapper.CaCertMapper;
+import com.sunyard.chsm.model.dto.CertDTO;
import com.sunyard.chsm.model.entity.CaCert;
import com.sunyard.chsm.service.CaCertService;
import com.sunyard.chsm.utils.gm.BCECUtils;
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/KeyInfoServiceImpl.java b/chsm-common/src/main/java/com/sunyard/chsm/service/impl/KeyInfoServiceImpl.java
similarity index 99%
rename from chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/KeyInfoServiceImpl.java
rename to chsm-common/src/main/java/com/sunyard/chsm/service/impl/KeyInfoServiceImpl.java
index b649965..27675c3 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/service/impl/KeyInfoServiceImpl.java
+++ b/chsm-common/src/main/java/com/sunyard/chsm/service/impl/KeyInfoServiceImpl.java
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sunyard.chsm.dto.KeyInfoDTO;
import com.sunyard.chsm.enums.EnableStatus;
import com.sunyard.chsm.enums.KeyCategory;
import com.sunyard.chsm.enums.KeyStatus;
@@ -15,6 +14,7 @@ import com.sunyard.chsm.mapper.KeyCsrMapper;
import com.sunyard.chsm.mapper.KeyInfoMapper;
import com.sunyard.chsm.mapper.KeyTemplateMapper;
import com.sunyard.chsm.mapper.SpKeyRecordMapper;
+import com.sunyard.chsm.model.dto.KeyInfoDTO;
import com.sunyard.chsm.model.entity.Application;
import com.sunyard.chsm.model.entity.KeyCsr;
import com.sunyard.chsm.model.entity.KeyInfo;
@@ -26,7 +26,6 @@ import com.sunyard.chsm.service.KeyInfoService;
import com.sunyard.chsm.utils.JsonUtils;
import com.sunyard.chsm.utils.gm.BCECUtils;
import com.sunyard.chsm.utils.gm.cert.CommonCertUtils;
-import com.sunyard.ssp.common.exception.SspwebException;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.crypto.params.ECDomainParameters;
@@ -330,7 +329,7 @@ public class KeyInfoServiceImpl implements KeyInfoService {
try {
if ((line = reader.readLine()) == null) break;
} catch (IOException e) {
- throw new SspwebException("文件读取异常");
+ throw new IllegalArgumentException("文件读取异常");
}
if (ObjectUtils.isEmpty(line)) {
continue;
@@ -358,7 +357,7 @@ public class KeyInfoServiceImpl implements KeyInfoService {
}
}
} catch (IOException e) {
- throw new SspwebException(e.getMessage());
+ throw new IllegalArgumentException(e.getMessage());
}
return String.format("恢复完成,共%d条数据,跳过已经存在的密钥%d条,恢复成功%d条,解析失败%d条", count, exd, suc, err);
}
diff --git a/chsm-web-manage/pom.xml b/chsm-web-manage/pom.xml
index 7ccb1a9..5397ab4 100644
--- a/chsm-web-manage/pom.xml
+++ b/chsm-web-manage/pom.xml
@@ -71,10 +71,6 @@
hutool-core
-
- org.apache.commons
- commons-lang3
-
commons-codec
commons-codec
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/AppCertController.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/AppCertController.java
index a5f7bb0..e538b33 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/AppCertController.java
+++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/AppCertController.java
@@ -1,8 +1,8 @@
package com.sunyard.chsm.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sunyard.chsm.dto.CertDTO;
import com.sunyard.chsm.model.R;
+import com.sunyard.chsm.model.dto.CertDTO;
import com.sunyard.chsm.service.AppCertService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/CaController.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/CaController.java
index ec3e385..990e767 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/CaController.java
+++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/CaController.java
@@ -2,8 +2,8 @@ package com.sunyard.chsm.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sunyard.chsm.constant.AuditLogConst;
-import com.sunyard.chsm.dto.CertDTO;
import com.sunyard.chsm.model.R;
+import com.sunyard.chsm.model.dto.CertDTO;
import com.sunyard.chsm.service.CaCertService;
import com.sunyard.ssp.common.annotation.AuditControllerLog;
import lombok.extern.slf4j.Slf4j;
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoAsymController.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoAsymController.java
index 451ebe7..4bd2fb7 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoAsymController.java
+++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoAsymController.java
@@ -1,9 +1,9 @@
package com.sunyard.chsm.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sunyard.chsm.dto.KeyInfoDTO;
import com.sunyard.chsm.enums.KeyCategory;
import com.sunyard.chsm.model.R;
+import com.sunyard.chsm.model.dto.KeyInfoDTO;
import com.sunyard.chsm.service.KeyInfoService;
import com.sunyard.chsm.utils.DateFormat;
import org.springframework.core.io.ByteArrayResource;
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoController.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoController.java
index dd4e689..5c3da82 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoController.java
+++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoController.java
@@ -1,10 +1,10 @@
package com.sunyard.chsm.controller;
import com.sunyard.chsm.constant.AuditLogConst;
-import com.sunyard.chsm.dto.KeyInfoDTO;
import com.sunyard.chsm.enums.KeyStatus;
import com.sunyard.chsm.model.Option;
import com.sunyard.chsm.model.R;
+import com.sunyard.chsm.model.dto.KeyInfoDTO;
import com.sunyard.chsm.service.KeyInfoService;
import com.sunyard.ssp.common.annotation.AuditControllerLog;
import com.sunyard.ssp.common.exception.SspwebException;
diff --git a/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoSymController.java b/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoSymController.java
index 1302e3e..410d6ed 100644
--- a/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoSymController.java
+++ b/chsm-web-manage/src/main/java/com/sunyard/chsm/controller/KeyInfoSymController.java
@@ -1,9 +1,9 @@
package com.sunyard.chsm.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sunyard.chsm.dto.KeyInfoDTO;
import com.sunyard.chsm.enums.KeyCategory;
import com.sunyard.chsm.model.R;
+import com.sunyard.chsm.model.dto.KeyInfoDTO;
import com.sunyard.chsm.service.KeyInfoService;
import com.sunyard.chsm.utils.DateFormat;
import org.springframework.beans.factory.annotation.Autowired;