public CryptographySettingsNode Build() { CryptographySettingsNode rootNode = new CryptographySettingsNode(); HashProviderCollectionNode hashProviderCollectionNode = new HashProviderCollectionNode(); foreach (HashProviderData hashProviderData in cryptographySettings.HashProviders) { CreateHashProviderNode(hashProviderCollectionNode, hashProviderData); } SymmetricCryptoProviderCollectionNode symmetricCryptoProviderCollectionNode = new SymmetricCryptoProviderCollectionNode(); foreach (SymmetricProviderData symmetricCryptoProviderData in cryptographySettings.SymmetricCryptoProviders) { CreateSymmetricCryptoProviderNode(symmetricCryptoProviderCollectionNode, symmetricCryptoProviderData); } rootNode.AddNode(hashProviderCollectionNode); rootNode.AddNode(symmetricCryptoProviderCollectionNode); rootNode.DefaultHashProvider = defaultHashProviderNode; rootNode.DefaultSymmetricCryptoProvider = defaultSymmetricProviderNode; return(rootNode); }
/// <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(CryptographySettings.SectionName)) { CryptographySettingsNode securitySettingsNode = null; try { IUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider); securitySettingsNode = hierarchy.FindNodeByType(typeof(CryptographySettingsNode)) as CryptographySettingsNode; if (securitySettingsNode == null) { return; } CryptographySettings securitySettings = securitySettingsNode.CryptographySettings; configurationContext.WriteConfiguration(CryptographySettings.SectionName, securitySettings); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, securitySettingsNode, e); } catch (InvalidOperationException e) { ServiceHelper.LogError(serviceProvider, securitySettingsNode, e); } } }
/// <summary> /// <para>Adds the <see cref="CryptographySettingsNode"/> to the current application, with its default childnodes.</para> /// </summary> /// <param name="e"><para>An <see cref="EventArgs"/> containing the event data.</para></param> protected override void OnExecuted(EventArgs e) { base.OnExecuted(e); CryptographySettingsNode node = ChildNode as CryptographySettingsNode; Debug.Assert(null != node, "The added node should be a CryptographySettingsNode"); node.AddNode(new HashProviderCollectionNode()); node.AddNode(new SymmetricCryptoProviderCollectionNode()); }
/// <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) { CryptographySettingsNode node = GetCryptographySettingsNode(serviceProvider); if (node != null) { CryptographySettings settings = node.CryptographySettings; configurationDictionary[CryptographySettings.SectionName] = settings; } }
/// <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(CryptographySettings.SectionName)) { CryptographySettings cryptographySettings = null; CryptographySettingsNode cryptographySettingsNode = null; try { cryptographySettings = (CryptographySettings)configurationContext.GetConfiguration(CryptographySettings.SectionName); cryptographySettingsNode = new CryptographySettingsNode(cryptographySettings); ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider); configurationNode.Nodes.Add(cryptographySettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, cryptographySettingsNode, 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(CryptographySettings.SectionName)) { CryptographySettings cryptographySettings = null; CryptographySettingsNode cryptographySettingsNode = null; try { cryptographySettings = (CryptographySettings)configurationContext.GetConfiguration(CryptographySettings.SectionName); cryptographySettingsNode = new CryptographySettingsNode(cryptographySettings); ConfigurationNode configurationNode = ServiceHelper.GetCurrentRootNode(serviceProvider); configurationNode.Nodes.Add(cryptographySettingsNode); } catch (ConfigurationException e) { ServiceHelper.LogError(serviceProvider, cryptographySettingsNode, e); } } }
/// <summary> /// Gets a <see cref="ConfigurationSectionInfo"/> object containing the Caching Block's configuration information. /// </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"/> object containing the Caching Block's configuration information.</returns> protected override ConfigurationSectionInfo GetConfigurationSectionInfo(IServiceProvider serviceProvider) { ConfigurationNode rootNode = ServiceHelper.GetCurrentRootNode(serviceProvider); CryptographySettingsNode node = null; if (rootNode != null) { node = (CryptographySettingsNode)rootNode.Hierarchy.FindNodeByType(rootNode, typeof(CryptographySettingsNode)); } CryptographySettings cryptoSection = null; if (node == null) { cryptoSection = null; } else { CryptographyManagerSettingsBuilder builder = new CryptographyManagerSettingsBuilder(serviceProvider, node); cryptoSection = builder.Build(); } return(new ConfigurationSectionInfo(node, cryptoSection, CryptographyConfigurationView.SectionName)); }
public CryptographySettingsNode Build() { CryptographySettingsNode rootNode = new CryptographySettingsNode(); HashProviderCollectionNode hashProviderCollectionNode = new HashProviderCollectionNode(); foreach (HashProviderData hashProviderData in cryptographySettings.HashProviders) { CreateHashProviderNode(hashProviderCollectionNode, hashProviderData); } SymmetricCryptoProviderCollectionNode symmetricCryptoProviderCollectionNode = new SymmetricCryptoProviderCollectionNode(); foreach (SymmetricProviderData symmetricCryptoProviderData in cryptographySettings.SymmetricCryptoProviders) { CreateSymmetricCryptoProviderNode(symmetricCryptoProviderCollectionNode, symmetricCryptoProviderData); } rootNode.AddNode(hashProviderCollectionNode); rootNode.AddNode(symmetricCryptoProviderCollectionNode); rootNode.DefaultHashProvider = defaultHashProviderNode; rootNode.DefaultSymmetricCryptoProvider = defaultSymmetricProviderNode; return rootNode; }
public CryptographyManagerSettingsBuilder(IServiceProvider serviceProvider, CryptographySettingsNode cryptographySettingsNode) { this.cryptographySettingsNode = cryptographySettingsNode; hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider); cryptographySettings = new CryptographySettings(); }
public CryptographyManagerSettingsBuilder(IServiceProvider serviceProvider, CryptographySettingsNode cryptographySettingsNode) { this.cryptographySettingsNode = cryptographySettingsNode; hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider); cryptographySettings = new CryptographySettings(); }