/// <summary> /// Creates a <see cref="S3XmlRepository"/> with keys stored at the given bucket & optional key prefix. /// </summary> /// <param name="s3Client">The S3 client.</param> /// <param name="config">The configuration object specifying how to write to S3.</param> /// <param name="services">An optional <see cref="IServiceProvider"/> to provide ancillary services.</param> /// <param name="mockWrapper">Wrapper object to ensure unit testing is feasible.</param> public S3XmlRepository(IAmazonS3 s3Client, IS3XmlRepositoryConfig config, IServiceProvider services, IMockingWrapper mockWrapper) { this.s3Client = s3Client ?? throw new ArgumentNullException(nameof(s3Client)); Config = config ?? throw new ArgumentNullException(nameof(config)); logger = services?.GetService <ILoggerFactory>()?.CreateLogger <S3XmlRepository>(); this.mockWrapper = mockWrapper; }
/// <summary> /// Copies settings from another settings object. /// </summary> /// <remarks> /// <see cref="Microsoft.Extensions.Options.IOptions{TOptions}"/> requires a parameterless constructor, so we end up with nasty hackery like this for handling programmatic options specification. /// </remarks> /// <param name="input">Input from which to copy configuration.</param> public void CopyFrom(IS3XmlRepositoryConfig input) { Bucket = input.Bucket; KeyPrefix = input.KeyPrefix; MaxS3QueryConcurrency = input.MaxS3QueryConcurrency; StorageClass = input.StorageClass; ServerSideEncryptionMethod = input.ServerSideEncryptionMethod; ServerSideEncryptionCustomerMethod = input.ServerSideEncryptionCustomerMethod; ServerSideEncryptionCustomerProvidedKey = input.ServerSideEncryptionCustomerProvidedKey; ServerSideEncryptionCustomerProvidedKeyMd5 = input.ServerSideEncryptionCustomerProvidedKeyMd5; ServerSideEncryptionKeyManagementServiceKeyId = input.ServerSideEncryptionKeyManagementServiceKeyId; ClientSideCompression = input.ClientSideCompression; ValidateMd5Metadata = input.ValidateMd5Metadata; ValidateETag = input.ValidateETag; }
/// <summary> /// Configures the data protection system to persist keys to a specified S3 bucket. /// </summary> /// <param name="builder">The <see cref="IDataProtectionBuilder"/>.</param> /// <param name="config">The configuration object specifying how to write to S3</param> /// <returns>A reference to the <see cref="IDataProtectionBuilder" /> after this operation has completed.</returns> public static IDataProtectionBuilder PersistKeysToAwsS3(this IDataProtectionBuilder builder, IS3XmlRepositoryConfig config) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } return(builder.PersistKeysToAwsS3Raw(null, config)); }
public DirectConfigure(IS3XmlRepositoryConfig input) { this.input = input ?? throw new ArgumentNullException(nameof(input)); }
private static IDataProtectionBuilder PersistKeysToAwsS3Raw(this IDataProtectionBuilder builder, IAmazonS3 s3Client, IS3XmlRepositoryConfig config) { builder.Services.AddSingleton <IConfigureOptions <S3XmlRepositoryConfig> >(new DirectConfigure(config)); return(builder.PersistKeysToAwsS3Impl(s3Client, sp => sp.GetRequiredService <IOptions <S3XmlRepositoryConfig> >())); }
/// <summary> /// Creates a <see cref="S3XmlRepository"/> with keys stored at the given bucket & optional key prefix. /// </summary> /// <param name="s3Client">The S3 client.</param> /// <param name="config">The configuration object specifying how to write to S3.</param> /// <param name="services">An optional <see cref="IServiceProvider"/> to provide ancillary services.</param> public S3XmlRepository(IAmazonS3 s3Client, IS3XmlRepositoryConfig config, IServiceProvider services) : this(s3Client, config, services, new MockingWrapper()) { }
/// <summary> /// Creates a <see cref="S3XmlRepository"/> with keys stored at the given bucket. /// </summary> /// <param name="s3Client">The S3 client.</param> /// <param name="config">The configuration object specifying how to write to S3.</param> public S3XmlRepository(IAmazonS3 s3Client, IS3XmlRepositoryConfig config) : this(s3Client, config, null) { }
public S3XmlRepository(IAmazonS3 client, IS3XmlRepositoryConfig config) { _client = client; Config = config ?? throw new ArgumentNullException(nameof(config)); }