-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new constructors in Signer classes to use java v1 credentials and…
… support to use different signing name (#26) Add new constructors in Signer classes to use java v1 credentials and add support use different signing name when signing requests
- Loading branch information
1 parent
95d2bd6
commit 3ae6ba0
Showing
7 changed files
with
307 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/com/amazonaws/neptune/auth/credentials/V1toV2CredentialsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.amazonaws.neptune.auth.credentials; | ||
|
||
import com.amazonaws.auth.AWSCredentials; | ||
import com.amazonaws.auth.AWSCredentialsProvider; | ||
import com.amazonaws.auth.AWSSessionCredentials; | ||
import com.amazonaws.auth.AnonymousAWSCredentials; | ||
import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider; | ||
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; | ||
import software.amazon.awssdk.auth.credentials.AwsCredentials; | ||
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; | ||
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; | ||
|
||
public class V1toV2CredentialsProvider implements AwsCredentialsProvider { | ||
private final AWSCredentialsProvider v1CredentialsProvider; | ||
|
||
public static AwsCredentialsProvider create(final AWSCredentialsProvider v1CredentialsProvider) { | ||
return new V1toV2CredentialsProvider(v1CredentialsProvider); | ||
} | ||
|
||
private V1toV2CredentialsProvider(final AWSCredentialsProvider v1CredentialsProvider) { | ||
this.v1CredentialsProvider = v1CredentialsProvider; | ||
} | ||
|
||
@Override | ||
public AwsCredentials resolveCredentials() { | ||
final AWSCredentials v1Credentials = this.v1CredentialsProvider.getCredentials(); | ||
|
||
if (v1Credentials instanceof AnonymousAWSCredentials) { | ||
return AnonymousCredentialsProvider.create().resolveCredentials(); | ||
} else if (v1Credentials instanceof AWSSessionCredentials) { | ||
return AwsSessionCredentials.builder() | ||
.accessKeyId(v1Credentials.getAWSAccessKeyId()) | ||
.secretAccessKey(v1Credentials.getAWSSecretKey()) | ||
.sessionToken(((AWSSessionCredentials) v1Credentials).getSessionToken()) | ||
.build(); | ||
} else { | ||
return AwsBasicCredentials.create(v1Credentials.getAWSAccessKeyId(), v1Credentials.getAWSSecretKey()); | ||
} | ||
} | ||
} |
Oops, something went wrong.