Example #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="request"></param>
 public HecpContext(IAcDomain acDomain, HecpRequest request)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     this.Request = request;
     this._acDomain = acDomain;
     if (request == null)
     {
         _isValidated = true;
         _isValid = false;
         this.Response = HecpResponse.Create(string.Empty);
         this.Response.UpdateStatus(Status.InvalidArgument, "请求参数为null");
     }
     else
     {
         this.Response = HecpResponse.Create(request.MessageId);
     }
 }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="acDomain"></param>
 /// <param name="request"></param>
 public HecpContext(IAcDomain acDomain, HecpRequest request)
 {
     if (acDomain == null)
     {
         throw new ArgumentNullException("acDomain");
     }
     this.Request   = request;
     this._acDomain = acDomain;
     if (request == null)
     {
         _isValidated  = true;
         _isValid      = false;
         this.Response = HecpResponse.Create(string.Empty);
         this.Response.UpdateStatus(Status.InvalidArgument, "请求参数为null");
     }
     else
     {
         this.Response = HecpResponse.Create(request.MessageId);
     }
 }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <param name="secretKey"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        public static bool Valid(HecpRequest request, string secretKey, SignatureMethod method)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            var credential = request.Credential;

            switch (method)
            {
            case SignatureMethod.Undefined:
                return(false);

            case SignatureMethod.HMAC_SHA1:
                return(credential.Password == Signature.Sign(request.ToOrignalString(request.Credential.CredentialData), secretKey));

            default:
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="secretKey"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        public static bool Valid(HecpRequest request, string secretKey, SignatureMethod method)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            var credential = request.Credential;

            switch (method)
            {
                case SignatureMethod.Undefined:
                    return false;
                case SignatureMethod.HMAC_SHA1:
                    return credential.Password == Signature.Sign(request.ToOrignalString(request.Credential.CredentialData), secretKey);
                default:
                    return false;
            }
        }