X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/d01e065586ef9df7735e8ceab342a79ea634f6a4..bef5d5c5f8ed2851116b83f58bb7373ad8264d05:/src/com/owncloud/android/authentication/AuthenticatorActivity.java diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 955dc547..a8293c34 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -35,7 +35,6 @@ import android.net.http.SslError; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; -import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; @@ -74,8 +73,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation; import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation; - -import com.owncloud.android.ui.dialog.AlertMessageDialog; + import com.owncloud.android.ui.dialog.SamlWebViewDialog; import com.owncloud.android.ui.dialog.SslUntrustedCertDialog; import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener; @@ -130,7 +128,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity public static final byte ACTION_UPDATE_TOKEN = 1; private static final String TAG_SAML_DIALOG = "samlWebViewDialog"; - private static final String TAG_ALERT_MESSAGE_DIALOG = "alertMessagewDialog"; private String mHostBaseUrl; private OwnCloudVersion mDiscoveredVersion; @@ -179,7 +176,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity public static String DIALOG_UNTRUSTED_CERT = "DIALOG_UNTRUSTED_CERT"; - private boolean mTryEmptyAuthorization = false; + private boolean mDetectAuthorizationMethod = false; /** @@ -900,17 +897,20 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mDiscoveredVersion = operation.getDiscoveredVersion(); mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString()); + // Refresh server status, but don't show it + updateServerStatusIconAndText(result); + /// update status icon and text if (mServerIsValid) { hideRefreshButton(); // Try to create an account with user and pass "", to know if it is a regular server // Update connect button in the answer of this method - tryEmptyAuthorization(); + detectAuthorizationMethod(); } else { showRefreshButton(); + // Show server status + showServerStatus(); } - updateServerStatusIconAndText(result); - showServerStatus(); /// very special case (TODO: move to a common place for all the remote operations) if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) { @@ -926,14 +926,11 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity /** * Try to access with user/pass ""/"", to know if it is a regular server */ - private void tryEmptyAuthorization() { - mTryEmptyAuthorization = true; + private void detectAuthorizationMethod() { + mDetectAuthorizationMethod = true; Log_OC.d(TAG, "Trying empty authorization to detect authentication method"); - /// be gentle with the user - showDialog(DIALOG_LOGIN_PROGRESS); - /// get the path to the root folder through WebDAV from the version server String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType); @@ -1146,10 +1143,15 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private void updateStatusIconFailUserName(){ - mAuthStatusIcon = android.R.drawable.ic_secure; + mAuthStatusIcon = R.drawable.common_error; mAuthStatusText = R.string.auth_fail_get_user_name; } + private void updateServerStatusIconNoRegularAuth(){ + mServerStatusIcon = R.drawable.common_error; + mServerStatusText = R.string.auth_can_not_auth_against_server; + } + /** * Processes the result of the request for and access token send * to an OAuth authorization server. @@ -1201,14 +1203,14 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } if (result.isSuccess()) { - - if (mTryEmptyAuthorization) { - //allow or not the user try to access the server + //allow or not the user try to access the server + if (mDetectAuthorizationMethod) { mOkButton.setEnabled(false); - mTryEmptyAuthorization = false; + mDetectAuthorizationMethod = false; mServerIsValid = false; - //show an alert message - showAlertMessageDialog(R.string.common_alert_title, R.string.auth_unsupported_auth_method); + //show an alert message ( Server Status ) + updateServerStatusIconNoRegularAuth(); + showServerStatus(); } else { Log_OC.d(TAG, "Successful access - time to save the account"); @@ -1228,10 +1230,14 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } } else { - if (mTryEmptyAuthorization) { - mTryEmptyAuthorization = false; + if (mDetectAuthorizationMethod && + ( result.getCode() == ResultCode.UNAUTHORIZED && result.isBasicAuthentication())) { + mDetectAuthorizationMethod = false; mOkButton.setEnabled(true); - + + // Show server status + showServerStatus(); + } else if (result.isServerFail() || result.isException()) { /// if server fail or exception in authorization, the UI is updated as when a server check failed mServerIsChecked = true; @@ -1781,10 +1787,5 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } } - - private void showAlertMessageDialog(int tittle, int message) { - DialogFragment newAlertMessage = AlertMessageDialog.newInstance(tittle, message); - newAlertMessage.show(getSupportFragmentManager(), TAG_ALERT_MESSAGE_DIALOG); - } }