@@ -113,21 +113,21 @@ public void AwsKmsEncryptDecryptKeyring() {
113
113
crypto .encryptData (kmsKeyring , EXAMPLE_DATA , encryptionContext );
114
114
115
115
List <?> masterKeys = encryptResult .getMasterKeys ();
116
+ List <String > masterKeyIds = encryptResult .getMasterKeyIds ();
116
117
// Assert CryptoResult returns empty list if keyrings are used.
117
- assert masterKeys .size () == 0 ;
118
+ assert masterKeys .isEmpty ();
119
+ assert masterKeyIds .isEmpty ();
118
120
119
121
final byte [] ciphertext = encryptResult .getResult ();
120
122
121
123
// Decrypt the data
122
- final CryptoResult <byte [], ?> decryptResult = crypto .decryptData (kmsKeyring , ciphertext );
123
- assert masterKeys .size () == 0 ;
124
-
125
- // Verify that the encryption context in the result contains the
126
- // encryption context supplied to the encryptData method.
127
- if (!encryptionContext .entrySet ().stream ()
128
- .allMatch (e -> e .getValue ().equals (decryptResult .getEncryptionContext ().get (e .getKey ())))) {
129
- throw new IllegalStateException ("Wrong Encryption Context!" );
130
- }
124
+ final CryptoResult <byte [], ?> decryptResult =
125
+ crypto .decryptData (kmsKeyring , ciphertext , encryptionContext );
126
+ masterKeys = decryptResult .getMasterKeys ();
127
+ masterKeyIds = decryptResult .getMasterKeyIds ();
128
+ // Assert CryptoResult returns empty list if keyrings are used.
129
+ assert masterKeys .isEmpty ();
130
+ assert masterKeyIds .isEmpty ();
131
131
132
132
// Verify that the decrypted plaintext matches the original plaintext
133
133
assert Arrays .equals (decryptResult .getResult (), EXAMPLE_DATA );
0 commit comments