private Match ( string host, int port, string authenticationType ) : bool | ||
host | string | |
port | int | |
authenticationType | string | |
return | bool |
public NetworkCredential GetCredential(string host, int port, string authenticationType) { 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"); } NetworkCredential credential = null; IDictionaryEnumerator enumerator = this.cacheForHosts.GetEnumerator(); while (enumerator.MoveNext()) { CredentialHostKey key = (CredentialHostKey)enumerator.Key; if (key.Match(host, port, authenticationType)) { credential = (NetworkCredential)enumerator.Value; } } return(credential); }
public NetworkCredential GetCredential(string host, int port, string authenticationType) { 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"); } bool globalLogEnabled = GlobalLog.IsEnabled; if (globalLogEnabled) { GlobalLog.Print("CredentialCache::GetCredential(host=\"" + host + ":" + port.ToString() + "\", authenticationType=\"" + authenticationType + "\")"); } NetworkCredential match = null; IDictionaryEnumerator credEnum = _cacheForHosts.GetEnumerator(); // Enumerate through every credential in the cache while (credEnum.MoveNext()) { CredentialHostKey key = (CredentialHostKey)credEnum.Key; // Determine if this credential is applicable to the current Uri/AuthType if (key.Match(host, port, authenticationType)) { match = (NetworkCredential)credEnum.Value; } } if (globalLogEnabled) { GlobalLog.Print("CredentialCache::GetCredential returning " + ((match == null) ? "null" : "(" + match.UserName + ":" + match.Domain + ")")); } return(match); }
public NetworkCredential GetCredential(string host, int port, string authenticationType) { 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, "host")); } if (port < 0) { throw new ArgumentOutOfRangeException(nameof(port)); } if (GlobalLog.IsEnabled) { GlobalLog.Print("CredentialCache::GetCredential(host=\"" + host + ":" + port.ToString() + "\", authenticationType=\"" + authenticationType + "\")"); } NetworkCredential match = null; // Enumerate through every credential in the cache foreach (KeyValuePair <CredentialHostKey, NetworkCredential> pair in _cacheForHosts) { CredentialHostKey key = pair.Key; // Determine if this credential is applicable to the current Uri/AuthType if (key.Match(host, port, authenticationType)) { match = pair.Value; } } if (GlobalLog.IsEnabled) { GlobalLog.Print("CredentialCache::GetCredential returning " + ((match == null) ? "null" : "(" + match.UserName + ":" + match.Domain + ")")); } return(match); }