mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-24 07:23:01 +08:00
改写部分使用StringUtils.equalsAny方法的代码,避免客户端jar包冲突引起不必要的麻烦
This commit is contained in:
parent
3e75064c51
commit
7bb3a1270d
@ -4,6 +4,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
|
|||||||
import com.github.binarywang.wxpay.service.impl.WxPayServiceAbstractImpl;
|
import com.github.binarywang.wxpay.service.impl.WxPayServiceAbstractImpl;
|
||||||
import com.github.binarywang.wxpay.util.SignUtils;
|
import com.github.binarywang.wxpay.util.SignUtils;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.thoughtworks.xstream.XStream;
|
import com.thoughtworks.xstream.XStream;
|
||||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
@ -25,6 +26,7 @@ import javax.xml.xpath.XPathFactory;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -222,9 +224,10 @@ public abstract class WxPayBaseResult {
|
|||||||
throw new WxPayException("参数格式校验错误!");
|
throw new WxPayException("参数格式校验错误!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> successStrings = Lists.newArrayList("SUCCESS", "");
|
||||||
//校验结果是否成功
|
//校验结果是否成功
|
||||||
if (!StringUtils.equalsAny(StringUtils.trimToEmpty(getReturnCode()).toUpperCase(), "SUCCESS", "")
|
if (!successStrings.contains(StringUtils.trimToEmpty(getReturnCode()).toUpperCase())
|
||||||
|| !StringUtils.equalsAny(StringUtils.trimToEmpty(getResultCode()).toUpperCase(), "SUCCESS", "")) {
|
|| !successStrings.contains(StringUtils.trimToEmpty(getResultCode()).toUpperCase())) {
|
||||||
StringBuilder errorMsg = new StringBuilder();
|
StringBuilder errorMsg = new StringBuilder();
|
||||||
if (getReturnCode() != null) {
|
if (getReturnCode() != null) {
|
||||||
errorMsg.append("返回代码:").append(getReturnCode());
|
errorMsg.append("返回代码:").append(getReturnCode());
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.github.binarywang.wxpay.util;
|
package com.github.binarywang.wxpay.util;
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.constant.WxPayConstants.SignType;
|
import com.github.binarywang.wxpay.constant.WxPayConstants.SignType;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import me.chanjar.weixin.common.util.BeanUtils;
|
import me.chanjar.weixin.common.util.BeanUtils;
|
||||||
import org.apache.commons.codec.binary.Hex;
|
import org.apache.commons.codec.binary.Hex;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import javax.crypto.Mac;
|
import javax.crypto.Mac;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
@ -56,8 +56,7 @@ public class SignUtils {
|
|||||||
StringBuilder toSign = new StringBuilder();
|
StringBuilder toSign = new StringBuilder();
|
||||||
for (String key : sortedMap.keySet()) {
|
for (String key : sortedMap.keySet()) {
|
||||||
String value = params.get(key);
|
String value = params.get(key);
|
||||||
if (StringUtils.isNotEmpty(value)
|
if (!Lists.newArrayList("sign", "key", "sign_type").contains(key)) {
|
||||||
&& !StringUtils.equalsAny(key, "sign", "key", "sign_type")) {
|
|
||||||
toSign.append(key).append("=").append(value).append("&");
|
toSign.append(key).append("=").append(value).append("&");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user