Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Configuration / AuthenticationModulesSection.cs / 1305376 / AuthenticationModulesSection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Configuration { using System.Configuration; using System.Collections.Generic; using System.Globalization; using System.Net; using System.Threading; public sealed class AuthenticationModulesSection : ConfigurationSection { public AuthenticationModulesSection() { this.properties.Add(this.authenticationModules); } protected override void PostDeserialize() { // Perf optimization. If the configuration is coming from machine.config // It is safe and we don't need to check for permissions. if (EvaluationContext.IsMachineLevel) return; try { ExceptionHelper.UnmanagedPermission.Demand(); } catch (Exception exception) { throw new ConfigurationErrorsException( SR.GetString(SR.net_config_section_permission, ConfigurationStrings.AuthenticationModulesSectionName), exception); } } [ConfigurationProperty("", IsDefaultCollection = true)] public AuthenticationModuleElementCollection AuthenticationModules { get { return (AuthenticationModuleElementCollection)this[this.authenticationModules]; } } protected override void InitializeDefault() { #if !FEATURE_PAL // Security this.AuthenticationModules.Add( new AuthenticationModuleElement(typeof(NegotiateClient).AssemblyQualifiedName)); this.AuthenticationModules.Add( new AuthenticationModuleElement(typeof(KerberosClient).AssemblyQualifiedName)); this.AuthenticationModules.Add( new AuthenticationModuleElement(typeof(NtlmClient).AssemblyQualifiedName)); this.AuthenticationModules.Add( new AuthenticationModuleElement(typeof(DigestClient).AssemblyQualifiedName)); this.AuthenticationModules.Add( new AuthenticationModuleElement(typeof(BasicClient).AssemblyQualifiedName)); #endif // !FEATURE_PAL // Security } protected override ConfigurationPropertyCollection Properties { get { return this.properties; } } ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); readonly ConfigurationProperty authenticationModules = new ConfigurationProperty(null, typeof(AuthenticationModuleElementCollection), null, ConfigurationPropertyOptions.IsDefaultCollection); } internal sealed class AuthenticationModulesSectionInternal { internal AuthenticationModulesSectionInternal(AuthenticationModulesSection section) { if (section.AuthenticationModules.Count > 0) { this.authenticationModules = new List(section.AuthenticationModules.Count); foreach(AuthenticationModuleElement authenticationModuleElement in section.AuthenticationModules) { Type type = null; try { type = Type.GetType(authenticationModuleElement.Type, true, true); // verify that its of the proper type of object if (!typeof(IAuthenticationModule).IsAssignableFrom(type)) { throw new InvalidCastException(SR.GetString(SR.net_invalid_cast, type.FullName, "IAuthenticationModule")); } } catch (Exception exception) { if (NclUtilities.IsFatal(exception)) throw; throw new ConfigurationErrorsException(SR.GetString(SR.net_config_authenticationmodules), exception); } this.authenticationModules.Add(type); } } } internal List AuthenticationModules { get { List retval = this.authenticationModules; if (retval == null) { retval = new List (0); } return retval; } } internal static object ClassSyncObject { get { if (classSyncObject == null) { object o = new object(); Interlocked.CompareExchange(ref classSyncObject, o, null); } return classSyncObject; } } static internal AuthenticationModulesSectionInternal GetSection() { lock (AuthenticationModulesSectionInternal.ClassSyncObject) { AuthenticationModulesSection section = PrivilegedConfigurationManager.GetSection(ConfigurationStrings.AuthenticationModulesSectionPath) as AuthenticationModulesSection; if (section == null) return null; return new AuthenticationModulesSectionInternal(section); } } List authenticationModules = null; static object classSyncObject = null; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Configuration { using System.Configuration; using System.Collections.Generic; using System.Globalization; using System.Net; using System.Threading; public sealed class AuthenticationModulesSection : ConfigurationSection { public AuthenticationModulesSection() { this.properties.Add(this.authenticationModules); } protected override void PostDeserialize() { // Perf optimization. If the configuration is coming from machine.config // It is safe and we don't need to check for permissions. if (EvaluationContext.IsMachineLevel) return; try { ExceptionHelper.UnmanagedPermission.Demand(); } catch (Exception exception) { throw new ConfigurationErrorsException( SR.GetString(SR.net_config_section_permission, ConfigurationStrings.AuthenticationModulesSectionName), exception); } } [ConfigurationProperty("", IsDefaultCollection = true)] public AuthenticationModuleElementCollection AuthenticationModules { get { return (AuthenticationModuleElementCollection)this[this.authenticationModules]; } } protected override void InitializeDefault() { #if !FEATURE_PAL // Security this.AuthenticationModules.Add( new AuthenticationModuleElement(typeof(NegotiateClient).AssemblyQualifiedName)); this.AuthenticationModules.Add( new AuthenticationModuleElement(typeof(KerberosClient).AssemblyQualifiedName)); this.AuthenticationModules.Add( new AuthenticationModuleElement(typeof(NtlmClient).AssemblyQualifiedName)); this.AuthenticationModules.Add( new AuthenticationModuleElement(typeof(DigestClient).AssemblyQualifiedName)); this.AuthenticationModules.Add( new AuthenticationModuleElement(typeof(BasicClient).AssemblyQualifiedName)); #endif // !FEATURE_PAL // Security } protected override ConfigurationPropertyCollection Properties { get { return this.properties; } } ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); readonly ConfigurationProperty authenticationModules = new ConfigurationProperty(null, typeof(AuthenticationModuleElementCollection), null, ConfigurationPropertyOptions.IsDefaultCollection); } internal sealed class AuthenticationModulesSectionInternal { internal AuthenticationModulesSectionInternal(AuthenticationModulesSection section) { if (section.AuthenticationModules.Count > 0) { this.authenticationModules = new List(section.AuthenticationModules.Count); foreach(AuthenticationModuleElement authenticationModuleElement in section.AuthenticationModules) { Type type = null; try { type = Type.GetType(authenticationModuleElement.Type, true, true); // verify that its of the proper type of object if (!typeof(IAuthenticationModule).IsAssignableFrom(type)) { throw new InvalidCastException(SR.GetString(SR.net_invalid_cast, type.FullName, "IAuthenticationModule")); } } catch (Exception exception) { if (NclUtilities.IsFatal(exception)) throw; throw new ConfigurationErrorsException(SR.GetString(SR.net_config_authenticationmodules), exception); } this.authenticationModules.Add(type); } } } internal List AuthenticationModules { get { List retval = this.authenticationModules; if (retval == null) { retval = new List (0); } return retval; } } internal static object ClassSyncObject { get { if (classSyncObject == null) { object o = new object(); Interlocked.CompareExchange(ref classSyncObject, o, null); } return classSyncObject; } } static internal AuthenticationModulesSectionInternal GetSection() { lock (AuthenticationModulesSectionInternal.ClassSyncObject) { AuthenticationModulesSection section = PrivilegedConfigurationManager.GetSection(ConfigurationStrings.AuthenticationModulesSectionPath) as AuthenticationModulesSection; if (section == null) return null; return new AuthenticationModulesSectionInternal(section); } } List authenticationModules = null; static object classSyncObject = null; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RowVisual.cs
- RectangleConverter.cs
- CompareInfo.cs
- RootBrowserWindow.cs
- FixedPage.cs
- BookmarkUndoUnit.cs
- MetadataFile.cs
- SeekStoryboard.cs
- ArgumentNullException.cs
- DrawingContextWalker.cs
- EdmToObjectNamespaceMap.cs
- SqlDataReaderSmi.cs
- ReflectEventDescriptor.cs
- RubberbandSelector.cs
- ReadWriteControlDesigner.cs
- MediaTimeline.cs
- SafeLocalMemHandle.cs
- RankException.cs
- HyperLinkStyle.cs
- FixedDocumentSequencePaginator.cs
- Tracking.cs
- CodeDefaultValueExpression.cs
- DocumentViewerConstants.cs
- DetailsViewUpdateEventArgs.cs
- TextPointerBase.cs
- PackageRelationshipCollection.cs
- InkCollectionBehavior.cs
- SplayTreeNode.cs
- CollectionMarkupSerializer.cs
- PlatformNotSupportedException.cs
- DataServiceQueryProvider.cs
- TemplatedWizardStep.cs
- Solver.cs
- ApplicationCommands.cs
- DelegateHelpers.Generated.cs
- SerialStream.cs
- ItemCollection.cs
- FtpCachePolicyElement.cs
- StringFreezingAttribute.cs
- RecipientInfo.cs
- HostedImpersonationContext.cs
- Rfc4050KeyFormatter.cs
- StringDictionary.cs
- X509Utils.cs
- BehaviorEditorPart.cs
- KoreanCalendar.cs
- EntityDesignerDataSourceView.cs
- ConversionContext.cs
- _KerberosClient.cs
- InvalidOleVariantTypeException.cs
- BitmapEffect.cs
- DesigntimeLicenseContext.cs
- PackUriHelper.cs
- PrintPreviewGraphics.cs
- EditingScope.cs
- PageSetupDialog.cs
- RbTree.cs
- DESCryptoServiceProvider.cs
- DataSourceControlBuilder.cs
- Win32SafeHandles.cs
- ComplexLine.cs
- UIElementCollection.cs
- FolderLevelBuildProvider.cs
- DirectoryNotFoundException.cs
- SmtpNtlmAuthenticationModule.cs
- CrossSiteScriptingValidation.cs
- DashStyles.cs
- ToolStripProgressBar.cs
- CaseInsensitiveComparer.cs
- LOSFormatter.cs
- DefaultTextStoreTextComposition.cs
- BufferedReadStream.cs
- MatrixCamera.cs
- TextTreeExtractElementUndoUnit.cs
- RootAction.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- Command.cs
- CustomWebEventKey.cs
- PointLight.cs
- EventlogProvider.cs
- EntitySet.cs
- DBCSCodePageEncoding.cs
- CompositeTypefaceMetrics.cs
- HtmlInputFile.cs
- PrintDialogException.cs
- JournalNavigationScope.cs
- PathFigureCollectionConverter.cs
- NonClientArea.cs
- EventSource.cs
- GradientStop.cs
- WorkflowHostingResponseContext.cs
- TableCellAutomationPeer.cs
- GridItemCollection.cs
- TableProviderWrapper.cs
- IisTraceListener.cs
- XmlWriterSettings.cs
- ParameterToken.cs
- NativeMethods.cs
- GenerateHelper.cs
- SqlServer2KCompatibilityCheck.cs