修复已知bug

2.14.4版本 微信支付 v3 启动报错 #90
 微信V3初始化apiServerUrl为null
This commit is contained in:
egan
2022-05-05 22:10:02 +08:00
parent 592a619c90
commit 7073d904fe
23 changed files with 82 additions and 79 deletions

View File

@@ -94,6 +94,7 @@ public abstract class BasePayService<PC extends PayConfigStorage> implements Pay
}
public BasePayService(PC payConfigStorage) {
this(payConfigStorage, null);
}
@@ -101,15 +102,11 @@ public abstract class BasePayService<PC extends PayConfigStorage> implements Pay
public BasePayService(PC payConfigStorage, HttpConfigStorage configStorage) {
setPayConfigStorage(payConfigStorage);
setRequestTemplateConfigStorage(configStorage);
initAfter();
}
/**
* 初始化之后执行
*/
protected void initAfter(){
}
/**
* Generate a Base64 encoded String from user , password
*

View File

@@ -428,7 +428,7 @@ public class HttpRequestTemplate {
return new ResponseEntity<>(statusCode, allHeaders, body);
}
catch (IOException e) {
throw new PayErrorException(new PayException("IOException", e.getLocalizedMessage()));
throw new PayErrorException(new PayException("IOException", e.getLocalizedMessage()), e);
}
finally {
httpRequest.releaseConnection();

View File

@@ -1,33 +1,15 @@
package com.egzosn.pay.common.util.sign;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.security.Security;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.UUID;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.http.message.BasicNameValuePair;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import static com.egzosn.pay.common.util.sign.SignTextUtils.parameterText;
import com.egzosn.pay.common.bean.SignType;
import com.egzosn.pay.common.bean.result.PayException;
import com.egzosn.pay.common.exception.PayErrorException;
import com.egzosn.pay.common.util.sign.encrypt.HmacSha256;
import com.egzosn.pay.common.util.str.StringUtils;
/**
* 签名 工具
@@ -209,5 +191,15 @@ public enum SignUtils implements SignType {
return this.verify(parameterText(params), sign, key, characterEncoding);
}
/**
* 初始化BC
*/
public static void initBc() {
if (null == Security.getProvider("BC")) {
Security.removeProvider("SunEC");
Security.addProvider(new BouncyCastleProvider());
}
}
}

View File

@@ -2,13 +2,13 @@ package com.egzosn.pay.common.util.sign.encrypt;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.Security;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.digest.DigestUtils;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import com.egzosn.pay.common.util.sign.SignUtils;
/**
* AES 加解密
@@ -30,12 +30,10 @@ public class AES {
private static final String ALGORITHM_MODE_PADDING = "AES/ECB/PKCS7Padding";
static {
if (null == Security.getProvider("BC")) {
Security.removeProvider("SunEC");
Security.addProvider(new BouncyCastleProvider());
}
SignUtils.initBc();
}
/**
* 解密
*