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) { // These couldn't possibly have been inserted into // the cache because of the test in Add(). return; } if (port < 0) { return; } ++_version; CredentialHostKey key = new CredentialHostKey(host, port, authenticationType); if (GlobalLog.IsEnabled) { GlobalLog.Print("CredentialCache::Remove() Removing key:[" + key.ToString() + "]"); } if (_cacheForHosts[key] is SystemNetworkCredential) { --_numbDefaultCredInCache; } _cacheForHosts.Remove(key); }
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; } if (_cacheForHosts == null) { if (GlobalLog.IsEnabled) { GlobalLog.Print("CredentialCache::Remove() Short-circuiting because the dictionary is null."); } return; } ++_version; var key = new CredentialHostKey(host, port, authenticationType); if (GlobalLog.IsEnabled) { GlobalLog.Print("CredentialCache::Remove() Removing key:[" + key.ToString() + "]"); } _cacheForHosts.Remove(key); }
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; } }
public override bool Equals(object comparand) { CredentialHostKey comparedCredentialKey = comparand as CredentialHostKey; if (comparand == null) { // This covers also the compared == null case return(false); } bool equals = string.Equals(AuthenticationType, comparedCredentialKey.AuthenticationType, StringComparison.OrdinalIgnoreCase) && string.Equals(Host, comparedCredentialKey.Host, StringComparison.OrdinalIgnoreCase) && Port == comparedCredentialKey.Port; GlobalLog.Print("CredentialKey::Equals(" + ToString() + ", " + comparedCredentialKey.ToString() + ") returns " + equals.ToString()); return(equals); }
public void Add(string host, int port, string authenticationType, NetworkCredential credential) { if (host == null) { throw new ArgumentNullException(nameof(host)); } if (authenticationType == null) { throw new ArgumentNullException(nameof(authenticationType)); } if (host.Length == 0) { throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(host)), nameof(host)); } if (port < 0) { throw new ArgumentOutOfRangeException(nameof(port)); } ++_version; var key = new CredentialHostKey(host, port, authenticationType); if (GlobalLog.IsEnabled) { GlobalLog.Print("CredentialCache::Add() Adding key:[" + key.ToString() + "], cred:[" + credential.Domain + "],[" + credential.UserName + "]"); } if (_cacheForHosts == null) { _cacheForHosts = new Dictionary <CredentialHostKey, NetworkCredential>(); } _cacheForHosts.Add(key, credential); }
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; } }
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); }