Ejemplo n.º 1
0
        public string CommonInitialize(Stream inputStream, QyPostModel postModel)
        {
            _postModel = postModel as QyPostModel;

            //1、从Stream获取加密字符串
            var postDataStr = GetEncryptPostDataString(inputStream);

            EncryptPostData = XLH.DeserializeXmlFromString <EncryptPostData>(postDataStr, Encoding.UTF8);

            //2、解密:获得明文字符串
            WXBizMsgCrypt msgCrypt = new WXBizMsgCrypt(_postModel.Token, _postModel.EncodingAESKey, _postModel.CorpId);
            string        msgXml   = null;
            var           result   = msgCrypt.DecryptMsg(_postModel.Msg_Signature, _postModel.Timestamp, _postModel.Nonce, postDataStr, ref msgXml);

            //判断result类型
            if (result != 0)
            {
                //验证没有通过,取消执行
                CancelExcute = true;
                return(null);
            }

            //XmlDocument requestDocument = new XmlDocument();
            //requestDocument.LoadXml(msgXml);
            //3、对解密后的字符串反序列化
            RequestMessage = XLH.DeserializeXmlFromString <RequestMessage>(msgXml, Encoding.UTF8);

            return(msgXml);
        }
Ejemplo n.º 2
0
 public bool Attach(Dictionary <int, RequestAgent> agents, int agentid, QyPostModel postModel)
 {
     if (agents.ContainsKey(agentid) || agents == null)
     {
         return(false);
     }
     else
     {
         agents.Add(agentid, this);
         this.postModel = postModel;
         return(true);
     }
 }
Ejemplo n.º 3
0
        public QyMessageHandler(Stream inputStream, QyPostModel postModel = null)
        {
            //var postDataStr = GetEncryptPostDataString(inputStream);

            RequestDocument = CommonInitialize(inputStream, postModel);
        }