/// <summary> /// Creates an instance of <see cref="ConfigureCryptographyExtension"/> passing the cryptography configuration's fluent interface builder. /// </summary> /// <param name="context">The current caching configuration's fluent interface builder.<br/> /// This interface must implement <see cref="IConfigureCryptographyExtension"/>.</param> protected ConfigureCryptographyExtension(IConfigureCryptography context) { contextExtension = context as IConfigureCryptographyExtension; if (contextExtension == null) throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, Resources.ExceptionParameterMustImplementType, typeof(IConfigureCryptographyExtension).FullName) , "context"); }
public EncryptUsingCustomSymmetricProviderNamedBuilder(IConfigureCryptography context, string customSymmetricCryptoProviderName, Type customSymmetricCryptoProviderType, NameValueCollection attributes) : base(context) { customSymmetricProviderData = new CustomSymmetricCryptoProviderData(customSymmetricCryptoProviderName, customSymmetricCryptoProviderType); customSymmetricProviderData.Attributes.Add(attributes); base.CryptographySettings.SymmetricCryptoProviders.Add(customSymmetricProviderData); }
/// <summary> /// Adds a <see cref="DpapiSymmetricCryptoProvider"/> to the cryptography configuration settings. /// </summary> /// <param name="context">Fluent interface extension point.</param> /// <param name="dpapiProviderName">The name of the <see cref="DpapiSymmetricCryptoProvider"/> that should be configured.</param> /// <returns>Fluent interface to further configure the created <see cref="DpapiSymmetricCryptoProviderData"/>.</returns> /// <seealso cref="DpapiSymmetricCryptoProvider"/> /// <seealso cref="DpapiSymmetricCryptoProviderData"/> public static IEncryptUsingDPAPIProviderNamed EncryptUsingDPAPIProviderNamed(this IConfigureCryptography context, string dpapiProviderName) { if (string.IsNullOrEmpty(dpapiProviderName)) { throw new ArgumentException("dpapiProviderName"); } return(new EncryptUsingDPAPIProviderNamedBuilder(context, dpapiProviderName)); }
public EncryptUsingKeyedHashAlgorithmProviderNamedBuilder(IConfigureCryptography context, string algorithmProviderName) : base(context) { providerData = new KeyedHashAlgorithmProviderData { Name = algorithmProviderName }; CryptographySettings.HashProviders.Add(providerData); }
public EncryptUsingDPAPIProviderNamedBuilder(IConfigureCryptography context, string dpapiProviderName) : base(context) { providerData = new DpapiSymmetricCryptoProviderData { Name = dpapiProviderName }; base.CryptographySettings.SymmetricCryptoProviders.Add(providerData); }
/// <summary> /// Creates an instance of <see cref="ConfigureCryptographyExtension"/> passing the cryptography configuration's fluent interface builder. /// </summary> /// <param name="context">The current caching configuration's fluent interface builder.<br/> /// This interface must implement <see cref="IConfigureCryptographyExtension"/>.</param> protected ConfigureCryptographyExtension(IConfigureCryptography context) { contextExtension = context as IConfigureCryptographyExtension; if (contextExtension == null) { throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, Resources.ExceptionParameterMustImplementType, typeof(IConfigureCryptographyExtension).FullName) , "context"); } }
public EncryptUsingSymmetricProviderNamedBuilder(IConfigureCryptography context, string algorithmProviderName) : base(context) { providerData = new SymmetricAlgorithmProviderData { Name = algorithmProviderName, Type = typeof(SymmetricAlgorithmProvider) }; base.CryptographySettings.SymmetricCryptoProviders.Add(providerData); }
/// <summary> /// Adds a custom symmetric crypto provider of type <paramref name="customSymmetricCryptoProviderType"/> to the cryptography configuration. /// </summary> /// <param name="context">Fluent interface extension point.</param> /// <param name="customSymmetricCryptoProviderName">The name of the symmetric crypto provider that should be added to configuration.</param> /// <param name="customSymmetricCryptoProviderType">The concrete type of the symmetric crypto provider.</param> /// <param name="attributes">Attributes that should be passed to <paramref name="customSymmetricCryptoProviderType"/> when creating an instance.</param> /// <returns>Fluent interface that can be used to further configure the created <see cref="CustomSymmetricCryptoProviderData"/>. </returns> /// <seealso cref="CustomSymmetricCryptoProviderData"/> public static IEncryptUsingCustomSymmetricProviderNamed EncryptUsingCustomSymmetricProviderNamed(this IConfigureCryptography context, string customSymmetricCryptoProviderName, Type customSymmetricCryptoProviderType, NameValueCollection attributes) { if (string.IsNullOrEmpty(customSymmetricCryptoProviderName)) { throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "customSymmetricCryptoProviderName"); } if (customSymmetricCryptoProviderType == null) { throw new ArgumentNullException("customSymmetricCryptoProviderType"); } if (attributes == null) { throw new ArgumentNullException("attributes"); } if (!typeof(ISymmetricCryptoProvider).IsAssignableFrom(customSymmetricCryptoProviderType)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionTypeMustImplementInterface, typeof(ISymmetricCryptoProvider)), "customSymmetricCryptoProviderType"); } return(new EncryptUsingCustomSymmetricProviderNamedBuilder(context, customSymmetricCryptoProviderName, customSymmetricCryptoProviderType, attributes)); }
/// <summary> /// Adds a <see cref="HashAlgorithmProvider"/> to the cryptography configuration settings. /// </summary> /// <param name="context">Fluent interface extension point.</param> /// <param name="algorithmProviderName">The name of the <see cref="HashAlgorithmProvider"/> that should be configured.</param> /// <returns>Fluent interface to further configure the created <see cref="HashAlgorithmProviderData"/>.</returns> /// <seealso cref="HashAlgorithmProvider"/> /// <seealso cref="HashAlgorithmProviderData"/> public static IEncryptUsingHashAlgorithmProviderNamed EncryptUsingHashAlgorithmProviderNamed(this IConfigureCryptography context, string algorithmProviderName) { if (string.IsNullOrEmpty(algorithmProviderName)) { throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "algorithmProviderName"); } return(new EncryptUsingHashAlgorithmProviderNamedBuilder(context, algorithmProviderName)); }
protected override void Arrange() { base.Arrange(); ConfigureCryptography = ConfigurationSourceBuilder.ConfigureCryptography(); }
protected override void Act() { ConfigureCryptography = base.ConfigurationSourceBuilder.ConfigureCryptography(); }
/// <summary> /// Adds a custom hash provider of type <typeparamref name="TCustomHashCryptoProvider"/> to the cryptography configuration. /// </summary> /// <typeparam name="TCustomHashCryptoProvider">The concrete type of the hash provider.</typeparam> /// <param name="context">Fluent interface extension point.</param> /// <param name="customHashCryptoProviderName">The name of the hash provider that should be added to configuration.</param> /// <returns>Fluent interface that can be used to further configure the created <see cref="CustomHashProviderData"/>. </returns> /// <seealso cref="CustomHashProviderData"/> public static IEncryptUsingCustomHashProviderNamed EncryptUsingCustomHashProviderNamed <TCustomHashCryptoProvider>(this IConfigureCryptography context, string customHashCryptoProviderName) where TCustomHashCryptoProvider : IHashProvider { return(EncryptUsingCustomHashProviderNamed(context, customHashCryptoProviderName, typeof(TCustomHashCryptoProvider), new NameValueCollection())); }
/// <summary> /// Adds a custom symmetric crypto provider of type <paramref name="customSymmetricCryptoProviderType"/> to the cryptography configuration. /// </summary> /// <param name="context">Fluent interface extension point.</param> /// <param name="customSymmetricCryptoProviderName">The name of the symmetric crypto provider that should be added to configuration.</param> /// <param name="customSymmetricCryptoProviderType">The concrete type of the symmetric crypto provider.</param> /// <returns>Fluent interface that can be used to further configure the created <see cref="CustomSymmetricCryptoProviderData"/>. </returns> /// <seealso cref="CustomSymmetricCryptoProviderData"/> public static IEncryptUsingCustomSymmetricProviderNamed EncryptUsingCustomSymmetricProviderNamed(this IConfigureCryptography context, string customSymmetricCryptoProviderName, Type customSymmetricCryptoProviderType) { return(EncryptUsingCustomSymmetricProviderNamed(context, customSymmetricCryptoProviderName, customSymmetricCryptoProviderType, new NameValueCollection())); }
/// <summary> /// Adds a custom symmetric crypto provider of type <typeparamref name="TCustomSymmetricCryptoProvider"/> to the cryptography configuration. /// </summary> /// <typeparam name="TCustomSymmetricCryptoProvider">The concrete type of the symmetric crypto provider.</typeparam> /// <param name="context">Fluent interface extension point.</param> /// <param name="customSymmetricCryptoProviderName">The name of the symmetric crypto provider that should be added to configuration.</param> /// <param name="attributes">Attributes that should be passed to <typeparamref name="TCustomSymmetricCryptoProvider"/> when creating an instance.</param> /// <returns>Fluent interface that can be used to further configure the created <see cref="CustomSymmetricCryptoProviderData"/>. </returns> /// <seealso cref="CustomSymmetricCryptoProviderData"/> public static IEncryptUsingCustomSymmetricProviderNamed EncryptUsingCustomSymmetricProviderNamed <TCustomSymmetricCryptoProvider>(this IConfigureCryptography context, string customSymmetricCryptoProviderName, NameValueCollection attributes) where TCustomSymmetricCryptoProvider : ISymmetricCryptoProvider { return(EncryptUsingCustomSymmetricProviderNamed(context, customSymmetricCryptoProviderName, typeof(TCustomSymmetricCryptoProvider), attributes)); }