コード例 #1
0
ファイル: AopJsonParser.cs プロジェクト: icprog/FlyBirdYoYo
        private static EncryptParseItem ParseEncryptItem(string body, string rootNode, int indexOfRootNode)
        {
            var signDataStartIndex = indexOfRootNode + rootNode.Length + 2;
            var indexOfSign        = body.IndexOf("\"" + AlipayConstants.SIGN + "\"");

            var signDataEndIndex = indexOfSign - 1;

            if (signDataEndIndex < 0)
            {
                signDataEndIndex = body.Length - 1;
            }

            var length = signDataEndIndex - signDataStartIndex;

            var encyptContent = body.Substring(signDataStartIndex + 1, length - 2);

            var item = new EncryptParseItem();

            item.encryptContent = encyptContent;
            item.startIndex     = signDataStartIndex;
            item.endIndex       = signDataEndIndex;


            return(item);
        }
コード例 #2
0
        private static EncryptParseItem ParseEncryptItem(string body, string rootNode, int indexOfRootNode)
        {
            //  第一个字母+长度+>
            var signDataStartIndex = indexOfRootNode + rootNode.Length + 1;

            var xmlStartNode       = "<" + AlipayConstants.ENCRYPT_NODE_NAME + ">";
            var xmlEndNode         = "</" + AlipayConstants.ENCRYPT_NODE_NAME + ">";
            var indexOfEncryptNode = body.IndexOf(xmlEndNode);

            if (indexOfEncryptNode < 0)
            {
                var item = new EncryptParseItem();
                item.encryptContent = null;
                item.startIndex     = 0;
                item.endIndex       = 0;

                return(item);
            }

            var startIndex = signDataStartIndex + xmlStartNode.Length;
            var bizLen     = indexOfEncryptNode - startIndex;

            var encryptBizContent = body.Substring(startIndex, bizLen);

            var item2 = new EncryptParseItem();

            item2.encryptContent = encryptBizContent;
            item2.startIndex     = signDataStartIndex;
            item2.endIndex       = indexOfEncryptNode + xmlEndNode.Length;

            return(item2);
        }
コード例 #3
0
ファイル: AopJsonParser.cs プロジェクト: icprog/FlyBirdYoYo
        /// <summary>
        ///     解析加密节点
        /// </summary>
        /// <param name="request"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        private static EncryptParseItem parseEncryptData(IAopRequest <T> request, string body)
        {
            var rootNode      = request.GetApiName().Replace(".", "_") + AlipayConstants.RESPONSE_SUFFIX;
            var errorRootNode = AlipayConstants.ERROR_RESPONSE;

            var indexOfRootNode  = body.IndexOf(rootNode);
            var indexOfErrorRoot = body.IndexOf(errorRootNode);

            EncryptParseItem result = null;

            if (indexOfRootNode > 0)
            {
                result = ParseEncryptItem(body, rootNode, indexOfRootNode);
            }
            else if (indexOfErrorRoot > 0)
            {
                result = ParseEncryptItem(body, errorRootNode, indexOfErrorRoot);
            }

            return(result);
        }