Skip to content

Commit

Permalink
Merge pull request chanjarster#218 from ukid/develop
Browse files Browse the repository at this point in the history
票据验证方法
  • Loading branch information
chanjarster committed Oct 23, 2015
2 parents 9363a67 + 123e5ef commit b5f0ee7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ public static String createSign(Map<String, String> packageParams, String signKe
}
}
toSign.append("key=" + signKey);
System.out.println(toSign.toString());
String sign = DigestUtils.md5Hex(toSign.toString())
.toUpperCase();
return sign;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -738,4 +737,15 @@ public interface WxMpService {
* @return
*/
WxMpPayCallback getJSSDKCallbackData(String xmlData);

/**
* <pre>
* 计算Map键值对是否和签名相符,
* 按照字段名的 ASCII 码从小到大排序(字典序)后,使用 URL 键值对的 格式(即 key1=value1&key2=value2...)拼接成字符串
* </pre>
* @param kvm
* @param signature
* @return
*/
public boolean checkJSSDKCallbackDataSignature(Map<String, String> kvm, String signature);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import java.io.InputStream;
import java.io.StringReader;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -76,7 +74,6 @@
import me.chanjar.weixin.mp.util.http.QrCodeRequestExecutor;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.Consts;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
Expand Down Expand Up @@ -937,5 +934,8 @@ public WxMpPayCallback getJSSDKCallbackData(String xmlData) {
return new WxMpPayCallback();
}


@Override
public boolean checkJSSDKCallbackDataSignature(Map<String, String> kvm, String signature) {
return signature.equals(WxCryptUtil.createSign(kvm, wxMpConfigStorage.getPartnerKey()));
}
}

0 comments on commit b5f0ee7

Please sign in to comment.