Skip to content

Commit 49c25f0

Browse files
committed
Added documentation and added another constructor for both region and IAM role.
1 parent b56dcc6 commit 49c25f0

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/main/java/software/aws/mcs/auth/SigV4AuthProvider.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,7 @@ public SigV4AuthProvider() {
105105
this(create(), null);
106106
}
107107

108-
private final static DriverOption REGION_OPTION = new DriverOption() {
109-
public String getPath() {
110-
return "advanced.auth-provider.aws-region";
111-
}
112-
};
108+
private final static DriverOption REGION_OPTION = () -> "advanced.auth-provider.aws-region";
113109

114110
private final static DriverOption ROLE_OPTION = () -> "advanced.auth-provider.aws-role";
115111

@@ -397,13 +393,12 @@ static int indexOf(byte[] target, byte[] pattern) {
397393
/**
398394
* Creates a STS role credential provider
399395
* @param roleArn The ARN of the role to assume
400-
* @param sessionName The name of the session
401396
* @param stsRegion The region of the STS endpoint
402397
* @return The STS role credential provider
403398
*/
404399
private static StsAssumeRoleCredentialsProvider createSTSRoleCredentialProvider(String roleArn,
405400
String stsRegion) {
406-
final String roleName= StringUtils.substringAfterLast(roleArn,":");
401+
final String roleName= StringUtils.substringAfterLast(roleArn,"/");
407402
final String sessionName="keyspaces-session-"+roleName+System.currentTimeMillis();
408403
StsClient stsClient = StsClient.builder()
409404
.region(Region.of(stsRegion))
@@ -420,7 +415,7 @@ private static StsAssumeRoleCredentialsProvider createSTSRoleCredentialProvider(
420415

421416
/**
422417
* Gets the default region for SigV4 if region is not provided.
423-
* @return
418+
* @return Default region
424419
*/
425420
private static String getDefaultRegion() {
426421
DefaultAwsRegionProviderChain chain = new DefaultAwsRegionProviderChain();

0 commit comments

Comments
 (0)