From bdf7f796e7a230d2f8022ea380ceead3df21950b Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 24 Aug 2017 16:29:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=94=AF=E4=BB=98=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=96=B9?= =?UTF-8?q?=E4=BE=BF=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binarywang/wxpay/config/WxPayConfig.java | 16 ++++++++-------- .../service/impl/WxPayServiceApacheHttpImpl.java | 8 ++++---- .../service/impl/WxPayServiceJoddHttpImpl.java | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java index d512cbe7..7d8cd5e1 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/config/WxPayConfig.java @@ -163,20 +163,20 @@ public class WxPayConfig { } public SSLContext initSSLContext() throws WxPayException { - if (StringUtils.isBlank(mchId)) { + if (StringUtils.isBlank(this.getMchId())) { throw new WxPayException("请确保商户号mchId已设置"); } - if (StringUtils.isBlank(this.keyPath)) { + if (StringUtils.isBlank(this.getKeyPath())) { throw new WxPayException("请确保证书文件地址keyPath已配置"); } InputStream inputStream; final String prefix = "classpath:"; - String fileHasProblemMsg = "证书文件【" + this.keyPath + "】有问题,请核实!"; - String fileNotFoundMsg = "证书文件【" + this.keyPath + "】不存在,请核实!"; - if (this.keyPath.startsWith(prefix)) { - String path = StringUtils.removeFirst(this.keyPath, prefix); + String fileHasProblemMsg = "证书文件【" + this.getKeyPath() + "】有问题,请核实!"; + String fileNotFoundMsg = "证书文件【" + this.getKeyPath() + "】不存在,请核实!"; + if (this.getKeyPath().startsWith(prefix)) { + String path = StringUtils.removeFirst(this.getKeyPath(), prefix); if (!path.startsWith("/")) { path = "/" + path; } @@ -186,7 +186,7 @@ public class WxPayConfig { } } else { try { - File file = new File(this.keyPath); + File file = new File(this.getKeyPath()); if (!file.exists()) { throw new WxPayException(fileNotFoundMsg); } @@ -199,7 +199,7 @@ public class WxPayConfig { try { KeyStore keystore = KeyStore.getInstance("PKCS12"); - char[] partnerId2charArray = mchId.toCharArray(); + char[] partnerId2charArray = this.getMchId().toCharArray(); keystore.load(inputStream, partnerId2charArray); this.sslContext = SSLContexts.custom().loadKeyMaterial(keystore, partnerId2charArray).build(); return this.sslContext; diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java index 14ef7c12..7d8dfcf7 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceApacheHttpImpl.java @@ -53,13 +53,13 @@ public class WxPayServiceApacheHttpImpl extends WxPayServiceAbstractImpl { .setSocketTimeout(this.getConfig().getHttpTimeout()) .build()); - if (StringUtils.isNotBlank(this.config.getHttpProxyHost()) - && this.config.getHttpProxyPort() > 0) { + if (StringUtils.isNotBlank(this.getConfig().getHttpProxyHost()) + && this.getConfig().getHttpProxyPort() > 0) { // 使用代理服务器 需要用户认证的代理服务器 CredentialsProvider provider = new BasicCredentialsProvider(); provider.setCredentials( - new AuthScope(this.config.getHttpProxyHost(), this.config.getHttpProxyPort()), - new UsernamePasswordCredentials(this.config.getHttpProxyUsername(), this.config.getHttpProxyPassword())); + new AuthScope(this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort()), + new UsernamePasswordCredentials(this.getConfig().getHttpProxyUsername(), this.getConfig().getHttpProxyPassword())); httpClientBuilder.setDefaultCredentialsProvider(provider); } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java index 7e7d31d9..553d858c 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceJoddHttpImpl.java @@ -26,8 +26,8 @@ public class WxPayServiceJoddHttpImpl extends WxPayServiceAbstractImpl { try { HttpRequest request = HttpRequest .post(url) - .timeout(this.config.getHttpTimeout()) - .connectionTimeout(this.config.getHttpConnectionTimeout()) + .timeout(this.getConfig().getHttpTimeout()) + .connectionTimeout(this.getConfig().getHttpConnectionTimeout()) .bodyText(requestStr); if (useKey) { @@ -39,9 +39,9 @@ public class WxPayServiceJoddHttpImpl extends WxPayServiceAbstractImpl { request.withConnectionProvider(provider); } - if (StringUtils.isNotBlank(this.config.getHttpProxyHost()) && this.config.getHttpProxyPort() > 0) { - ProxyInfo httpProxy = new ProxyInfo(ProxyType.HTTP, this.config.getHttpProxyHost(), this.config.getHttpProxyPort(), - this.config.getHttpProxyUsername(), this.config.getHttpProxyPassword()); + if (StringUtils.isNotBlank(this.getConfig().getHttpProxyHost()) && this.getConfig().getHttpProxyPort() > 0) { + ProxyInfo httpProxy = new ProxyInfo(ProxyType.HTTP, this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort(), + this.getConfig().getHttpProxyUsername(), this.getConfig().getHttpProxyPassword()); HttpConnectionProvider provider = request.connectionProvider(); if (null == provider) { provider = new SocketHttpConnectionProvider();