@@ -106,11 +106,13 @@ public static void SharedCacheAcrossHierarchicalKeyringsGetItemPutItem(
106
106
// using the Material Providers Library
107
107
// This CMC takes in:
108
108
// - CacheType
109
- final MaterialProviders matProv = MaterialProviders .builder ()
109
+ final MaterialProviders matProv = MaterialProviders
110
+ .builder ()
110
111
.MaterialProvidersConfig (MaterialProvidersConfig .builder ().build ())
111
112
.build ();
112
113
113
- final CacheType cache = CacheType .builder ()
114
+ final CacheType cache = CacheType
115
+ .builder ()
114
116
.Default (DefaultCache .builder ().entryCapacity (100 ).build ())
115
117
.build ();
116
118
@@ -124,7 +126,8 @@ public static void SharedCacheAcrossHierarchicalKeyringsGetItemPutItem(
124
126
125
127
// 2. Create a CacheType object for the sharedCryptographicMaterialsCache
126
128
// Note that the `cache` parameter in the Hierarchical Keyring Input takes a `CacheType` as input
127
- final CacheType sharedCache = CacheType .builder ()
129
+ final CacheType sharedCache = CacheType
130
+ .builder ()
128
131
// This is the `Shared` CacheType that passes an already initialized shared cache
129
132
.Shared (sharedCryptographicMaterialsCache )
130
133
.build ();
@@ -137,9 +140,11 @@ public static void SharedCacheAcrossHierarchicalKeyringsGetItemPutItem(
137
140
// to initially create and populate your KeyStore.
138
141
// Note that keyStoreTableName is the physical Key Store,
139
142
// and keystore1 is instances of this physical Key Store.
140
- final KeyStore keystore1 = KeyStore .builder ()
143
+ final KeyStore keystore1 = KeyStore
144
+ .builder ()
141
145
.KeyStoreConfig (
142
- KeyStoreConfig .builder ()
146
+ KeyStoreConfig
147
+ .builder ()
143
148
.ddbClient (DynamoDbClient .create ())
144
149
.ddbTableName (keyStoreTableName )
145
150
.logicalKeyStoreName (logicalKeyStoreName )
@@ -164,7 +169,8 @@ public static void SharedCacheAcrossHierarchicalKeyringsGetItemPutItem(
164
169
// Branch Key ID at the top of this example before creating Hierarchical Keyrings with a Shared Cache.
165
170
// partitionId for this example is a random UUID
166
171
final CreateAwsKmsHierarchicalKeyringInput keyringInput1 =
167
- CreateAwsKmsHierarchicalKeyringInput .builder ()
172
+ CreateAwsKmsHierarchicalKeyringInput
173
+ .builder ()
168
174
.keyStore (keystore1 )
169
175
.branchKeyId (branchKeyId )
170
176
.ttlSeconds (600 ) // This dictates how often we call back to KMS to authorize use of the branch keys
@@ -221,9 +227,11 @@ public static void SharedCacheAcrossHierarchicalKeyringsGetItemPutItem(
221
227
// - If you set the Logical Key Store Names for K1 and K2 to be different,
222
228
// HK1 (which uses Key Store instance K1) and HK2 (which uses Key Store
223
229
// instance K2) will NOT be able to share cache entries.
224
- final KeyStore keystore2 = KeyStore .builder ()
230
+ final KeyStore keystore2 = KeyStore
231
+ .builder ()
225
232
.KeyStoreConfig (
226
- KeyStoreConfig .builder ()
233
+ KeyStoreConfig
234
+ .builder ()
227
235
.ddbClient (DynamoDbClient .create ())
228
236
.ddbTableName (keyStoreTableName )
229
237
.logicalKeyStoreName (logicalKeyStoreName )
@@ -243,7 +251,8 @@ public static void SharedCacheAcrossHierarchicalKeyringsGetItemPutItem(
243
251
// Branch Key ID at the top of this example before creating Hierarchical Keyrings with a Shared Cache.
244
252
// partitionId for this example is a random UUID
245
253
final CreateAwsKmsHierarchicalKeyringInput keyringInput2 =
246
- CreateAwsKmsHierarchicalKeyringInput .builder ()
254
+ CreateAwsKmsHierarchicalKeyringInput
255
+ .builder ()
247
256
.keyStore (keystore2 )
248
257
.branchKeyId (branchKeyId )
249
258
.ttlSeconds (600 ) // This dictates how often we call back to KMS to authorize use of the branch keys
@@ -302,31 +311,35 @@ public static DynamoDbClient GetDdbClient(
302
311
// Create the DynamoDb Encryption configuration for the table we will be writing to.
303
312
final Map <String , DynamoDbTableEncryptionConfig > tableConfigs =
304
313
new HashMap <>();
305
- final DynamoDbTableEncryptionConfig config =
306
- DynamoDbTableEncryptionConfig .builder ()
307
- .logicalTableName (ddbTableName )
308
- .partitionKeyName ("partition_key" )
309
- .sortKeyName ("sort_key" )
310
- .attributeActionsOnEncrypt (attributeActionsOnEncrypt )
311
- .keyring (hierarchicalKeyring )
312
- .allowedUnsignedAttributePrefix (unsignAttrPrefix )
313
- .build ();
314
+ final DynamoDbTableEncryptionConfig config = DynamoDbTableEncryptionConfig
315
+ .builder ()
316
+ .logicalTableName (ddbTableName )
317
+ .partitionKeyName ("partition_key" )
318
+ .sortKeyName ("sort_key" )
319
+ .attributeActionsOnEncrypt (attributeActionsOnEncrypt )
320
+ .keyring (hierarchicalKeyring )
321
+ .allowedUnsignedAttributePrefix (unsignAttrPrefix )
322
+ .build ();
314
323
tableConfigs .put (ddbTableName , config );
315
324
316
325
// Create the DynamoDb Encryption Interceptor
317
326
DynamoDbEncryptionInterceptor encryptionInterceptor =
318
- DynamoDbEncryptionInterceptor .builder ()
327
+ DynamoDbEncryptionInterceptor
328
+ .builder ()
319
329
.config (
320
- DynamoDbTablesEncryptionConfig .builder ()
330
+ DynamoDbTablesEncryptionConfig
331
+ .builder ()
321
332
.tableEncryptionConfigs (tableConfigs )
322
333
.build ()
323
334
)
324
335
.build ();
325
336
326
337
// Create a new AWS SDK DynamoDb client using the DynamoDb Encryption Interceptor above
327
- final DynamoDbClient ddbClient = DynamoDbClient .builder ()
338
+ final DynamoDbClient ddbClient = DynamoDbClient
339
+ .builder ()
328
340
.overrideConfiguration (
329
- ClientOverrideConfiguration .builder ()
341
+ ClientOverrideConfiguration
342
+ .builder ()
330
343
.addExecutionInterceptor (encryptionInterceptor )
331
344
.build ()
332
345
)
@@ -353,7 +366,8 @@ public static void PutGetItems(
353
366
AttributeValue .builder ().s ("encrypt and sign me!" ).build ()
354
367
);
355
368
356
- final PutItemRequest putRequest = PutItemRequest .builder ()
369
+ final PutItemRequest putRequest = PutItemRequest
370
+ .builder ()
357
371
.tableName (ddbTableName )
358
372
.item (item )
359
373
.build ();
@@ -373,7 +387,8 @@ public static void PutGetItems(
373
387
keyToGet .put ("partition_key" , AttributeValue .builder ().s ("id" ).build ());
374
388
keyToGet .put ("sort_key" , AttributeValue .builder ().n ("0" ).build ());
375
389
376
- final GetItemRequest getRequest = GetItemRequest .builder ()
390
+ final GetItemRequest getRequest = GetItemRequest
391
+ .builder ()
377
392
.key (keyToGet )
378
393
.tableName (ddbTableName )
379
394
.build ();
0 commit comments