예제 #1
0
        /// <summary>
        /// <para>Load the configured protection mechanism for the section. This is the <see cref="KeyAlgorithmPairStorageProviderData"/> to load the <see cref="KeyAlgorithmPair"/>.</para>
        /// </summary>
        /// <param name="sectionName">
        /// <para>The name of the section to encrypt.</para>
        /// </param>
        /// <param name="context">
        /// <para>A <see cref="ConfigurationContext"/> object.</para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="context"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="ConfigurationException">
        /// <para>An error occured in configuration.</para>
        /// </exception>
        public void Load(ConfigurationContext context, string sectionName)
        {
            ArgumentValidation.CheckForNullReference(context, "context");
            ArgumentValidation.CheckForNullReference(sectionName, "sectionName");
            ArgumentValidation.CheckForEmptyString(sectionName, "sectionName");

            ConfigurationSettings    settings = context.GetMetaConfiguration();
            ConfigurationSectionData data     = settings.ConfigurationSections[sectionName];

            if (null == data)
            {
                InvalidSectionExceptionBuilder builder = new InvalidSectionExceptionBuilder(sectionName, context.ConfigurationFile);
                throw builder.ThrowException();
            }

            if ((null == settings.KeyAlgorithmPairStorageProviderData) && (data.Encrypt))
            {
                throw new ConfigurationException(SR.ExceptionNoKeyAlgorithmStorageProvider);
            }

            if (data.Encrypt)
            {
                SetDataToBeEncrypted(context);
            }
        }
예제 #2
0
 /// <summary>
 /// <para>Gets the <see cref="ConfigurationSettings"/>.</para>
 /// </summary>
 /// <returns>
 /// <para>The <see cref="ConfigurationSettings"/>.</para>
 /// </returns>
 public virtual ConfigurationSettings GetConfigurationSettings()
 {
     return(ConfigurationContext.GetMetaConfiguration());
 }
예제 #3
0
        /// <summary>
        /// <para>Load the configured protection mechanism for the section. This is the <see cref="KeyAlgorithmPairStorageProviderData"/> to load the <see cref="KeyAlgorithmPair"/>.</para>
        /// </summary>
        /// <param name="sectionName">
        /// <para>The name of the section to encrypt.</para>
        /// </param>
        /// <param name="context">
        /// <para>A <see cref="ConfigurationContext"/> object.</para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="context"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="ConfigurationException">
        /// <para>An error occured in configuration.</para>
        /// </exception>
        public void Load(ConfigurationContext context, string sectionName)
        {
            ArgumentValidation.CheckForNullReference(context, "context");
            ArgumentValidation.CheckForNullReference(sectionName, "sectionName");
            ArgumentValidation.CheckForEmptyString(sectionName, "sectionName");

            ConfigurationSettings settings = context.GetMetaConfiguration();
            ConfigurationSectionData data = settings.ConfigurationSections[sectionName];
            if (null == data)
            {
                InvalidSectionExceptionBuilder builder = new InvalidSectionExceptionBuilder(sectionName, context.ConfigurationFile);
                throw builder.ThrowException();
            }

            if ((null == settings.KeyAlgorithmPairStorageProviderData) && (data.Encrypt))
            {
                throw new ConfigurationException(SR.ExceptionNoKeyAlgorithmStorageProvider);
            }

            if (data.Encrypt)
            {
                SetDataToBeEncrypted(context);
            }
        }