77 int num = currentIndex;
78 while (currentIndex < data.Length && data[currentIndex] !=
'=' && !
CharIsSpaceOrTab(data[currentIndex]))
82 if (currentIndex == data.Length)
87 int length = currentIndex - num;
94 if (currentIndex == data.Length || data[currentIndex] !=
'=')
100 while (currentIndex < data.Length && (
CharIsSpaceOrTab(data[currentIndex]) || data[currentIndex] ==
'='))
105 return data.Substring(num,
length);
111 if (data[currentIndex] ==
'"')
122 while (currentIndex < data.Length && ((flag && data[currentIndex] !=
'"') || (!flag && data[currentIndex] !=
',')))
126 if (currentIndex == data.Length || (!flag &&
CharIsSpaceOrTab(data[currentIndex])))
130 if (flag && data[currentIndex] ==
'"' && data[currentIndex - 1] ==
'\\')
144 if (currentIndex == data.Length)
149 if (data[currentIndex++] !=
',')
276 if (!
TryGetValidAuthenticationChallengeForScheme(
"Negotiate",
AuthenticationType.Negotiate,
authUri,
credentials,
responseAuthenticationHeaderValues,
out challenge) && !
TryGetValidAuthenticationChallengeForScheme(
"NTLM",
AuthenticationType.Ntlm,
authUri,
credentials,
responseAuthenticationHeaderValues,
out challenge) && !
TryGetValidAuthenticationChallengeForScheme(
"Digest",
AuthenticationType.Digest,
authUri,
credentials,
responseAuthenticationHeaderValues,
out challenge))
303 return response.StatusCode ==
HttpStatusCode.ProxyAuthenticationRequired;
310 return response.Headers.WwwAuthenticate;
312 return response.Headers.ProxyAuthenticate;
337 if (
string.IsNullOrEmpty(
text))
438 System.
Net.
NetEventSource.
Info(
pool.PreAuthCredentials,
$"Adding Basic credential to cache, uri={authUri}, username={challenge.Credential.UserName}",
"SendWithAuthAsync");
446 System.
Net.
NetEventSource.
Info(
pool.PreAuthCredentials,
$"Basic credential present in cache, uri={authUri}, username={challenge.Credential.UserName}",
"SendWithAuthAsync");
520 sb.AppendKeyValue(
"username",
credential.UserName);
522 sb.AppendKeyValue(
"realm",
value);
523 sb.AppendKeyValue(
"nonce",
nonce);
524 sb.AppendKeyValue(
"uri",
request.RequestUri.PathAndQuery);
549 string a2 = request.Method.Method +
":" +
request.RequestUri.PathAndQuery;
550 if (
qop ==
"auth-int")
579 return value ==
"true";
590 while (num < data.Length)
592 int num2 = data[num++] % 3;
593 int num3 = data[num++] % ((
num2 == 0) ? 10 : 26);
625 if (
item ==
"Session-Based-Authentication")
650 if (
response.Headers.ConnectionClose.GetValueOrDefault())
660 System.
Net.
NetEventSource.
Info(connection,
$"Authentication: {challenge.AuthenticationType}, Uri: {authUri.AbsoluteUri}",
"SendWithNtAuthAsync");
static bool TryGetSwitch(string switchName, out bool isEnabled)
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
bool ContainsKey(TKey key)
void Add(TKey key, TValue value)
static string ToBase64String(byte[] inArray)
static ? string GetEnvironmentVariable(string variable)
static unsafe string ToString(ReadOnlySpan< byte > bytes, Casing casing=Casing.Upper)
static Task< IPHostEntry > GetHostEntryAsync(string hostNameOrAddress)
readonly Dictionary< string, string > Parameters
static bool MustValueBeQuoted(string key)
void Parse(string challenge)
string GetNextKey(string data, int currentIndex, out int parsedIndex)
DigestResponse(string challenge)
static bool CharIsSpaceOrTab(char ch)
string GetNextValue(string data, int currentIndex, bool expectQuotes, out int parsedIndex)
static async ValueTask< HttpResponseMessage > SendWithAuthAsync(HttpRequestMessage request, Uri authUri, bool async, ICredentials credentials, bool preAuthenticate, bool isProxyAuth, bool doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken)
static bool IsAuthenticationChallenge(HttpResponseMessage response, bool isProxyAuth)
static readonly int[] s_alphaNumChooser
static string ComputeHash(string data, string algorithm)
static void SetBasicAuthToken(HttpRequestMessage request, NetworkCredential credential, bool isProxyAuth)
static ValueTask< HttpResponseMessage > SendWithRequestAuthAsync(HttpRequestMessage request, bool async, ICredentials credentials, bool preAuthenticate, HttpConnectionPool pool, CancellationToken cancellationToken)
static ValueTask< HttpResponseMessage > InnerSendAsync(HttpRequestMessage request, bool async, bool isProxyAuth, bool doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken)
static volatile int s_usePortInSpn
static bool IsServerNonceStale(DigestResponse digestResponse)
static Task< HttpResponseMessage > SendWithNtProxyAuthAsync(HttpRequestMessage request, Uri proxyUri, bool async, ICredentials proxyCredentials, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken)
static HttpHeaderValueCollection< AuthenticationHeaderValue > GetResponseAuthenticationHeaderValues(HttpResponseMessage response, bool isProxyAuth)
static bool TryGetAuthenticationChallenge(HttpResponseMessage response, bool isProxyAuth, Uri authUri, ICredentials credentials, out AuthenticationChallenge challenge)
static async Task< string > GetDigestTokenForCredential(NetworkCredential credential, HttpRequestMessage request, DigestResponse digestResponse)
static async Task< HttpResponseMessage > SendWithNtAuthAsync(HttpRequestMessage request, Uri authUri, bool async, ICredentials credentials, bool isProxyAuth, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken)
static Task< HttpResponseMessage > InnerSendAsync(HttpRequestMessage request, bool async, bool isProxyAuth, HttpConnectionPool pool, HttpConnection connection, CancellationToken cancellationToken)
static bool TryGetChallengeDataForScheme(string scheme, HttpHeaderValueCollection< AuthenticationHeaderValue > authenticationHeaderValues, out string challengeData)
static void SetRequestAuthenticationHeaderValue(HttpRequestMessage request, AuthenticationHeaderValue headerValue, bool isProxyAuth)
static Task< HttpResponseMessage > SendWithNtConnectionAuthAsync(HttpRequestMessage request, bool async, ICredentials credentials, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken)
static ValueTask< HttpResponseMessage > SendWithProxyAuthAsync(HttpRequestMessage request, Uri proxyUri, bool async, ICredentials proxyCredentials, bool doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken)
static bool TryGetValidAuthenticationChallengeForScheme(string scheme, AuthenticationType authenticationType, Uri uri, ICredentials credentials, HttpHeaderValueCollection< AuthenticationHeaderValue > authenticationHeaderValues, out AuthenticationChallenge challenge)
static bool IsSessionAuthenticationChallenge(HttpResponseMessage response)
static bool TryGetRepeatedChallenge(HttpResponseMessage response, string scheme, bool isProxyAuth, out string challengeData)
static string GetRandomAlphaNumericString()
static async ValueTask< bool > TrySetDigestAuthToken(HttpRequestMessage request, NetworkCredential credential, DigestResponse digestResponse, bool isProxyAuth)
static bool ProxySupportsConnectionAuth(HttpResponseMessage response)
async Task< HttpResponseMessage > SendAsyncCore(HttpRequestMessage request, bool async, CancellationToken cancellationToken)
async ValueTask DrainResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken)
TransportContext TransportContext
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void AuthenticationError(Uri uri, string message)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
static void AuthenticationInfo(Uri uri, string message)
ChannelBinding? GetChannelBinding(ChannelBindingKind kind)
static void Fill(Span< byte > data)
static new SHA256 Create()
static StringComparer OrdinalIgnoreCase
static string GetStringAndRelease(StringBuilder sb)
static StringBuilder Acquire(int capacity=16)
NetworkCredential Credential
AuthenticationChallenge(AuthenticationType authenticationType, string schemeName, NetworkCredential credential, string challenge)
void AppendLiteral(string value)
void AppendFormatted(ReadOnlySpan< char > value)