代码扫描问题解决

This commit is contained in:
liulu
2025-01-14 17:26:50 +08:00
parent 334607a896
commit 3e1572dcad
49 changed files with 528 additions and 435 deletions
@@ -4,6 +4,8 @@ import com.sunyard.chsm.model.R;
import com.sunyard.chsm.param.AppTokenReq;
import com.sunyard.chsm.param.AppTokenResp;
import com.sunyard.chsm.service.AppLoginService;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -26,6 +28,10 @@ public class AppLoginController {
@Resource
private AppLoginService appLoginService;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields("qwer");
}
/**
* 获取应用Token接口
@@ -3,9 +3,27 @@ package com.sunyard.chsm.controller;
import com.sunyard.chsm.auth.AuthCode;
import com.sunyard.chsm.constant.AuthCodeConst;
import com.sunyard.chsm.model.R;
import com.sunyard.chsm.param.*;
import com.sunyard.chsm.param.AsymDecryptReq;
import com.sunyard.chsm.param.AsymDecryptResp;
import com.sunyard.chsm.param.AsymEncryptReq;
import com.sunyard.chsm.param.AsymEncryptResp;
import com.sunyard.chsm.param.AsymEnvelopeSealReq;
import com.sunyard.chsm.param.AsymEnvelopeSealResp;
import com.sunyard.chsm.param.AsymEnvelopeUnsealReq;
import com.sunyard.chsm.param.AsymEnvelopeUnsealResp;
import com.sunyard.chsm.param.AsymSignP7Req;
import com.sunyard.chsm.param.AsymSignP7Resp;
import com.sunyard.chsm.param.AsymSignRawReq;
import com.sunyard.chsm.param.AsymSignRawResp;
import com.sunyard.chsm.param.AsymVerifyP7Req;
import com.sunyard.chsm.param.AsymVerifyRawReq;
import com.sunyard.chsm.param.ExportPubKeyReq;
import com.sunyard.chsm.param.ExportPubKeyResp;
import com.sunyard.chsm.param.VerifyResp;
import com.sunyard.chsm.service.AsymKeyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -26,6 +44,11 @@ public class AsymKeyController {
@Autowired
private AsymKeyService asymKeyService;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields("qwer");
}
/**
* 导出非对称公钥
*
@@ -3,11 +3,23 @@ package com.sunyard.chsm.controller;
import com.sunyard.chsm.model.R;
import com.sunyard.chsm.model.dto.CertDTO;
import com.sunyard.chsm.param.*;
import com.sunyard.chsm.param.CertExinfoResp;
import com.sunyard.chsm.param.CertInfoResp;
import com.sunyard.chsm.param.ExportCertReq;
import com.sunyard.chsm.param.ExportCertResp;
import com.sunyard.chsm.param.ImportCertReq;
import com.sunyard.chsm.service.AppCertService;
import com.sunyard.chsm.service.CertService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
@@ -27,6 +39,11 @@ public class CertController {
@Resource
private CertService certService;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields("qwer");
}
/**
* 导出证书
*
@@ -14,6 +14,8 @@ import com.sunyard.chsm.sdf.context.AlgId;
import com.sunyard.chsm.sdf.model.EccPubKey;
import com.sunyard.chsm.utils.CodecUtils;
import org.springframework.util.Assert;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@@ -40,6 +42,11 @@ public class HashController {
@Resource
private DeviceManager deviceManager;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields("qwer");
}
/**
* 计算Hash
*
@@ -118,7 +125,7 @@ public class HashController {
SdfApiAdapter sdf = context.getSdfApiAdapter();
sdf.hashUpdate(context.getSessionHandle(), bytes);
HashResp resp = new HashResp();
resp.setHandle(req.getHandle());
// resp.setHandle(req.getHandle());
return R.data(resp);
}
@@ -139,7 +146,7 @@ public class HashController {
byte[] hash = sdf.hashFinish(context.getSessionHandle());
sdf.closeSession(context.getSessionHandle());
HashResp resp = new HashResp();
resp.setHandle(req.getHandle());
// resp.setHandle(req.getHandle());
resp.setHash(CodecUtils.encodeBase64(hash));
return R.data(resp);
}
@@ -11,6 +11,8 @@ import com.sunyard.chsm.param.KeyManageReq;
import com.sunyard.chsm.param.KeyUpdateReq;
import com.sunyard.chsm.service.KeyManageService;
import org.springframework.util.Assert;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -32,6 +34,11 @@ public class KeyManageController {
@Resource
private KeyManageService keyManageService;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields("qwer");
}
/**
* 查询密钥列表
*
@@ -7,6 +7,8 @@ import com.sunyard.chsm.param.GenRandomReq;
import com.sunyard.chsm.param.GenRandomResp;
import com.sunyard.chsm.sdf.SdfApiService;
import com.sunyard.chsm.utils.CodecUtils;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@@ -25,6 +27,11 @@ public class RandomController {
@Resource
private SdfApiService sdfApiService;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields("qwer");
}
/**
* 获取随机数
*
@@ -16,6 +16,8 @@ import com.sunyard.chsm.param.SymMacResp;
import com.sunyard.chsm.param.VerifyResp;
import com.sunyard.chsm.service.SymKeyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -36,6 +38,11 @@ public class SymKeyController {
@Autowired
private SymKeyService symKeyService;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields("qwer");
}
/**
* 对称加密
*
@@ -30,7 +30,7 @@ public abstract class BaseTest {
protected static final String asymKeyTemplate = "asym-sm2-001";
protected static final String ak = "216205d408130d83d13c5072305b8b65";
protected static final String sk = "ae64515d1d5adec2cc6ae8726d0c1bbc";
protected static final String server = "http://172.16.18.46:9890";
protected static final String server = "http://172.16.18.42:9890";
protected static final RestTemplate restTemplate;
protected static final String token;