@@ -284,7 +284,6 @@ static KmsMasterKeyProvider.RegionalClientSupplier clientFactory(
284
284
: AWSKMSClientBuilder .standard ();
285
285
286
286
return region -> {
287
- /* Check for early return (Postcondition): If a client already exists, use that. */
288
287
if (clientCache .containsKey (region )) {
289
288
return clientCache .get (region );
290
289
}
@@ -381,10 +380,6 @@ private AwsKmsMrkAwareMasterKeyProvider(
381
380
// # kms-mrk-are-unique.md#Implementation) and the function MUST return
382
381
// # success.
383
382
assertMrksAreUnique (keyIds );
384
- /* Precondition: A region is required to contact AWS KMS.
385
- * This is an edge case because the default region will be the same as the SDK default,
386
- * but it is still possible.
387
- */
388
383
if (!isDiscovery
389
384
&& defaultRegion == null
390
385
&& keyIds .stream ()
@@ -447,16 +442,6 @@ static void assertMrksAreUnique(List<String> keyIdentifiers) {
447
442
// # arn.md#identifying-an-aws-kms-multi-region-key) this function MUST
448
443
// # exit successfully.
449
444
//
450
- /* Postcondition: Filter out duplicate resources that are not multi-region keys.
451
- * I expect only have duplicates of specific multi-region keys.
452
- * In JSON something like
453
- * {
454
- * "mrk-edb7fe6942894d32ac46dbb1c922d574" : [
455
- * "arn:aws:kms:us-west-2:111122223333:key/mrk-edb7fe6942894d32ac46dbb1c922d574",
456
- * "arn:aws:kms:us-east-2:111122223333:key/mrk-edb7fe6942894d32ac46dbb1c922d574"
457
- * ]
458
- * }
459
- */
460
445
.filter (maybeMrk -> isMRK (maybeMrk .getKey ()))
461
446
/* Flatten the duplicate identifiers into a single list. */
462
447
.flatMap (mrkEntry -> mrkEntry .getValue ().stream ())
@@ -481,35 +466,12 @@ static void assertMrksAreUnique(List<String> keyIdentifiers) {
481
466
*/
482
467
static String getResourceForResourceTypeKey (String identifier ) {
483
468
final AwsKmsCmkArnInfo info = parseInfoFromKeyArn (identifier );
484
- /* Check for early return (Postcondition): Non-ARNs may be raw resources.
485
- * Raw aliases ('alias/my-key')
486
- * or key ids ('mrk-edb7fe6942894d32ac46dbb1c922d574').
487
- */
488
469
if (info == null ) return identifier ;
489
470
490
- /* Check for early return (Postcondition): Return the identifier for non-key resource types.
491
- * I only care about duplicate multi-region *keys*.
492
- * Any other resource type
493
- * should get filtered out.
494
- * I return the entire identifier
495
- * on the off chance that
496
- * a customer has created
497
- * an alias with a name `mrk-*`.
498
- * This way such an alias
499
- * can never accidentally
500
- * collided with an existing multi-region key
501
- * or a duplicate alias.
502
- */
503
471
if (!info .getResourceType ().equals ("key" )) {
504
472
return identifier ;
505
473
}
506
474
507
- /* Postcondition: Return the key id.
508
- * This will be used
509
- * to find different regional replicas of
510
- * the same multi-region key
511
- * because the key id for replicas is always the same.
512
- */
513
475
return info .getResource ();
514
476
}
515
477
@@ -559,10 +521,6 @@ public AwsKmsMrkAwareMasterKey getMasterKey(final String providerId, final Strin
559
521
// = compliance/framework/aws-kms/aws-kms-mrk-aware-master-key-provider.txt#2.7
560
522
// # In discovery mode, the requested
561
523
// # AWS KMS key identifier MUST be a well formed AWS KMS ARN.
562
- /* Precondition: Discovery mode requires requestedKeyArn be an ARN.
563
- * This function is called on the encrypt path.
564
- * It _may_ be the case that a raw key id, for example, was configured.
565
- */
566
524
if (isDiscovery_ && requestedKeyArnInfo == null ) {
567
525
throw new NoSuchMasterKeyException (
568
526
"Cannot use AWS KMS identifiers " + "when in discovery mode." );
0 commit comments