企业号:新增获取微信服务器IP地址接口&调整回调模式下的首次验证的签名方式
This commit is contained in:
@@ -15,7 +15,6 @@ public class HttpWeixinMessage implements Serializable {
|
||||
@XStreamAlias("Encrypt")
|
||||
private String encryptContent;
|
||||
private EncryptType encryptType;
|
||||
private String msgSignature;
|
||||
|
||||
// 以下字段每次被动消息时都会带上
|
||||
private String echoStr;
|
||||
@@ -23,10 +22,11 @@ public class HttpWeixinMessage implements Serializable {
|
||||
private String nonce;
|
||||
private String signature;
|
||||
|
||||
// 冗余字段
|
||||
private String token;
|
||||
|
||||
// xml消息主体
|
||||
private String xmlContent;
|
||||
// xml消息明文主体
|
||||
private String originalContent;
|
||||
|
||||
// request method
|
||||
private String method;
|
||||
@@ -55,14 +55,6 @@ public class HttpWeixinMessage implements Serializable {
|
||||
this.encryptType = encryptType;
|
||||
}
|
||||
|
||||
public String getMsgSignature() {
|
||||
return msgSignature;
|
||||
}
|
||||
|
||||
public void setMsgSignature(String msgSignature) {
|
||||
this.msgSignature = msgSignature;
|
||||
}
|
||||
|
||||
public String getEchoStr() {
|
||||
return echoStr;
|
||||
}
|
||||
@@ -103,12 +95,12 @@ public class HttpWeixinMessage implements Serializable {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getXmlContent() {
|
||||
return xmlContent;
|
||||
public String getOriginalContent() {
|
||||
return originalContent;
|
||||
}
|
||||
|
||||
public void setXmlContent(String xmlContent) {
|
||||
this.xmlContent = xmlContent;
|
||||
public void setOriginalContent(String originalContent) {
|
||||
this.originalContent = originalContent;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
@@ -123,9 +115,9 @@ public class HttpWeixinMessage implements Serializable {
|
||||
public String toString() {
|
||||
return "HttpMessage [toUserName=" + toUserName + ", encryptContent="
|
||||
+ encryptContent + ", encryptType=" + encryptType
|
||||
+ ", msgSignature=" + msgSignature + ", echoStr=" + echoStr
|
||||
+ ", timeStamp=" + timeStamp + ", nonce=" + nonce
|
||||
+ ", signature=" + signature + ", token=" + token
|
||||
+ ", xmlContent=" + xmlContent + ", method=" + method + "]";
|
||||
+ ", echoStr=" + echoStr + ", timeStamp=" + timeStamp
|
||||
+ ", nonce=" + nonce + ", signature=" + signature + ", token="
|
||||
+ token + ", originalContent=" + originalContent + ", method="
|
||||
+ method + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class MessageUtil {
|
||||
/**
|
||||
* 对xml消息加密
|
||||
*
|
||||
* @param appId
|
||||
* @param appId 应用ID
|
||||
* @param encodingAesKey
|
||||
* 加密密钥
|
||||
* @param xmlContent
|
||||
@@ -107,7 +107,7 @@ public class MessageUtil {
|
||||
// 使用BASE64对加密后的字符串进行编码
|
||||
return Base64.encodeBase64String(encrypted);
|
||||
} catch (Exception e) {
|
||||
throw new WeixinException("-40006", "AES加密失败");
|
||||
throw new WeixinException("-40006", "AES加密失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class MessageUtil {
|
||||
// 解密
|
||||
original = cipher.doFinal(encrypted);
|
||||
} catch (Exception e) {
|
||||
throw new WeixinException("-40007", "AES解密失败");
|
||||
throw new WeixinException("-40007", "AES解密失败:" + e.getMessage());
|
||||
}
|
||||
String xmlContent, fromAppId;
|
||||
try {
|
||||
@@ -156,7 +156,8 @@ public class MessageUtil {
|
||||
fromAppId = new String(Arrays.copyOfRange(bytes, 20 + xmlLength,
|
||||
bytes.length), org.apache.http.Consts.UTF_8);
|
||||
} catch (Exception e) {
|
||||
throw new WeixinException("-40008", "公众平台发送的xml不合法");
|
||||
throw new WeixinException("-40008", "公众平台发送的xml不合法:"
|
||||
+ e.getMessage());
|
||||
}
|
||||
// 校验appId是否一致
|
||||
if (!fromAppId.trim().equals(appId)) {
|
||||
@@ -198,8 +199,7 @@ public class MessageUtil {
|
||||
return null;
|
||||
}
|
||||
MessageType messageType = MessageType.valueOf(type.toLowerCase());
|
||||
Class<? extends BaseMsg> messageClass = messageType
|
||||
.getMessageClass();
|
||||
Class<? extends BaseMsg> messageClass = messageType.getMessageClass();
|
||||
if (messageType == MessageType.event) {
|
||||
type = doc.selectSingleNode("/xml/Event").getStringValue();
|
||||
messageClass = EventType.valueOf(type.toLowerCase())
|
||||
|
||||
Reference in New Issue
Block a user