浏览代码

update tt

master
xhxu 3 年前
父节点
当前提交
ff84724877
共有 2 个文件被更改,包括 7 次插入5 次删除
  1. +4
    -2
      mallinkService/src/main/java/com/iformall/service/toutiao/api/impl/TtOpenComponentServiceImpl.java
  2. +3
    -3
      mallinkService/src/main/java/com/iformall/service/toutiao/utils/ServerVerification.java

+ 4
- 2
mallinkService/src/main/java/com/iformall/service/toutiao/api/impl/TtOpenComponentServiceImpl.java 查看文件

@@ -12,6 +12,7 @@ import com.iformall.service.toutiao.api.bean.TtOpenGsonBuilder;
import com.iformall.service.toutiao.api.bean.TtOpenRetrieveCode;
import com.iformall.service.toutiao.api.bean.TtOpenTicket;
import com.iformall.service.toutiao.utils.MsgDecrypt;
import com.iformall.service.toutiao.utils.ServerVerification;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.crypto.SHA1;
@@ -79,8 +80,9 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService {
@Override
public boolean checkSignature(String timestamp, String nonce, String encrypt, String signature) {
try {
return SHA1.gen(getWxOpenConfigStorage().getComponentToken(), timestamp, nonce, encrypt)
.equals(signature);
ServerVerification verification = new ServerVerification();
String newMsgSignature = verification.getMsgSignature(getWxOpenConfigStorage().getComponentToken(),timestamp, nonce, encrypt);
return verification.verify(signature,newMsgSignature);
} catch (Exception e) {
this.log.error("Checking signature failed, and the reason is :" + e.getMessage());
return false;


+ 3
- 3
mallinkService/src/main/java/com/iformall/service/toutiao/utils/ServerVerification.java 查看文件

@@ -5,7 +5,7 @@ import java.security.MessageDigest;

public class ServerVerification {

private String getMsgSignature(String tpToken, String timestamp, String nonce, String encrypt) throws Exception {
public String getMsgSignature(String tpToken, String timestamp, String nonce, String encrypt) throws Exception {
String[] values = new String[] {tpToken, timestamp, nonce, encrypt};
Arrays.sort(values);

@@ -41,9 +41,9 @@ public class ServerVerification {
}
}

private void verify(String msgSignature, String newMsgSignature) {
public boolean verify(String msgSignature, String newMsgSignature) {
boolean res = msgSignature.equals(newMsgSignature);
System.out.println(res);
return res;
}

public static void main(String[] args) throws Exception {


正在加载...
取消
保存