Пример #1
0
        public virtual VerifiedSignature Authenticate(HttpRequest request, HttpResponse response)
        {
            VerifiedSignature verifiedSignature = null;

            try
            {
                verifiedSignature = HttpSignature.VerifiedSignature(HttpContext.Current.Request, _signatureSpec,
                                                                    _keyStore);
                if (verifiedSignature != null && verifiedSignature.Valid)
                {
                    this.OnAuthenticateSuccess(verifiedSignature);
                }
            }
            catch (InvalidSignatureException ex)
            {
                _log.Error(string.Format("Invalid signature: {0}, {1}", ex.Message, ex.ToString()));
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }

            if (verifiedSignature == null || !verifiedSignature.Valid)
            {
                HttpContext.Current.Response.StatusCode = 401;
                HttpContext.Current.Response.AddHeader("WWW-Authenticate", _signatureSpec.WwwAuthenticateChallenge());
                HttpContext.Current.Response.Write("Signature authentication required.");
                HttpContext.Current.Response.End();
                this.OnAuthenticateFailure(verifiedSignature);
            }
            return(verifiedSignature);
        }
Пример #2
0
 public virtual void OnAuthenticateFailure(VerifiedSignature signature)
 {
     return;
 }
 public virtual void OnAuthenticateSuccess(VerifiedSignature signature)
 {
     return;
 }
Пример #4
0
 public virtual void OnAuthenticateSuccess(VerifiedSignature signature)
 {
     return;
 }
 public virtual void OnAuthenticateFailure(VerifiedSignature signature)
 {
     return;
 }