From 8677e91fd904d959fddc4340aecaa17d046e9a5b Mon Sep 17 00:00:00 2001 From: texastony <5892063+texastony@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:13:41 -0800 Subject: [PATCH] chore(Java): polish Java examples --- .../hierarchy/mutations/DescribeMutationExample.java | 4 +++- .../example/hierarchy/mutations/MutationExample.java | 4 +++- .../hierarchy/mutations/MutationsProvider.java | 11 +++++++++++ .../cryptography/example/hierarchy/ExampleTests.java | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/DescribeMutationExample.java b/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/DescribeMutationExample.java index bfbd3f7a0..e1ea50c5e 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/DescribeMutationExample.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/DescribeMutationExample.java @@ -3,6 +3,7 @@ package software.amazon.cryptography.example.hierarchy.mutations; import static software.amazon.cryptography.example.hierarchy.mutations.MutationsProvider.MutableBranchKeyPropertiesToString; +import static software.amazon.cryptography.example.hierarchy.mutations.MutationsProvider.MutationTokenToString; import static software.amazon.cryptography.example.hierarchy.mutations.MutationsProvider.MutationsToString; import static software.amazon.cryptography.example.hierarchy.mutations.MutationsProvider.executeInitialize; @@ -75,7 +76,8 @@ public static DescribeMutationOutput Example( ); // The Description object holds Details and the Token. System.out.println( - "The Token to continue the Mutation is: " + description.MutationToken() + "The Token to continue the Mutation is: " + + MutationTokenToString(description.MutationToken()) ); return output; } diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/MutationExample.java b/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/MutationExample.java index 022517366..f552ba123 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/MutationExample.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/MutationExample.java @@ -64,7 +64,8 @@ public static String End2End( String kmsKeyArnTerminal, String branchKeyId, @Nullable SystemKey systemKey, - @Nullable KeyStoreAdmin admin + @Nullable KeyStoreAdmin admin, + @Nullable Boolean doNotVersion ) { final SystemKey _systemKey = systemKey == null ? MutationsProvider.KmsSystemKey() @@ -87,6 +88,7 @@ public static String End2End( .Identifier(branchKeyId) .Strategy(strategy) .SystemKey(_systemKey) + .DoNotVersion(doNotVersion) .build(); InitializeMutationOutput initOutput = _admin.InitializeMutation(initInput); diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/MutationsProvider.java b/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/MutationsProvider.java index e5a26d216..94d7b0b4a 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/MutationsProvider.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/examples/java/software/amazon/cryptography/example/hierarchy/mutations/MutationsProvider.java @@ -250,4 +250,15 @@ static String MutableBranchKeyPropertiesToString( properties.CustomEncryptionContext().toString() ); } + + static String MutationTokenToString(MutationToken token) { + return ( + "branch-key-id: " + + token.Identifier() + + "\nuuid: " + + token.UUID() + + "\ncreateTime: " + + token.CreateTime() + ); + } } diff --git a/AwsCryptographicMaterialProviders/runtimes/java/src/testExamples/java/software/amazon/cryptography/example/hierarchy/ExampleTests.java b/AwsCryptographicMaterialProviders/runtimes/java/src/testExamples/java/software/amazon/cryptography/example/hierarchy/ExampleTests.java index 1113f7666..c2413e45b 100644 --- a/AwsCryptographicMaterialProviders/runtimes/java/src/testExamples/java/software/amazon/cryptography/example/hierarchy/ExampleTests.java +++ b/AwsCryptographicMaterialProviders/runtimes/java/src/testExamples/java/software/amazon/cryptography/example/hierarchy/ExampleTests.java @@ -30,7 +30,8 @@ public void End2EndReEncryptTest() { Fixtures.POSTAL_HORN_KEY_ARN, branchKeyId, MutationsProvider.TrustStorage(), - AdminProvider.admin() + AdminProvider.admin(), + false ); System.out.println( "\nMutated Branch Key: " +