Exemplo n.º 1
0
        private bool IsProxyAuthenticationRequired(WebException ex, HttpWebRequest req)
        {
            bool isProxyAuthRequired = false;

            if (ex.Response != null)
            {
                var httpResp = ex.Response as HttpWebResponse;
                if (httpResp != null)
                {
                    if (httpResp.StatusCode == HttpStatusCode.ProxyAuthenticationRequired)
                    {
                        isProxyAuthRequired = true;

                        lock (proxyAuthReqiredLocker)
                            authTarget = AuthenticationTarget.Proxy;
                    }
                    else
                    {
                        var headers = httpResp.Headers[httpWWWAuthenticateKey];
                        if (!string.IsNullOrEmpty(headers) &&
                            (httpResp.ResponseUri == null || !httpResp.ResponseUri.Host.Equals(req.RequestUri.Host, StringComparison.OrdinalIgnoreCase)))
                        {
                            isProxyAuthRequired = true;
                            lock (proxyAuthReqiredLocker)
                                authTarget = AuthenticationTarget.Request;
                        }
                    }
                }
            }

            return(isProxyAuthRequired);
        }
Exemplo n.º 2
0
 public CredentialsCacheItem(AuthenticationScheme authenticationScheme, AuthenticationTarget authenticationTarget, string userName, Guid jobId)
 {
     this.userName             = userName;
     this.jobId                = jobId;
     this.authenticationScheme = authenticationScheme;
     this.authenticationTarget = authenticationTarget;
 }
Exemplo n.º 3
0
 public CredentialsCacheItem(BitsCredentials credentials, Guid jobId)
 {
     this.userName             = credentials.UserName;
     this.jobId                = jobId;
     this.authenticationScheme = credentials.AuthenticationScheme;
     this.authenticationTarget = credentials.AuthenticationTarget;
 }
Exemplo n.º 4
0
 public void RemoveCredentials(AuthenticationTarget target, AuthenticationScheme scheme)
 {
     try
     {
         if (job2 != null)// only supported from IBackgroundCopyJob2 and above
         {
             job2.RemoveCredentials((BG_AUTH_TARGET)target, (BG_AUTH_SCHEME)scheme);
         }
     }
     catch (COMException exception)
     {
         manager.PublishException(this, exception);
     }
 }
Exemplo n.º 5
0
 public void RemoveCredentials(AuthenticationTarget target, AuthenticationScheme scheme)
 {
     try
     {
         if (job2 != null)// only supported from IBackgroundCopyJob2 and above
         {
             job2.RemoveCredentials((BG_AUTH_TARGET)target, (BG_AUTH_SCHEME)scheme);
         }
     }
     catch (COMException exception)
     {
         manager.PublishException(this, exception);
     }
 }
 public SharePointAuthenticationOptions()
 {
     Target = AuthenticationTarget.SPHost;
 }