|
39 | 39 | import org.springframework.vault.authentication.AppRoleAuthenticationOptions.RoleId; |
40 | 40 | import org.springframework.vault.authentication.AppRoleAuthenticationOptions.SecretId; |
41 | 41 | import org.springframework.vault.authentication.AwsEc2AuthenticationOptions.AwsEc2AuthenticationOptionsBuilder; |
42 | | -import org.springframework.vault.authentication.AwsIamAuthenticationOptions.AwsIamAuthenticationOptionsBuilder; |
43 | 42 | import org.springframework.vault.authentication.AzureMsiAuthenticationOptions.AzureMsiAuthenticationOptionsBuilder; |
44 | 43 | import org.springframework.vault.authentication.CubbyholeAuthenticationOptions.CubbyholeAuthenticationOptionsBuilder; |
45 | 44 | import org.springframework.vault.authentication.KubernetesAuthenticationOptions.KubernetesAuthenticationOptionsBuilder; |
@@ -389,11 +388,7 @@ protected ClientAuthentication awsIamAuthentication() { |
389 | 388 | Assert.isTrue(StringUtils.hasText(role), |
390 | 389 | "Vault AWS-IAM authentication: Role (vault.aws-iam.role) must not be empty"); |
391 | 390 |
|
392 | | - AwsIamAuthenticationOptionsBuilder builder = AwsIamAuthenticationOptions.builder() |
393 | | - .role(role) |
394 | | - .credentialsProvider(DefaultCredentialsProvider.create()); |
395 | | - |
396 | | - return new AwsIamAuthentication(builder.build(), restOperations()); |
| 391 | + return AwsIam.doCreateIamAuthentication(role, restOperations()); |
397 | 392 | } |
398 | 393 |
|
399 | 394 | protected ClientAuthentication azureMsiAuthentication() { |
@@ -491,4 +486,18 @@ enum AuthenticationMethod { |
491 | 486 |
|
492 | 487 | } |
493 | 488 |
|
| 489 | + static class AwsIam { |
| 490 | + |
| 491 | + static ClientAuthentication doCreateIamAuthentication(String role, RestOperations restOperations) { |
| 492 | + |
| 493 | + AwsIamAuthenticationOptions.AwsIamAuthenticationOptionsBuilder builder = AwsIamAuthenticationOptions |
| 494 | + .builder() |
| 495 | + .role(role) |
| 496 | + .credentialsProvider(DefaultCredentialsProvider.create()); |
| 497 | + |
| 498 | + return new AwsIamAuthentication(builder.build(), restOperations); |
| 499 | + } |
| 500 | + |
| 501 | + } |
| 502 | + |
494 | 503 | } |
0 commit comments