-
Notifications
You must be signed in to change notification settings - Fork 19
chore: update internal legacy override with adapter pattern #2054
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
Changes from all commits
ec8077c
e89541c
f6f27e4
e5ea095
03d25db
ea7b465
0290cff
c3d2567
53297ce
817d8fa
f520e9d
7ebefe7
75255c0
294abef
5a57429
cab0510
018c92b
eef8a56
ce47673
befb6bd
651d343
4b157e2
07d9e4d
3298a2d
e319647
b2d2414
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.internaldafny.legacy; | ||
|
|
||
| import java.security.GeneralSecurityException; | ||
| import java.util.Map; | ||
| import software.amazon.awssdk.services.dynamodb.model.AttributeValue; | ||
|
|
||
| public interface LegacyEncryptorAdapter { | ||
| Map<String, AttributeValue> encryptRecord( | ||
| Map< | ||
| String, | ||
| software.amazon.awssdk.services.dynamodb.model.AttributeValue | ||
| > item | ||
| ) throws GeneralSecurityException; | ||
|
|
||
| Map< | ||
| String, | ||
| software.amazon.awssdk.services.dynamodb.model.AttributeValue | ||
| > decryptRecord( | ||
| Map< | ||
| String, | ||
| software.amazon.awssdk.services.dynamodb.model.AttributeValue | ||
| > item | ||
| ) throws GeneralSecurityException; | ||
|
|
||
| String getMaterialDescriptionFieldName(); | ||
| String getSignatureFieldName(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.internaldafny.legacy; | ||
|
|
||
| import static software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.internaldafny.legacy.InternalLegacyOverride.V1MapToV2Map; | ||
| import static software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.internaldafny.legacy.InternalLegacyOverride.V2MapToV1Map; | ||
|
|
||
| import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DynamoDBEncryptor; | ||
| import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; | ||
| import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionFlags; | ||
| import java.security.GeneralSecurityException; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| public class V1EncryptorAdapter implements LegacyEncryptorAdapter { | ||
|
|
||
| private final DynamoDBEncryptor encryptor; | ||
| private final Map<String, Set<EncryptionFlags>> actions; | ||
| private final EncryptionContext encryptionContext; | ||
|
|
||
| V1EncryptorAdapter( | ||
| DynamoDBEncryptor encryptor, | ||
| Map<String, Set<EncryptionFlags>> actions, | ||
| EncryptionContext encryptionContext | ||
| ) { | ||
| this.encryptor = encryptor; | ||
| this.actions = actions; | ||
| this.encryptionContext = encryptionContext; | ||
| } | ||
|
|
||
| @Override | ||
| public Map< | ||
| String, | ||
| software.amazon.awssdk.services.dynamodb.model.AttributeValue | ||
| > encryptRecord( | ||
| Map< | ||
| String, | ||
| software.amazon.awssdk.services.dynamodb.model.AttributeValue | ||
| > item | ||
| ) throws GeneralSecurityException { | ||
| return V1MapToV2Map( | ||
| encryptor.encryptRecord(V2MapToV1Map(item), actions, encryptionContext) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public Map< | ||
| String, | ||
| software.amazon.awssdk.services.dynamodb.model.AttributeValue | ||
|
Contributor
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. This V1 class always returns in V2 terms; this means a customers MUST have both SDK v1 and SDK v2 loaded to use this V1 class.
Member
Author
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. Yes. If using DB-ESDK, SDK V2 must be in included in the artifact.
Contributor
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. Is it SDK v1 & SDK v2, or only SDK v2? |
||
| > decryptRecord( | ||
| Map< | ||
| String, | ||
| software.amazon.awssdk.services.dynamodb.model.AttributeValue | ||
| > item | ||
| ) throws GeneralSecurityException { | ||
| return V1MapToV2Map( | ||
| encryptor.decryptRecord(V2MapToV1Map(item), actions, encryptionContext) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public String getMaterialDescriptionFieldName() { | ||
| return encryptor.getMaterialDescriptionFieldName(); | ||
| } | ||
|
|
||
| @Override | ||
| public String getSignatureFieldName() { | ||
| return encryptor.getSignatureFieldName(); | ||
| } | ||
| } | ||
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.
I need to review this file locally.
There is a lot going on here.