mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-11-01 20:13:12 +08:00
#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:
@ -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);
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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>", "");
|
||||
|
||||
Reference in New Issue
Block a user