mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-31 04:49:54 +08:00
@@ -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
|
||||
*
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user