import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;\r
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;\r
import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;\r
-
+\r
import com.owncloud.android.ui.dialog.SamlWebViewDialog;\r
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;\r
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener;\r
\r
public static String DIALOG_UNTRUSTED_CERT = "DIALOG_UNTRUSTED_CERT";\r
\r
- private boolean mTryEmptyAuthorization = false;\r
+ private boolean mDetectAuthorizationMethod = false;\r
\r
\r
/**\r
mIsSslConn = (result.getCode() == ResultCode.OK_SSL);\r
mOcServerChkOperation = null;\r
\r
+ \r
+ /// retrieve discovered version and normalize server URL\r
+ mDiscoveredVersion = operation.getDiscoveredVersion();\r
+ mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString());\r
+ \r
+ // Refresh server status, but don't show it\r
+ updateServerStatusIconAndText(result);\r
+ \r
/// update status icon and text\r
if (mServerIsValid) {\r
hideRefreshButton();\r
// Try to create an account with user and pass "", to know if it is a regular server\r
- tryEmptyAuthorization();\r
+ // Update connect button in the answer of this method\r
+ detectAuthorizationMethod();\r
} else {\r
showRefreshButton();\r
+ // Show server status\r
+ showServerStatus();\r
}\r
- updateServerStatusIconAndText(result);\r
- showServerStatus();\r
\r
/// very special case (TODO: move to a common place for all the remote operations)\r
if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {\r
showUntrustedCertDialog(result);\r
}\r
\r
- /// retrieve discovered version and normalize server URL\r
- mDiscoveredVersion = operation.getDiscoveredVersion();\r
- mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString());\r
-\r
-// /// allow or not the user try to access the server\r
-// mOkButton.setEnabled(mServerIsValid);\r
\r
} // else nothing ; only the last check operation is considered; \r
// multiple can be triggered if the user amends a URL before a previous check can be triggered\r
/**\r
* Try to access with user/pass ""/"", to know if it is a regular server\r
*/\r
- private void tryEmptyAuthorization() {\r
- mTryEmptyAuthorization = true;\r
+ private void detectAuthorizationMethod() {\r
+ mDetectAuthorizationMethod = true;\r
\r
Log_OC.d(TAG, "Trying empty authorization to detect authentication method");\r
\r
- /// be gentle with the user\r
- showDialog(DIALOG_LOGIN_PROGRESS);\r
- \r
/// get the path to the root folder through WebDAV from the version server\r
String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType);\r
\r
\r
\r
private void updateStatusIconFailUserName(){\r
- mAuthStatusIcon = android.R.drawable.ic_secure;\r
+ mAuthStatusIcon = R.drawable.common_error;\r
mAuthStatusText = R.string.auth_fail_get_user_name;\r
}\r
\r
+ private void updateServerStatusIconNoRegularAuth(){\r
+ mServerStatusIcon = R.drawable.common_error;\r
+ mServerStatusText = R.string.auth_can_not_auth_against_server;\r
+ }\r
+ \r
/**\r
* Processes the result of the request for and access token send \r
* to an OAuth authorization server.\r
}\r
\r
if (result.isSuccess()) {\r
- \r
- if (mTryEmptyAuthorization) {\r
- //allow or not the user try to access the server\r
- mOkButton.setEnabled(mServerIsValid);\r
- mTryEmptyAuthorization = false;\r
+ //allow or not the user try to access the server\r
+ if (mDetectAuthorizationMethod) {\r
+ mOkButton.setEnabled(false);\r
+ mDetectAuthorizationMethod = false;\r
+ mServerIsValid = false;\r
+ //show an alert message ( Server Status )\r
+ updateServerStatusIconNoRegularAuth();\r
+ showServerStatus();\r
\r
} else {\r
Log_OC.d(TAG, "Successful access - time to save the account");\r
}\r
}\r
\r
- } else if (result.isServerFail() || result.isException()) {\r
- /// if server fail or exception in authorization, the UI is updated as when a server check failed\r
- mServerIsChecked = true;\r
- mServerIsValid = false;\r
- mIsSslConn = false;\r
- mOcServerChkOperation = null;\r
- mDiscoveredVersion = null;\r
- mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString());\r
+ } else {\r
+ if (mDetectAuthorizationMethod && \r
+ ( result.getCode() == ResultCode.UNAUTHORIZED && result.isBasicAuthentication())) {\r
+ mDetectAuthorizationMethod = false;\r
+ mOkButton.setEnabled(true);\r
+ \r
+ // Show server status\r
+ showServerStatus();\r
+ \r
+ } else if (result.isServerFail() || result.isException()) {\r
+ /// if server fail or exception in authorization, the UI is updated as when a server check failed\r
+ mServerIsChecked = true;\r
+ mServerIsValid = false;\r
+ mIsSslConn = false;\r
+ mOcServerChkOperation = null;\r
+ mDiscoveredVersion = null;\r
+ mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString());\r
+\r
+ // update status icon and text\r
+ updateServerStatusIconAndText(result);\r
+ showServerStatus();\r
+ mAuthStatusIcon = 0;\r
+ mAuthStatusText = 0;\r
+ showAuthStatus();\r
+\r
+ // update input controls state\r
+ showRefreshButton();\r
+ mOkButton.setEnabled(false);\r
\r
- // update status icon and text\r
- updateServerStatusIconAndText(result);\r
- showServerStatus();\r
- mAuthStatusIcon = 0;\r
- mAuthStatusText = 0;\r
- showAuthStatus();\r
- \r
- // update input controls state\r
- showRefreshButton();\r
- mOkButton.setEnabled(false);\r
+ // very special case (TODO: move to a common place for all the remote operations) (dangerous here?)\r
+ if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {\r
+ showUntrustedCertDialog(result);\r
+ }\r
\r
- // very special case (TODO: move to a common place for all the remote operations) (dangerous here?)\r
- if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {\r
- showUntrustedCertDialog(result);\r
+ } else { // authorization fail due to client side - probably wrong credentials\r
+ updateAuthStatusIconAndText(result);\r
+ showAuthStatus();\r
+ Log_OC.d(TAG, "Access failed: " + result.getLogMessage());\r
}\r
-\r
- } else { // authorization fail due to client side - probably wrong credentials\r
- updateAuthStatusIconAndText(result);\r
- showAuthStatus();\r
- Log_OC.d(TAG, "Access failed: " + result.getLogMessage());\r
}\r
\r
}\r