修改
This commit is contained in:
@@ -106,34 +106,6 @@ public class Signature {
|
||||
}
|
||||
}
|
||||
|
||||
//获取签名
|
||||
@PostMapping("/getSign2")
|
||||
ResultBean<String> getSign2(@RequestParam("parameters") Map<String, String> parameters,
|
||||
@RequestParam("appKey") String appKey,
|
||||
@RequestParam("secret") String secret) {
|
||||
ResultBean<String> rb = ResultBean.fireFail();
|
||||
try {
|
||||
// 1. 参数校验
|
||||
if (parameters == null || parameters.isEmpty()) {
|
||||
return rb.setMsg("Parameters cannot be empty.");
|
||||
}
|
||||
if (StringUtils.isEmpty(appKey)) {
|
||||
return rb.setMsg("AppKey cannot be empty.");
|
||||
}
|
||||
if (StringUtils.isEmpty(secret)) {
|
||||
return rb.setMsg("Secret cannot be empty.");
|
||||
}
|
||||
|
||||
// 生成签名
|
||||
String sign = SignatureUtil.generateSignature(parameters, appKey, secret);
|
||||
return rb.success().setData(sign);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return rb.setMsg("Unsupported encoding: " + e.getMessage());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
return rb.setMsg("Algorithm not found: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 对传入的参数集合进行签名处理
|
||||
|
||||
@@ -20,6 +20,6 @@ public class SignatureQuery {
|
||||
//业务参数
|
||||
private Map<String, String> parameters = new HashMap<>();
|
||||
|
||||
|
||||
//原签名值
|
||||
private String receivedSignature;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user