Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:Wechat-Group/weixin-java-tools i…
Browse files Browse the repository at this point in the history
…nto wechat-develop

* 'develop' of github.com:Wechat-Group/weixin-java-tools: (67 commits)
  发布3.3.1.B测试版本
  Wechat-Group#900 增加新增团购券、现金抵扣券、折扣券、兑换券以及普通优惠券的接口
  Wechat-Group#899 WxCpXmlMessage增加存放xml消息的所有属性值的allFieldsMap属性
  企业微信部门创建接口create返回值改为long类型
  修改totalFee字段类型为Integer
  update contributor list
  Update demo.md
  Update readme.md
  Upgrade org.dom4j:dom4j to version 2.1.1
  Update readme.md
  更改版本号,准备发布最新正式版
  项目更名
  Update readme.md
  Update readme.md
  Update readme.md
  Wechat-Group#888 修复微信支付部分接口请求中签名方法不统一的问题
  增加些注释
  优化代码
  发布3.2.10.B测试版本
  Wechat-Group#889 修复一些潜在的XXE漏洞代码
  ...
  • Loading branch information
comeonc committed Jan 2, 2019
2 parents d886704 + 8c45021 commit f5fe09d
Show file tree
Hide file tree
Showing 135 changed files with 3,530 additions and 1,226 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ sonar-project.properties

!/.mvn/wrapper/maven-wrapper.jar
*.versionsBackup

# STS
.factorypath
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please refer to [【代码贡献指南】](contribution.md).
6 changes: 3 additions & 3 deletions contribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
-***暂停此种方式,请使用第一种***)另外一种贡献代码的方式就是加入SDK Developers开发组,前提是对自己的代码足够自信就可以申请加入,加入之后可以随时直接提交代码,但要注意对所做的修改或新增的代码进行单元测试,保证提交代码没有明显问题。

### PR方式贡献代码步骤
* 在 GitHub 上 `fork` 到自己的仓库,如 `my_user/weixin-java-tools`,然后 `clone` 到本地,并设置用户信息。
* 在 GitHub 上 `fork` 到自己的仓库,如 `my_user/WxJava`,然后 `clone` 到本地,并设置用户信息。

