123333
This commit is contained in:
@@ -13,12 +13,20 @@ public class YunxinManager {
|
||||
@Autowired
|
||||
private YunxinProperties yunxinProperties;
|
||||
|
||||
public boolean checkNotify(String body,String curTime){
|
||||
public boolean checkNotify(String body,String curTime, String checkSum,String md5){
|
||||
try {
|
||||
String appSecret = yunxinProperties.getAppSecret();
|
||||
String verifyMD5 = CheckSumBuilder.getMD5(body);
|
||||
if(md5 == null || !md5.equals(verifyMD5)){
|
||||
log.error("云信回调校验异常,md5 不相等");
|
||||
return false;
|
||||
}
|
||||
String verifyChecksum = CheckSumBuilder.getCheckSum(appSecret, verifyMD5, curTime);
|
||||
return verifyMD5 != null && verifyMD5.equals(verifyChecksum);
|
||||
if(checkSum == null || !checkSum.equals(verifyChecksum)){
|
||||
log.error("云信回调校验异常,checkSum 不相等");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
log.info("检查云信回调数据失败",e);
|
||||
return false;
|
||||
|
||||
@@ -4,9 +4,20 @@ import java.security.MessageDigest;
|
||||
|
||||
public class CheckSumBuilder {
|
||||
|
||||
public static void main(String[] args) {
|
||||
String appSecret = "77c09917d2de";
|
||||
String curTime = "1707115388876";
|
||||
String body = "{\"clientType\":\"IOS\",\"code\":\"200\",\"clientIp\":\"117.153.13.133\",\"accid\":\"33503\",\"sdkVersion\":\"91301\",\"eventType\":\"2\",\"deviceId\":\"2957635E-A852-4EBD-94C7-AA1FFA71551B\",\"timestamp\":\"1707115388795\"}";
|
||||
String verifyMD5 = CheckSumBuilder.getMD5(body);
|
||||
System.out.println(verifyMD5);
|
||||
String verifyChecksum = CheckSumBuilder.getCheckSum(appSecret, verifyMD5, curTime);
|
||||
System.out.println(verifyChecksum);
|
||||
}
|
||||
|
||||
|
||||
// 计算并获取CheckSum
|
||||
public static String getCheckSum(String appSecret, String nonce, String curTime) {
|
||||
return encode("sha1", appSecret + nonce + curTime);
|
||||
public static String getCheckSum(String appSecret, String bodyMd5, String curTime) {
|
||||
return encode("sha1", appSecret + bodyMd5 + curTime);
|
||||
}
|
||||
|
||||
// 计算并获取md5值
|
||||
|
||||
Reference in New Issue
Block a user