7 [global::__DynamicallyInvokable]
16 private int m_index = -1;
18 private int m_version;
24 if (m_index < 0 || m_index >= m_array.Length)
28 if (m_version != m_cache.m_version)
32 return m_array[m_index];
47 if (m_version != m_cache.m_version)
51 if (++m_index < m_array.Length)
55 m_index = m_array.Length;
69 internal int m_version;
71 private int m_NumbDefaultCredInCache;
73 internal bool IsDefaultInCache => m_NumbDefaultCredInCache != 0;
77 [global::__DynamicallyInvokable]
80 [global::__DynamicallyInvokable]
84 return SystemNetworkCredential.defaultCredential;
90 [global::__DynamicallyInvokable]
93 [global::__DynamicallyInvokable]
97 return SystemNetworkCredential.defaultCredential;
102 [global::__DynamicallyInvokable]
115 [global::__DynamicallyInvokable]
118 if (uriPrefix ==
null)
122 if (authType ==
null)
126 if (cred is SystemNetworkCredential &&
string.Compare(authType,
"NTLM",
StringComparison.OrdinalIgnoreCase) != 0 && (!DigestClient.WDigestAvailable ||
string.Compare(authType,
"Digest",
StringComparison.OrdinalIgnoreCase) != 0) &&
string.Compare(authType,
"Kerberos",
StringComparison.OrdinalIgnoreCase) != 0 &&
string.Compare(authType,
"Negotiate",
StringComparison.OrdinalIgnoreCase) != 0)
128 throw new ArgumentException(SR.GetString(
"net_nodefaultcreds", authType),
"authType");
131 CredentialKey key =
new CredentialKey(uriPrefix, authType);
132 cache.
Add(key, cred);
133 if (cred is SystemNetworkCredential)
135 m_NumbDefaultCredInCache++;
151 [global::__DynamicallyInvokable]
158 if (authenticationType ==
null)
162 if (host.Length == 0)
170 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)
172 throw new ArgumentException(SR.GetString(
"net_nodefaultcreds", authenticationType),
"authenticationType");
175 CredentialHostKey key =
new CredentialHostKey(host, port, authenticationType);
176 cacheForHosts.
Add(key, credential);
177 if (credential is SystemNetworkCredential)
179 m_NumbDefaultCredInCache++;
186 [global::__DynamicallyInvokable]
189 if (!(uriPrefix ==
null) && authType !=
null)
192 CredentialKey key =
new CredentialKey(uriPrefix, authType);
193 if (cache[key] is SystemNetworkCredential)
195 m_NumbDefaultCredInCache--;
205 [global::__DynamicallyInvokable]
206 public void Remove(
string host,
int port,
string authenticationType)
208 if (host !=
null && authenticationType !=
null && port >= 0)
211 CredentialHostKey key =
new CredentialHostKey(host, port, authenticationType);
212 if (cacheForHosts[key] is SystemNetworkCredential)
214 m_NumbDefaultCredInCache--;
216 cacheForHosts.
Remove(key);
226 [global::__DynamicallyInvokable]
229 if (uriPrefix ==
null)
233 if (authType ==
null)
242 CredentialKey credentialKey = (CredentialKey)enumerator.
Key;
243 if (credentialKey.Match(uriPrefix, authType))
245 int uriPrefixLength = credentialKey.UriPrefixLength;
246 if (uriPrefixLength > num)
248 num = uriPrefixLength;
269 [global::__DynamicallyInvokable]
276 if (authenticationType ==
null)
280 if (host.Length == 0)
292 CredentialHostKey credentialHostKey = (CredentialHostKey)enumerator.
Key;
293 if (credentialHostKey.Match(host, port, authenticationType))
303 [global::__DynamicallyInvokable]
306 return new CredentialEnumerator(
this, cache, cacheForHosts, m_version);
IEnumerator GetEnumerator()
Returns an enumerator that can iterate through the T:System.Net.CredentialCache instance.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
void Remove(string host, int port, string authenticationType)
Deletes a T:System.Net.NetworkCredential instance from the cache if it is associated with the specifi...
void Reset()
Sets the enumerator to its initial position, which is before the first element in the collection.
virtual void Add(object key, object value)
Adds an element with the specified key and value into the T:System.Collections.Hashtable.
bool MoveNext()
Advances the enumerator to the next element of the collection.
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
object Key
Gets the key of the current dictionary entry.
void Remove(Uri uriPrefix, string authType)
Deletes a T:System.Net.NetworkCredential instance from the cache if it is associated with the specifi...
The exception that is thrown when the value of an argument is outside the allowable range of values a...
EnvironmentPermissionAccess
Specifies access to environment variables.
virtual ICollection Values
Gets an T:System.Collections.ICollection containing the values in the T:System.Collections....
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
void Add(string host, int port, string authenticationType, NetworkCredential credential)
Adds a T:System.Net.NetworkCredential instance for use with SMTP to the credential cache and associat...
NetworkCredential GetCredential(Uri uriPrefix, string authType)
Returns the T:System.Net.NetworkCredential instance associated with the specified Uniform Resource Id...
Provides storage for multiple credentials.
Represents a collection of key/value pairs that are organized based on the hash code of the key....
void Add(Uri uriPrefix, string authType, NetworkCredential cred)
Adds a T:System.Net.NetworkCredential instance to the credential cache for use with protocols other t...
static ICredentials DefaultCredentials
Gets the system credentials of the application.
object Current
Gets the element in the collection at the current position of the enumerator.
Provides the interface for retrieving credentials for a host, port, and authentication type.
Provides the base authentication interface for retrieving credentials for Web client authentication.
NetworkCredential GetCredential(string host, int port, string authenticationType)
Returns the T:System.Net.NetworkCredential instance associated with the specified host,...
CredentialCache()
Creates a new instance of the T:System.Net.CredentialCache class.
The exception that is thrown when one of the arguments provided to a method is not valid.
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
static NetworkCredential DefaultNetworkCredentials
Gets the network credentials of the current security context.
virtual void Remove(object key)
Removes the element with the specified key from the T:System.Collections.Hashtable.
object Value
Gets the value of the current dictionary entry.
Enumerates the elements of a nongeneric dictionary.
The exception that is thrown when a method call is invalid for the object's current state.
Controls access to system and user environment variables. This class cannot be inherited.
Provides credentials for password-based authentication schemes such as basic, digest,...
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
Supports a simple iteration over a non-generic collection.
virtual int Count
Gets the number of key/value pairs contained in the T:System.Collections.Hashtable.