Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
feat: Enable AWS China Regions (#51)
Browse files Browse the repository at this point in the history
* feat: Enable AWS China Regions
  • Loading branch information
tunderwood authored Aug 10, 2020
1 parent a636b8f commit be4f02a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
version=7.2.2
version=7.3.0
groupId=com.nike
artifactId=cerberus-client
4 changes: 2 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ configurations.all {
force "net.sourceforge.pmd:pmd-java:6.21.0"

dependencySubstitution {
substitute module("org.mortbay.jetty:jetty") with module("org.eclipse.jetty:jetty-server:9.4.28.v20200408")
substitute module("org.mortbay.jetty:jetty-util") with module("org.eclipse.jetty:jetty-util:9.4.28.v20200408")
substitute module("org.mortbay.jetty:jetty") with module("org.eclipse.jetty:jetty-server:9.4.31.v20200723")
substitute module("org.mortbay.jetty:jetty-util") with module("org.eclipse.jetty:jetty-util:9.4.31.v20200723")
substitute module("dom4j:dom4j:1.6.1") with module("org.dom4j:dom4j:2.1.3")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class CerberusClientFactory {

public static final int DEFAULT_TIMEOUT = 15_000;
public static final int DEFAULT_TIMEOUT = 30_000;
public static final TimeUnit DEFAULT_TIMEOUT_UNIT = TimeUnit.MILLISECONDS;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* Provider for allowing users to authenticate with Cerberus with the STS auth endpoint.
Expand All @@ -57,6 +54,12 @@ public class StsCerberusCredentialsProvider extends BaseAwsCredentialsProvider {

private static final Logger LOGGER = LoggerFactory.getLogger(BaseAwsCredentialsProvider.class);

private final List<String> CHINA_REGIONS = new ArrayList<String>(
Arrays.asList(
"cn-north-1",
"cn-northwest-1")
);

private final Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.create();

Expand Down Expand Up @@ -160,8 +163,10 @@ private void signRequest(com.amazonaws.Request request, AWSCredentials credentia
*/
protected Map<String, String> getSignedHeaders(){

final String url = "https://sts." + regionName + ".amazonaws.com";

String url = "https://sts." + regionName + ".amazonaws.com";
if(CHINA_REGIONS.contains(regionName)) {
url += ".cn";
}
URI endpoint = null;

try {
Expand Down

0 comments on commit be4f02a

Please sign in to comment.