10 private static object instanceLock =
new object();
12 private static IAuthenticationManager internalInstance =
null;
14 internal const string authenticationManagerRoot =
"System.Net.AuthenticationManager";
16 internal const string configHighPerformance =
"System.Net.AuthenticationManager.HighPerformance";
18 internal const string configPrefixLookupMaxCount =
"System.Net.AuthenticationManager.PrefixLookupMaxCount";
20 private static IAuthenticationManager Instance
24 if (internalInstance ==
null)
28 if (internalInstance ==
null)
30 internalInstance = SelectAuthenticationManagerInstance();
34 return internalInstance;
44 return Instance.CredentialPolicy;
48 ExceptionHelper.ControlPolicyPermission.Demand();
49 Instance.CredentialPolicy = value;
57 internal static SpnDictionary SpnDictionary => Instance.SpnDictionary;
59 internal static bool OSSupportsExtendedProtection => Instance.OSSupportsExtendedProtection;
61 internal static bool SspSupportsExtendedProtection => Instance.SspSupportsExtendedProtection;
71 private static IAuthenticationManager SelectAuthenticationManagerInstance()
76 if (RegistryConfiguration.GlobalConfigReadInt(
"System.Net.AuthenticationManager.HighPerformance", 0) == 1)
80 else if (RegistryConfiguration.AppConfigReadInt(
"System.Net.AuthenticationManager.HighPerformance", 0) == 1)
86 int? num = ReadPrefixLookupMaxEntriesConfig();
87 if (num.HasValue && num > 0)
89 return new AuthenticationManager2(num.Value);
91 return new AuthenticationManager2();
101 return new AuthenticationManagerDefault();
104 private static int? ReadPrefixLookupMaxEntriesConfig()
107 int num = RegistryConfiguration.GlobalConfigReadInt(
"System.Net.AuthenticationManager.PrefixLookupMaxCount", -1);
112 num = RegistryConfiguration.AppConfigReadInt(
"System.Net.AuthenticationManager.PrefixLookupMaxCount", -1);
120 internal static void EnsureConfigLoaded()
122 Instance.EnsureConfigLoaded();
136 return Instance.Authenticate(challenge, request, credentials);
147 return Instance.PreAuthenticate(request, credentials);
156 ExceptionHelper.UnmanagedPermission.Demand();
157 Instance.Register(authenticationModule);
167 ExceptionHelper.UnmanagedPermission.Demand();
168 Instance.Unregister(authenticationModule);
178 ExceptionHelper.UnmanagedPermission.Demand();
179 Instance.Unregister(authenticationScheme);
184 Instance.BindModule(uri, response, module);
187 internal static int FindSubstringNotInQuotes(
string challenge,
string signature)
190 if (challenge !=
null && signature !=
null && challenge.Length >= signature.Length)
194 for (
int i = 0; i < challenge.Length; i++)
200 if (challenge[i] ==
'"')
211 if (i != challenge.Length - 1 && (challenge[i] !=
'"' || num2 <= num3))
215 if (i == challenge.Length - 1)
217 num2 = challenge.Length;
224 int num5 = num2 - num3 - 1;
227 num = IndexOf(challenge, signature, num4, num5);
230 if ((num == 0 || challenge[num - 1] ==
' ' || challenge[num - 1] ==
',') && (num + signature.Length == challenge.Length || challenge[num + signature.Length] ==
' ' || challenge[num + signature.Length] ==
','))
234 num5 -= num - num4 + 1;
244 private static int IndexOf(
string challenge,
string lwrCaseSignature,
int start,
int count)
246 count += start + 1 - lwrCaseSignature.Length;
247 while (start < count)
250 for (i = 0; i < lwrCaseSignature.Length && (challenge[start + i] | 0x20) == lwrCaseSignature[i]; i++)
253 if (i == lwrCaseSignature.Length)
262 internal static int SplitNoQuotes(
string challenge, ref
int offset)
266 if (challenge !=
null && num < challenge.Length)
270 for (
int i = num; i < challenge.Length; i++)
272 if (num2 > num3 && challenge[i] ==
'\\' && i + 1 < challenge.Length && challenge[i + 1] ==
'"')
276 else if (challenge[i] ==
'"')
287 else if (challenge[i] ==
'=' && num2 <= num3 && offset < 0)
291 else if (challenge[i] ==
',' && num2 <= num3)
300 internal static Authorization GetGroupAuthorization(IAuthenticationModule thisModule,
string token,
bool finished, NTAuthentication authSession,
bool shareAuthenticatedConnections,
bool mutualAuth)
302 return new Authorization(token, finished, shareAuthenticatedConnections ?
null : (thisModule.GetType().FullName +
"/" + authSession.UniqueUserId), mutualAuth);
static IEnumerator RegisteredModules
Gets a list of authentication modules that are registered with the authentication manager.
static StringDictionary CustomTargetNameDictionary
Gets the dictionary that contains Service Principal Names (SPNs) that are used to identify hosts duri...
Contains an authentication message for an Internet server.
static void Unregister(string authenticationScheme)
Removes authentication modules with the specified authentication scheme from the list of registered m...
Makes a request to a Uniform Resource Identifier (URI). This is an abstract class.
Implements a hash table with the key and the value strongly typed to be strings rather than objects.
The Authorization header, which specifies the credentials that the client presents in order to authen...
static ICredentialPolicy CredentialPolicy
Gets or sets the credential policy to be used for resource requests made using the T:System....
static Authorization PreAuthenticate(WebRequest request, ICredentials credentials)
Preauthenticates a request.
Provides the base authentication interface for retrieving credentials for Web client authentication.
Manages the authentication modules called during the client authentication process.
Provides the base authentication interface for Web client authentication modules.
static Authorization Authenticate(string challenge, WebRequest request, ICredentials credentials)
Calls each registered authentication module to find the first module that can respond to the authenti...
static void Unregister(IAuthenticationModule authenticationModule)
Removes the specified authentication module from the list of registered modules.
Defines the credential policy to be used for resource requests that are made using T:System....
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
The exception that is thrown when a call is made to the M:System.Threading.Thread....
Supports a simple iteration over a non-generic collection.
static void Register(IAuthenticationModule authenticationModule)
Registers an authentication module with the authentication manager.