20
20
import com .amazonaws .services .dynamodbv2 .model .AttributeValue ;
21
21
import com .amazonaws .services .dynamodbv2 .testing .FakeKMS ;
22
22
import com .amazonaws .services .kms .AWSKMS ;
23
+ import com .amazonaws .services .kms .model .DecryptRequest ;
24
+ import com .amazonaws .services .kms .model .DecryptResult ;
23
25
import com .amazonaws .services .kms .model .GenerateDataKeyRequest ;
24
26
import com .amazonaws .services .kms .model .GenerateDataKeyResult ;
25
27
import com .amazonaws .util .Base64 ;
@@ -50,7 +52,7 @@ public class DirectKmsMaterialProviderTest {
50
52
51
53
@ BeforeMethod
52
54
public void setUp () {
53
- description = new HashMap <String , String >();
55
+ description = new HashMap <>();
54
56
description .put ("TestKey" , "test value" );
55
57
description = Collections .unmodifiableMap (description );
56
58
ctx = new EncryptionContext .Builder ().build ();
@@ -87,7 +89,7 @@ public void simple() throws GeneralSecurityException {
87
89
public void simpleWithKmsEc () throws GeneralSecurityException {
88
90
DirectKmsMaterialProvider prov = new DirectKmsMaterialProvider (kms , keyId );
89
91
90
- Map <String , AttributeValue > attrVals = new HashMap <String , AttributeValue >();
92
+ Map <String , AttributeValue > attrVals = new HashMap <>();
91
93
attrVals .put ("hk" , new AttributeValue ("HashKeyValue" ));
92
94
attrVals .put ("rk" , new AttributeValue ("RangeKeyValue" ));
93
95
@@ -116,7 +118,7 @@ public void simpleWithKmsEc() throws GeneralSecurityException {
116
118
public void simpleWithKmsEc2 () throws GeneralSecurityException {
117
119
DirectKmsMaterialProvider prov = new DirectKmsMaterialProvider (kms , keyId );
118
120
119
- Map <String , AttributeValue > attrVals = new HashMap <String , AttributeValue >();
121
+ Map <String , AttributeValue > attrVals = new HashMap <>();
120
122
attrVals .put ("hk" , new AttributeValue ().withN ("10" ));
121
123
attrVals .put ("rk" , new AttributeValue ().withN ("20" ));
122
124
@@ -145,7 +147,7 @@ public void simpleWithKmsEc2() throws GeneralSecurityException {
145
147
public void simpleWithKmsEc3 () throws GeneralSecurityException {
146
148
DirectKmsMaterialProvider prov = new DirectKmsMaterialProvider (kms , keyId );
147
149
148
- Map <String , AttributeValue > attrVals = new HashMap <String , AttributeValue >();
150
+ Map <String , AttributeValue > attrVals = new HashMap <>();
149
151
attrVals .put ("hk" ,
150
152
new AttributeValue ().withB (ByteBuffer .wrap ("Foo" .getBytes (StandardCharsets .UTF_8 ))));
151
153
attrVals .put ("rk" ,
@@ -198,7 +200,7 @@ public void testRefresh() {
198
200
199
201
@ Test
200
202
public void explicitContentKeyAlgorithm () throws GeneralSecurityException {
201
- Map <String , String > desc = new HashMap <String , String >();
203
+ Map <String , String > desc = new HashMap <>();
202
204
desc .put (WrappedRawMaterials .CONTENT_KEY_ALGORITHM , "AES" );
203
205
204
206
DirectKmsMaterialProvider prov = new DirectKmsMaterialProvider (kms , keyId , desc );
@@ -215,7 +217,7 @@ public void explicitContentKeyAlgorithm() throws GeneralSecurityException {
215
217
216
218
@ Test
217
219
public void explicitContentKeyLength128 () throws GeneralSecurityException {
218
- Map <String , String > desc = new HashMap <String , String >();
220
+ Map <String , String > desc = new HashMap <>();
219
221
desc .put (WrappedRawMaterials .CONTENT_KEY_ALGORITHM , "AES/128" );
220
222
221
223
DirectKmsMaterialProvider prov = new DirectKmsMaterialProvider (kms , keyId , desc );
@@ -234,7 +236,7 @@ public void explicitContentKeyLength128() throws GeneralSecurityException {
234
236
235
237
@ Test
236
238
public void explicitContentKeyLength256 () throws GeneralSecurityException {
237
- Map <String , String > desc = new HashMap <String , String >();
239
+ Map <String , String > desc = new HashMap <>();
238
240
desc .put (WrappedRawMaterials .CONTENT_KEY_ALGORITHM , "AES/256" );
239
241
240
242
DirectKmsMaterialProvider prov = new DirectKmsMaterialProvider (kms , keyId , desc );
@@ -336,7 +338,7 @@ public GenerateDataKeyResult generateDataKey(GenerateDataKeyRequest r) {
336
338
}
337
339
338
340
private static class ExtendedKmsMaterialProvider extends DirectKmsMaterialProvider {
339
- protected final String encryptionKeyIdAttributeName ;
341
+ private final String encryptionKeyIdAttributeName ;
340
342
341
343
public ExtendedKmsMaterialProvider (AWSKMS kms , String encryptionKeyId , String encryptionKeyIdAttributeName ) {
342
344
super (kms , encryptionKeyId );
@@ -365,6 +367,16 @@ protected void validateEncryptionKeyId(String encryptionKeyId, EncryptionContext
365
367
throw new DynamoDBMappingException ("encryption key ids do not match." );
366
368
}
367
369
}
370
+
371
+ @ Override
372
+ protected DecryptResult decrypt (DecryptRequest request , EncryptionContext context ) {
373
+ return super .decrypt (request , context );
374
+ }
375
+
376
+ @ Override
377
+ protected GenerateDataKeyResult generateDataKey (GenerateDataKeyRequest request , EncryptionContext context ) {
378
+ return super .generateDataKey (request , context );
379
+ }
368
380
}
369
381
370
382
private static EncryptionContext ctx (EncryptionMaterials mat ) {
0 commit comments