Skip to content

Commit

Permalink
chore(Java): polish Java examples
Browse files Browse the repository at this point in the history
  • Loading branch information
texastony committed Dec 17, 2024
1 parent b98cd0c commit 311eddc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -87,6 +88,7 @@ public static String End2End(
.Identifier(branchKeyId)
.Strategy(strategy)
.SystemKey(_systemKey)
.DoNotVersion(doNotVersion)
.build();

InitializeMutationOutput initOutput = _admin.InitializeMutation(initInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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: " +
Expand Down

0 comments on commit 311eddc

Please sign in to comment.