Skip to content

Commit b37f15d

Browse files
authored
Merge branch 'dev' into fadi/prompt-create
2 parents 009696d + a9bc81d commit b37f15d

17 files changed

+107
-81
lines changed

changelog

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ MSAL Wiki : https://github.com/AzureAD/microsoft-authentication-library-for-andr
33
vNext
44
----------
55
- [MINOR] Add prompt=create support. (#1611)
6+
- [PATCH] Ensure consistent TAGs in the logger (#1612)
67
- [MAJOR] Deprecate methods not using TokenParameters (#1595)
78
- [PATCH] Update gson version to 2.8.9
89

msal/src/main/java/com/microsoft/identity/client/Account.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void setId(@Nullable final String id) {
6969
@NonNull
7070
@Override
7171
public String getId() {
72-
final String methodName = ":getId";
72+
final String methodTag = TAG + ":getId";
7373
String id;
7474

7575
ClientInfo clientInfo = null;
@@ -79,7 +79,7 @@ public String getId() {
7979
clientInfo = new ClientInfo(mClientInfo);
8080
} catch (final MsalClientException e) {
8181
Logger.error(
82-
TAG,
82+
methodTag,
8383
"Failed to parse ClientInfo",
8484
e
8585
);
@@ -98,15 +98,15 @@ public String getId() {
9898
// This could happen because the ID token that we have for WPJ accounts may not contain
9999
// oid claim because we used to not ask for PROFILE scope in that token.
100100
com.microsoft.identity.common.logging.Logger.warn(
101-
TAG + methodName,
101+
methodTag,
102102
"Unable to get account id from either ClientInfo or IdToken. Attempting to obtain from home account id."
103103
);
104104
id = com.microsoft.identity.common.java.util.StringUtil.getUIdFromHomeAccountId(mHomeAccountId);
105105
}
106106

107107
if (StringUtil.isEmpty(id)) {
108108
com.microsoft.identity.common.logging.Logger.warn(
109-
TAG + methodName,
109+
methodTag,
110110
"Account ID is empty. Returning MISSING_FROM_THE_TOKEN_RESPONSE."
111111
);
112112

msal/src/main/java/com/microsoft/identity/client/AccountAdapter.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ static AccountRecord getAccountInternal(@NonNull final String clientId,
362362
@NonNull OAuth2TokenCache oAuth2TokenCache,
363363
@NonNull final String homeAccountIdentifier,
364364
@Nullable final String realm) {
365+
final String methodTag = TAG + ":getAccountInternal";
365366
final AccountRecord accountToReturn;
366367

367368
if (!StringUtil.isNullOrEmpty(homeAccountIdentifier)) {
@@ -372,7 +373,7 @@ static AccountRecord getAccountInternal(@NonNull final String clientId,
372373
realm
373374
);
374375
} else {
375-
Logger.warn(TAG, "homeAccountIdentifier was null or empty -- invalid criteria");
376+
Logger.warn(methodTag, "homeAccountIdentifier was null or empty -- invalid criteria");
376377
accountToReturn = null;
377378
}
378379

msal/src/main/java/com/microsoft/identity/client/AuthenticationResult.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,17 @@ public UUID getCorrelationId() {
126126

127127
@Nullable
128128
private UUID sanitizeCorrelationId(@Nullable final String correlationId) {
129-
final String methodName = "sanitizeCorrelationId";
129+
final String methodTag = TAG + ":sanitizeCorrelationId";
130130

131131
if (TextUtils.isEmpty(correlationId)) {
132-
Logger.warn(TAG + methodName, "Correlation id was empty, returning null.");
132+
Logger.warn(methodTag, "Correlation id was empty, returning null.");
133133
return null;
134134
}
135135

136136
try {
137137
return UUID.fromString(correlationId);
138138
} catch (IllegalArgumentException e) {
139-
Logger.error(TAG + methodName, "Correlation id is not a valid UUID.", e);
139+
Logger.error(methodTag, "Correlation id is not a valid UUID.", e);
140140
return null;
141141
}
142142
}

msal/src/main/java/com/microsoft/identity/client/AuthenticationResultAdapter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ static IAuthenticationResult adapt(@NonNull final ILocalAuthenticationResult loc
5858
static MsalDeclinedScopeException declinedScopeExceptionFromResult(@NonNull final ILocalAuthenticationResult localAuthenticationResult,
5959
@NonNull final List<String> declinedScopes,
6060
@NonNull final TokenParameters requestParameters) {
61-
final String methodName = ":declinedScopeExceptionFromResult";
61+
final String methodTag = TAG + ":declinedScopeExceptionFromResult";
6262
final List<String> grantedScopes = Arrays.asList(localAuthenticationResult.getScope());
63-
Logger.warn(TAG + methodName,
63+
Logger.warn(methodTag,
6464
"Returning DeclinedScopeException as not all requested scopes are granted," +
6565
" Requested scopes: " + requestParameters.getScopes().toString()
6666
+ " Granted scopes:" + grantedScopes.toString());

msal/src/main/java/com/microsoft/identity/client/BrowserTabActivity.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,17 @@ public final class BrowserTabActivity extends Activity {
6060
@Override
6161
protected void onCreate(final Bundle savedInstanceState) {
6262
super.onCreate(savedInstanceState);
63+
64+
final String methodTag = TAG + ":onCreate";
65+
6366
if (savedInstanceState == null
6467
&& getIntent() != null
6568
&& !StringUtil.isEmpty(getIntent().getDataString())) {
6669
final Intent responseIntent = BrowserAuthorizationFragment.createCustomTabResponseIntent(this, getIntent().getDataString());
6770
if (responseIntent != null) {
6871
startActivity(responseIntent);
6972
} else {
70-
Logger.warn(TAG, "Received NULL response intent. Unable to complete authorization.");
73+
Logger.warn(methodTag, "Received NULL response intent. Unable to complete authorization.");
7174
Toast.makeText(getApplicationContext(), "Unable to complete authorization as there is no interactive call in progress. This can be due to closing the app while the authorization was in process.", Toast.LENGTH_LONG).show();
7275
}
7376
finish();

msal/src/main/java/com/microsoft/identity/client/CurrentTaskBrowserTabActivity.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public final class CurrentTaskBrowserTabActivity extends Activity {
8080
protected void onCreate(final Bundle savedInstanceState) {
8181
super.onCreate(savedInstanceState);
8282

83+
final String methodTag = TAG + ":onCreate";
8384
final String response = getIntent().getDataString();
8485

8586
if (savedInstanceState == null
@@ -91,7 +92,7 @@ && getIntent() != null
9192
if (responseIntent != null) {
9293
startActivityForResult(responseIntent, REDIRECT_RECEIVED_CODE);
9394
} else {
94-
Logger.warn(TAG, "Received NULL response intent. Unable to complete authorization.");
95+
Logger.warn(methodTag, "Received NULL response intent. Unable to complete authorization.");
9596
Toast.makeText(getApplicationContext(), "Unable to complete authorization as there is no interactive call in progress. This can be due to closing the app while the authorization was in process.", Toast.LENGTH_LONG).show();
9697
}
9798
}
@@ -101,6 +102,8 @@ && getIntent() != null
101102
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
102103
super.onActivityResult(requestCode, resultCode, data);
103104

105+
final String methodTag = TAG + ":onActivityResult";
106+
104107
if (resultCode == RESULT_CANCELED) {
105108
// We weren't able to open CurrentTaskAuthorizationActivity from the back stack. Send a broadcast
106109
// instead.
@@ -121,7 +124,7 @@ public void onReceive(Context context, Intent intent) {
121124
hasNullTaskAffinity = true;
122125
}
123126
} catch (final PackageManager.NameNotFoundException e) {
124-
Logger.warn(TAG, null, "Package name not found for: " + CurrentTaskBrowserTabActivity.this.getComponentName());
127+
Logger.warn(methodTag, null, "Package name not found for: " + CurrentTaskBrowserTabActivity.this.getComponentName());
125128
}
126129

127130
finishActivity(REDIRECT_RECEIVED_CODE);

msal/src/main/java/com/microsoft/identity/client/MsalChromeCustomTabManager.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ public MsalChromeCustomTabManager(final Activity activity) {
6666
}
6767

6868
protected void verifyChromeTabOrBrowser() throws MsalClientException {
69+
final String methodTag = TAG +":verifyChromeTabOrBrowser";
70+
6971
if (mChromePackageWithCustomTabSupport == null) {
70-
Logger.warn(TAG, "Custom tab is not supported by Chrome.");
72+
Logger.warn(methodTag, "Custom tab is not supported by Chrome.");
7173

7274
} else if (MsalUtils.getChromePackage(mParentActivity.getApplicationContext()) == null) {
73-
Logger.warn(TAG, "Chrome is not installed.");
75+
Logger.warn(methodTag, "Chrome is not installed.");
7476
throw new MsalClientException(ErrorStrings.CHROME_NOT_INSTALLED, "Chrome is not installed.");
7577
}
7678
}
@@ -104,6 +106,8 @@ public synchronized void bindCustomTabsService() {
104106
* Helper method to wait for MsalCustomTabsServiceConnection to establish.
105107
*/
106108
private boolean waitForServiceConnectionToEstablish(CountDownLatch latch) {
109+
final String methodTag = TAG + ":waitForServiceConnectionToEstablish";
110+
107111
boolean connectionEstablished = true;
108112
try {
109113
// await returns true if count is 0, false if action times out
@@ -114,10 +118,10 @@ private boolean waitForServiceConnectionToEstablish(CountDownLatch latch) {
114118
// to be safe, we'll skip warmup and rely on mCustomTabsServiceIsBound
115119
// to unbind the Service when onStop() is called.
116120
connectionEstablished = false;
117-
Logger.warn(TAG, "Connection to CustomTabs timed out. Skipping warmup.");
121+
Logger.warn(methodTag, "Connection to CustomTabs timed out. Skipping warmup.");
118122
}
119123
} catch (final InterruptedException e) {
120-
Logger.error(TAG, "Failed to connect to CustomTabs. Skipping warmup.", e);
124+
Logger.error(methodTag, "Failed to connect to CustomTabs. Skipping warmup.", e);
121125
connectionEstablished = false;
122126
}
123127
return connectionEstablished;
@@ -141,11 +145,12 @@ public synchronized void unbindCustomTabsService() {
141145
* @param requestUrl URL to be loaded.
142146
*/
143147
public void launchChromeTabOrBrowserForUrl(String requestUrl) {
148+
final String methodTag = TAG + ":launchChromeTabOrBrowserForUrl";
144149
if (mChromePackageWithCustomTabSupport != null && mCustomTabsIntent != null) {
145-
Logger.info(TAG, "ChromeCustomTab support is available, launching chrome tab.");
150+
Logger.info(methodTag, "ChromeCustomTab support is available, launching chrome tab.");
146151
mCustomTabsIntent.launchUrl(mParentActivity, Uri.parse(requestUrl));
147152
} else {
148-
Logger.info(TAG, "Chrome tab support is not available, launching chrome browser.");
153+
Logger.info(methodTag, "Chrome tab support is not available, launching chrome browser.");
149154
final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(requestUrl));
150155
////TODO: Can move MsalUtils chrome specific util method to common when refactoring.
151156
browserIntent.setPackage(MsalUtils.getChromePackage(mParentActivity.getApplicationContext()));

msal/src/main/java/com/microsoft/identity/client/MultipleAccountPublicClientApplication.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ public void getAccount(@NonNull final String identifier,
218218
private void getAccountInternal(@NonNull final String identifier,
219219
@NonNull final GetAccountCallback callback,
220220
@NonNull final String publicApiId) {
221+
final String methodTag = TAG + ":getAccountInternal";
222+
221223
if (callback == null) {
222224
throw new IllegalArgumentException("callback cannot be null or empty");
223225
}
@@ -230,9 +232,8 @@ private void getAccountInternal(@NonNull final String identifier,
230232
TokenMigrationCallback migrationCallback = new TokenMigrationCallback() {
231233
@Override
232234
public void onMigrationFinished(int numberOfAccountsMigrated) {
233-
final String methodName = ":getAccount";
234235

235-
Logger.verbose(TAG + methodName, "Get account with the identifier.");
236+
Logger.verbose(methodTag, "Get account with the identifier.");
236237

237238
try {
238239
final CommandParameters params = CommandParametersAdapter.createCommandParameters(mPublicClientConfiguration, mPublicClientConfiguration.getOAuth2TokenCache());
@@ -247,7 +248,7 @@ public void onMigrationFinished(int numberOfAccountsMigrated) {
247248
@Override
248249
public void onTaskCompleted(final List<ICacheRecord> result) {
249250
if (null == result || result.size() == 0) {
250-
Logger.verbose(TAG + methodName, "No account found.");
251+
Logger.verbose(methodTag, "No account found.");
251252
callback.onTaskCompleted(null);
252253
} else {
253254
// First, transform the result into IAccount + TenantProfile form
@@ -281,7 +282,7 @@ public void onTaskCompleted(final List<ICacheRecord> result) {
281282

282283
@Override
283284
public void onError(final BaseException exception) {
284-
Logger.error(TAG + methodName, exception.getMessage(), exception);
285+
Logger.error(methodTag, exception.getMessage(), exception);
285286
callback.onError(MsalExceptionAdapter.msalExceptionFromBaseException(exception));
286287
}
287288

@@ -295,7 +296,7 @@ public void onCancel() {
295296

296297
CommandDispatcher.submitSilent(loadAccountCommand);
297298
} catch (final MsalClientException e) {
298-
Logger.error(TAG + methodName, e.getMessage(), e);
299+
Logger.error(methodTag, e.getMessage(), e);
299300
callback.onError(e);
300301
}
301302
}
@@ -349,12 +350,13 @@ public void removeAccount(@Nullable final IAccount account,
349350
private void removeAccountInternal(@Nullable final IAccount account,
350351
@NonNull final RemoveAccountCallback callback,
351352
@NonNull final String publicApiId) {
353+
final String methodTag = TAG + ":removeAccountInternal";
352354
// First, cast the input IAccount to a MultiTenantAccount
353355
final MultiTenantAccount multiTenantAccount = (MultiTenantAccount) account;
354356

355357
//create the parameter
356358
if (null == multiTenantAccount) {
357-
Logger.warn(TAG,
359+
Logger.warn(methodTag,
358360
"Requisite IAccount or IAccount fields were null. " +
359361
"Insufficient criteria to remove IAccount."
360362
);

0 commit comments

Comments
 (0)