44import java .util .List ;
55import java .util .TreeMap ;
66import javax .crypto .SecretKey ;
7+ import software .amazon .awssdk .core .ApiName ;
78import software .amazon .awssdk .core .SdkBytes ;
89import software .amazon .awssdk .services .kms .KmsClient ;
910import software .amazon .awssdk .services .kms .model .DecryptRequest ;
1011import software .amazon .awssdk .services .kms .model .DecryptResponse ;
1112import software .amazon .awssdk .services .kms .model .EncryptRequest ;
1213import software .amazon .awssdk .services .kms .model .EncryptResponse ;
1314import software .amazon .encryption .s3 .S3EncryptionClientException ;
15+ import software .amazon .encryption .s3 .internal .ApiNameVersion ;
1416
1517/**
1618 * AESKeyring will call to KMS to wrap the data key used to encrypt content.
@@ -21,6 +23,8 @@ public class KMSContextKeyring implements Keyring {
2123
2224 private static final String ENCRYPTION_CONTEXT_ALGORITHM_KEY = "aws:x-amz-cek-alg" ;
2325
26+ private static final ApiName API_NAME = ApiNameVersion .apiNameWithVersion ();
27+
2428 private final KmsClient _kmsClient ;
2529 private final String _wrappingKeyId ;
2630 private final DataKeyGenerator _dataKeyGenerator ;
@@ -56,6 +60,7 @@ public EncryptionMaterials onEncrypt(EncryptionMaterials materials) {
5660 .keyId (_wrappingKeyId )
5761 .encryptionContext (encryptionContext )
5862 .plaintext (SdkBytes .fromByteArray (materials .plaintextDataKey ()))
63+ .overrideConfiguration (builder -> builder .addApiName (API_NAME ))
5964 .build ();
6065
6166 EncryptResponse response = _kmsClient .encrypt (request );
@@ -94,6 +99,7 @@ public DecryptionMaterials onDecrypt(final DecryptionMaterials materials, List<E
9499 .keyId (_wrappingKeyId )
95100 .encryptionContext (materials .encryptionContext ())
96101 .ciphertextBlob (SdkBytes .fromByteArray (encryptedDataKey .ciphertext ()))
102+ .overrideConfiguration (builder -> builder .addApiName (API_NAME ))
97103 .build ();
98104
99105 DecryptResponse response = _kmsClient .decrypt (request );
0 commit comments