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

Commit 41bfb30

Browse files
author
Peter Nied
committed
Prevent authentication callback from being reused
Within the MSA flow there are scenarios where an authentication callback would recieve a failure, and then a success message due to how slient authentication is treated during an interactive login. Changing the SDK to handle this scenario and isolate this strange case so callbacks should only be acted on once.
1 parent 839f121 commit 41bfb30

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ org.gradle.jvmargs=-XX:MaxPermSize=512m
2121
mavenRepoUrl = https://api.bintray.com/maven/onedrive/Maven/onedrive-sdk-android
2222
mavenGroupId = com.onedrive.sdk
2323
mavenArtifactId = onedrive-sdk-android
24-
mavenVersion = 1.0.0
24+
mavenVersion = 1.0.1
2525
nightliesUrl = http://dl.bintray.com/onedrive/Maven

onedrivesdk/src/main/java/com/onedrive/sdk/authentication/MSAAuthenticator.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,12 @@ public synchronized IAccountInfo login(final String emailAddressHint) throws Cli
166166
public void onAuthComplete(final LiveStatus liveStatus,
167167
final LiveConnectSession liveConnectSession,
168168
final Object o) {
169-
if (liveStatus != LiveStatus.CONNECTED) {
170-
error.set(new ClientAuthenticatorException("Was unable to connect to the MSA login session",
171-
OneDriveErrorCodes.AuthenticationFailure));
172-
mLogger.logError(error.get().getMessage(), error.get());
169+
if (liveStatus == LiveStatus.NOT_CONNECTED) {
170+
mLogger.logDebug("Received invalid login failure from silent authentication with MSA, ignoring.");
171+
} else {
172+
mLogger.logDebug("Successful interactive login");
173+
waiter.signal();
173174
}
174-
175-
mLogger.logDebug("Successful login");
176-
waiter.signal();
177175
}
178176

179177
@Override
@@ -256,13 +254,13 @@ public synchronized IAccountInfo loginSilent() throws ClientException {
256254
public void onAuthComplete(final LiveStatus liveStatus,
257255
final LiveConnectSession liveConnectSession,
258256
final Object o) {
259-
if (liveStatus != LiveStatus.CONNECTED) {
260-
error.set(new ClientAuthenticatorException("Was unable to connect to the MSA login session",
261-
OneDriveErrorCodes.AuthenticationFailure));
257+
if (liveStatus == LiveStatus.NOT_CONNECTED) {
258+
error.set(new ClientAuthenticatorException("Failed silent login, interactive login required",
259+
OneDriveErrorCodes.AuthenticationFailure));
262260
mLogger.logError(error.get().getMessage(), error.get());
261+
} else {
262+
mLogger.logDebug("Successful silent login");
263263
}
264-
265-
mLogger.logDebug("Successful silent login");
266264
loginSilentWaiter.signal();
267265
}
268266

0 commit comments

Comments
 (0)