Skip to content

Commit

Permalink
#18252 - [REQ] add sessionToken support to AWS4Auth (#18253)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfriesen authored Apr 11, 2024
1 parent 44ae981 commit 97c1dc8
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,29 @@ public class ApiClient {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
{{#withAWSV4Signature}}
for (Authentication auth : authentications.values()) {
if (auth instanceof AWS4Auth) {
((AWS4Auth) auth).setCredentials(accessKey, secretKey, sessionToken);
((AWS4Auth) auth).setRegion(region);
((AWS4Auth) auth).setService(service);
return;
}
}
{{/withAWSV4Signature}}
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import java.util.stream.Collectors;

import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.signer.Aws4Signer;
import software.amazon.awssdk.auth.signer.params.Aws4SignerParams;
Expand All @@ -41,6 +42,10 @@ public class AWS4Auth implements Authentication {
this.credentials = AwsBasicCredentials.create(accessKey, secretKey);
}

public void setCredentials(String accessKey, String secretKey, String sessionToken) {
this.credentials = AwsSessionCredentials.create(accessKey, secretKey, sessionToken);
}

public void setRegion(String region) {
this.region = region;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,27 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
for (Authentication auth : authentications.values()) {
if (auth instanceof AWS4Auth) {
((AWS4Auth) auth).setCredentials(accessKey, secretKey, sessionToken);
((AWS4Auth) auth).setRegion(region);
((AWS4Auth) auth).setService(service);
return;
}
}
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.signer.Aws4Signer;
import software.amazon.awssdk.auth.signer.params.Aws4SignerParams;
Expand All @@ -52,6 +53,10 @@ public void setCredentials(String accessKey, String secretKey) {
this.credentials = AwsBasicCredentials.create(accessKey, secretKey);
}

public void setCredentials(String accessKey, String secretKey, String sessionToken) {
this.credentials = AwsSessionCredentials.create(accessKey, secretKey, sessionToken);
}

public void setRegion(String region) {
this.region = region;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,19 @@ public void setAWS4Configuration(String accessKey, String secretKey, String regi
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Helper method to set credentials for AWSV4 Signature
*
* @param accessKey Access Key
* @param secretKey Secret Key
* @param sessionToken Session Token
* @param region Region
* @param service Service to access to
*/
public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) {
throw new RuntimeException("No AWS4 authentication configured!");
}

/**
* Set the User-Agent header's value (by adding to the default header map).
*
Expand Down

0 comments on commit 97c1dc8

Please sign in to comment.