Exemple #1
0
 private void BuildSymmetricCryptoProviders()
 {
     foreach (HashProviderNode hashProviderNode in hierarchy.FindNodesByType(cryptographySettingsNode, typeof(HashProviderNode)))
     {
         cryptographySettings.HashProviders.Add(hashProviderNode.HashProviderData);
     }
 }
Exemple #2
0
        private void BuildPolicies()
        {
            IList <ConfigurationNode> policies = hierarchy.FindNodesByType(exceptionHandlingSettingsNode, typeof(ExceptionPolicyNode));

            foreach (ConfigurationNode policyNode in policies)
            {
                exceptionHandlingSettings.ExceptionPolicies.Add(CreateExceptionPolicyData((ExceptionPolicyNode)policyNode));
            }
        }
Exemple #3
0
        private void BuildCacheManagers()
        {
            foreach (CacheManagerNode managerNode in hierarchy.FindNodesByType(cacheSettingsNode, typeof(CacheManagerNode)))
            {
                CacheManagerData cacheManagerData      = managerNode.CacheManagerData;
                CacheStorageNode storageNodeForManager = (CacheStorageNode)hierarchy.FindNodeByType(managerNode, typeof(CacheStorageNode));
                cacheManagerData.CacheStorage = (storageNodeForManager == null) ? Resources.NullStorageName : storageNodeForManager.Name;

                if (cacheManagerData.CacheStorage == Resources.NullStorageName && !cacheConfiguration.BackingStores.Contains(Resources.NullStorageName))
                {
                    cacheConfiguration.BackingStores.Add(new CacheStorageData(Resources.NullStorageName, typeof(NullBackingStore)));
                }

                cacheConfiguration.CacheManagers.Add(cacheManagerData);
            }
        }
        /// <summary>
        /// Initializes the database listener and adds it to the logging settings.
        /// </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)
        {
            IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);

            foreach (LoggingDatabaseNode loggingDatabaseNode in hierarchy.FindNodesByType(typeof(LoggingDatabaseNode)))
            {
                foreach (ConnectionStringSettingsNode connectionStringNode in hierarchy.FindNodesByType(typeof(ConnectionStringSettingsNode)))
                {
                    if (connectionStringNode.Name == ((FormattedDatabaseTraceListenerData)loggingDatabaseNode.TraceListenerData).DatabaseInstanceName)
                    {
                        loggingDatabaseNode.DatabaseInstance = connectionStringNode;
                        break;
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Saves the cryptogrpahy configuration to an configuration source and stores protected keys.
        /// </summary>
        /// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
        public override void Save(IServiceProvider serviceProvider)
        {
            base.Save(serviceProvider);

            IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);

            foreach (ICryptographicKeyConfigurationNode nodeWithKey in hierarchy.FindNodesByType(typeof(KeyedHashAlgorithmProviderNode)))
            {
                SaveProtectedKey(nodeWithKey, serviceProvider);
            }

            foreach (ICryptographicKeyConfigurationNode nodeWithKey in hierarchy.FindNodesByType(typeof(SymmetricAlgorithmProviderNode)))
            {
                SaveProtectedKey(nodeWithKey, serviceProvider);
            }
        }
        protected override void OpenCore(IServiceProvider serviceProvider, ConfigurationApplicationNode rootNode, ConfigurationSection section)
        {
            IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);

            foreach (LoggingExceptionHandlerNode handlerNode in hierarchy.FindNodesByType(typeof(LoggingExceptionHandlerNode)))
            {
                foreach (CategoryTraceSourceNode categoryNode in hierarchy.FindNodesByType(typeof(CategoryTraceSourceNode)))
                {
                    if (categoryNode.Name == ((LoggingExceptionHandlerData)handlerNode.ExceptionHandlerData).LogCategory)
                    {
                        handlerNode.LogCategory = categoryNode;
                        break;
                    }
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Initializes the logging handler and adds it to the exception settings.
        /// </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)
        {
            // since logging and exception handling gets loaded before us then we can search for any logging handlers and set the trace source
            IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);

            foreach (LoggingExceptionHandlerNode handlerNode in hierarchy.FindNodesByType(typeof(LoggingExceptionHandlerNode)))
            {
                foreach (CategoryTraceSourceNode categoryNode in hierarchy.FindNodesByType(typeof(CategoryTraceSourceNode)))
                {
                    if (categoryNode.Name == ((LoggingExceptionHandlerData)handlerNode.ExceptionHandlerData).LogCategory)
                    {
                        handlerNode.LogCategory = categoryNode;
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Initializes the security caching store and adds it to the exception settings.
        /// </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, System.Configuration.ConfigurationSection section)
        {
            IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);

            foreach (CachingStoreProviderNode securityCacheNode in hierarchy.FindNodesByType(typeof(CachingStoreProviderNode)))
            {
                foreach (CacheManagerNode cacheManagerNode in hierarchy.FindNodesByType(typeof(CacheManagerNode)))
                {
                    if (cacheManagerNode.Name == securityCacheNode.cacheManagerName)
                    {
                        securityCacheNode.CacheManager = cacheManagerNode;
                        break;
                    }
                }
            }
            base.OpenCore(serviceProvider, rootNode, section);
        }
Exemple #9
0
        /// <summary>
        /// Initializes the data cache storage and adds it to the caching settings.
        /// </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)
        {
            // since logging and exception handling gets loaded before us then we can search for any logging handlers and set the trace source
            IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);

            foreach (DataCacheStorageNode dataCacheStorageNode in hierarchy.FindNodesByType(typeof(DataCacheStorageNode)))
            {
                foreach (ConnectionStringSettingsNode connectionNode in hierarchy.FindNodesByType(typeof(ConnectionStringSettingsNode)))
                {
                    if (connectionNode.Name == dataCacheStorageNode.connectionStringName)
                    {
                        dataCacheStorageNode.DatabaseInstance = connectionNode;
                        break;
                    }
                }
            }
        }
Exemple #10
0
 private void BuildAuthorizationRules()
 {
     foreach (AuthorizationRuleNode ruleNode in hierarchy.FindNodesByType(typeof(AuthorizationRuleNode)))
     {
         AuthorizationRuleProviderData data = (AuthorizationRuleProviderData)securityConfiguration.AuthorizationProviders.Get(ruleNode.Parent.Name);
         data.Rules.Add(ruleNode.AuthorizationRuleData);
     }
 }
        public override void Save(IServiceProvider serviceProvider)
        {
            IErrorLogService         errorService            = ServiceHelper.GetErrorService(serviceProvider);
            IEnvironmentMergeService environmentMergeService = serviceProvider.GetService(typeof(IEnvironmentMergeService)) as IEnvironmentMergeService;

            if (environmentMergeService != null)
            {
                if (environmentMergeService.EnvironmentMergeInProgress)
                {
                    return;
                }
            }

            IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);

            Debug.Assert(hierarchy != null);

            ConfigurationApplicationNode configurationRootNode = hierarchy.FindNodeByType(typeof(ConfigurationApplicationNode)) as ConfigurationApplicationNode;

            Debug.Assert(configurationRootNode != null);

            string configurationFileDirectory = Path.GetDirectoryName(configurationRootNode.ConfigurationFile);

            foreach (EnvironmentNode environmentNode in hierarchy.FindNodesByType(typeof(EnvironmentNode)))
            {
                string environmentDeltaFilePath =
                    Path.Combine(configurationFileDirectory, environmentNode.EnvironmentDeltaFile);

                Dictionary <string, ConfigurationNodeMergeData> mergeDataByPath =
                    environmentNode.EnvironmentMergeData.UnfoldMergeData(hierarchy, false);
                EnvironmentMergeSection environmentMergeSection = new EnvironmentMergeSection();
                environmentMergeSection.EnvironmentName      = environmentNode.Name;
                environmentMergeSection.EnvironmentDeltaFile = environmentNode.EnvironmentConfigurationFile;

                CopyEnvironmentOverrides(environmentMergeSection, mergeDataByPath, hierarchy);
                string protectionProvider = GetProtectionProviderName(environmentNode);

                try
                {
                    FileConfigurationSource fileConfigurationSource =
                        new FileConfigurationSource(environmentDeltaFilePath, false);
                    if (!string.IsNullOrEmpty(protectionProvider))
                    {
                        fileConfigurationSource.Save(EnvironmentMergeSection.EnvironmentMergeData, environmentMergeSection, protectionProvider);
                    }
                    else
                    {
                        fileConfigurationSource.Add(EnvironmentMergeSection.EnvironmentMergeData, environmentMergeSection);
                    }
                }
                catch (ConfigurationErrorsException configurationErrors)
                {
                    errorService.LogErrors(configurationErrors);
                }
            }
        }
        private string CreateConnectionString(ConnectionStringSettingsNode node)
        {
            List <ConnectionStringNameValuePair> pairs = new List <ConnectionStringNameValuePair>();

            foreach (ParameterNode paramNode in hierarchy.FindNodesByType(node, typeof(ParameterNode)))
            {
                pairs.Add(new ConnectionStringNameValuePair(paramNode.Name, paramNode.Value));
            }
            return(ConnectionStringParser.Build(pairs));
        }
Exemple #13
0
 /// <summary>
 /// Updates the exception policy node reference to point to ones defined under
 /// the exception handling block.
 /// </summary>
 /// <param name="hierarchy">Hierarchy to use to locate other exception policy nodes.</param>
 public override void ResolveNodeReferences(IConfigurationUIHierarchy hierarchy)
 {
     if (!String.IsNullOrEmpty(exceptionPolicyName))
     {
         foreach (ExceptionPolicyNode exceptionPolicyNode in hierarchy.FindNodesByType(typeof(ExceptionPolicyNode)))
         {
             if (string.Compare(exceptionPolicyName, exceptionPolicyNode.Name) == 0)
             {
                 ExceptionPolicy = exceptionPolicyNode;
                 break;
             }
         }
     }
 }
Exemple #14
0
        public DatabaseSettings Build()
        {
            DatabaseSettings settings = new DatabaseSettings();

            foreach (ProviderMappingNode node in hierarchy.FindNodesByType(databaseSectionNode, typeof(ProviderMappingNode)))
            {
                settings.ProviderMappings.Add(node.ProviderMapping);
            }
            if (null != databaseSectionNode.DefaultDatabase)
            {
                settings.DefaultDatabase = databaseSectionNode.DefaultDatabase.Name;
            }
            return(settings);
        }
Exemple #15
0
 /// <summary>
 /// Updates the reference to the authorization node to point to the correct
 /// instance stored in the hierarchy.
 /// </summary>
 /// <remarks>This method supports the internal Enterprise Library configuration console
 /// and is not intended to be called by user code.</remarks>
 /// <param name="hierarchy"><see cref="IConfigurationUIHierarchy"/> to use to resolve
 /// references.</param>
 public override void ResolveNodeReferences(IConfigurationUIHierarchy hierarchy)
 {
     if (!String.IsNullOrEmpty(authorizationProviderName))
     {
         foreach (AuthorizationProviderNode authProviderNode in hierarchy.FindNodesByType(typeof(AuthorizationProviderNode)))
         {
             if (string.Compare(authorizationProviderName, authProviderNode.Name) == 0)
             {
                 AuthorizationProvider = authProviderNode;
                 break;
             }
         }
     }
 }
Exemple #16
0
        public WebServiceSettings Build()
        {
            webServiceSettings.DefaultWebServiceURL =
                webServiceSettingsNode.DefaultWebServiceURLSetting.Name;

            foreach (WebServiceURLNode webServiceURLNode in
                     hierarchy.FindNodesByType(webServiceSettingsNode, typeof(WebServiceURLNode)))
            {
                webServiceSettings.WebServiceURLs.Add(new
                                                      WebServiceURL(webServiceURLNode.Name, webServiceURLNode.URL));
            }

            return(webServiceSettings);
        }
Exemple #17
0
        /// <summary>
        /// Initializes the symmetric cache store encryption designtime and adds it to the caching settings.
        /// </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)
        {
            IConfigurationUIHierarchy hierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider);

            foreach (SymmetricStorageEncryptionProviderNode symmetricStorageEncryptionNode in hierarchy.FindNodesByType(typeof(SymmetricStorageEncryptionProviderNode)))
            {
                foreach (SymmetricCryptoProviderNode symmetricCryptoProviderNode in hierarchy.FindNodesByType(typeof(SymmetricCryptoProviderNode)))
                {
                    if (symmetricCryptoProviderNode.Name == symmetricStorageEncryptionNode.symmetricCryptoProviderNodeName)
                    {
                        symmetricStorageEncryptionNode.SymmetricInstance = symmetricCryptoProviderNode;
                        break;
                    }
                }
            }
        }
Exemple #18
0
        public OracleConnectionSettings Build()
        {
            oracleConnectionSettings = new OracleConnectionSettings();
            IList <ConfigurationNode> connections = hierarchy.FindNodesByType(typeof(OracleConnectionElementNode));

            for (int index = 0; index < connections.Count; ++index)
            {
                OracleConnectionData data = new OracleConnectionData();
                data.Name = connections[index].Parent.Name;
                foreach (OraclePackageElementNode node in connections[index].Nodes)
                {
                    data.Packages.Add(node.OraclePackageElement);
                }
                oracleConnectionSettings.OracleConnectionsData.Add(data);
            }
            return(oracleConnectionSettings);
        }
Exemple #19
0
        public DatabaseSettings Build()
        {
            DatabaseSettings settings = new DatabaseSettings();

            if (!this.databaseSectionNode.RequirePermission)                    // don't set if false
            {
                settings.SectionInformation.RequirePermission = this.databaseSectionNode.RequirePermission;
            }
            foreach (ProviderMappingNode node in hierarchy.FindNodesByType(databaseSectionNode, typeof(ProviderMappingNode)))
            {
                settings.ProviderMappings.Add(node.ProviderMapping);
            }
            if (null != databaseSectionNode.DefaultDatabase)
            {
                settings.DefaultDatabase = databaseSectionNode.DefaultDatabase.Name;
            }
            return(settings);
        }