/// <summary> /// <para>Saves the configuration settings created for the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public void Save(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(SecuritySettings.SectionName)) { SecuritySettingsNode securitySettingsNode = null; try { IUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider); securitySettingsNode = hierarchy.FindNodeByType(typeof(SecuritySettingsNode)) as SecuritySettingsNode; if (securitySettingsNode == null) { return; } SecuritySettings securitySettings = securitySettingsNode.SecuritySettings; configurationContext.WriteConfiguration(SecuritySettings.SectionName, securitySettings); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, securitySettingsNode, e); } catch (InvalidOperationException e) { ServiceHelper.LogError(serviceProvider, securitySettingsNode, e); } } }
/// <summary> /// After the <see cref="SecuritySettingsNode"/> is added, adds the default nodes. /// </summary> /// <param name="node">The <see cref="SecuritySettingsNode"/>.S</param> protected override void ExecuteCore(ConfigurationNode node) { base.ExecuteCore(node); SecuritySettingsNode securitySettingsNode = (SecuritySettingsNode)ChildNode; securitySettingsNode.AddNode(new AuthorizationProviderCollectionNode()); securitySettingsNode.AddNode(new SecurityCacheProviderCollectionNode()); }
/// <summary> /// <para>Adds to the dictionary configuration data for /// the enterpriselibrary.configurationSettings configuration section.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="configurationDictionary"> /// <para>A <see cref="ConfigurationDictionary"/> to add /// configuration data to.</para></param> public void BuildContext(IServiceProvider serviceProvider, ConfigurationDictionary configurationDictionary) { SecuritySettingsNode node = GetSecuritySettingsNode(serviceProvider); if (node != null) { SecuritySettings settings = node.SecuritySettings; configurationDictionary[SecuritySettings.SectionName] = settings; } }
/// <summary> /// Opens the security settings configuration section, builds the design time nodes and adds them to the application node. /// </summary> /// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param> /// <param name="rootNode">The root node of the application.</param> /// <param name="section">The <see cref="ConfigurationSection"/> that was opened from the <see cref="IConfigurationSource"/>.</param> protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section) { if (null != section) { SecuritySettingsNodeBuilder nodeBuilder = new SecuritySettingsNodeBuilder(serviceProvider, (SecuritySettings)section); SecuritySettingsNode node = nodeBuilder.Build(); SetProtectionProvider(section, node); rootNode.AddNode(node); } }
/// <summary> /// Gets the a <see cref="ConfigurationSectionInfo"/> for the security settings configuration section. /// </summary> /// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param> /// <returns>A <see cref="ConfigurationSectionInfo"/> for the security settings configuration section.</returns> protected override ConfigurationSectionInfo GetConfigurationSectionInfo(IServiceProvider serviceProvider) { ConfigurationNode rootNode = ServiceHelper.GetCurrentRootNode(serviceProvider); SecuritySettingsNode node = null; if (null != rootNode) { node = rootNode.Hierarchy.FindNodeByType(rootNode, typeof(SecuritySettingsNode)) as SecuritySettingsNode; } SecuritySettings securitySettings = null; if (node != null) { SecuritySettingsBuilder builder = new SecuritySettingsBuilder(serviceProvider, node); securitySettings = builder.Build(); } return(new ConfigurationSectionInfo(node, securitySettings, SecuritySettings.SectionName)); }
public SecuritySettingsNode Build() { SecuritySettingsNode rootNode = new SecuritySettingsNode(); AuthorizationProviderCollectionNode authorizationProviderCollectionNode = new AuthorizationProviderCollectionNode(); this.authorizationProviderCollectionNode_ = authorizationProviderCollectionNode; settings.AuthorizationProviders.ForEach(new Action<AuthorizationProviderData>(BuildAuthorizationProviders)); SecurityCacheProviderCollectionNode securityCacheProviderCollectionNode = new SecurityCacheProviderCollectionNode(); this.securityCacheProviderCollectionNode_ = securityCacheProviderCollectionNode; settings.SecurityCacheProviders.ForEach(new Action<SecurityCacheProviderData>(BuildSecurityCacheProviders)); rootNode.AddNode(authorizationProviderCollectionNode); rootNode.AddNode(securityCacheProviderCollectionNode); rootNode.DefaultAuthorizationInstance = defaultAuthorizationNode; rootNode.DefaultSecurityCacheInstance = defaultSecurityCacheProviderNode; return rootNode; }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(SecuritySettings.SectionName)) { SecuritySettings securitySettings = null; SecuritySettingsNode securitySettingsNode = null; try { securitySettings = (SecuritySettings)configurationContext.GetConfiguration(SecuritySettings.SectionName); securitySettingsNode = new SecuritySettingsNode(securitySettings); ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider); configurationNode.Nodes.Add(securitySettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, securitySettingsNode, e); } } }
/// <summary> /// <para>Opens the configuration settings and registers them with the application.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> public void Open(IServiceProvider serviceProvider) { ConfigurationContext configurationContext = ServiceHelper.GetCurrentConfigurationContext(serviceProvider); if (configurationContext.IsValidSection(SecuritySettings.SectionName)) { SecuritySettings securitySettings = null; SecuritySettingsNode securitySettingsNode = null; try { securitySettings = (SecuritySettings)configurationContext.GetConfiguration(SecuritySettings.SectionName); securitySettingsNode = new SecuritySettingsNode(securitySettings); ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider); configurationNode.Nodes.Add(securitySettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, securitySettingsNode, e); } } }
public SecuritySettingsNode Build() { SecuritySettingsNode rootNode = new SecuritySettingsNode(); AuthorizationProviderCollectionNode authorizationProviderCollectionNode = new AuthorizationProviderCollectionNode(); this.authorizationProviderCollectionNode_ = authorizationProviderCollectionNode; settings.AuthorizationProviders.ForEach(new Action <AuthorizationProviderData>(BuildAuthorizationProviders)); SecurityCacheProviderCollectionNode securityCacheProviderCollectionNode = new SecurityCacheProviderCollectionNode(); this.securityCacheProviderCollectionNode_ = securityCacheProviderCollectionNode; settings.SecurityCacheProviders.ForEach(new Action <SecurityCacheProviderData>(BuildSecurityCacheProviders)); rootNode.AddNode(authorizationProviderCollectionNode); rootNode.AddNode(securityCacheProviderCollectionNode); rootNode.DefaultAuthorizationInstance = defaultAuthorizationNode; rootNode.DefaultSecurityCacheInstance = defaultSecurityCacheProviderNode; return(rootNode); }
/// <summary> /// /// </summary> /// <param name="serviceProvider"></param> /// <param name="securitySettingsNode"></param> public SecuritySettingsBuilder(IServiceProvider serviceProvider, SecuritySettingsNode securitySettingsNode) { this.securitySettingsNode = securitySettingsNode; hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider); }
/// <summary> /// /// </summary> /// <param name="serviceProvider"></param> /// <param name="securitySettingsNode"></param> public SecuritySettingsBuilder(IServiceProvider serviceProvider, SecuritySettingsNode securitySettingsNode) { this.securitySettingsNode = securitySettingsNode; hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider); }