@@ -34,18 +34,19 @@ def Build(config: DynamoDbItemEncryptorConfig_DynamoDbItemEncryptorConfig):
34
34
35
35
legacy_override = config .legacyOverride .value
36
36
37
+ maybe_encryptor = aws_dbesdk_dynamodb .smithygenerated .aws_cryptography_dbencryptionsdk_dynamodb .dafny_to_smithy .aws_cryptography_dbencryptionsdk_dynamodb_LegacyDynamoDbEncryptorReference (
38
+ legacy_override .encryptor
39
+ )
40
+
37
41
# Precondition: The encryptor MUST be a DynamoDBEncryptor
38
42
if not _HAS_LEGACY_DDBEC :
39
43
return InternalLegacyOverride .CreateBuildFailure (
40
44
InternalLegacyOverride .CreateError ("Could not find aws-dynamodb-encryption-python installation" )
41
45
)
42
- if not isinstance (legacy_override . encryptor , EncryptedClient ):
46
+ if not isinstance (maybe_encryptor , EncryptedClient ):
43
47
return InternalLegacyOverride .CreateBuildFailure (
44
48
InternalLegacyOverride .CreateError ("Legacy encryptor is not supported" )
45
49
)
46
- maybe_encryptor = aws_dbesdk_dynamodb .smithygenerated .aws_cryptography_dbencryptionsdk_dynamodb .dafny_to_smithy .aws_cryptography_dbencryptionsdk_dynamodb_LegacyDynamoDbEncryptorReference (
47
- legacy_override .encryptor
48
- )
49
50
50
51
# Preconditions: MUST be able to create valid encryption context
51
52
maybe_encryption_context = InternalLegacyOverride .legacyEncryptionContext (config )
@@ -59,7 +60,9 @@ def Build(config: DynamoDbItemEncryptorConfig_DynamoDbItemEncryptorConfig):
59
60
60
61
# Create and return the legacy override instance
61
62
legacy_instance = InternalLegacyOverride ()
62
- legacy_instance .encryptor = maybe_encryptor
63
+ # Store both the original encryptor and the wrapped reference
64
+ legacy_instance .original_encryptor = legacy_override .encryptor # Store the original EncryptedClient
65
+ legacy_instance .encryptor = maybe_encryptor # Store the wrapped LegacyDynamoDbEncryptorReference
63
66
legacy_instance .policy = legacy_override .policy
64
67
# Access the value property, not calling it as a function
65
68
legacy_instance .encryption_context = maybe_encryption_context .value
@@ -200,9 +203,11 @@ def DecryptItem(self, input):
200
203
InternalLegacyOverride .CreateError ("Item does not contain required legacy fields" )
201
204
)
202
205
203
- # Use the encryptor to decrypt the item using the instance attributes
204
- decrypted_item = self .encryptor .decrypt_item (
205
- encrypted_item , actions = self .attribute_actions , encryption_context = self .encryption_context
206
+ # Use the original EncryptedClient to decrypt the item
207
+ decrypted_item = self .original_encryptor .decrypt_item (
208
+ encrypted_item ,
209
+ attribute_actions = self .attribute_actions ,
210
+ encryption_context = self .encryption_context
206
211
)
207
212
208
213
# Create the output with the decrypted item
@@ -215,7 +220,8 @@ def DecryptItem(self, input):
215
220
216
221
def __init__ (self ):
217
222
super ().__init__ ()
218
- self .encryptor = None
223
+ self .encryptor = None # LegacyDynamoDbEncryptorReference
224
+ self .original_encryptor = None # Original EncryptedClient with encrypt_item/decrypt_item methods
219
225
self .attribute_actions = None
220
226
self .encryption_context = None
221
227
self .policy = None
0 commit comments