diff --git a/maven-version-rules.xml b/maven-version-rules.xml new file mode 100644 index 00000000..b3872f47 --- /dev/null +++ b/maven-version-rules.xml @@ -0,0 +1,23 @@ + + + .*(-|\.)(alpha|Alpha|ALPHA|beta|Beta|BETA|rc|RC).* + + + + + .*-alpha[\.\-].* + .*-b[0-9]+ + + + + + .*-b.* + + + + diff --git a/pom.xml b/pom.xml index 4710d7bf..4df3d954 100644 --- a/pom.xml +++ b/pom.xml @@ -2,9 +2,14 @@ 4.0.0 + + org.oxerr + oxerr-parent + 1.1.0 + com.foxinmy weixin4j - 1.9.1 + 1.10.0 pom weixin4j https://github.com/foxinmy/weixin4j @@ -19,7 +24,7 @@ - https://github.com/foxinmy/weixin4j + https://github.com/foxinmy/weixin4j/tree/master scm:git:git://github.com/foxinmy/weixin4j.git scm:git:git@github.com:foxinmy/weixin4j.git HEAD @@ -48,29 +53,18 @@ weixin4j-serverX weixin4j-pay weixin4j-example + weixin4j-coverage - UTF-8 1.6 1.6 - 1.2.31 + zh_CN - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - 1.6 - 1.6 - ${project.build.sourceEncoding} - - org.apache.maven.plugins maven-resources-plugin - 2.6 ${project.build.sourceEncoding} @@ -83,35 +77,29 @@ - org.apache.maven.plugins - maven-jar-plugin - 2.5 - - - default-jar - package - - jar - - - target/classes - - *.properties - *.xml - *.txt - **/*.md - - - true - - true - - - + org.codehaus.mojo + versions-maven-plugin + + file:///${session.executionRootDirectory}/maven-version-rules.xml + - com.amashchenko.maven.plugin - gitflow-maven-plugin + org.jacoco + jacoco-maven-plugin + + + + prepare-agent + + + + report + verify + + report + + + @@ -149,19 +137,11 @@ public - ${project.build.sourceEncoding} - ${project.build.sourceEncoding} - ${project.build.sourceEncoding} http://docs.oracle.com/javase/7/docs/api - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 - org.apache.maven.plugins maven-gpg-plugin @@ -175,19 +155,6 @@ - - org.apache.maven.plugins - maven-site-plugin - 3.9.1 - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18 - - true - - org.apache.maven.plugins maven-assembly-plugin @@ -208,9 +175,14 @@ - com.amashchenko.maven.plugin - gitflow-maven-plugin - 1.15.0 + org.codehaus.mojo + findbugs-maven-plugin + 3.0.5 + + + org.jacoco + jacoco-maven-plugin + 0.8.7 @@ -307,17 +279,72 @@ + + javax.servlet.jsp + jsp-api + 2.2 + + + javax.xml.bind + jaxb-api + 2.3.1 + + + org.apache.httpcomponents + httpclient + 4.5.13 + org.bouncycastle bcprov-jdk16 1.46 + + org.springframework + spring-context + 5.3.9 + + + org.springframework + spring-webmvc + 5.3.9 + + + com.alibaba + fastjson + 1.2.78 + + + com.squareup.okhttp3 + okhttp + 4.9.1 + + + ch.qos.logback + logback-core + 1.2.5 + + + io.netty + netty-all + 4.1.67.Final + + + commons-codec + commons-codec + 1.15 + junit junit - 4.13.1 + 4.13.2 test + + redis.clients + jedis + 3.6.3 + diff --git a/weixin4j-base/pom.xml b/weixin4j-base/pom.xml index cb24f6a1..bb2053d0 100644 --- a/weixin4j-base/pom.xml +++ b/weixin4j-base/pom.xml @@ -5,13 +5,43 @@ com.foxinmy weixin4j - 1.9.1 + 1.10.0 weixin4j-base weixin4j-base 微信开发基础工程 https://github.com/foxinmy/weixin4j/tree/master/weixin4j-base + + true + + + + org.apache.maven.plugins + maven-jar-plugin + + + default-jar + package + + jar + + + target/classes + + *.properties + *.xml + *.txt + **/*.md + + + true + + + + + + src/main/resources @@ -23,7 +53,6 @@ com.alibaba fastjson - ${fastjson.version} junit @@ -32,25 +61,22 @@ commons-httpclient commons-httpclient - 3.0 + 3.1 true org.apache.httpcomponents httpclient - 4.3.6 true io.netty netty-all - 4.1.42.Final true com.squareup.okhttp3 okhttp - 3.4.1 true @@ -62,7 +88,6 @@ redis.clients jedis - 2.8.1 true @@ -79,7 +104,6 @@ javax.xml.bind jaxb-api - 2.2.11 provided diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisCacheStorager.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisCacheStorager.java index de084bd4..84a3f238 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisCacheStorager.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/cache/RedisCacheStorager.java @@ -8,7 +8,7 @@ import com.foxinmy.weixin4j.util.SerializationUtils; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; -import redis.clients.util.Pool; +import redis.clients.jedis.util.Pool; /** * 用Redis保存缓存对象(推荐使用) diff --git a/weixin4j-coverage/pom.xml b/weixin4j-coverage/pom.xml new file mode 100644 index 00000000..56c4018f --- /dev/null +++ b/weixin4j-coverage/pom.xml @@ -0,0 +1,77 @@ + + + 4.0.0 + + + com.foxinmy + weixin4j + 1.10.0 + + + weixin4j-coverage + weixin4j-coverage + pom + Compute aggregated test code coverage. + + + true + + + + + ${project.groupId} + weixin4j-base + ${project.version} + + + ${project.groupId} + weixin4j-mp + ${project.version} + + + ${project.groupId} + weixin4j-qy + ${project.version} + + + ${project.groupId} + weixin4j-wxa + ${project.version} + + + ${project.groupId} + weixin4j-server + ${project.version} + + + ${project.groupId} + weixin4j-serverX + ${project.version} + + + ${project.groupId} + weixin4j-pay + ${project.version} + + + + + + + org.jacoco + jacoco-maven-plugin + + + + report-aggregate + + + + + + + + diff --git a/weixin4j-example/pom.xml b/weixin4j-example/pom.xml index a5639f6a..6abc1c1d 100644 --- a/weixin4j-example/pom.xml +++ b/weixin4j-example/pom.xml @@ -5,7 +5,7 @@ com.foxinmy weixin4j - 1.9.1 + 1.10.0 war weixin4j-example @@ -76,7 +76,6 @@ org.springframework spring-webmvc - 4.1.3.RELEASE javax.servlet @@ -87,7 +86,6 @@ javax.servlet.jsp jsp-api - 2.1 provided @@ -103,7 +101,6 @@ com.squareup.okhttp3 okhttp - 3.3.1 diff --git a/weixin4j-mp/pom.xml b/weixin4j-mp/pom.xml index e33e2df5..61161c5e 100644 --- a/weixin4j-mp/pom.xml +++ b/weixin4j-mp/pom.xml @@ -5,18 +5,46 @@ com.foxinmy weixin4j - 1.9.1 + 1.10.0 weixin4j-mp weixin4j-mp https://github.com/foxinmy/weixin4j/tree/master/weixin4j-mp 微信公众平台API + + true + org.apache.maven.plugins maven-assembly-plugin + + org.apache.maven.plugins + maven-jar-plugin + + + default-jar + package + + jar + + + target/classes + + *.properties + *.xml + *.txt + **/*.md + + + true + + + + + @@ -29,7 +57,6 @@ javax.xml.bind jaxb-api - 2.2.11 provided diff --git a/weixin4j-pay/pom.xml b/weixin4j-pay/pom.xml index e28e51c8..cda1166c 100644 --- a/weixin4j-pay/pom.xml +++ b/weixin4j-pay/pom.xml @@ -1,53 +1,83 @@ - - - weixin4j - com.foxinmy - 1.9.1 - - 4.0.0 - weixin4j-pay - weixin4j-pay - https://github.com/foxinmy/weixin4j/tree/master/weixin4j-pay - 微信支付商户平台API - - - kit-lee - Kit lee - ryuji.cn@gmail.com - https://github.com/kit-lee - - kit_21cn@21cn.com - https://github.com/kit-lee/weixin4j - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - - com.foxinmy - weixin4j-base - ${project.version} - - - - javax.xml.bind - jaxb-api - 2.2.11 - provided - - - junit - junit - - + + + weixin4j + com.foxinmy + 1.10.0 + + 4.0.0 + weixin4j-pay + weixin4j-pay + https://github.com/foxinmy/weixin4j/tree/master/weixin4j-pay + 微信支付商户平台API + + true + + + + kit-lee + Kit lee + ryuji.cn@gmail.com + https://github.com/kit-lee + + kit_21cn@21cn.com + https://github.com/kit-lee/weixin4j + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + default-jar + package + + jar + + + target/classes + + *.properties + *.xml + *.txt + **/*.md + + + true + + + + + + + + + + com.foxinmy + weixin4j-base + ${project.version} + + + + javax.xml.bind + jaxb-api + provided + + + junit + junit + + diff --git a/weixin4j-qy/pom.xml b/weixin4j-qy/pom.xml index 267d9581..866faf8d 100644 --- a/weixin4j-qy/pom.xml +++ b/weixin4j-qy/pom.xml @@ -5,18 +5,46 @@ com.foxinmy weixin4j - 1.9.1 + 1.10.0 weixin4j-qy weixin4j-qy https://github.com/foxinmy/weixin4j/tree/master/weixin4j-qy 微信企业号API + + true + org.apache.maven.plugins maven-assembly-plugin + + org.apache.maven.plugins + maven-jar-plugin + + + default-jar + package + + jar + + + target/classes + + *.properties + *.xml + *.txt + **/*.md + + + true + + + + + diff --git a/weixin4j-server/pom.xml b/weixin4j-server/pom.xml index e87af0da..bbc47dc6 100644 --- a/weixin4j-server/pom.xml +++ b/weixin4j-server/pom.xml @@ -6,12 +6,15 @@ com.foxinmy weixin4j - 1.9.1 + 1.10.0 weixin4j-server weixin4j-server https://github.com/foxinmy/weixin4j/tree/master/weixin4j-server 微信消息netty服务器 + + true + io.netty @@ -27,13 +30,11 @@ com.alibaba fastjson - ${fastjson.version} javax.xml.bind jaxb-api - 2.2.11 provided @@ -43,13 +44,11 @@ org.apache.httpcomponents httpclient - 4.3.6 test org.springframework spring-context - 4.2.0.RELEASE true diff --git a/weixin4j-serverX/pom.xml b/weixin4j-serverX/pom.xml index 611aad32..f9f8c6df 100644 --- a/weixin4j-serverX/pom.xml +++ b/weixin4j-serverX/pom.xml @@ -6,15 +6,12 @@ com.foxinmy weixin4j - 1.9.1 + 1.10.0 weixin4j-serverX weixin4j-serverX https://github.com/foxinmy/weixin4j/tree/master/weixin4j-serverX 微信消息接入服务(spring mvc实现) - - 4.2.0.RELEASE - junit @@ -23,13 +20,11 @@ org.springframework spring-webmvc - ${spring.version} javax.xml.bind jaxb-api - 2.2.11 provided @@ -47,7 +42,6 @@ javax.servlet.jsp jsp-api provided - 2.1 diff --git a/weixin4j-wxa/pom.xml b/weixin4j-wxa/pom.xml index cc04275b..6a433666 100644 --- a/weixin4j-wxa/pom.xml +++ b/weixin4j-wxa/pom.xml @@ -5,7 +5,7 @@ com.foxinmy weixin4j - 1.9.1 + 1.10.0 weixin4j-wxa weixin4j-wxa @@ -21,19 +21,18 @@ - com.foxinmy + ${project.groupId} weixin4j-base ${project.version} - com.foxinmy + ${project.groupId} weixin4j-mp ${project.version} commons-codec commons-codec - 1.10 junit @@ -42,7 +41,6 @@ ch.qos.logback logback-core - 1.1.8 test diff --git a/weixin4j-wxa/src/main/java/com/foxinmy/weixin4j/wxa/WXBizDataCrypt.java b/weixin4j-wxa/src/main/java/com/foxinmy/weixin4j/wxa/WXBizDataCrypt.java index 2e2fc943..42feca96 100644 --- a/weixin4j-wxa/src/main/java/com/foxinmy/weixin4j/wxa/WXBizDataCrypt.java +++ b/weixin4j-wxa/src/main/java/com/foxinmy/weixin4j/wxa/WXBizDataCrypt.java @@ -15,12 +15,12 @@ import com.alibaba.fastjson.JSONObject; */ public class WXBizDataCrypt { - private final String appid; + private final String appId; private final String sessionKey; - public WXBizDataCrypt(String appid, String sessionKey) { - this.appid = appid; + public WXBizDataCrypt(String appId, String sessionKey) { + this.appId = appId; this.sessionKey = sessionKey; } @@ -40,8 +40,8 @@ public class WXBizDataCrypt { final String decryptedText = new String(decryptedBytes, Charset.forName("UTF-8")); final JSONObject decrypted = JSON.parseObject(decryptedText); - final String appId = decrypted.getJSONObject("watermark").getString("appid"); - if (!appId.equals(this.appid)) { + final String watermarkAppId = decrypted.getJSONObject("watermark").getString("appid"); + if (!watermarkAppId.equals(this.appId)) { throw new IllegalArgumentException("Invalid Buffer"); } diff --git a/weixin4j-wxa/src/site/markdown/index.md b/weixin4j-wxa/src/site/markdown/index.md new file mode 100644 index 00000000..99071e80 --- /dev/null +++ b/weixin4j-wxa/src/site/markdown/index.md @@ -0,0 +1,33 @@ +## 欢迎来到 weixin4j-wxa +微信小程序 API 支持 + +### 如何使用 + +```java +var appId = "YOUR APP ID"; +var appSecret = "YOUR APP SECRET"; +var wxAccount = new WeixinAccount(appId, appSecret); +var wxa = new WeixinAppFacade(wxAccount); +var jsCode = request.getParameter("jsCode"); +var session = wxa.getLoginApi().jscode2session(jsCode); +``` + +*更多 API 见 [WeixinAppFacade JavaDoc](apidocs/index.html?com/foxinmy/weixin4j/wxa/WeixinAppFacade.html)。* + +### 解密数据 +客户端 API +[`wx.getUserInfo(Object object)`](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html) +[`wx.getUserProfile(Object object)`](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserProfile.html) +等请求后得到的加密数据,可以通过下面的方法来解密。 + +客户端将获得的加密数据发往业务服务器,业务服务器收到加密数据后, +使用[登录凭证校验 API](apidocs/index.html?com/foxinmy/weixin4j/wxa/api/LoginApi.html) +获得的 `sessionKey` 解密并进行后续操作: + +```java +var encryptedData = request.getParameter("encryptedData"); +var iv = request.getParameter("iv"); +var sessionKey = session.getSessionKey(); +var wxBizDataCrypt = new WXBizDataCrypt(appId, sessionKey); +var decryptedData = wxBizDataCrypt.decryptData(encryptedData, iv); +``` diff --git a/weixin4j-wxa/src/site/site.xml b/weixin4j-wxa/src/site/site.xml new file mode 100644 index 00000000..7a2d5ea6 --- /dev/null +++ b/weixin4j-wxa/src/site/site.xml @@ -0,0 +1,21 @@ + + + + 微信小程序 + + + 微信小程序 + 微信小程序 + data:image/svg+xml;charset=UTF-8,%3csvg width='36' height='36' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M27.4362985 16.6454925c-.7072239 1.1607165-1.8835821 2.0505075-3.2927761 2.4601791-.0354627.0102687-.0705672.0212538-.1062687.0309254-.2176716.0618508-.4409552.0997015-.6622089.0997015-.9763582 0-1.5276418-.6594627-1.2315224-1.4730746.216597-.5949851.785194-1.097194 1.4791642-1.3296717 1.0755821-.3922388 1.8271044-1.2868059 1.8271044-2.3277612 0-1.4026268-1.3645373-2.5397014-3.0476417-2.5397014-1.6832239 0-3.0476418 1.1370746-3.0476418 2.5397014v7.788418c0 1.8730746-1.0852538 3.515582-2.709015 4.4445373-.8851343.506388-1.9277612.8040597-3.0475224.8040597-3.1743283 0-5.75665667-2.3545075-5.75665667-5.248597 0-.9211941.26340299-1.7863881.72238806-2.5397015.71032836-1.1658508 1.89397011-2.0586269 3.31164181-2.4656717.001194-.0003582.0022686-.0007164.0034627-.0010746.2390447-.0743881.4869253-.1157015.7313433-.1157015.9806567 0 1.5345671.6625672 1.2371343 1.4797612-.2015523.553791-.7443582 1.0306866-1.377194 1.2844179-.0755821.025194-.1491344.0534925-.2217314.0833433-1.0052537.4150448-1.6980298 1.2762985-1.6980298 2.2746269 0 1.4026268 1.3644179 2.539582 3.0476417 2.539582 1.6831045 0 3.0475224-1.1369552 3.0475224-2.539582v-7.788418c0-1.873194 1.0851344-3.515582 2.709015-4.44465667.8851343-.50638806 1.9277612-.8040597 3.0476418-.8040597 3.1742089 0 5.7566567 2.35450747 5.7566567 5.24871637 0 .9210747-.2635224 1.7863881-.7225075 2.5397015M18 2C9.16346269 2 2 9.16346269 2 18c0 8.8365373 7.16346269 16 16 16 8.8365373 0 16-7.1634627 16-16 0-8.83653731-7.1634627-16-16-16' fill='%2307C160' fill-rule='evenodd'/%3e%3c/svg%3e + https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/backend-api.html + + + + + + +