| package com.matrix.component.wechat.externalInterface.protocol.rsaProtocal; | 
|   | 
|   | 
| import com.matrix.component.wechat.externalInterface.common.RandomStringGenerator; | 
| import com.matrix.component.wechat.externalInterface.common.Signature; | 
| import com.matrix.component.wechat.externalInterface.common.WechatConfigure; | 
|   | 
| import java.lang.reflect.Field; | 
| import java.util.HashMap; | 
| import java.util.Map; | 
|   | 
| /** | 
|  * 公钥请求类 | 
|  * | 
|  * @author  wzy | 
|  */ | 
| public class JsApiRSAReqData { | 
|   | 
|     private String mch_id; | 
|     private String nonce_str; | 
|     private String sign; | 
|     private String sign_type; | 
|   | 
|   | 
|     public JsApiRSAReqData() { | 
|         this.mch_id = WechatConfigure.mchID; | 
|         this.nonce_str = RandomStringGenerator.getRandomStringByLength(32); | 
|         this.sign = Signature.getSign(toMap()); | 
|         this.sign_type = "MD5"; | 
|     } | 
|   | 
|     public Map<String, Object> toMap() { | 
|         Map<String, Object> map = new HashMap<String, Object>(); | 
|         Field[] fields = this.getClass().getDeclaredFields(); | 
|         for (Field field : fields) { | 
|             Object obj; | 
|             try { | 
|                 obj = field.get(this); | 
|                 if (obj != null) { | 
|                     map.put(field.getName(), obj); | 
|                 } | 
|             } catch (IllegalArgumentException e) { | 
|                 e.printStackTrace(); | 
|             } catch (IllegalAccessException e) { | 
|                 e.printStackTrace(); | 
|             } | 
|         } | 
|         return map; | 
|     } | 
| } |