diff --git a/changelog b/changelog index 455916b2f..96de9249f 100644 --- a/changelog +++ b/changelog @@ -3,7 +3,8 @@ MSAL Wiki : https://github.com/AzureAD/microsoft-authentication-library-for-andr Version 2.2.3 ---------- - Remove the broker check for MSA FRT saving function (#1571) -- Picks up common@3.6.6 +- Fix msal get account crash in Account Matcher due to NPE because account id was missing (#1558) +- Picks up common@3.6.7 Version 2.2.2 ---------- diff --git a/common b/common index 22dd82282..cae3aa724 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 22dd8228235ebc26ea77cf1508ca2216d034957b +Subproject commit cae3aa7240fbc4297bfa29c455e0076c7f98f72e diff --git a/msal/build.gradle b/msal/build.gradle index 1556e289f..8ec341d7d 100644 --- a/msal/build.gradle +++ b/msal/build.gradle @@ -274,9 +274,9 @@ dependencies { transitive = false } - snapshotApi(group: 'com.microsoft.identity', name: 'common', version: '3.6.6', changing: true) + snapshotApi(group: 'com.microsoft.identity', name: 'common', version: '3.6.7', changing: true) - distApi("com.microsoft.identity:common:3.6.6") { + distApi("com.microsoft.identity:common:3.6.7") { transitive = false } } diff --git a/msal/src/main/java/com/microsoft/identity/client/Account.java b/msal/src/main/java/com/microsoft/identity/client/Account.java index 54b050868..6024a0219 100644 --- a/msal/src/main/java/com/microsoft/identity/client/Account.java +++ b/msal/src/main/java/com/microsoft/identity/client/Account.java @@ -31,6 +31,7 @@ import com.microsoft.identity.common.internal.providers.microsoft.MicrosoftIdToken; import com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryIdToken; import com.microsoft.identity.common.internal.providers.oauth2.IDToken; +import com.microsoft.identity.common.internal.util.AccountUtil; import com.microsoft.identity.common.internal.util.StringUtil; import java.util.Map; @@ -47,6 +48,7 @@ public class Account implements IAccount { private String mHomeOid; private String mHomeTenantId; private String mEnvironment; + private String mHomeAccountId; public Account( @Nullable final String clientInfo, @@ -69,6 +71,7 @@ void setId(@Nullable final String id) { @NonNull @Override public String getId() { + final String methodName = ":getId"; String id; ClientInfo clientInfo = null; @@ -93,6 +96,24 @@ public String getId() { id = mHomeOid; } + if (StringUtil.isEmpty(id)) { + com.microsoft.identity.common.logging.Logger.warn( + TAG + methodName, + "Unable to get account id from either ClientInfo or IdToken. Attempting to obtain from home account id." + ); + id = AccountUtil.getUIdFromHomeAccountId(mHomeAccountId); + } + + if (StringUtil.isEmpty(id)) { + com.microsoft.identity.common.logging.Logger.error( + TAG + methodName, + "Account ID is empty. Returning MISSING_FROM_THE_TOKEN_RESPONSE.", + null + ); + + id = MISSING_FROM_THE_TOKEN_RESPONSE; + } + return id; } @@ -162,4 +183,8 @@ public String getAuthority() { return MISSING_FROM_THE_TOKEN_RESPONSE; } + + public void setHomeAccountId(@NonNull final String homeAccountId) { + mHomeAccountId = homeAccountId; + } } diff --git a/msal/src/main/java/com/microsoft/identity/client/AccountAdapter.java b/msal/src/main/java/com/microsoft/identity/client/AccountAdapter.java index 799c19e5c..09ad7c3da 100644 --- a/msal/src/main/java/com/microsoft/identity/client/AccountAdapter.java +++ b/msal/src/main/java/com/microsoft/identity/client/AccountAdapter.java @@ -293,6 +293,8 @@ private static List createRootAccounts( getIdToken(homeCacheRecord) ); + ((MultiTenantAccount) rootAccount).setHomeAccountId(homeCacheRecord.getAccount().getHomeAccountId()); + // Set the tenant_id ((MultiTenantAccount) rootAccount).setTenantId( StringUtil.getTenantInfo( diff --git a/msal/versioning/version.properties b/msal/versioning/version.properties index 23851f18e..79fed11b6 100644 --- a/msal/versioning/version.properties +++ b/msal/versioning/version.properties @@ -1,3 +1,3 @@ #Wed Aug 01 15:24:11 PDT 2018 -versionName=2.2.3 +versionName=2.2.3-RC1 versionCode=0