-
Notifications
You must be signed in to change notification settings - Fork 65
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 #157 from mobsuccess-devops/feat/replace-credentia…
…ls-and-providers feat: replace credentials and providers with v2
- Loading branch information
Showing
16 changed files
with
365 additions
and
374 deletions.
There are no files selected for viewing
28 changes: 19 additions & 9 deletions
28
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,23 +1,33 @@ | ||
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; | ||
|
||
public class CompatibilityHelper { | ||
|
||
/** | ||
* Convert an exception to an SdkException | ||
* Convert credentials from v2 to v1 | ||
* | ||
* @param e Exception to convert | ||
* @return SdkException | ||
* @param newCreadientials v2 credentials | ||
* @return v1 credentials | ||
*/ | ||
public static SdkException toSdkException(Exception e) { | ||
if (e instanceof com.amazonaws.SdkClientException) { | ||
return SdkClientException.create(e.getMessage(), e.getCause()); | ||
} else if (e instanceof SdkException) { | ||
return (SdkException) e; | ||
public static AWSCredentials toV1Credentials(AwsCredentials newCreadientials) { | ||
if (newCreadientials instanceof AwsSessionCredentials) { | ||
return new BasicSessionCredentials( | ||
newCreadientials.accessKeyId(), | ||
newCreadientials.secretAccessKey(), | ||
((AwsSessionCredentials) newCreadientials).sessionToken() | ||
); | ||
} else { | ||
return SdkException.create(e.getMessage(), e); | ||
return new BasicAWSCredentials( | ||
newCreadientials.accessKeyId(), | ||
newCreadientials.secretAccessKey() | ||
); | ||
} | ||
} | ||
} |
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
47 changes: 0 additions & 47 deletions
47
src/main/java/software/amazon/msk/auth/iam/internals/EnhancedProfileCredentialsProvider.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.