\r
package com.owncloud.android.authentication;\r
\r
-import java.net.URLDecoder;\r
-\r
import android.accounts.Account;\r
import android.accounts.AccountManager;\r
import android.app.AlertDialog;\r
import android.widget.EditText;\r
import android.widget.TextView;\r
import android.widget.TextView.OnEditorActionListener;\r
-import android.widget.Toast;\r
\r
import com.actionbarsherlock.app.SherlockDialogFragment;\r
import com.owncloud.android.Log_OC;\r
mAuthCheckOperation = new ExistenceCheckOperation("", this, false);\r
WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, false);\r
mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);\r
+ \r
}\r
\r
/**\r
// NOTHING TO DO ; can't find out what situation that leads to the exception in this code, but user logs signal that it happens\r
}\r
\r
- if (result.isTemporalRedirection() || result.isIdPRedirection()) {\r
+ if (result.isTemporalRedirection() && result.isIdPRedirection()) {\r
String url = result.getRedirectedLocation();\r
String targetUrl = mHostBaseUrl + AccountUtils.getWebdavPath(mDiscoveredVersion, mCurrentAuthTokenType);\r
\r
mSamlDialog = SamlWebViewDialog.newInstance(url, targetUrl); \r
mSamlDialog.show(getSupportFragmentManager(), TAG_SAML_DIALOG);\r
\r
- mAuthStatusIcon = android.R.drawable.ic_secure;\r
- mAuthStatusText = R.string.auth_follow_auth_server;\r
+ mAuthStatusIcon = 0;\r
+ mAuthStatusText = 0;\r
\r
} else {\r
mAuthStatusIcon = R.drawable.common_error;\r
case ACCOUNT_NOT_NEW:\r
mAuthStatusText = R.string.auth_account_not_new;\r
break;\r
+ case ACCOUNT_NOT_THE_SAME:\r
+ mAuthStatusText = R.string.auth_account_not_the_same;\r
+ break;\r
case UNHANDLED_HTTP_CODE:\r
case UNKNOWN_ERROR:\r
mAuthStatusText = R.string.auth_unknown_error_title;\r
if (result.isSuccess()) {\r
Log_OC.d(TAG, "Successful access - time to save the account");\r
\r
- boolean success = true;\r
+ boolean success = false;\r
if (mAction == ACTION_CREATE) {\r
success = createAccount();\r
\r
} else {\r
- updateToken();\r
+ success = updateToken();\r
}\r
\r
if (success) {\r
showAuthStatus();\r
Log_OC.d(TAG, "Access failed: " + result.getLogMessage());\r
}\r
+\r
}\r
\r
\r
* Sets the proper response to get that the Account Authenticator that started this activity saves \r
* a new authorization token for mAccount.\r
*/\r
- private void updateToken() {\r
+ private boolean updateToken() {\r
Bundle response = new Bundle();\r
response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);\r
response.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccount.type);\r
mAccountMgr.setAuthToken(mAccount, mCurrentAuthTokenType, mAuthToken);\r
\r
} else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mCurrentAuthTokenType)) {\r
+ String username = getUserNameForSamlSso();\r
+ if (!mUsernameInput.getText().toString().equals(username)) {\r
+ // fail - not a new account, but an existing one; disallow\r
+ RemoteOperationResult result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_THE_SAME); \r
+ updateAuthStatusIconAndText(result);\r
+ showAuthStatus();\r
+ Log_OC.d(TAG, result.getLogMessage());\r
+ \r
+ return false;\r
+ }\r
+ \r
response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);\r
// the next line is necessary; by now, notifications are calling directly to the AuthenticatorActivity to update, without AccountManager intervention\r
mAccountMgr.setAuthToken(mAccount, mCurrentAuthTokenType, mAuthToken);\r
}\r
setAccountAuthenticatorResult(response);\r
\r
- // Sync Account\r
- syncAccount();\r
+ return true;\r
}\r
\r
\r
Log_OC.d(TAG, result.getLogMessage());\r
return false;\r
\r
- \r
} else {\r
\r
if (isOAuth || isSaml) {\r
if (sessionCookie != null && sessionCookie.length() > 0) {\r
Log_OC.d(TAG, "Successful SSO - time to save the account");\r
mAuthToken = sessionCookie;\r
- boolean success = true;\r
+ boolean success = false;\r
if (mAction == ACTION_CREATE) {\r
success = createAccount();\r
\r
} else {\r
- updateToken();\r
+ success = updateToken();\r
}\r
if (success) {\r
finish();\r
}\r
}\r
+\r
\r
}\r
\r
// TODO - show fail\r
Log_OC.d(TAG, "SSO failed");\r
}\r
- }\r
\r
+ }\r
\r
/** Show auth_message \r
* \r