internal void ClearAuthReq(HttpWebRequest httpWebRequest)
 {
     this.TriedPreAuth  = false;
     this.Authorization = null;
     this.UniqueGroupId = null;
     httpWebRequest.Headers.Remove(this.AuthorizationHeader);
 }
 internal void PreAuthIfNeeded(HttpWebRequest httpWebRequest, ICredentials authInfo)
 {
     if (!this.TriedPreAuth)
     {
         this.TriedPreAuth = true;
         if (authInfo != null)
         {
             this.PrepareState(httpWebRequest);
             System.Net.Authorization authorization = null;
             try
             {
                 authorization = AuthenticationManager.PreAuthenticate(httpWebRequest, authInfo);
                 if ((authorization != null) && (authorization.Message != null))
                 {
                     this.UniqueGroupId = authorization.ConnectionGroupId;
                     httpWebRequest.Headers.Set(this.AuthorizationHeader, authorization.Message);
                 }
             }
             catch (Exception)
             {
                 this.ClearSession(httpWebRequest);
             }
         }
     }
 }
 internal void ClearAuthReq(HttpWebRequest httpWebRequest)
 {
     this.TriedPreAuth = false;
     this.Authorization = null;
     this.UniqueGroupId = null;
     httpWebRequest.Headers.Remove(this.AuthorizationHeader);
 }
        internal bool AttemptAuthenticate(HttpWebRequest httpWebRequest, ICredentials authInfo)
        {
            if ((this.Authorization != null) && this.Authorization.Complete)
            {
                if (this.IsProxyAuth)
                {
                    this.ClearAuthReq(httpWebRequest);
                }
                return(false);
            }
            if (authInfo == null)
            {
                return(false);
            }
            string challenge = httpWebRequest.AuthHeader(this.AuthenticateHeader);

            if (challenge == null)
            {
                if ((!this.IsProxyAuth && (this.Authorization != null)) && (httpWebRequest.ProxyAuthenticationState.Authorization != null))
                {
                    httpWebRequest.Headers.Set(this.AuthorizationHeader, this.Authorization.Message);
                }
                return(false);
            }
            this.PrepareState(httpWebRequest);
            try
            {
                this.Authorization = AuthenticationManager.Authenticate(challenge, httpWebRequest, authInfo);
            }
            catch (Exception)
            {
                this.Authorization = null;
                this.ClearSession(httpWebRequest);
                throw;
            }
            if (this.Authorization == null)
            {
                return(false);
            }
            if (this.Authorization.Message == null)
            {
                this.Authorization = null;
                return(false);
            }
            this.UniqueGroupId = this.Authorization.ConnectionGroupId;
            try
            {
                httpWebRequest.Headers.Set(this.AuthorizationHeader, this.Authorization.Message);
            }
            catch
            {
                this.Authorization = null;
                this.ClearSession(httpWebRequest);
                throw;
            }
            return(true);
        }
 internal bool AttemptAuthenticate(HttpWebRequest httpWebRequest, ICredentials authInfo)
 {
     if ((this.Authorization != null) && this.Authorization.Complete)
     {
         if (this.IsProxyAuth)
         {
             this.ClearAuthReq(httpWebRequest);
         }
         return false;
     }
     if (authInfo == null)
     {
         return false;
     }
     string challenge = httpWebRequest.AuthHeader(this.AuthenticateHeader);
     if (challenge == null)
     {
         if ((!this.IsProxyAuth && (this.Authorization != null)) && (httpWebRequest.ProxyAuthenticationState.Authorization != null))
         {
             httpWebRequest.Headers.Set(this.AuthorizationHeader, this.Authorization.Message);
         }
         return false;
     }
     this.PrepareState(httpWebRequest);
     try
     {
         this.Authorization = AuthenticationManager.Authenticate(challenge, httpWebRequest, authInfo);
     }
     catch (Exception)
     {
         this.Authorization = null;
         this.ClearSession(httpWebRequest);
         throw;
     }
     if (this.Authorization == null)
     {
         return false;
     }
     if (this.Authorization.Message == null)
     {
         this.Authorization = null;
         return false;
     }
     this.UniqueGroupId = this.Authorization.ConnectionGroupId;
     try
     {
         httpWebRequest.Headers.Set(this.AuthorizationHeader, this.Authorization.Message);
     }
     catch
     {
         this.Authorization = null;
         this.ClearSession(httpWebRequest);
         throw;
     }
     return true;
 }
        public static bool _Authenticate_System_String_System_Net_WebRequest_System_Net_ICredentials( )
        {
            //Parameters
            System.String           challenge   = null;
            System.Net.WebRequest   request     = null;
            System.Net.ICredentials credentials = null;

            //ReturnType/Value
            System.Net.Authorization returnVal_Real        = null;
            System.Net.Authorization returnVal_Intercepted = null;

            //Exception
            Exception exception_Real        = null;
            Exception exception_Intercepted = null;

            InterceptionMaintenance.disableInterception( );

            try
            {
                returnValue_Real = System.Net.AuthenticationManager.Authenticate(challenge, request, credentials);
            }

            catch (Exception e)
            {
                exception_Real = e;
            }


            InterceptionMaintenance.enableInterception( );

            try
            {
                returnValue_Intercepted = System.Net.AuthenticationManager.Authenticate(challenge, request, credentials);
            }

            catch (Exception e)
            {
                exception_Intercepted = e;
            }


            Return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted));
        }