Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fcf2380

Browse files
committedJun 3, 2024·
Formatting
1 parent 95e1b27 commit fcf2380

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed
 

‎.github/workflows/ci_examples_java.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
library: DynamoDbEncryption
6969
diff-generated-code: false
7070
update-and-regenerate-mpl: true
71-
71+
7272
- name: Build and locally deploy dependencies for examples
7373
shell: bash
7474
working-directory: ./DynamoDbEncryption

‎DynamoDbEncryption/runtimes/java/src/main/java/software/amazon/cryptography/dbencryptionsdk/dynamodb/itemencryptor/internaldafny/legacy/InternalLegacyOverride.java

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
package software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.internaldafny.legacy;
22

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;
317
import Wrappers_Compile.Option;
418
import Wrappers_Compile.Result;
519
import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DynamoDBEncryptor;
@@ -16,20 +30,6 @@
1630
import software.amazon.cryptography.dbencryptionsdk.dynamodb.internaldafny.types.LegacyPolicy;
1731
import software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.ToNative;
1832
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;
3333
import software.amazon.cryptography.dbencryptionsdk.structuredencryption.internaldafny.types.CryptoAction;
3434

3535
public class InternalLegacyOverride extends _ExternBase_InternalLegacyOverride {
@@ -95,7 +95,9 @@ > EncryptItem(
9595
) {
9696
// Precondition: Policy MUST allow the caller to encrypt.
9797
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+
);
99101
}
100102

101103
try {
@@ -147,7 +149,9 @@ > DecryptItem(
147149
!_policy.is_FORCE__LEGACY__ENCRYPT__ALLOW__LEGACY__DECRYPT() &&
148150
!_policy.is_FORBID__LEGACY__ENCRYPT__ALLOW__LEGACY__DECRYPT()
149151
) {
150-
return CreateDecryptItemFailure(createError("Legacy Policy does not support decrypt."));
152+
return CreateDecryptItemFailure(
153+
createError("Legacy Policy does not support decrypt.")
154+
);
151155
}
152156
try {
153157
Map<
@@ -199,7 +203,9 @@ public static Result<Option<InternalLegacyOverride>, Error> Build(
199203

200204
// Precondition: The encryptor MUST be a DynamoDBEncryptor
201205
if (!isDynamoDBEncryptor(maybeEncryptor)) {
202-
return CreateBuildFailure(createError("Legacy encryptor is not supported"));
206+
return CreateBuildFailure(
207+
createError("Legacy encryptor is not supported")
208+
);
203209
}
204210
// Preconditions: MUST be able to create valid encryption context
205211
final InternalResult<EncryptionContext, Error> maybeEncryptionContext =
@@ -208,8 +214,12 @@ public static Result<Option<InternalLegacyOverride>, Error> Build(
208214
return CreateBuildFailure(maybeEncryptionContext.error());
209215
}
210216
// 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+
);
213223
if (maybeActions.isFailure()) {
214224
return CreateBuildFailure(maybeEncryptionContext.error());
215225
}
@@ -222,13 +232,18 @@ public static Result<Option<InternalLegacyOverride>, Error> Build(
222232
legacyOverride.dtor_policy()
223233
);
224234

225-
return CreateBuildSuccess(CreateInternalLegacyOverrideSome(internalLegacyOverride));
235+
return CreateBuildSuccess(
236+
CreateInternalLegacyOverrideSome(internalLegacyOverride)
237+
);
226238
}
227239

228240
// Everything below this point is an implementation detail
229241

230242
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+
);
232247
return Error.create_DynamoDbItemEncryptorException(dafnyMessage);
233248
}
234249

@@ -248,7 +263,10 @@ public static DafnySequence<Character> ToDafnyString(String s) {
248263
);
249264
}
250265

251-
public static InternalResult<EncryptionContext, Error> legacyEncryptionContext(
266+
public static InternalResult<
267+
EncryptionContext,
268+
Error
269+
> legacyEncryptionContext(
252270
software.amazon.cryptography.dbencryptionsdk.dynamodb.itemencryptor.internaldafny.types.DynamoDbItemEncryptorConfig config
253271
) {
254272
try {
@@ -273,7 +291,10 @@ public static InternalResult<EncryptionContext, Error> legacyEncryptionContext(
273291
}
274292
}
275293

276-
public static InternalResult<Map<String, Set<EncryptionFlags>>, Error> legacyActions(
294+
public static InternalResult<
295+
Map<String, Set<EncryptionFlags>>,
296+
Error
297+
> legacyActions(
277298
DafnyMap<
278299
? extends DafnySequence<? extends Character>,
279300
? extends CryptoAction

0 commit comments

Comments
 (0)
Please sign in to comment.