Ejemplo n.º 1
0
        private void ApplyEncryptionKey(EncryptionKey keyFromOptions, MediaDownloader download)
        {
            var effectiveKey = keyFromOptions ?? EncryptionKey;

            download.ModifyRequest += effectiveKey.ModifyRequest;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs a new client wrapping the given <see cref="StorageService"/>.
 /// </summary>
 /// <param name="service">The service to wrap. Must not be null.</param>
 /// <param name="encryptionKey">Optional <see cref="EncryptionKey"/> to use for object-based operations by default. May be null,
 /// in which case <see cref="EncryptionKey.None"/> will be used.</param>
 public StorageClientImpl(StorageService service, EncryptionKey encryptionKey = null)
 {
     Service       = GaxPreconditions.CheckNotNull(service, nameof(service));
     EncryptionKey = encryptionKey ?? EncryptionKey.None;
 }
Ejemplo n.º 3
0
        private void ApplyEncryptionKey(EncryptionKey keyFromOptions, CustomMediaUpload upload)
        {
            var effectiveKey = keyFromOptions ?? EncryptionKey;

            upload.Options.ModifySessionInitiationRequest += effectiveKey.ModifyRequest;
        }
Ejemplo n.º 4
0
        private void ApplyEncryptionKey <TRequest>(EncryptionKey keyFromOptions, ClientServiceRequest <TRequest> request)
        {
            var effectiveKey = keyFromOptions ?? EncryptionKey;

            request.ModifyRequest += effectiveKey.ModifyRequest;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Asynchronously creates a <see cref="StorageClient"/>, using application default credentials if
        /// no credentials are specified.
        /// </summary>
        /// <remarks>
        /// The credentials are scoped as necessary.
        /// </remarks>
        /// <param name="credential">Optional <see cref="GoogleCredential"/>.</param>
        /// <param name="encryptionKey">Optional <see cref="EncryptionKey"/> to use for all relevant object-based operations by default. May be null.</param>
        /// <returns>The task representing the created <see cref="StorageClient"/>.</returns>
        public static Task <StorageClient> CreateAsync(GoogleCredential credential = null, EncryptionKey encryptionKey = null) =>
        new StorageClientBuilder
        {
            Credential    = credential?.CreateScoped(s_scopes),
            EncryptionKey = encryptionKey,
            BaseUri       = EndpointOverride
        }

        .BuildAsync();
        private void ApplyEncryptionKey(EncryptionKey keyFromOptions, string kmsNameFromOptions, CustomMediaUpload upload)
        {
            var effectiveKey = GetEffectiveEncryptionKey(keyFromOptions, kmsNameFromOptions);

            upload.Options.ModifySessionInitiationRequest += effectiveKey.ModifyRequest;
        }
        /// <summary>
        /// Applies an encryption key to a request. Note that there is no overload without a kmsNameFromOptions, even though most
        /// requests don't have one, just to avoid missing one accidentally.
        /// </summary>
        /// <param name="keyFromOptions">The encryption key specified in the operation-specific options, or null.</param>
        /// <param name="kmsNameFromOptions">The KMS key name specified in the operation-specific options, or null.</param>
        /// <param name="request">The request to apply this to.</param>
        private void ApplyEncryptionKey <TRequest>(EncryptionKey keyFromOptions, string kmsNameFromOptions, ClientServiceRequest <TRequest> request)
        {
            var effectiveKey = GetEffectiveEncryptionKey(keyFromOptions, kmsNameFromOptions);

            request.ModifyRequest += effectiveKey.ModifyRequest;
        }