package com.owncloud.android.ui.activity;
import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.httpclient.Credentials;
import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
import com.owncloud.android.operations.CreateFolderOperation;
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.OwnCloudClientMap;
+import com.owncloud.android.lib.common.accounts.AccountUtils;
+import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
+import com.owncloud.android.lib.common.network.BearerCredentials;
import com.owncloud.android.lib.common.network.CertificateCombinedException;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
mRightFragmentContainer = findViewById(R.id.right_fragment_container);
if (savedInstanceState == null) {
createMinFragments();
- } else {
- Log_OC.d(TAG, "Init the secondFragment again");
- if (mDualPane) {
- initFragmentsWithFile();
- }
}
// Action bar setup
mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) && !SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event));
- }
- removeStickyBroadcast(intent);
- Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
- setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
-
- if (mSyncInProgress) {
- getListOfFilesFragment().showSwipeProgress();
+ if (SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
+ equals(event) &&
+ /// TODO refactor and make common
+ synchResult != null && !synchResult.isSuccess() &&
+ (synchResult.getCode() == ResultCode.UNAUTHORIZED ||
+ synchResult.isIdPRedirection() ||
+ (synchResult.isException() && synchResult.getException()
+ instanceof AuthenticatorException))) {
+
+
+ OwnCloudClient client = OwnCloudClientMap.removeClientFor(getAccount());
+ if (client != null) {
+ Credentials cred = client.getCredentials();
+ String ssoSessionCookie = client.getSsoSessionCookie();
+ if (cred != null || ssoSessionCookie != null) {
+ boolean bearerAuthorization = (cred != null && cred instanceof BearerCredentials);
+ boolean samlBasedSsoAuthorization = (cred == null && ssoSessionCookie != null);
+ AccountManager am = AccountManager.get(context);
+
+ if (bearerAuthorization) {
+ am.invalidateAuthToken(getAccount().type,
+ ((BearerCredentials)cred).getAccessToken());
+
+ } else if (samlBasedSsoAuthorization ) {
+ am.invalidateAuthToken(getAccount().type, ssoSessionCookie);
+
+ } else {
+ am.clearPassword(getAccount());
+ }
+ }
+ }
+
+ requestCredentialsUpdate();
- } else {
- getListOfFilesFragment().hideSwipeProgress();
}
+ }
+ removeStickyBroadcast(intent);
+ Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
+ setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
+
}
if (synchResult != null) {
getAccount(),
getApplicationContext()
);
- synchFolderOp.execute(getAccount(), this, null, null, this);
+ synchFolderOp.execute(getAccount(), this, null, null);
setSupportProgressBarIndeterminateVisibility(true);
}