Skip to content

Commit c5067e0

Browse files
author
AWS
committed
AWS SDK for Android 2.4.7
1 parent 6591694 commit c5067e0

File tree

40 files changed

+199
-156
lines changed

40 files changed

+199
-156
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Change Log - AWS SDK for Android
22

3+
## [Release 2.4.7](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.4.7)
4+
5+
### Improvements:
6+
7+
- **Amazon Cognito Auth**
8+
- Making Cognito App Integration and Federation feature generally available
9+
10+
- **AWS IoT**
11+
- Add API to enable/disable auto-resubscribe feature.
12+
13+
### Bug Fixes:
14+
15+
- **AWS IoT**
16+
- Fixed bug that caused reconnecting to the session to throw an exception due to failure to obtain credentials.
17+
318
## [Release 2.4.6](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.4.6)
419

520
### Bug Fixes:
@@ -13,6 +28,8 @@
1328

1429
## [Release 2.4.5](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.4.5)
1530

31+
### Bug Fixes:
32+
1633
- **Amazon S3**
1734
- Fixed bug that caused keys to convert spaces to url encoded characters. See [issue #310](https://github.com/aws/aws-sdk-android/issues/310)
1835

aws-android-sdk-apigateway-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
<parent>
1313
<groupId>com.amazonaws</groupId>
1414
<artifactId>aws-android-sdk-pom</artifactId>
15-
<version>2.4.6</version>
15+
<version>2.4.7</version>
1616
</parent>
1717

1818
<dependencies>
1919
<dependency>
2020
<groupId>com.amazonaws</groupId>
2121
<artifactId>aws-android-sdk-core</artifactId>
2222
<optional>false</optional>
23-
<version>2.4.6</version>
23+
<version>2.4.7</version>
2424
</dependency>
2525
</dependencies>
2626

aws-android-sdk-autoscaling/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
<parent>
1313
<groupId>com.amazonaws</groupId>
1414
<artifactId>aws-android-sdk-pom</artifactId>
15-
<version>2.4.6</version>
15+
<version>2.4.7</version>
1616
</parent>
1717

1818
<dependencies>
1919
<dependency>
2020
<groupId>com.amazonaws</groupId>
2121
<artifactId>aws-android-sdk-core</artifactId>
2222
<optional>false</optional>
23-
<version>2.4.6</version>
23+
<version>2.4.7</version>
2424
</dependency>
2525
</dependencies>
2626

aws-android-sdk-cloudwatch/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
<parent>
1313
<groupId>com.amazonaws</groupId>
1414
<artifactId>aws-android-sdk-pom</artifactId>
15-
<version>2.4.6</version>
15+
<version>2.4.7</version>
1616
</parent>
1717

1818
<dependencies>
1919
<dependency>
2020
<groupId>com.amazonaws</groupId>
2121
<artifactId>aws-android-sdk-core</artifactId>
2222
<optional>false</optional>
23-
<version>2.4.6</version>
23+
<version>2.4.7</version>
2424
</dependency>
2525
</dependencies>
2626

aws-android-sdk-cognito/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<artifactId>aws-android-sdk-cognito</artifactId>
77
<packaging>jar</packaging>
88
<name>AWS SDK for Android - Amazon Cognito Sync</name>
9-
<version>2.4.6</version>
9+
<version>2.4.7</version>
1010
<description>The AWS Android SDK for Amazon Cognito Sync module holds the client classes that are used for communicating with Amazon Cognito Sync Service</description>
1111
<url>http://aws.amazon.com/sdkforandroid</url>
1212

1313
<parent>
1414
<groupId>com.amazonaws</groupId>
1515
<artifactId>aws-android-sdk-pom</artifactId>
16-
<version>2.4.6</version>
16+
<version>2.4.7</version>
1717
</parent>
1818

1919
<licenses>
@@ -29,7 +29,7 @@
2929
<groupId>com.amazonaws</groupId>
3030
<artifactId>aws-android-sdk-core</artifactId>
3131
<optional>false</optional>
32-
<version>2.4.6</version>
32+
<version>2.4.7</version>
3333
</dependency>
3434
<dependency>
3535
<groupId>com.google.android</groupId>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fabric-identifier=com.amazonaws.aws-android-sdk-cognito
2-
fabric-version=2.4.6
2+
fabric-version=2.4.7
33
fabric-build-type=binary

aws-android-sdk-cognitoauth/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<artifactId>aws-android-sdk-cognitoauth</artifactId>
77
<packaging>aar</packaging>
88
<name>AWS SDK for Android - Amazon Cognito Auth</name>
9-
<version>2.4.6</version>
9+
<version>2.4.7</version>
1010
<description>The AWS Android SDK with app integration for Amazon Cognito Your User Pools Service</description>
1111
<url>http://aws.amazon.com/sdkforandroid</url>
1212

1313
<parent>
1414
<groupId>com.amazonaws</groupId>
1515
<artifactId>aws-android-sdk-pom</artifactId>
16-
<version>2.4.6</version>
16+
<version>2.4.7</version>
1717
</parent>
1818

1919
<repositories>

aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/AuthClient.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ public void run() {
252252
final Uri fqdn = new Uri.Builder()
253253
.scheme(ClientConstants.DOMAIN_SCHEME)
254254
.authority(pool.getAppWebDomain())
255+
.appendPath(ClientConstants.DOMAIN_PATH_OAUTH2)
255256
.appendPath(ClientConstants.DOMAIN_PATH_TOKEN_ENDPOINT)
256257
.build();
257258

@@ -287,10 +288,10 @@ public void run() {
287288
String response =
288289
httpClient.httpPost(new URL(fqdn.toString()), httpHeaderParams, httpBodyParams);
289290
final AuthUserSession session = AuthHttpResponseParser.parseHttpResponse(response);
290-
final String username = session.getUsername();
291+
userId = session.getUsername();
291292

292293
// Cache tokens if successful
293-
LocalDataManager.cacheSession(context, pool.getAppId(), username, session, tokenScopes);
294+
LocalDataManager.cacheSession(context, pool.getAppId(), userId, session, tokenScopes);
294295

295296
// Return tokens
296297
returnCallback = new Runnable() {
@@ -350,6 +351,7 @@ public void run() {
350351
final Uri fqdn = new Uri.Builder()
351352
.scheme(ClientConstants.DOMAIN_SCHEME)
352353
.authority(pool.getAppWebDomain())
354+
.appendPath(ClientConstants.DOMAIN_PATH_OAUTH2)
353355
.appendPath(ClientConstants.DOMAIN_PATH_TOKEN_ENDPOINT)
354356
.build();
355357

@@ -461,7 +463,9 @@ private void launchCognitoAuth(final String redirectUri, final Set<String> token
461463
// Build the complete web domain to launch the login screen
462464
Uri.Builder builder = new Uri.Builder()
463465
.scheme(ClientConstants.DOMAIN_SCHEME)
464-
.authority(pool.getAppWebDomain()).appendPath(ClientConstants.DOMAIN_PATH_SIGN_IN)
466+
.authority(pool.getAppWebDomain())
467+
.appendPath(ClientConstants.DOMAIN_PATH_OAUTH2)
468+
.appendPath(ClientConstants.DOMAIN_PATH_SIGN_IN)
465469
.appendQueryParameter(ClientConstants.DOMAIN_QUERY_PARAM_CLIENT_ID, pool.getAppId())
466470
.appendQueryParameter(ClientConstants.DOMAIN_QUERY_PARAM_REDIRECT_URI, redirectUri)
467471
.appendQueryParameter(ClientConstants.DOMAIN_QUERY_PARAM_RESPONSE_TYPE,

aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/util/AuthHttpClient.java

Lines changed: 73 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.io.BufferedReader;
2626
import java.io.DataOutputStream;
27+
import java.io.InputStream;
2728
import java.io.InputStreamReader;
2829
import java.net.HttpURLConnection;
2930
import java.net.URL;
@@ -39,67 +40,76 @@
3940

4041
public final class AuthHttpClient {
4142

42-
public String httpPost(final URL uri, final Map<String, String> headerParams, final Map<String, String> bodyParams) throws Exception {
43-
if (uri == null || bodyParams == null || bodyParams.size() < 1 ) {
44-
throw new AuthClientException("Invalid http request parameters");
45-
}
46-
47-
final HttpsURLConnection httpsURLConnection = (HttpsURLConnection) uri.openConnection();
48-
DataOutputStream httpOutputStream = null;
49-
BufferedReader br = null;
50-
try {
51-
// Request header
52-
httpsURLConnection.setRequestMethod(ClientConstants.HTTP_REQUEST_TYPE_POST);
53-
httpsURLConnection.setDoOutput(true);
54-
for (Map.Entry<String, String> param: headerParams.entrySet()) {
55-
httpsURLConnection.addRequestProperty(param.getKey(), param.getValue());
56-
}
57-
58-
// Request body
59-
StringBuilder reqBuilder = new StringBuilder();
60-
int index = bodyParams.size();
61-
for (Map.Entry<String, String> param: bodyParams.entrySet()) {
62-
reqBuilder.append(URLEncoder.encode(param.getKey(), "UTF-8")).append('=').append(URLEncoder.encode(param.getValue(), "UTF-8"));
63-
if(index-- > 1){
64-
reqBuilder.append('&');
65-
}
66-
}
67-
String requestBody = reqBuilder.toString();
68-
69-
httpOutputStream = new DataOutputStream(httpsURLConnection.getOutputStream());
70-
71-
httpOutputStream.writeBytes(requestBody);
72-
httpOutputStream.flush();
73-
74-
// Parse response
75-
Map<String, List<String>> respHeaders = httpsURLConnection.getHeaderFields();
76-
77-
int responseCode = httpsURLConnection.getResponseCode();
78-
79-
if (responseCode >= HttpURLConnection.HTTP_OK &&
80-
responseCode < HttpURLConnection.HTTP_INTERNAL_ERROR) {
81-
// Return response from the http call
82-
br = new BufferedReader(new InputStreamReader(httpsURLConnection.getInputStream()));
83-
String line = "";
84-
StringBuilder responseOutput = new StringBuilder();
85-
while ((line = br.readLine()) != null) {
86-
responseOutput.append(line);
87-
}
88-
return responseOutput.toString();
89-
} else {
90-
// Throw a Cognito Client Exception
91-
throw new AuthServiceException(httpsURLConnection.getResponseMessage());
92-
}
93-
94-
} catch (final Exception e) {
95-
throw e;
96-
} finally {
97-
if (httpOutputStream != null) {
98-
httpOutputStream.close();
99-
}
100-
if (br != null) {
101-
br.close();
102-
}
103-
}
104-
}
43+
public String httpPost(final URL uri, final Map<String, String> headerParams, final Map<String, String> bodyParams) throws Exception {
44+
if (uri == null || bodyParams == null || bodyParams.size() < 1 ) {
45+
throw new AuthClientException("Invalid http request parameters");
46+
}
47+
48+
final HttpsURLConnection httpsURLConnection = (HttpsURLConnection) uri.openConnection();
49+
DataOutputStream httpOutputStream = null;
50+
BufferedReader br = null;
51+
try {
52+
// Request header
53+
httpsURLConnection.setRequestMethod(ClientConstants.HTTP_REQUEST_TYPE_POST);
54+
httpsURLConnection.setDoOutput(true);
55+
for (Map.Entry<String, String> param: headerParams.entrySet()) {
56+
httpsURLConnection.addRequestProperty(param.getKey(), param.getValue());
57+
}
58+
59+
// Request body
60+
StringBuilder reqBuilder = new StringBuilder();
61+
int index = bodyParams.size();
62+
for (Map.Entry<String, String> param: bodyParams.entrySet()) {
63+
reqBuilder.append(URLEncoder.encode(param.getKey(), "UTF-8")).append('=').append(URLEncoder.encode(param.getValue(), "UTF-8"));
64+
if(index-- > 1){
65+
reqBuilder.append('&');
66+
}
67+
}
68+
String requestBody = reqBuilder.toString();
69+
70+
httpOutputStream = new DataOutputStream(httpsURLConnection.getOutputStream());
71+
72+
httpOutputStream.writeBytes(requestBody);
73+
httpOutputStream.flush();
74+
75+
// Parse response
76+
Map<String, List<String>> respHeaders = httpsURLConnection.getHeaderFields();
77+
78+
int responseCode = httpsURLConnection.getResponseCode();
79+
80+
if (responseCode >= HttpURLConnection.HTTP_OK &&
81+
responseCode < HttpURLConnection.HTTP_INTERNAL_ERROR) {
82+
83+
// Return response from the http call
84+
InputStream httpDataStream;
85+
if (responseCode < HttpURLConnection.HTTP_BAD_REQUEST) {
86+
httpDataStream = httpsURLConnection.getInputStream();
87+
} else {
88+
httpDataStream = httpsURLConnection.getErrorStream();
89+
}
90+
br = new BufferedReader(new InputStreamReader(httpDataStream));
91+
92+
String line = "";
93+
StringBuilder responseOutput = new StringBuilder();
94+
while ((line = br.readLine()) != null) {
95+
responseOutput.append(line);
96+
}
97+
98+
return responseOutput.toString();
99+
} else {
100+
// Throw a Cognito Client Exception
101+
throw new AuthServiceException(httpsURLConnection.getResponseMessage());
102+
}
103+
104+
} catch (final Exception e) {
105+
throw e;
106+
} finally {
107+
if (httpOutputStream != null) {
108+
httpOutputStream.close();
109+
}
110+
if (br != null) {
111+
br.close();
112+
}
113+
}
114+
}
105115
}

aws-android-sdk-cognitoauth/src/main/java/com/amazonaws/mobileconnectors/cognitoauth/util/ClientConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public abstract class ClientConstants {
2929
public static final String AUTH_RESPONSE_TYPE_CODE = "code";
3030
public static final String CHROME_PACKAGE = "com.android.chrome";
3131
public static final int CHROME_NAVIGATION_CANCELLED = 6;
32+
public static final String DOMAIN_PATH_OAUTH2 = "oauth2";
3233
public static final String DOMAIN_PATH_SIGN_IN = "authorize";
3334
public static final String DOMAIN_PATH_SIGN_OUT = "logout";
3435
public static final String DOMAIN_PATH_TOKEN_ENDPOINT = "token";

0 commit comments

Comments
 (0)