#379 WxOpenXmlMessage 增加 加密 WxMpXmlOutMessage接口 MpConfigStorage 返回aeskey和token MpService可以直接加密 增加 全网发布用例

* 增加 微信第三方平台 接口

* WxOpenXmlMessage 消息处理

* 增加 摇周边部分接口

* fix

* fix

* rebase

* 增加 摇周边部分接口

* fix

* fix

* unix 换行符

* fix 三方接口BUG

* fix URL 错误

* WxOpenMpServiceImpl 修改为包可见,防止用户混淆
WxOpenXmlMessage 增加 加密 WxMpXmlOutMessage接口
MpConfigStorage 返回aeskey和token MpService可以直接加密

增加 全网发布用例
This commit is contained in:
007gzs
2017-11-21 20:55:17 +08:00
committed by Binary Wang
parent 556487078c
commit 5c9ec87bb8
5 changed files with 39 additions and 6 deletions

View File

@ -29,11 +29,11 @@ public interface WxOpenComponentService {
/**
* 用code换取oauth2的access token
*/
String OAUTH2_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&code=%s&grant_type=authorization_code&component_appid=%s";
String OAUTH2_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/component/access_token?appid=%s&code=%s&grant_type=authorization_code&component_appid=%s";
/**
* 刷新oauth2的access token
*/
String OAUTH2_REFRESH_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s&component_appid==%s";
String OAUTH2_REFRESH_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/component/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s&component_appid==%s";
WxMpService getWxMpServiceByAppid(String appid);

View File

@ -329,7 +329,7 @@ public class WxOpenInMemoryConfigStorage implements WxOpenConfigStorage {
@Override
public String getToken() {
return null;
return wxOpenConfigStorage.getComponentToken();
}
@Override
@ -340,7 +340,7 @@ public class WxOpenInMemoryConfigStorage implements WxOpenConfigStorage {
@Override
public String getAesKey() {
return null;
return wxOpenConfigStorage.getComponentAesKey();
}
@Override

View File

@ -9,7 +9,7 @@ import me.chanjar.weixin.open.api.WxOpenComponentService;
/**
* @author <a href="https://github.com/007gzs">007</a>
*/
public class WxOpenMpServiceImpl extends WxMpServiceImpl {
/* package */ class WxOpenMpServiceImpl extends WxMpServiceImpl {
private WxOpenComponentService wxOpenComponentService;
private WxMpConfigStorage wxMpConfigStorage;
private String appId;

View File

@ -5,6 +5,7 @@ import com.thoughtworks.xstream.annotations.XStreamConverter;
import lombok.Data;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
import me.chanjar.weixin.open.util.WxOpenCryptUtil;
import me.chanjar.weixin.open.util.xml.XStreamTransformer;
@ -52,6 +53,12 @@ public class WxOpenXmlMessage implements Serializable {
@XStreamConverter(value = XStreamCDataConverter.class)
private String preAuthCode;
public static String wxMpOutXmlMessageToEncryptedXml(WxMpXmlOutMessage message, WxOpenConfigStorage wxOpenConfigStorage){
String plainXml = message.toXml();
WxOpenCryptUtil pc = new WxOpenCryptUtil(wxOpenConfigStorage);
return pc.encrypt(plainXml);
}
public static WxOpenXmlMessage fromXml(String xml) {
//修改微信变态的消息内容格式,方便解析
xml = xml.replace("</PicList><PicList>", "");