|
|
@ -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()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 对传入的参数集合进行签名处理 |
|
|
|