internal AuthenticationChallenge(AuthenticationSchemes scheme, string realm) : base(scheme, new NameValueCollection())
 {
     this.Parameters["realm"] = realm;
     if (scheme == AuthenticationSchemes.Digest)
     {
         this.Parameters["nonce"]     = AuthenticationBase.CreateNonceValue();
         this.Parameters["algorithm"] = "MD5";
         this.Parameters["qop"]       = "auth";
     }
 }
示例#2
0
        private void initAsDigest()
        {
            string text = Parameters["qop"];

            if (text != null)
            {
                if (text.Split(',').Contains((string qop) => qop.Trim().ToLower() == "auth"))
                {
                    Parameters["qop"]    = "auth";
                    Parameters["cnonce"] = AuthenticationBase.CreateNonceValue();
                    Parameters["nc"]     = $"{++_nonceCount:x8}";
                }
                else
                {
                    Parameters["qop"] = null;
                }
            }
            Parameters["method"]   = "GET";
            Parameters["response"] = CreateRequestDigest(Parameters);
        }
        private void initAsDigest()
        {
            string item = this.Parameters["qop"];

            if (item != null)
            {
                if (!item.Split(new char[] { ',' }).Contains <string>((string qop) => qop.Trim().ToLower() == "auth"))
                {
                    this.Parameters["qop"] = null;
                }
                else
                {
                    this.Parameters["qop"]    = "auth";
                    this.Parameters["cnonce"] = AuthenticationBase.CreateNonceValue();
                    uint num = this._nonceCount + 1;
                    this._nonceCount      = num;
                    this.Parameters["nc"] = string.Format("{0:x8}", num);
                }
            }
            this.Parameters["method"]   = "GET";
            this.Parameters["response"] = AuthenticationResponse.CreateRequestDigest(this.Parameters);
        }
        internal static AuthenticationChallenge Parse(string value)
        {
            AuthenticationChallenge authenticationChallenge;
            AuthenticationChallenge authenticationChallenge1;

            string[] strArrays = value.Split(new char[] { ' ' }, 2);
            if ((int)strArrays.Length == 2)
            {
                string lower = strArrays[0].ToLower();
                if (lower == "basic")
                {
                    authenticationChallenge1 = new AuthenticationChallenge(AuthenticationSchemes.Basic, AuthenticationBase.ParseParameters(strArrays[1]));
                }
                else if (lower == "digest")
                {
                    authenticationChallenge1 = new AuthenticationChallenge(AuthenticationSchemes.Digest, AuthenticationBase.ParseParameters(strArrays[1]));
                }
                else
                {
                    authenticationChallenge1 = null;
                }
                authenticationChallenge = authenticationChallenge1;
            }
            else
            {
                authenticationChallenge = null;
            }
            return(authenticationChallenge);
        }
        internal static AuthenticationResponse Parse(string value)
        {
            AuthenticationResponse authenticationResponse;
            AuthenticationResponse authenticationResponse1;

            try
            {
                string[] strArrays = value.Split(new char[] { ' ' }, 2);
                if ((int)strArrays.Length == 2)
                {
                    string lower = strArrays[0].ToLower();
                    if (lower == "basic")
                    {
                        authenticationResponse1 = new AuthenticationResponse(AuthenticationSchemes.Basic, AuthenticationResponse.ParseBasicCredentials(strArrays[1]));
                    }
                    else if (lower == "digest")
                    {
                        authenticationResponse1 = new AuthenticationResponse(AuthenticationSchemes.Digest, AuthenticationBase.ParseParameters(strArrays[1]));
                    }
                    else
                    {
                        authenticationResponse1 = null;
                    }
                    authenticationResponse = authenticationResponse1;
                    return(authenticationResponse);
                }
                else
                {
                    authenticationResponse = null;
                    return(authenticationResponse);
                }
            }
            catch
            {
            }
            authenticationResponse = null;
            return(authenticationResponse);
        }
示例#6
0
 internal static AuthenticationResponse Parse(string value)
 {
     //Discarded unreachable code: IL_0079
     try
     {
         string[] array = value.Split(new char[1] {
             ' '
         }, 2);
         if (array.Length != 2)
         {
             return(null);
         }
         string text = array[0].ToLower();
         return((text == "basic") ? new AuthenticationResponse(AuthenticationSchemes.Basic, ParseBasicCredentials(array[1])) : ((!(text == "digest")) ? null : new AuthenticationResponse(AuthenticationSchemes.Digest, AuthenticationBase.ParseParameters(array[1]))));
     }
     catch
     {
     }
     return(null);
 }
        internal static AuthenticationChallenge Parse(string value)
        {
            string[] array = value.Split(new char[1] {
                ' '
            }, 2);
            if (array.Length != 2)
            {
                return(null);
            }
            string text = array[0].ToLower();

            return((text == "basic") ? new AuthenticationChallenge(AuthenticationSchemes.Basic, AuthenticationBase.ParseParameters(array[1])) : ((!(text == "digest")) ? null : new AuthenticationChallenge(AuthenticationSchemes.Digest, AuthenticationBase.ParseParameters(array[1]))));
        }