-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from mobsuccess-devops/feat/replace-request
feat: replace request and signer api v1 to v2
- Loading branch information
Showing
10 changed files
with
105 additions
and
144 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
29 changes: 6 additions & 23 deletions
29
src/main/java/software/amazon/msk/auth/iam/CompatibilityHelper.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 |
---|---|---|
@@ -1,33 +1,16 @@ | ||
package software.amazon.msk.auth.iam; | ||
|
||
import com.amazonaws.auth.AWSCredentials; | ||
import com.amazonaws.auth.BasicAWSCredentials; | ||
import com.amazonaws.auth.BasicSessionCredentials; | ||
import software.amazon.awssdk.auth.credentials.AwsCredentials; | ||
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; | ||
import software.amazon.awssdk.core.exception.SdkClientException; | ||
import software.amazon.awssdk.core.exception.SdkException; | ||
import software.amazon.awssdk.regions.Region; | ||
|
||
public class CompatibilityHelper { | ||
|
||
/** | ||
* Convert credentials from v2 to v1 | ||
* Convert region from v1 to v2 | ||
* | ||
* @param newCreadientials v2 credentials | ||
* @return v1 credentials | ||
* @param region v1 region | ||
* @return v2 region | ||
*/ | ||
public static AWSCredentials toV1Credentials(AwsCredentials newCreadientials) { | ||
if (newCreadientials instanceof AwsSessionCredentials) { | ||
return new BasicSessionCredentials( | ||
newCreadientials.accessKeyId(), | ||
newCreadientials.secretAccessKey(), | ||
((AwsSessionCredentials) newCreadientials).sessionToken() | ||
); | ||
} else { | ||
return new BasicAWSCredentials( | ||
newCreadientials.accessKeyId(), | ||
newCreadientials.secretAccessKey() | ||
); | ||
} | ||
public static Region toV2Region(com.amazonaws.regions.Region region) { | ||
return Region.of(region.getName()); | ||
} | ||
} |
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
Oops, something went wrong.