|
@@ -1,8 +1,9 @@
|
|
|
package com.dragoninfo.dcuc.duceap.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.dragoninfo.dcuc.common.exception.GmIntegrityException;
|
|
|
import com.dragoninfo.dcuc.duceap.bpo.CodeGmBPO;
|
|
|
-import com.dragoninfo.dcuc.duceap.config.CodeGmConfig;
|
|
|
+import com.dragoninfo.dcuc.duceap.config.GmConfig;
|
|
|
import com.dragoninfo.dcuc.duceap.entity.CodeGmSign;
|
|
|
import com.dragoninfo.dcuc.duceap.service.ICodeGmService;
|
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
|
|
@@ -33,12 +34,12 @@ public class CodeGmServiceImpl implements ICodeGmService {
|
|
|
private SM3SignStrategy sm3SignStrategy;
|
|
|
|
|
|
@Autowired
|
|
|
- private CodeGmConfig gmConfig;
|
|
|
+ private GmConfig gmConfig;
|
|
|
|
|
|
@Override
|
|
|
- public ResponseDTO codeGmCheck(String codeId) {
|
|
|
+ public ResponseStatus codeGmCheck(String codeId) {
|
|
|
if(!gmConfig.getCheckCodeIds().contains(codeId)){
|
|
|
- return ResponseDTO.success(ResponseStatus.SUCCESS_CODE,"无需校验");
|
|
|
+ return ResponseStatus.success();
|
|
|
}
|
|
|
List<CodeRecord> codeRecords = CodeInfoUtils.getCodeListByCodeDicId(codeId);
|
|
|
List<CodeGmSign> signs = getCodeGmSignByCodeId(codeId);
|
|
@@ -49,35 +50,35 @@ public class CodeGmServiceImpl implements ICodeGmService {
|
|
|
String code = codeRecord.getValue();
|
|
|
CodeGmSign codeGmSign = signMap.get(code);
|
|
|
if(null == codeGmSign){
|
|
|
- return ResponseDTO.fail(ResponseStatus.FAIL_CODE,"缺少国密签名数据",null);
|
|
|
+ throw new GmIntegrityException();
|
|
|
}
|
|
|
String digest = codeGmSign.getDigest();
|
|
|
String origin = codeRecord.getLabel() + codeRecord.getValue();
|
|
|
String summary = sm3SignStrategy.summary(origin);
|
|
|
if(!summary.equals(digest)){
|
|
|
- return ResponseDTO.fail(ResponseStatus.FAIL_CODE,"国密完整性异常",null);
|
|
|
+ throw new GmIntegrityException();
|
|
|
}
|
|
|
}
|
|
|
- return ResponseDTO.success(ResponseStatus.SUCCESS_CODE,"国密数据校验成功");
|
|
|
+ return ResponseStatus.success();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResponseDTO codeGmCheckCodes(String codeIds) {
|
|
|
+ public ResponseStatus codeGmCheckCodes(String codeIds) {
|
|
|
if(StringUtils.isBlank(codeIds)){
|
|
|
return ResponseDTO.fail(ResponseStatus.FAIL_CODE,"codeIds为空",null);
|
|
|
}
|
|
|
String[] codeIdArr = codeIds.split(StrUtil.COMMA);
|
|
|
for (String codeId : codeIdArr) {
|
|
|
- ResponseDTO responseDTO = codeGmCheck(codeId);
|
|
|
+ ResponseStatus responseDTO = codeGmCheck(codeId);
|
|
|
if(!responseDTO.getStatusCode().equals(ResponseStatus.SUCCESS_CODE)){
|
|
|
return responseDTO;
|
|
|
}
|
|
|
}
|
|
|
- return ResponseDTO.success(ResponseStatus.SUCCESS_CODE,"国密数据校验成功");
|
|
|
+ return ResponseStatus.success();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResponseDTO codeGmSign(String codeId) {
|
|
|
+ public ResponseStatus codeGmSign(String codeId) {
|
|
|
List<CodeRecord> codeRecords = CodeInfoUtils.getCodeListByCodeDicId(codeId);
|
|
|
//去重
|
|
|
ArrayList<CodeRecord> collect = codeRecords.stream()
|
|
@@ -91,7 +92,7 @@ public class CodeGmServiceImpl implements ICodeGmService {
|
|
|
codeGmSign.setDigest(summary);
|
|
|
codeGmBPO.save(codeGmSign);
|
|
|
}
|
|
|
- return ResponseDTO.success(ResponseStatus.SUCCESS_CODE,"保存成功");
|
|
|
+ return ResponseStatus.success();
|
|
|
}
|
|
|
|
|
|
|