ariesy 解决鉴权问题

release
yefei 2 years ago
parent a88185769e
commit 0057c04952
  1. 1
      dxhy-common/pom.xml
  2. 3
      dxhy-core/src/main/java/com/dxhy/core/thread/PoolAddTaxThread.java
  3. 15
      dxhy-erp/src/main/java/com/dxhy/erp/controller/InterfaceController.java
  4. 1
      dxhy-erp/src/main/java/com/dxhy/erp/utils/HmacSHA1Util.java

@ -78,6 +78,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>

@ -246,7 +246,7 @@ public class PoolAddTaxThread extends BaseThread {
this.cicleExport(pramsMap, default_curr, excelFile.toString(), out, writer);
this.detailCicleExport(pramsMap, default_curr, excelFile.toString(), out, writer);
writer.finish();
// writer.finish();
// FTP文件存储路径
String[] toDay = DateUtil.today().split("-");
String ftpFilePath = fileService.getPathPrefix() + userName + "/" + "excelFile/" + toDay[0] + "/"
@ -275,6 +275,7 @@ public class PoolAddTaxThread extends BaseThread {
// 记录导出出错状态
exportLogService.updateFail(id, errmsg, dbName);
} finally {
writer.finish();
// 发送导出消息到mq
String responseResult = JsonResponseUtils.responseResult(msg);
sender.sendToMsg(responseResult);

@ -105,6 +105,8 @@ public class InterfaceController extends AbstractController {
private VoucherRecordService voucherRecordService;
@Resource
private BaseIReceiptInvoiceService baseIReceiptInvoiceService;
@Value("${erp.ipUrl}")
private String ipUrl;
/**
*
@ -119,7 +121,7 @@ public class InterfaceController extends AbstractController {
@PathVariable("version") String version,
@PathVariable("interfaceName") String interfaceName,
@ApiParam(name = "requestParam", value = "业务报文", required = true) @RequestBody String content) {
log.info("{} SDK对外接口请求,version:{},interfaceName:{},content:{}",LOGGER_MSG,version,interfaceName,content);
log.info("{} SDK对外接口请求,version:{},interfaceName:{},content:{},请求url={}",LOGGER_MSG,version,interfaceName,content,request.getRequestURL().toString());
DxhyInterfaceResponse dxhyInterfaceResponse = new DxhyInterfaceResponse(RespStatusEnum.FAIL2);
long startTime = System.currentTimeMillis();
try {
@ -148,7 +150,7 @@ public class InterfaceController extends AbstractController {
/**
* 鉴权
*/
result = authV5(request, dxhyInterfaceRequest,secretKey);
result = authV5(version+"/"+interfaceName,request, dxhyInterfaceRequest,secretKey);
long end1 = System.currentTimeMillis();
log.debug("{}鉴权耗时{}毫秒", LOGGER_MSG, end1 - begin1);
if (!ConfigurerInfo.SUCCSSCODE.equals(result.getCode())) {
@ -293,14 +295,18 @@ public class InterfaceController extends AbstractController {
return result;
}
private CheckResult authV5(HttpServletRequest request, DxhyInterfaceRequest dxhyInterfaceRequest,String secretKey) {
private CheckResult authV5(String url,HttpServletRequest request, DxhyInterfaceRequest dxhyInterfaceRequest,String secretKey) {
CheckResult checkResult = new CheckResult(RespStatusEnum.AUTHFAIL);
String reqUrl = request.getRequestURL().toString();
if (reqUrl.contains(ConfigureConstant.STRING_WH)) {
reqUrl = reqUrl.substring(ConfigureConstant.INT_0, reqUrl.indexOf(ConfigureConstant.STRING_WH));
}
log.debug("{}请求路径:{}", LOGGER_MSG, reqUrl);
//获取鉴权URL
String signUrl = getAuthUrl(reqUrl, request.getMethod());
// String signUrl = getAuthUrl(reqUrl, request.getMethod());
String signUrl = ipUrl+url+"?";
TreeMap<String, String> sortMap = new TreeMap<>();
sortMap.put(ConfigurerInfo.SECRETID, dxhyInterfaceRequest.getSecretId());
sortMap.put(ConfigurerInfo.DATA_EXCHANGE_ID, dxhyInterfaceRequest.getDataExchangeId());
@ -323,7 +329,6 @@ public class InterfaceController extends AbstractController {
return checkResult;
}
public String commonDecrypt(String zipCode, String encryptCode, String content,String secretKey) {
String result = "";
byte[] de = content.getBytes();

@ -121,6 +121,7 @@ public class HmacSHA1Util {
* @throws Exception
*/
public static String genSign(String url, TreeMap<String, String> signMap, String secretKey) {
log.debug("请求生成签名的url={},signMap={}",url,signMap);
boolean flag = Boolean.TRUE;
StringBuilder keyVal = new StringBuilder();
for (Map.Entry<String, String> entry : signMap.entrySet()) {

Loading…
Cancel
Save