\r
package com.owncloud.android.authentication;\r
\r
+import java.io.IOException;\r
import java.security.cert.X509Certificate;\r
import java.util.Map;\r
\r
import android.accounts.Account;\r
import android.accounts.AccountManager;\r
+import android.accounts.AuthenticatorException;\r
+import android.accounts.OperationCanceledException;\r
import android.app.Dialog;\r
import android.content.ComponentName;\r
import android.content.Context;\r
import com.owncloud.android.MainApp;\r
import com.owncloud.android.R;\r
import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener;\r
+import com.owncloud.android.lib.common.OwnCloudAccount;\r
+import com.owncloud.android.lib.common.OwnCloudClient;\r
+import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;\r
import com.owncloud.android.lib.common.accounts.AccountTypeUtils;\r
import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;\r
import com.owncloud.android.lib.common.network.CertificateCombinedException;\r
mWaitingForOpId = savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID);\r
mIsFirstAuthAttempt = savedInstanceState.getBoolean(KEY_AUTH_IS_FIRST_ATTEMPT_TAG);\r
}\r
+\r
+\r
\r
/// load user interface\r
setContentView(R.layout.account_setup);\r
* intended to defer the processing of the redirection caught in \r
* {@link #onNewIntent(Intent)} until {@link #onResume()} \r
* \r
- * See {@link #loadSavedInstanceState(Bundle)}\r
+ * See {@link #onSaveInstanceState(Bundle)}\r
*/\r
@Override\r
protected void onSaveInstanceState(Bundle outState) {\r
}\r
\r
private void accessRootFolderRemoteOperation(String username, String password) {\r
+ // delete the account if the token has changed\r
+ if (mAction == ACTION_UPDATE_TOKEN || mAction == ACTION_UPDATE_EXPIRED_TOKEN) {\r
+ // Remove the cookies in AccountManager\r
+ mAccountMgr.setUserData(mAccount, Constants.KEY_COOKIES, null);\r
+ }\r
+\r
Intent existenceCheckIntent = new Intent();\r
existenceCheckIntent.setAction(OperationsService.ACTION_EXISTENCE_CHECK);\r
existenceCheckIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mServerInfo.mBaseUrl);\r
private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperationResult result) {\r
mWaitingForOpId = Long.MAX_VALUE;\r
dismissDialog(WAIT_DIALOG_TAG);\r
-
- if (result.isIdPRedirection()) {
+\r
+ if (result.isIdPRedirection()) {\r
String targetUrl = mServerInfo.mBaseUrl \r
+ AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);\r
\r
/**\r
* Processes the result of the server check performed when the user finishes the enter of the\r
* server URL.\r
- * \r
- * @param operation Server check performed.\r
+ *\r
* @param result Result of the check.\r
*/\r
private void onGetServerInfoFinish(RemoteOperationResult result) {\r
* Processes the result of the access check performed to try the user credentials.\r
* \r
* Creates a new account through the AccountManager.\r
- * \r
- * @param operation Access check performed.\r
+ *\r
* @param result Result of the operation.\r
*/\r
private void onAuthorizationCheckFinish(RemoteOperationResult result) {\r
finish();\r
}\r
\r
- } else if (result.isServerFail() || result.isException()) {
+ } else if (result.isServerFail() || result.isException()) {\r
/// server errors or exceptions in authorization take to requiring a new check of \r
/// the server\r
mServerIsChecked = true;\r
mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);\r
}\r
/// add user data to the new account; TODO probably can be done in the last parameter \r
- // addAccountExplicitly, or in KEY_USERDATA
+ // addAccountExplicitly, or in KEY_USERDATA\r
mAccountMgr.setUserData(\r
mAccount, Constants.KEY_OC_VERSION, mServerInfo.mVersion.getVersion()\r
);\r
mAccountMgr.setUserData(\r
mAccount, Constants.KEY_OC_BASE_URL, mServerInfo.mBaseUrl\r
);\r
-
+\r
if (isSaml) {\r
mAccountMgr.setUserData(mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE"); \r
} else if (isOAuth) {\r
/**\r
* Updates the content and visibility state of the icon and text associated\r
* to the last check on the ownCloud server.\r
- * \r
- * @param serverStatusText Resource identifier of the text to show.\r
- * @param serverStatusIcon Resource identifier of the icon to show.\r
*/\r
private void showServerStatus() {\r
if (mServerStatusIcon == 0 && mServerStatusText == 0) {\r
mCurrentOperation = next.second;
RemoteOperationResult result = null;
try {
+ OwnCloudAccount ocAccount;
/// prepare client object to send the request to the ownCloud server
if (mLastTarget == null || !mLastTarget.equals(next.first)) {
mLastTarget = next.first;
if (mLastTarget.mAccount != null) {
- OwnCloudAccount ocAccount = new OwnCloudAccount(mLastTarget.mAccount, mService);
- mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
- getClientFor(ocAccount, mService);
+ ocAccount = new OwnCloudAccount(mLastTarget.mAccount, mService);
mStorageManager = new FileDataStorageManager(
mLastTarget.mAccount,
mService.getContentResolver()
credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials(
mLastTarget.mCookie); // SAML SSO
}
- OwnCloudAccount ocAccount = new OwnCloudAccount(
+ ocAccount = new OwnCloudAccount(
mLastTarget.mServerUrl, credentials);
- mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
- getClientFor(ocAccount, mService);
mStorageManager = null;
}
+ mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton().
+ getClientFor(ocAccount, mService);
}
/// perform the operation