Simplify checks of authentication needed after change in library; as a side effect, uploads failed due to SAML session expired are stored with right 'credentials error', instead of 'unknown'

This commit is contained in:
David A. Velasco 2016-03-14 09:31:38 +01:00
parent e78bf9179b
commit d053f34b8f
8 changed files with 12 additions and 23 deletions

@ -1 +1 @@
Subproject commit dc3ae324c30872b905397c76f6ad9391ec482e66
Subproject commit 0a693f2b4e4f36414eae5d8c7d2d9e9d3c4700e5

View file

@ -545,10 +545,7 @@ public class FileDownloader extends Service
int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker :
R.string.downloader_download_failed_ticker;
boolean needsToUpdateCredentials = (
downloadResult.getCode() == ResultCode.UNAUTHORIZED ||
downloadResult.isIdPRedirection()
);
boolean needsToUpdateCredentials = (ResultCode.UNAUTHORIZED.equals(downloadResult.getCode()));
tickerId = (needsToUpdateCredentials) ?
R.string.downloader_download_failed_credentials_error : tickerId;

View file

@ -1047,10 +1047,7 @@ public class FileUploader extends Service
String content;
// check credentials error
boolean needsToUpdateCredentials = (
uploadResult.getCode() == ResultCode.UNAUTHORIZED ||
uploadResult.isIdPRedirection()
);
boolean needsToUpdateCredentials = (ResultCode.UNAUTHORIZED.equals(uploadResult.getCode()));
tickerId = (needsToUpdateCredentials) ?
R.string.uploader_upload_failed_credentials_error : tickerId;

View file

@ -34,6 +34,8 @@ import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
import android.content.Context;
import android.net.Uri;
import org.apache.commons.httpclient.HttpStatus;
/**
* Operation to find out what authentication method requires
* the server to access files.
@ -99,7 +101,7 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
}
// analyze response
if (result.getCode() == ResultCode.UNAUTHORIZED) {
if (result.getHttpCode() == HttpStatus.SC_UNAUTHORIZED) {
String authRequest = ((result.getAuthenticateHeader()).trim()).toLowerCase();
if (authRequest.startsWith("basic")) {
authMethod = AuthenticationMethod.BASIC_HTTP_AUTH;

View file

@ -300,9 +300,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
} else if (result.getCode() != ResultCode.FILE_NOT_FOUND) {
// in failures, the statistics for the global result are updated
if ( result.getCode() == RemoteOperationResult.ResultCode.UNAUTHORIZED ||
result.isIdPRedirection()
) {
if (RemoteOperationResult.ResultCode.UNAUTHORIZED.equals(result.getCode())) {
mSyncResult.stats.numAuthExceptions++;
} else if (result.getException() instanceof DavException) {
@ -395,10 +393,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
private void notifyFailedSynchronization() {
NotificationCompat.Builder notificationBuilder = createNotificationBuilder();
boolean needsToUpdateCredentials = (
mLastFailedResult != null && (
mLastFailedResult.getCode() == ResultCode.UNAUTHORIZED ||
mLastFailedResult.isIdPRedirection()
)
mLastFailedResult != null &&
ResultCode.UNAUTHORIZED.equals(mLastFailedResult.getCode())
);
if (needsToUpdateCredentials) {
// let the user update credentials with one click

View file

@ -743,7 +743,6 @@ public class FileActivity extends AppCompatActivity
if (!result.isSuccess() && (
result.getCode() == ResultCode.UNAUTHORIZED ||
result.isIdPRedirection() ||
(result.isException() && result.getException() instanceof AuthenticatorException)
)) {

View file

@ -1028,8 +1028,7 @@ public class FileDisplayActivity extends HookActivity implements
equals(event) &&/// TODO refactor and make common
synchResult != null && !synchResult.isSuccess() &&
(synchResult.getCode() == ResultCode.UNAUTHORIZED ||
synchResult.isIdPRedirection() ||
(ResultCode.UNAUTHORIZED.equals(synchResult.getCode()) ||
(synchResult.isException() && synchResult.getException()
instanceof AuthenticatorException))) {

View file

@ -481,9 +481,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
equals(event) &&
/// TODO refactor and make common
synchResult != null && !synchResult.isSuccess() &&
(synchResult.getCode() == ResultCode.UNAUTHORIZED ||
synchResult.isIdPRedirection() ||
(synchResult.isException() && synchResult.getException()
(ResultCode.UNAUTHORIZED.equals(synchResult.getCode()) ||
(synchResult.isException() && synchResult.getException()
instanceof AuthenticatorException))) {
requestCredentialsUpdate(context);