Skip to content

Commit 885b8d5

Browse files
minbiKarthikeyan
authored andcommitted
[MobileClient] Fix drop-in UI initialization from awsconfiguration.json (#860)
1 parent 75ac7f6 commit 885b8d5

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
* AWS IoT SDK for Android now supports MQTT over TLS with X.509 client certificate authentication on port 443. Previously this combination of protocol and authentication mechanism was only supported on port 8883. `connectUsingALPN()` method allows developers to connect to AWS IoT using client certificate authentication on port 443. Please look at [this blog](https://aws.amazon.com/blogs/iot/mqtt-with-tls-client-authentication-on-port-443-why-it-is-useful-and-how-it-works/) for more details.
99
* **Breaking Change:** Please note that the type of aws-android-sdk-iot artifact is being changed from a`jar` to an `aar`. Also note that the `aar` artifacts needs to be explicitly specified in the dependency as `implementation ("com.amazonaws:aws-android-sdk-iot:2.12.+@aar") { transitive =true }` on some of the older versions of gradle.
1010

11+
### Bug Fixes
12+
13+
* **AWS Mobile Client**
14+
* Fixed a bug when initializing drop-in UI that caused the Facebook, Google, or Userpools provider to not be instantiated.
15+
16+
### Misc. Updates
17+
18+
* Model updates for the following services
19+
* AWS IoT
20+
* Amazon Transcribe
21+
22+
## [Release 2.12.7](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.12.7)
23+
1124
### Enhancements
1225

1326
* **AWS Mobile Client**

aws-android-sdk-mobile-client/src/main/java/com/amazonaws/mobile/client/AWSMobileClient.java

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ public void run() {
481481
identityManager.setConfiguration(awsConfiguration);
482482
identityManager.setPersistenceEnabled(mIsPersistenceEnabled);
483483
IdentityManager.setDefaultIdentityManager(identityManager);
484-
registerConfigSignInProviders();
484+
registerConfigSignInProviders(awsConfiguration);
485485
identityManager.addSignInStateChangeListener(new SignInStateChangeListener() {
486486
@Override
487487
public void onUserSignedIn() {
@@ -565,7 +565,7 @@ public void onUserSignedOut() {
565565
}
566566
}
567567

568-
JSONObject hostedUIJSON = getHostedUIJSON();
568+
JSONObject hostedUIJSON = getHostedUIJSON(awsConfiguration);
569569
if (hostedUIJSON != null) {
570570
try {
571571
// Pre-warm the Custom Tabs based on
@@ -617,10 +617,9 @@ public void onFailure(Exception e) {
617617
return;
618618
}
619619

620-
final UserStateDetails userStateDetails = getUserStateDetails(true);
621-
622620
AWSMobileClient.this.awsConfiguration = awsConfiguration;
623621

622+
final UserStateDetails userStateDetails = getUserStateDetails(true);
624623
callback.onResult(userStateDetails);
625624
setUserState(userStateDetails);
626625
}
@@ -629,6 +628,10 @@ public void onFailure(Exception e) {
629628
}
630629

631630
JSONObject getHostedUIJSONFromJSON() {
631+
return getHostedUIJSONFromJSON(this.awsConfiguration);
632+
}
633+
634+
JSONObject getHostedUIJSONFromJSON(final AWSConfiguration awsConfig) {
632635
final JSONObject mobileClientJSON = awsConfiguration.optJsonObject("Auth");
633636
if (mobileClientJSON != null && mobileClientJSON.has("OAuth")) {
634637
try {
@@ -643,8 +646,12 @@ JSONObject getHostedUIJSONFromJSON() {
643646
}
644647

645648
JSONObject getHostedUIJSON() {
649+
return getHostedUIJSON(this.awsConfiguration);
650+
}
651+
652+
JSONObject getHostedUIJSON(final AWSConfiguration awsConfig) {
646653
try {
647-
JSONObject hostedUIJSONFromJSON = getHostedUIJSONFromJSON();
654+
JSONObject hostedUIJSONFromJSON = getHostedUIJSONFromJSON(awsConfig);
648655
if (hostedUIJSONFromJSON == null) {
649656
return null;
650657
}
@@ -3147,18 +3154,26 @@ private void registerUserSignInProvidersWithPermissions() {
31473154
* AWSConfiguration.
31483155
*/
31493156
private void registerConfigSignInProviders() {
3157+
registerConfigSignInProviders(this.awsConfiguration);
3158+
}
3159+
3160+
/**
3161+
* Register the SignInProvider and permissions based on the
3162+
* AWSConfiguration.
3163+
*/
3164+
private void registerConfigSignInProviders(final AWSConfiguration awsConfig) {
31503165
Log.d(TAG, "Using the SignInProviderConfig from `awsconfiguration.json`.");
31513166
final IdentityManager identityManager = IdentityManager.getDefaultIdentityManager();
31523167

3153-
if (isConfigurationKeyPresent(USER_POOLS)) {
3168+
if (isConfigurationKeyPresent(USER_POOLS, awsConfig)) {
31543169
identityManager.addSignInProvider(CognitoUserPoolsSignInProvider.class);
31553170
}
31563171

3157-
if (isConfigurationKeyPresent(FACEBOOK)) {
3172+
if (isConfigurationKeyPresent(FACEBOOK, awsConfig)) {
31583173
identityManager.addSignInProvider(FacebookSignInProvider.class);
31593174
}
31603175

3161-
if (isConfigurationKeyPresent(GOOGLE)) {
3176+
if (isConfigurationKeyPresent(GOOGLE, awsConfig)) {
31623177
identityManager.addSignInProvider(GoogleSignInProvider.class);
31633178
}
31643179
}
@@ -3169,8 +3184,17 @@ private void registerConfigSignInProviders() {
31693184
* @param configurationKey The key for SignIn in AWSConfiguration
31703185
*/
31713186
private boolean isConfigurationKeyPresent(final String configurationKey) {
3187+
return isConfigurationKeyPresent(configurationKey, this.awsConfiguration);
3188+
}
3189+
3190+
/**
3191+
* Check if the AWSConfiguration has the specified key.
3192+
*
3193+
* @param configurationKey The key for SignIn in AWSConfiguration
3194+
*/
3195+
private boolean isConfigurationKeyPresent(final String configurationKey, final AWSConfiguration awsConfig) {
31723196
try {
3173-
JSONObject jsonObject = this.awsConfiguration.optJsonObject(configurationKey);
3197+
JSONObject jsonObject = awsConfig.optJsonObject(configurationKey);
31743198
if (configurationKey.equals(GOOGLE)) {
31753199
return jsonObject != null && jsonObject.getString(GOOGLE_WEBAPP_CONFIG_KEY) != null;
31763200
} else {

0 commit comments

Comments
 (0)