Files
xq-server/ruoyi-yunxin/src/main/java/com/ruoyi/yunxin/manager/YunxinManager.java
张良(004796) 273ee16e8c init
2024-03-04 18:54:18 +08:00

37 lines
1.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.ruoyi.yunxin.manager;
import com.ruoyi.yunxin.config.YunxinProperties;
import com.ruoyi.yunxin.util.CheckSumBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class YunxinManager {
@Autowired
private YunxinProperties yunxinProperties;
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);
if(checkSum == null || !checkSum.equals(verifyChecksum)){
log.error("云信回调校验异常checkSum 不相等");
return false;
}
return true;
}catch (Exception e){
log.info("检查云信回调数据失败",e);
return false;
}
}
}