Update owncloud library reference
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index 91ff58f..80a522b 100644 (file)
@@ -64,26 +64,24 @@ import com.owncloud.android.R;
 import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener;\r
 import com.owncloud.android.lib.common.accounts.AccountTypeUtils;\r
 import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;\r
-import com.owncloud.android.operations.DetectAuthenticationMethodOperation.AuthenticationMethod;\r
-import com.owncloud.android.operations.GetServerInfoOperation;\r
-import com.owncloud.android.operations.OAuth2GetAccessToken;\r
-
 import com.owncloud.android.lib.common.network.CertificateCombinedException;\r
 import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;\r
 import com.owncloud.android.lib.common.operations.RemoteOperation;\r
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;\r
 import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;\r
+import com.owncloud.android.lib.common.utils.Log_OC;\r
 import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;\r
+import com.owncloud.android.lib.resources.status.OwnCloudVersion;\r
 import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;\r
-\r
+import com.owncloud.android.operations.DetectAuthenticationMethodOperation.AuthenticationMethod;\r
+import com.owncloud.android.operations.GetServerInfoOperation;\r
+import com.owncloud.android.operations.OAuth2GetAccessToken;\r
 import com.owncloud.android.services.OperationsService;\r
 import com.owncloud.android.services.OperationsService.OperationsServiceBinder;\r
 import com.owncloud.android.ui.dialog.IndeterminateProgressDialog;\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
-import com.owncloud.android.utils.Log_OC;\r
-import com.owncloud.android.lib.resources.status.OwnCloudVersion;\r
 \r
 /**\r
  * This Activity is used to add an ownCloud account to the App\r
@@ -723,9 +721,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             Intent getServerInfoIntent = new Intent();\r
             getServerInfoIntent.setAction(OperationsService.ACTION_GET_SERVER_INFO);\r
             getServerInfoIntent.putExtra(OperationsService.EXTRA_SERVER_URL, uri);\r
-            getServerInfoIntent.putExtra(OperationsService.EXTRA_AUTH_TOKEN_TYPE, mAuthTokenType);\r
             if (mOperationsServiceBinder != null) {\r
-                //Log_OC.wtf(TAG, "checking server..." );\r
                 mWaitingForOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent);\r
             } else {\r
               Log_OC.wtf(TAG, "Server check tried with OperationService unbound!" );\r
@@ -837,22 +833,16 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
                 IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true);\r
         dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);\r
 \r
-        /// test credentials accessing the root folder\r
-        String remotePath ="";\r
-        boolean successIfAbsent = false;\r
-        startExistenceCheckRemoteOperation(\r
-                remotePath, this, successIfAbsent, username, password);\r
+        /// validate credentials accessing the root folder\r
+        accessRootFolderRemoteOperation(username, password);\r
         \r
     }\r
 \r
-    private void startExistenceCheckRemoteOperation(\r
-            String remotePath, Context context, boolean successIfAbsent,\r
-            String username, String password) {\r
+    private void accessRootFolderRemoteOperation(String username, String password) {\r
         Intent existenceCheckIntent = new Intent();\r
         existenceCheckIntent.setAction(OperationsService.ACTION_EXISTENCE_CHECK);\r
         existenceCheckIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mServerInfo.mBaseUrl);\r
-        existenceCheckIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath);\r
-        existenceCheckIntent.putExtra(OperationsService.EXTRA_SUCCESS_IF_ABSENT, successIfAbsent);\r
+        existenceCheckIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, "/");\r
         existenceCheckIntent.putExtra(OperationsService.EXTRA_USERNAME, username);\r
         existenceCheckIntent.putExtra(OperationsService.EXTRA_PASSWORD, password);\r
         existenceCheckIntent.putExtra(OperationsService.EXTRA_AUTH_TOKEN, mAuthToken);\r
@@ -900,11 +890,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
                 IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true);\r
         dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);\r
 \r
-        /// test credentials accessing the root folder\r
-        String remotePath ="";\r
-        boolean successIfAbsent = false;\r
-        startExistenceCheckRemoteOperation(\r
-                remotePath, this, successIfAbsent, "", "");\r
+        /// validate credentials accessing the root folder\r
+        accessRootFolderRemoteOperation("", "");\r
 \r
     }\r
 \r
@@ -952,7 +939,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 \r
                 if (!mUsernameInput.getText().toString().equals(username)) {\r
                     // fail - not a new account, but an existing one; disallow\r
-                    result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_THE_SAME); \r
+                    result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_THE_SAME);\r
+                    /*\r
+                    OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(\r
+                            new OwnCloudAccount(\r
+                                    Uri.parse(mServerInfo.mBaseUrl),\r
+                                    OwnCloudCredentialsFactory.newSamlSsoCredentials(mAuthToken))\r
+                            );\r
+                            */\r
+                    mAuthToken = "";\r
                     updateAuthStatusIconAndText(result);\r
                     showAuthStatus();\r
                     Log_OC.d(TAG, result.getLogMessage());\r
@@ -1167,6 +1162,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         case UNKNOWN_ERROR:\r
             mServerStatusText = R.string.auth_unknown_error_title;\r
             break;\r
+        case OK_REDIRECT_TO_NON_SECURE_CONNECTION:\r
+            mServerStatusIcon = android.R.drawable.ic_partial_secure;\r
+            mServerStatusText = R.string.auth_redirect_non_secure_connection_title;\r
+            break;\r
         default:\r
             mServerStatusText = 0;\r
             mServerStatusIcon = 0;\r
@@ -1290,10 +1289,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             //mAuthToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Constants.KEY_ACCESS_TOKEN);\r
             Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken);\r
             \r
-            String remotePath ="";\r
-            boolean successIfAbsent = false;\r
-            startExistenceCheckRemoteOperation(\r
-                    remotePath, this, successIfAbsent, "", "");\r
+            accessRootFolderRemoteOperation("", "");\r
 \r
         } else {\r
             updateAuthStatusIconAndText(result);\r