public void Add(string host, int port, string authenticationType, NetworkCredential credential)
 {
     if (host == null)
     {
         throw new ArgumentNullException("host");
     }
     if (authenticationType == null)
     {
         throw new ArgumentNullException("authenticationType");
     }
     if (host.Length == 0)
     {
         throw new ArgumentException(SR.GetString("net_emptystringcall", new object[] { "host" }));
     }
     if (port < 0)
     {
         throw new ArgumentOutOfRangeException("port");
     }
     if ((((credential is SystemNetworkCredential) && (string.Compare(authenticationType, "NTLM", StringComparison.OrdinalIgnoreCase) != 0)) && (!DigestClient.WDigestAvailable || (string.Compare(authenticationType, "Digest", StringComparison.OrdinalIgnoreCase) != 0))) && ((string.Compare(authenticationType, "Kerberos", StringComparison.OrdinalIgnoreCase) != 0) && (string.Compare(authenticationType, "Negotiate", StringComparison.OrdinalIgnoreCase) != 0)))
     {
         throw new ArgumentException(SR.GetString("net_nodefaultcreds", new object[] { authenticationType }), "authenticationType");
     }
     this.m_version++;
     CredentialHostKey key = new CredentialHostKey(host, port, authenticationType);
     this.cacheForHosts.Add(key, credential);
     if (credential is SystemNetworkCredential)
     {
         this.m_NumbDefaultCredInCache++;
     }
 }
Пример #2
0
        public void Add(string host, int port, string authenticationType, NetworkCredential credential) {
            //
            // parameter validation
            //
            if (host==null) {
                throw new ArgumentNullException("host");
            }

            if (authenticationType==null) {
                throw new ArgumentNullException("authenticationType");
            }
            
            if (host.Length == 0) {
                throw new ArgumentException(SR.GetString(SR.net_emptystringcall,"host"));
            }

            if (port < 0) {
                throw new ArgumentOutOfRangeException("port");
            }
            if ((credential is SystemNetworkCredential)
#if !FEATURE_PAL
                && !((string.Compare(authenticationType, NtlmClient.AuthType, StringComparison.OrdinalIgnoreCase)==0)
                     || (DigestClient.WDigestAvailable && (string.Compare(authenticationType, DigestClient.AuthType, StringComparison.OrdinalIgnoreCase)==0))
                     || (string.Compare(authenticationType, KerberosClient.AuthType, StringComparison.OrdinalIgnoreCase)==0)
                     || (string.Compare(authenticationType, NegotiateClient.AuthType, StringComparison.OrdinalIgnoreCase)==0))
#endif
                ) {
                throw new ArgumentException(SR.GetString(SR.net_nodefaultcreds, authenticationType), "authenticationType");
            }

            ++m_version;

            CredentialHostKey key = new CredentialHostKey(host,port, authenticationType);

            GlobalLog.Print("CredentialCache::Add() Adding key:[" + key.ToString() + "], cred:[" + credential.Domain + "],[" + credential.UserName + "]");

            cacheForHosts.Add(key, credential);
            if (credential is SystemNetworkCredential) {
                ++m_NumbDefaultCredInCache;
            }
        }
Пример #3
0
        public void Remove(string host, int port, string authenticationType) {
            if (host==null || authenticationType==null) {
                // these couldn't possibly have been inserted into
                // the cache because of the test in Add()
                return;
            }

            if (port < 0) {
                return;
            }


            ++m_version;

            CredentialHostKey key = new CredentialHostKey(host, port, authenticationType);

            GlobalLog.Print("CredentialCache::Remove() Removing key:[" + key.ToString() + "]");

            if (cacheForHosts[key] is SystemNetworkCredential) {
                --m_NumbDefaultCredInCache;
            }
            cacheForHosts.Remove(key);
        }
Пример #4
0
        public void Add(string host, int port, string authenticationType, NetworkCredential credential)
        {
            // Parameter validation
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }

            if (authenticationType == null)
            {
                throw new ArgumentNullException("authenticationType");
            }

            if (host.Length == 0)
            {
                throw new ArgumentException(SR.Format(SR.net_emptystringcall, "host"));
            }

            if (port < 0)
            {
                throw new ArgumentOutOfRangeException("port");
            }

            ++_version;

            CredentialHostKey key = new CredentialHostKey(host, port, authenticationType);

            GlobalLog.Print("CredentialCache::Add() Adding key:[" + key.ToString() + "], cred:[" + credential.Domain + "],[" + credential.UserName + "]");

            _cacheForHosts.Add(key, credential);
            if (credential is SystemNetworkCredential)
            {
                ++_numbDefaultCredInCache;
            }
        }
 public void Remove(string host, int port, string authenticationType)
 {
     if (((host != null) && (authenticationType != null)) && (port >= 0))
     {
         this.m_version++;
         CredentialHostKey key = new CredentialHostKey(host, port, authenticationType);
         if (this.cacheForHosts[key] is SystemNetworkCredential)
         {
             this.m_NumbDefaultCredInCache--;
         }
         this.cacheForHosts.Remove(key);
     }
 }