Added skeleton of new operation to detect authentication method in the server side
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index 33ddbf7..a8293c3 100644 (file)
@@ -176,7 +176,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 \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
@@ -905,7 +905,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
                 hideRefreshButton();\r
                 // Try to create an account with user and pass "", to know if it is a regular server\r
                 // Update connect button in the answer of this method\r
-                tryEmptyAuthorization();\r
+                detectAuthorizationMethod();\r
             } else {\r
                 showRefreshButton();\r
                 // Show server status\r
@@ -926,8 +926,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     /**\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
@@ -1149,7 +1149,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     \r
     private void updateServerStatusIconNoRegularAuth(){\r
         mServerStatusIcon = R.drawable.common_error;\r
-        mServerStatusText = R.string.auth_unsupported_auth_method;\r
+        mServerStatusText = R.string.auth_can_not_auth_against_server;\r
     }\r
     \r
     /**\r
@@ -1203,11 +1203,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         }\r
         \r
         if (result.isSuccess()) {\r
-            \r
-            if (mTryEmptyAuthorization) {\r
-                //allow or not the user try to access the server\r
+            //allow or not the user try to access the server\r
+            if (mDetectAuthorizationMethod) {\r
                 mOkButton.setEnabled(false);\r
-                mTryEmptyAuthorization = false;\r
+                mDetectAuthorizationMethod = false;\r
                 mServerIsValid = false;\r
                 //show an alert message ( Server Status )\r
                 updateServerStatusIconNoRegularAuth();\r
@@ -1231,8 +1230,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             }\r
 \r
         } else {\r
-            if (mTryEmptyAuthorization) {\r
-                mTryEmptyAuthorization = false;\r
+            if (mDetectAuthorizationMethod  && \r
+                    ( result.getCode() == ResultCode.UNAUTHORIZED && result.isBasicAuthentication())) {\r
+                mDetectAuthorizationMethod = false;\r
                 mOkButton.setEnabled(true);\r
                 \r
                 // Show server status\r