Ejemplo n.º 1
0
      /// <summary>return WebProxy to be used.</summary>
      internal WebProxy Select()
      {
         Debug.Assert(_proxies.Count > 0);

         Proxy proxy = GetProxyForConnection();

         // If there is no responsive proxy (i.e. all proxies are down),
         // set all to responsive irrespective of their last retry time 
         // and start from the first one again.
         if (proxy == null)
         {
            SetAllResponsive();
            proxy = GetProxyForConnection();
         }

         WebProxy webProxy = proxy.GetWebProxy();
         //If it was previously determined that the proxy supports integrated authentication,
         //set the appropriate property of the WebProxy object.
         if (SupportsIntegratedAuthentication(webProxy))
            webProxy.Credentials = CredentialCache.DefaultCredentials;
         // Get credentials from cache and set it in WebProxy that we are going to return.
         // In case connection is direct (without proxy), there can not be any proxy credentials
         else if (webProxy.Address != null)
            webProxy.Credentials = CredentialsCache.GetInstance().GetCredentials(webProxy.Address);

         return webProxy;
      }
Ejemplo n.º 2
0
 /// <summary>Set the credentials in the Cache.</summary>
 /// <param name="webProxy"></param>
 /// <param name="networkCredentials"></param>
 internal void SetCredentials(WebProxy webProxy, NetworkCredential networkCredentials)
 {
    CredentialsCache.GetInstance().SetCredentials(webProxy.Address, networkCredentials);
 }