```bash
$ git clone git@github.com:my_user/weixin-java-tools.git
$ git clone git@github.com:my_user/WxJava.git
$ cd weixin-java-tools
$ git config user.name "yourname"
$ git config user.email "your email"
Expand All @@ -27,7 +27,7 @@ $ git push
* 定期使用项目仓库内容更新自己仓库内容。

```bash
$ git remote add upstream https://github.com/wechat-group/weixin-java-tools
$ git remote add upstream https://github.com/Wechat-Group/WxJava
$ git fetch upstream
$ git checkout develop
$ git rebase upstream/develop
Expand Down
4 changes: 2 additions & 2 deletions demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
1. 开放平台Demo:[GitHub](http://github.com/Wechat-Group/weixin-java-open-demo)[码云](http://gitee.com/binary/weixin-java-open-demo)
1. 公众号Demo:
- 使用Spring MVC实现的公众号Demo:[GitHub](http://github.com/binarywang/weixin-java-mp-demo-springmvc)、[码云](https://gitee.com/binary/weixin-java-mp-demo)
- 使用Spring Boot实现的公众号Demo:[GitHub](http://github.com/binarywang/weixin-java-mp-demo-springboot)、[码云](http://gitee.com/binary/weixin-java-mp-demo-springboot)
- 含公众号和部分微信支付代码的Demo:[GitHub](http://github.com/Wechat-Group/weixin-java-tools-springmvc)、[码云](http://gitee.com/binary/weixin-java-tools-springmvc)
- 使用Spring Boot实现的公众号Demo(支持多公众号):[GitHub](http://github.com/binarywang/weixin-java-mp-demo-springboot)、[码云](http://gitee.com/binary/weixin-java-mp-demo-springboot)
- 含公众号和部分微信支付代码的Demo:[GitHub](http://github.com/Wechat-Group/weixin-java-springmvc)、[码云](http://gitee.com/binary/weixin-java-tools-springmvc)
15 changes: 10 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>3.2.4.B</version>
<artifactId>wx-java</artifactId>
<version>3.3.1.B</version>
<packaging>pom</packaging>
<name>Weixin Java Tools - Parent</name>
<name>WxJava - Weixin/Wechat Java SDK</name>
<description>微信开发Java SDK</description>
<url>https://github.com/wechat-group/weixin-java-tools</url>
<url>https://github.com/Wechat-Group/WxJava</url>

<licenses>
<license>
Expand Down Expand Up @@ -85,6 +85,11 @@
<email>007gzs@gmail.com</email>
<url>https://github.com/007gzs</url>
</developer>
<developer>
<name>Howard Liu</name>
<email>liuxinghao1988@gmail.com</email>
<url>https://github.com/howardliu-cn</url>
</developer>
</developers>

<scm>
Expand All @@ -109,7 +114,7 @@

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<httpclient.version>4.5</httpclient.version>
<jetty.version>9.3.0.RC0</jetty.version>
<jetty.version>9.3.24.v20180605</jetty.version>
</properties>

<dependencyManagement>
Expand Down
Binary file modified qrcodes/alipay_qrcode.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed qrcodes/wechat_qrcode.jpg
Binary file not shown.
122 changes: 65 additions & 57 deletions readme.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions weixin-java-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>3.2.4.B</version>
<artifactId>wx-java</artifactId>
<version>3.3.1.B</version>
</parent>

<artifactId>weixin-java-common</artifactId>
<name>Weixin Java Tools - Common</name>
<name>WxJava - Common</name>
<description>微信开发Java SDK公共模块</description>

<dependencies>
Expand Down Expand Up @@ -117,7 +117,7 @@
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.0.0</version>
<version>2.1.1</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void run() {
}
}
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public void run() {
Thread.sleep(StandardSessionManager.this.backgroundProcessorDelay * 1000L);
backgroundProcess();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
StandardSessionManager.this.log.error("SessionManagerImpl.backgroundProcess error", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public class WxCryptUtil {
@Override
protected DocumentBuilder initialValue() {
try {
return DocumentBuilderFactory.newInstance().newDocumentBuilder();
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setExpandEntityReferences(false);
return factory.newDocumentBuilder();
} catch (ParserConfigurationException exc) {
throw new IllegalArgumentException(exc);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package me.chanjar.weixin.common.util.http;

import java.io.File;
import java.io.IOException;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaDownloadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMediaDownloadRequestExecutor;

import java.io.File;

/**
* 下载媒体文件请求执行器,请求的参数是String, 返回的结果是File
* 下载媒体文件请求执行器.
* 请求的参数是String, 返回的结果是File
* 视频文件不支持下载
*
* @author Daniel Qian
Expand All @@ -21,6 +24,11 @@ public BaseMediaDownloadRequestExecutor(RequestHttp<H, P> requestHttp, File tmpD
this.tmpDirFile = tmpDirFile;
}

@Override
public void execute(String uri, String data, ResponseHandler<File> handler) throws WxErrorException, IOException {
handler.handle(this.execute(uri, data));
}

public static RequestExecutor<File, String> create(RequestHttp requestHttp, File tmpDirFile) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public String getFileName() throws WxErrorException {
private String getFileName(CloseableHttpResponse response) throws WxErrorException {
Header[] contentDispositionHeader = response.getHeaders("Content-disposition");
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").errorCode(99999).build());
}

return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
Expand All @@ -76,15 +76,15 @@ private String getFileName(Response response) throws WxErrorException {

private String extractFileNameFromContentString(String content) throws WxErrorException {
if (content == null || content.length() == 0) {
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").errorCode(99999).build());
}

Matcher m = PATTERN.matcher(content);
if (m.matches()) {
return m.group(1);
}

throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").errorCode(99999).build());
}

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package me.chanjar.weixin.common.util.http;

import java.io.File;
import java.io.IOException;

import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpMediaUploadRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpMediaUploadRequestExecutor;

import java.io.File;

/**
* 上传媒体文件请求执行器,请求的参数是File, 返回的结果是String
* 上传媒体文件请求执行器.
* 请求的参数是File, 返回的结果是String
*
* @author Daniel Qian
*/
Expand All @@ -19,6 +22,11 @@ public MediaUploadRequestExecutor(RequestHttp requestHttp) {
this.requestHttp = requestHttp;
}

@Override
public void execute(String uri, File data, ResponseHandler<WxMediaUploadResult> handler) throws WxErrorException, IOException {
handler.handle(this.execute(uri, data));
}

public static RequestExecutor<WxMediaUploadResult, File> create(RequestHttp requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package me.chanjar.weixin.common.util.http;

import me.chanjar.weixin.common.error.WxErrorException;

import java.io.IOException;

import me.chanjar.weixin.common.error.WxErrorException;

/**
* http请求执行器
* http请求执行器.
*
* @param <T> 返回值类型
* @param <E> 请求参数类型
Expand All @@ -14,8 +14,25 @@
public interface RequestExecutor<T, E> {

/**
* 执行http请求.
*
* @param uri uri
* @param data 数据
* @return 响应结果
* @throws WxErrorException 自定义异常
* @throws IOException io异常
*/
T execute(String uri, E data) throws WxErrorException, IOException;


/**
* 执行http请求.
*
* @param uri uri
* @param data 数据
* @param handler http响应处理器
* @throws WxErrorException 自定义异常
* @throws IOException io异常
*/
void execute(String uri, E data, ResponseHandler<T> handler) throws WxErrorException, IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@

/**
* Created by ecoolper on 2017/4/22.
*
* @author ecoolper
*/
public interface RequestHttp<H, P> {

/**
* 返回httpClient
* 返回httpClient.
*
* @return 返回httpClient
*/
H getRequestHttpClient();

/**
* 返回httpProxy
* 返回httpProxy.
*
* @return 返回httpProxy
*/
P getRequestHttpProxy();

/**
* 返回HttpType.
*
* @return HttpType
*/
HttpType getRequestType();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package me.chanjar.weixin.common.util.http;

/**
* <pre>
* http请求响应回调处理接口.
* Created by Binary Wang on 2018/12/8.
* </pre>
*
* @param <T> 返回值类型
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public interface ResponseHandler<T> {
/**
* 响应结果处理.
*
* @param t 要处理的对象
*/
void handle(T t);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package me.chanjar.weixin.common.util.http;

import java.io.IOException;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientSimpleGetRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimpleGetRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpSimpleGetRequestExecutor;

/**
* 简单的GET请求执行器,请求的参数是String, 返回的结果也是String
* 简单的GET请求执行器.
* 请求的参数是String, 返回的结果也是String
*
* @author Daniel Qian
*/
Expand All @@ -16,6 +20,11 @@ public SimpleGetRequestExecutor(RequestHttp<H, P> requestHttp) {
this.requestHttp = requestHttp;
}

@Override
public void execute(String uri, String data, ResponseHandler<String> handler) throws WxErrorException, IOException {
handler.handle(this.execute(uri, data));
}

public static RequestExecutor<String, String> create(RequestHttp requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package me.chanjar.weixin.common.util.http;

import java.io.IOException;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.apache.ApacheSimplePostRequestExecutor;
import me.chanjar.weixin.common.util.http.jodd.JoddHttpSimplePostRequestExecutor;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpSimplePostRequestExecutor;
Expand All @@ -17,6 +20,11 @@ public SimplePostRequestExecutor(RequestHttp requestHttp) {
this.requestHttp = requestHttp;
}

@Override
public void execute(String uri, String data, ResponseHandler<String> handler) throws WxErrorException, IOException {
handler.handle(this.execute(uri, data));
}

public static RequestExecutor<String, String> create(RequestHttp requestHttp) {
switch (requestHttp.getRequestType()) {
case APACHE_HTTP:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package me.chanjar.weixin.common.util.http.apache;

import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
import java.io.IOException;

import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;

import java.io.IOException;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.http.RequestHttp;
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;

/**
* Created by ecoolper on 2017/5/4.
Expand Down
Loading

0 comments on commit f5fe09d

Please sign in to comment.