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

Commit be4f02a

Browse files
authored
feat: Enable AWS China Regions (#51)
* feat: Enable AWS China Regions
1 parent a636b8f commit be4f02a

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
version=7.2.2
16+
version=7.3.0
1717
groupId=com.nike
1818
artifactId=cerberus-client

gradle/dependencies.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ configurations.all {
2929
force "net.sourceforge.pmd:pmd-java:6.21.0"
3030

3131
dependencySubstitution {
32-
substitute module("org.mortbay.jetty:jetty") with module("org.eclipse.jetty:jetty-server:9.4.28.v20200408")
33-
substitute module("org.mortbay.jetty:jetty-util") with module("org.eclipse.jetty:jetty-util:9.4.28.v20200408")
32+
substitute module("org.mortbay.jetty:jetty") with module("org.eclipse.jetty:jetty-server:9.4.31.v20200723")
33+
substitute module("org.mortbay.jetty:jetty-util") with module("org.eclipse.jetty:jetty-util:9.4.31.v20200723")
3434
substitute module("dom4j:dom4j:1.6.1") with module("org.dom4j:dom4j:2.1.3")
3535
}
3636
}

src/main/java/com/nike/cerberus/client/CerberusClientFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*/
3838
public class CerberusClientFactory {
3939

40-
public static final int DEFAULT_TIMEOUT = 15_000;
40+
public static final int DEFAULT_TIMEOUT = 30_000;
4141
public static final TimeUnit DEFAULT_TIMEOUT_UNIT = TimeUnit.MILLISECONDS;
4242

4343
/**

src/main/java/com/nike/cerberus/client/auth/aws/StsCerberusCredentialsProvider.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@
4141
import java.io.IOException;
4242
import java.net.URI;
4343
import java.net.URISyntaxException;
44-
import java.util.Arrays;
45-
import java.util.HashMap;
46-
import java.util.List;
47-
import java.util.Map;
44+
import java.util.*;
4845

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

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

57+
private final List<String> CHINA_REGIONS = new ArrayList<String>(
58+
Arrays.asList(
59+
"cn-north-1",
60+
"cn-northwest-1")
61+
);
62+
6063
private final Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
6164
.create();
6265

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

163-
final String url = "https://sts." + regionName + ".amazonaws.com";
164-
166+
String url = "https://sts." + regionName + ".amazonaws.com";
167+
if(CHINA_REGIONS.contains(regionName)) {
168+
url += ".cn";
169+
}
165170
URI endpoint = null;
166171

167172
try {

0 commit comments

Comments
 (0)