Commit 7cbc29fa authored by qinxunjia's avatar qinxunjia

优化配置,增加日志

parent 7b5c8a80
...@@ -35,7 +35,7 @@ public class DmHubApi { ...@@ -35,7 +35,7 @@ public class DmHubApi {
try { try {
boolean checkResult = this.checkSignature(timestamp, signature); boolean checkResult = this.checkSignature(timestamp, signature);
if (!checkResult) { if (!checkResult) {
return new DmHubResponse("555", "签名校验不通过"); return new DmHubResponse("555", "接口请求签名校验不通过");
} }
response = messageService.createTemplate(params); response = messageService.createTemplate(params);
} catch (Exception e) { } catch (Exception e) {
...@@ -58,7 +58,7 @@ public class DmHubApi { ...@@ -58,7 +58,7 @@ public class DmHubApi {
try { try {
boolean checkResult = this.checkSignature(timestamp, signature); boolean checkResult = this.checkSignature(timestamp, signature);
if (!checkResult) { if (!checkResult) {
return new DmHubResponse("555", "签名校验不通过"); return new DmHubResponse("555", "接口请求签名校验不通过");
} }
response = messageService.sendCode(params); response = messageService.sendCode(params);
} catch (Exception e) { } catch (Exception e) {
...@@ -82,7 +82,7 @@ public class DmHubApi { ...@@ -82,7 +82,7 @@ public class DmHubApi {
try { try {
boolean checkResult = this.checkSignature(timestamp, signature); boolean checkResult = this.checkSignature(timestamp, signature);
if (!checkResult) { if (!checkResult) {
return new DmHubResponse("555", "签名校验不通过"); return new DmHubResponse("555", "接口请求签名校验不通过");
} }
response = messageService.batchSendOneByOne(request); response = messageService.batchSendOneByOne(request);
} catch (Exception e) { } catch (Exception e) {
...@@ -94,8 +94,11 @@ public class DmHubApi { ...@@ -94,8 +94,11 @@ public class DmHubApi {
} }
public boolean checkSignature(String timestamp, String signature) { public boolean checkSignature(String timestamp, String signature) {
String encrypt = Md5Util.encrypt(DmHubConfig.appId + DmHubConfig.appSecret + timestamp); String signStr = DmHubConfig.appId + DmHubConfig.appSecret + "20200619072847";
String encrypt = Md5Util.encrypt(signStr);
log.info("待签名串:"+encrypt);
if (!encrypt.equals(signature)) { if (!encrypt.equals(signature)) {
log.error("签名不一致,插件生成签名:{}", encrypt);
return false; return false;
} }
return true; return true;
...@@ -124,4 +127,10 @@ public class DmHubApi { ...@@ -124,4 +127,10 @@ public class DmHubApi {
log.info("**********单条发送出参*******:{}", JSONObject.toJSONString(response)); log.info("**********单条发送出参*******:{}", JSONObject.toJSONString(response));
return response; return response;
} }
public static void main(String[] args) {
String a = "1smsdemo" + "ac031765c3a8c9acc4747808e4fe5918" + "20200619070139";
String encrypt = Md5Util.encrypt(a);
System.out.println(encrypt);
}
} }
...@@ -21,27 +21,27 @@ public class DmHubConfig { ...@@ -21,27 +21,27 @@ public class DmHubConfig {
DmHubConfig.applicationId = applicationId; DmHubConfig.applicationId = applicationId;
} }
@Value("{system.config.dmHub.applicationKey}") @Value("${system.config.dmHub.applicationKey}")
public void setApplicationKey(String applicationKey) { public void setApplicationKey(String applicationKey) {
DmHubConfig.applicationKey = applicationKey; DmHubConfig.applicationKey = applicationKey;
} }
@Value("{system.config.dmHub.tokenUrl}") @Value("${system.config.dmHub.tokenUrl}")
public void setTokenUrl(String tokenUrl) { public void setTokenUrl(String tokenUrl) {
DmHubConfig.tokenUrl = tokenUrl; DmHubConfig.tokenUrl = tokenUrl;
} }
@Value("{system.config.dmHub.report}") @Value("${system.config.dmHub.report}")
public void setReport(String report) { public void setReport(String report) {
DmHubConfig.report = report; DmHubConfig.report = report;
} }
@Value("{system.config.dmHub.appId}") @Value("${system.config.dmHub.appId}")
public void setAppId(String appId) { public void setAppId(String appId) {
DmHubConfig.appId = appId; DmHubConfig.appId = appId;
} }
@Value("{system.config.dmHub.appSecret}") @Value("${system.config.dmHub.appSecret}")
public void setAppSecret(String appSecret) { public void setAppSecret(String appSecret) {
DmHubConfig.appSecret = appSecret; DmHubConfig.appSecret = appSecret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment