1
1
package software .amazon .cryptography .dbencryptionsdk .dynamodb .itemencryptor .internaldafny .legacy ;
2
2
3
+ /**
4
+ * This file does *NOT* import a lot of things.
5
+ * This is because it is dealing with converting
6
+ * between different versions of the same name.
7
+ * The DynamoDbItemEncryptor module has Dafny and Java versions
8
+ * of the same type.
9
+ * This means that `EncryptItemOutput` for example
10
+ * needs to be disambiguated between the Dafny version and the Java version.
11
+ * In order to make it clearer at each call-site exactly what is happening
12
+ * the full import is used.
13
+ * IDEs tend to fight this so I'm sorry.
14
+ */
15
+
16
+ import StandardLibraryInternal .InternalResult ;
3
17
import Wrappers_Compile .Option ;
4
18
import Wrappers_Compile .Result ;
5
19
import com .amazonaws .services .dynamodbv2 .datamodeling .encryption .DynamoDBEncryptor ;
16
30
import software .amazon .cryptography .dbencryptionsdk .dynamodb .internaldafny .types .LegacyPolicy ;
17
31
import software .amazon .cryptography .dbencryptionsdk .dynamodb .itemencryptor .ToNative ;
18
32
import software .amazon .cryptography .dbencryptionsdk .dynamodb .itemencryptor .internaldafny .types .Error ;
19
- /**
20
- * This file does *NOT* import a lot of things.
21
- * This is because it is dealing with converting
22
- * between different versions of the same name.
23
- * The DynamoDbItemEncryptor module has Dafny and Java versions
24
- * of the same type.
25
- * This means that `EncryptItemOutput` for example
26
- * needs to be disambiguated between the Dafny version and the Java version.
27
- * In order to make it clearer at each call-site exactly what is happening
28
- * the full import is used.
29
- * IDEs tend to fight this so I'm sorry.
30
- */
31
-
32
- import StandardLibraryInternal .InternalResult ;
33
33
import software .amazon .cryptography .dbencryptionsdk .structuredencryption .internaldafny .types .CryptoAction ;
34
34
35
35
public class InternalLegacyOverride extends _ExternBase_InternalLegacyOverride {
@@ -95,7 +95,9 @@ > EncryptItem(
95
95
) {
96
96
// Precondition: Policy MUST allow the caller to encrypt.
97
97
if (!_policy .is_FORCE__LEGACY__ENCRYPT__ALLOW__LEGACY__DECRYPT ()) {
98
- return CreateEncryptItemFailure (createError ("Legacy Policy does not support encrypt." ));
98
+ return CreateEncryptItemFailure (
99
+ createError ("Legacy Policy does not support encrypt." )
100
+ );
99
101
}
100
102
101
103
try {
@@ -147,7 +149,9 @@ > DecryptItem(
147
149
!_policy .is_FORCE__LEGACY__ENCRYPT__ALLOW__LEGACY__DECRYPT () &&
148
150
!_policy .is_FORBID__LEGACY__ENCRYPT__ALLOW__LEGACY__DECRYPT ()
149
151
) {
150
- return CreateDecryptItemFailure (createError ("Legacy Policy does not support decrypt." ));
152
+ return CreateDecryptItemFailure (
153
+ createError ("Legacy Policy does not support decrypt." )
154
+ );
151
155
}
152
156
try {
153
157
Map <
@@ -199,7 +203,9 @@ public static Result<Option<InternalLegacyOverride>, Error> Build(
199
203
200
204
// Precondition: The encryptor MUST be a DynamoDBEncryptor
201
205
if (!isDynamoDBEncryptor (maybeEncryptor )) {
202
- return CreateBuildFailure (createError ("Legacy encryptor is not supported" ));
206
+ return CreateBuildFailure (
207
+ createError ("Legacy encryptor is not supported" )
208
+ );
203
209
}
204
210
// Preconditions: MUST be able to create valid encryption context
205
211
final InternalResult <EncryptionContext , Error > maybeEncryptionContext =
@@ -208,8 +214,12 @@ public static Result<Option<InternalLegacyOverride>, Error> Build(
208
214
return CreateBuildFailure (maybeEncryptionContext .error ());
209
215
}
210
216
// Precondition: All actions MUST be supported types
211
- final InternalResult <Map <String , Set <EncryptionFlags >>, Error > maybeActions =
212
- legacyActions (legacyOverride .dtor_attributeActionsOnEncrypt ());
217
+ final InternalResult <
218
+ Map <String , Set <EncryptionFlags >>,
219
+ Error
220
+ > maybeActions = legacyActions (
221
+ legacyOverride .dtor_attributeActionsOnEncrypt ()
222
+ );
213
223
if (maybeActions .isFailure ()) {
214
224
return CreateBuildFailure (maybeEncryptionContext .error ());
215
225
}
@@ -222,13 +232,18 @@ public static Result<Option<InternalLegacyOverride>, Error> Build(
222
232
legacyOverride .dtor_policy ()
223
233
);
224
234
225
- return CreateBuildSuccess (CreateInternalLegacyOverrideSome (internalLegacyOverride ));
235
+ return CreateBuildSuccess (
236
+ CreateInternalLegacyOverrideSome (internalLegacyOverride )
237
+ );
226
238
}
227
239
228
240
// Everything below this point is an implementation detail
229
241
230
242
public static Error createError (String message ) {
231
- final DafnySequence <Character > dafnyMessage = software .amazon .smithy .dafny .conversion .ToDafny .Simple .CharacterSequence (message );
243
+ final DafnySequence <Character > dafnyMessage =
244
+ software .amazon .smithy .dafny .conversion .ToDafny .Simple .CharacterSequence (
245
+ message
246
+ );
232
247
return Error .create_DynamoDbItemEncryptorException (dafnyMessage );
233
248
}
234
249
@@ -248,7 +263,10 @@ public static DafnySequence<Character> ToDafnyString(String s) {
248
263
);
249
264
}
250
265
251
- public static InternalResult <EncryptionContext , Error > legacyEncryptionContext (
266
+ public static InternalResult <
267
+ EncryptionContext ,
268
+ Error
269
+ > legacyEncryptionContext (
252
270
software .amazon .cryptography .dbencryptionsdk .dynamodb .itemencryptor .internaldafny .types .DynamoDbItemEncryptorConfig config
253
271
) {
254
272
try {
@@ -273,7 +291,10 @@ public static InternalResult<EncryptionContext, Error> legacyEncryptionContext(
273
291
}
274
292
}
275
293
276
- public static InternalResult <Map <String , Set <EncryptionFlags >>, Error > legacyActions (
294
+ public static InternalResult <
295
+ Map <String , Set <EncryptionFlags >>,
296
+ Error
297
+ > legacyActions (
277
298
DafnyMap <
278
299
? extends DafnySequence <? extends Character >,
279
300
? extends CryptoAction
0 commit comments