-
Notifications
You must be signed in to change notification settings - Fork 16
feat: extend delegating client to enable non-encrypted API operations… #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
import software.amazon.awssdk.core.sync.RequestBody; | ||
import software.amazon.awssdk.core.sync.ResponseTransformer; | ||
import software.amazon.awssdk.http.AbortableInputStream; | ||
import software.amazon.awssdk.services.s3.DelegatingS3Client; | ||
import software.amazon.awssdk.services.s3.S3AsyncClient; | ||
import software.amazon.awssdk.services.s3.S3Client; | ||
import software.amazon.awssdk.services.s3.model.AbortMultipartUploadRequest; | ||
|
@@ -59,13 +60,14 @@ | |
* This client is a drop-in replacement for the S3 client. It will automatically encrypt objects | ||
* on putObject and decrypt objects on getObject using the provided encryption key(s). | ||
*/ | ||
public class S3EncryptionClient implements S3Client { | ||
public class S3EncryptionClient extends DelegatingS3Client { | ||
|
||
// Used for request-scoped encryption contexts for supporting keys | ||
public static final ExecutionAttribute<Map<String, String>> ENCRYPTION_CONTEXT = new ExecutionAttribute<>("EncryptionContext"); | ||
// TODO: Replace with UploadPartRequest.isLastPart() when launched. | ||
// Used for multipart uploads | ||
public static final ExecutionAttribute<Boolean> IS_LAST_PART = new ExecutionAttribute<>("isLastPart"); | ||
|
||
private final S3AsyncClient _wrappedClient; | ||
private final S3AsyncClient _wrappedCrtClient; | ||
private final CryptographicMaterialsManager _cryptoMaterialsManager; | ||
|
@@ -77,6 +79,9 @@ public class S3EncryptionClient implements S3Client { | |
private final MultipartUploadObjectPipeline _multipartPipeline; | ||
|
||
private S3EncryptionClient(Builder builder) { | ||
// The non-encrypted APIs will use a default client. | ||
// In the future, we may want to make this configurable. | ||
super(S3Client.create()); | ||
_wrappedClient = builder._wrappedClient; | ||
_wrappedCrtClient = builder._wrappedCrtClient; | ||
_cryptoMaterialsManager = builder._cryptoMaterialsManager; | ||
|
@@ -206,11 +211,6 @@ public AbortMultipartUploadResponse abortMultipartUpload(AbortMultipartUploadReq | |
return _multipartPipeline.abortMultipartUpload(request); | ||
} | ||
|
||
@Override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nb: the delegating client's implementation is |
||
public String serviceName() { | ||
return _wrappedClient.serviceName(); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
_wrappedClient.close(); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nb: the delegating client's implementation is
final
but also identical to this one.