static private UpdateMetadataWithEncryptionInstructions ( |
||
request | /// AmazonWebServiceRequest encrypted using the given instruction /// | |
instructions | /// Non-null instruction used to encrypt the data in this AmazonWebServiceRequest . /// | |
Résultat | void |
/// <summary> /// Updates the request where the metadata contains encryption information /// and the input stream contains the encrypted object contents. /// </summary> /// <param name="putObjectRequest"> /// The request whose contents are to be encrypted. /// </param> private void GenerateEncryptedObjectRequestUsingMetadata(PutObjectRequest putObjectRequest) { // Create instruction EncryptionInstructions instructions = EncryptionUtils.GenerateInstructions(this.encryptionMaterials); EncryptionUtils.AddUnencryptedContentLengthToMetadata(putObjectRequest); // Encrypt the object data with the instruction putObjectRequest.InputStream = EncryptionUtils.EncryptRequestUsingInstruction(putObjectRequest.InputStream, instructions); // Update the metadata EncryptionUtils.UpdateMetadataWithEncryptionInstructions(putObjectRequest, instructions); }
/// <summary> /// Performs encryption for PutObject and MultiPartUpload, /// also adding encryption information to object metadata or /// instruction file /// </summary> /// <param name="request">AmazonWebServiceRequest on which encryption is performed </param> protected override void ProcessPreRequestHandlers(AmazonWebServiceRequest request) { base.ProcessPreRequestHandlers(request); var putObjectRequest = request as PutObjectRequest; if (putObjectRequest != null) { if (this.amazonS3CryptoConfig.StorageMode == CryptoStorageMode.InstructionFile) { GenerateEncryptedObjectRequestUsingInstructionFile(putObjectRequest); } else { GenerateEncryptedObjectRequestUsingMetadata(putObjectRequest); } } var initiateMultiPartRequest = request as InitiateMultipartUploadRequest; if (initiateMultiPartRequest != null) { EncryptionInstructions instructions = EncryptionUtils.GenerateInstructions(this.encryptionMaterials); if (this.amazonS3CryptoConfig.StorageMode == CryptoStorageMode.ObjectMetadata) { EncryptionUtils.UpdateMetadataWithEncryptionInstructions(initiateMultiPartRequest, instructions); } initiateMultiPartRequest.EnvelopeKey = instructions.EnvelopeKey; initiateMultiPartRequest.IV = instructions.InitializationVector; } var uploadPartRequest = request as UploadPartRequest; if (uploadPartRequest != null) { GenerateEncryptedUploadPartRequest(uploadPartRequest); } }