View Javadoc
1   package com.zone.weixin4j.request;
2   
3   import com.zone.weixin4j.type.EncryptType;
4   import com.zone.weixin4j.util.AesToken;
5   
6   import javax.servlet.http.HttpServletRequest;
7   
8   
9   /**
10   * 微信请求
11   *
12   * @author jinyu(foxinmy@gmail.com)
13   * @className WeixinRequest
14   * @date 2015年3月29日
15   * @see
16   * @since JDK 1.6
17   */
18  public class WeixinRequest {
19  
20      /**
21       * 请求的URI
22       */
23      private String uri;
24  
25      // 以下字段每次被动消息时都会带上
26      /**
27       * 随机字符串
28       */
29      private String echoStr;
30      /**
31       * 时间戳
32       */
33      private String timeStamp;
34      /**
35       * 随机数
36       */
37      private String nonce;
38      /**
39       * 参数签名
40       */
41      private String signature;
42      /**
43       * AES模式下消息签名
44       */
45      private String msgSignature;
46  
47      /**
48       * 加密类型(POST时存在)
49       *
50       * @see com.zone.weixin4j.type.EncryptType
51       */
52      private EncryptType encryptType;
53  
54      /**
55       * xml消息明文主体
56       */
57      private String originalContent;
58  
59      /**
60       * xml消息密文主体(AES时存在)
61       */
62      private String encryptContent;
63      /**
64       * aes & token
65       */
66      private AesToken aesToken;
67  
68      private HttpServletRequest request;
69  
70      public WeixinRequest(String uri,
71                           EncryptType encryptType, String echoStr, String timeStamp,
72                           String nonce, String signature, String msgSignature,
73                           String originalContent, String encryptContent, AesToken aesToken) {
74          this.uri = uri;
75          this.encryptType = encryptType;
76          this.echoStr = echoStr;
77          this.timeStamp = timeStamp;
78          this.nonce = nonce;
79          this.signature = signature;
80          this.msgSignature = msgSignature;
81          this.originalContent = originalContent;
82          this.encryptContent = encryptContent;
83          this.aesToken = aesToken;
84      }
85  
86      public WeixinRequest(String uri,
87                           EncryptType encryptType, String echoStr, String timeStamp,
88                           String nonce, String signature, String msgSignature,
89                           String originalContent, String encryptContent, AesToken aesToken, HttpServletRequest request) {
90          this.uri = uri;
91          this.encryptType = encryptType;
92          this.echoStr = echoStr;
93          this.timeStamp = timeStamp;
94          this.nonce = nonce;
95          this.signature = signature;
96          this.msgSignature = msgSignature;
97          this.originalContent = originalContent;
98          this.encryptContent = encryptContent;
99          this.aesToken = aesToken;
100         this.request = request;
101     }
102 
103     public String getUri() {
104         return uri;
105     }
106 
107     public String getEchoStr() {
108         return echoStr;
109     }
110 
111     public String getTimeStamp() {
112         return timeStamp;
113     }
114 
115     public String getNonce() {
116         return nonce;
117     }
118 
119     public String getSignature() {
120         return signature;
121     }
122 
123     public String getMsgSignature() {
124         return msgSignature;
125     }
126 
127     public EncryptType getEncryptType() {
128         return encryptType;
129     }
130 
131     public String getOriginalContent() {
132         return originalContent;
133     }
134 
135     public String getEncryptContent() {
136         return encryptContent;
137     }
138 
139     public AesToken getAesToken() {
140         return aesToken;
141     }
142 
143     public HttpServletRequest getHttpServletRequest() {
144         return request;
145     }
146 
147     public WeixinRequest setHttpServletRequest(HttpServletRequest httpServletRequest) {
148         this.request = httpServletRequest;
149         return this;
150     }
151 
152     @Override
153     public String toString() {
154         return "WeixinRequest [uri=" + uri + ", echoStr=" + echoStr
155                 + ", timeStamp=" + timeStamp + ", nonce=" + nonce
156                 + ", signature=" + signature + ", msgSignature=" + msgSignature
157                 + ", encryptType=" + encryptType + ", originalContent="
158                 + originalContent + ", encryptContent=" + encryptContent
159                 + ", aesToken=" + aesToken + "]";
160     }
161 }