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; rootNode.RequirePermission = cryptographySettings.SectionInformation.RequirePermission; return(rootNode); }
/// <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> /// Opens the caching configuration from an application configuration file. /// </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 <see cref="ConfigurationApplicationNode"/> of the hierarchy.</param> /// <param name="section">The caching configuration section or null if no section was found.</param> protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section) { if (null != section) { CryptographyManagerSettingsNodeBuilder builder = new CryptographyManagerSettingsNodeBuilder(serviceProvider, (CryptographySettings)section); CryptographySettingsNode node = builder.Build(); SetProtectionProvider(section, node); rootNode.AddNode(node); } }
/// <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(); } string protectionProviderName = GetProtectionProviderName(node); return(new ConfigurationSectionInfo(node, cryptoSection, CryptographyConfigurationView.SectionName, protectionProviderName)); }
public CryptographyManagerSettingsBuilder(IServiceProvider serviceProvider, CryptographySettingsNode cryptographySettingsNode) { this.cryptographySettingsNode = cryptographySettingsNode; hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider); cryptographySettings = new CryptographySettings(); }