using System; using System.Collections; using System.Collections.Specialized; namespace System.Net { /// Manages the authentication modules called during the client authentication process. // Token: 0x020001FB RID: 507 public class AuthenticationManager { // Token: 0x0600112F RID: 4399 RVA: 0x000321E8 File Offset: 0x000303E8 private AuthenticationManager() { } // Token: 0x06001131 RID: 4401 RVA: 0x00032204 File Offset: 0x00030404 private static void EnsureModules() { object obj = AuthenticationManager.locker; lock (obj) { if (AuthenticationManager.modules == null) { AuthenticationManager.modules = new ArrayList(); AuthenticationManager.modules.Add(new BasicClient()); AuthenticationManager.modules.Add(new DigestClient()); } } } /// Gets or sets the credential policy to be used for resource requests made using the class. /// An object that implements the interface that determines whether credentials are sent with requests. The default value is null. // Token: 0x170005AA RID: 1450 // (get) Token: 0x06001132 RID: 4402 RVA: 0x00032280 File Offset: 0x00030480 // (set) Token: 0x06001133 RID: 4403 RVA: 0x00032288 File Offset: 0x00030488 public static ICredentialPolicy CredentialPolicy { get { return AuthenticationManager.credential_policy; } set { AuthenticationManager.credential_policy = value; } } // Token: 0x06001134 RID: 4404 RVA: 0x00032290 File Offset: 0x00030490 private static Exception GetMustImplement() { return new NotImplementedException(); } /// Gets the dictionary that contains Service Principal Names (SPNs) that are used to identify hosts during Kerberos authentication for requests made using and its derived classes. /// A writable that contains the SPN values for keys composed of host information. // Token: 0x170005AB RID: 1451 // (get) Token: 0x06001135 RID: 4405 RVA: 0x00032298 File Offset: 0x00030498 [global::System.MonoTODO] public static global::System.Collections.Specialized.StringDictionary CustomTargetNameDictionary { get { throw AuthenticationManager.GetMustImplement(); } } /// Gets a list of authentication modules that are registered with the authentication manager. /// An that enables the registered authentication modules to be read. /// /// /// /// // Token: 0x170005AC RID: 1452 // (get) Token: 0x06001136 RID: 4406 RVA: 0x000322A0 File Offset: 0x000304A0 public static IEnumerator RegisteredModules { get { AuthenticationManager.EnsureModules(); return AuthenticationManager.modules.GetEnumerator(); } } // Token: 0x06001137 RID: 4407 RVA: 0x000322B4 File Offset: 0x000304B4 internal static void Clear() { AuthenticationManager.EnsureModules(); ArrayList arrayList = AuthenticationManager.modules; lock (arrayList) { AuthenticationManager.modules.Clear(); } } /// Calls each registered authentication module to find the first module that can respond to the authentication request. /// An instance of the class containing the result of the authorization attempt. If there is no authentication module to respond to the challenge, this method returns null. /// The challenge returned by the Internet resource. /// The that initiated the authentication challenge. /// The associated with this request. /// /// is null.-or- is null.-or- is null. /// /// /// /// // Token: 0x06001138 RID: 4408 RVA: 0x00032304 File Offset: 0x00030504 public static Authorization Authenticate(string challenge, WebRequest request, ICredentials credentials) { if (request == null) { throw new ArgumentNullException("request"); } if (credentials == null) { throw new ArgumentNullException("credentials"); } if (challenge == null) { throw new ArgumentNullException("challenge"); } return AuthenticationManager.DoAuthenticate(challenge, request, credentials); } // Token: 0x06001139 RID: 4409 RVA: 0x00032344 File Offset: 0x00030544 private static Authorization DoAuthenticate(string challenge, WebRequest request, ICredentials credentials) { AuthenticationManager.EnsureModules(); ArrayList arrayList = AuthenticationManager.modules; lock (arrayList) { foreach (object obj in AuthenticationManager.modules) { IAuthenticationModule authenticationModule = (IAuthenticationModule)obj; Authorization authorization = authenticationModule.Authenticate(challenge, request, credentials); if (authorization != null) { authorization.Module = authenticationModule; return authorization; } } } return null; } /// Preauthenticates a request. /// An instance of the class if the request can be preauthenticated; otherwise, null. If is null, this method returns null. /// A to an Internet resource. /// The associated with the request. /// /// is null. /// /// /// /// // Token: 0x0600113A RID: 4410 RVA: 0x0003240C File Offset: 0x0003060C public static Authorization PreAuthenticate(WebRequest request, ICredentials credentials) { if (request == null) { throw new ArgumentNullException("request"); } if (credentials == null) { return null; } AuthenticationManager.EnsureModules(); ArrayList arrayList = AuthenticationManager.modules; lock (arrayList) { foreach (object obj in AuthenticationManager.modules) { IAuthenticationModule authenticationModule = (IAuthenticationModule)obj; Authorization authorization = authenticationModule.PreAuthenticate(request, credentials); if (authorization != null) { authorization.Module = authenticationModule; return authorization; } } } return null; } /// Registers an authentication module with the authentication manager. /// The to register with the authentication manager. /// /// is null. /// /// /// /// // Token: 0x0600113B RID: 4411 RVA: 0x000324EC File Offset: 0x000306EC public static void Register(IAuthenticationModule authenticationModule) { if (authenticationModule == null) { throw new ArgumentNullException("authenticationModule"); } AuthenticationManager.DoUnregister(authenticationModule.AuthenticationType, false); ArrayList arrayList = AuthenticationManager.modules; lock (arrayList) { AuthenticationManager.modules.Add(authenticationModule); } } /// Removes the specified authentication module from the list of registered modules. /// The to remove from the list of registered modules. /// /// is null. /// The specified is not registered. /// /// /// /// // Token: 0x0600113C RID: 4412 RVA: 0x00032558 File Offset: 0x00030758 public static void Unregister(IAuthenticationModule authenticationModule) { if (authenticationModule == null) { throw new ArgumentNullException("authenticationModule"); } AuthenticationManager.DoUnregister(authenticationModule.AuthenticationType, true); } /// Removes authentication modules with the specified authentication scheme from the list of registered modules. /// The authentication scheme of the module to remove. /// /// is null. /// A module for this authentication scheme is not registered. /// /// /// /// // Token: 0x0600113D RID: 4413 RVA: 0x00032578 File Offset: 0x00030778 public static void Unregister(string authenticationScheme) { if (authenticationScheme == null) { throw new ArgumentNullException("authenticationScheme"); } AuthenticationManager.DoUnregister(authenticationScheme, true); } // Token: 0x0600113E RID: 4414 RVA: 0x00032594 File Offset: 0x00030794 private static void DoUnregister(string authenticationScheme, bool throwEx) { AuthenticationManager.EnsureModules(); ArrayList arrayList = AuthenticationManager.modules; lock (arrayList) { IAuthenticationModule authenticationModule = null; foreach (object obj in AuthenticationManager.modules) { IAuthenticationModule authenticationModule2 = (IAuthenticationModule)obj; string authenticationType = authenticationModule2.AuthenticationType; if (string.Compare(authenticationType, authenticationScheme, true) == 0) { authenticationModule = authenticationModule2; break; } } if (authenticationModule == null) { if (throwEx) { throw new InvalidOperationException("Scheme not registered."); } } else { AuthenticationManager.modules.Remove(authenticationModule); } } } // Token: 0x04000F4A RID: 3914 private static ArrayList modules; // Token: 0x04000F4B RID: 3915 private static object locker = new object(); // Token: 0x04000F4C RID: 3916 private static ICredentialPolicy credential_policy = null; } }