Removed lost dependencies and unneeded parameters; updated library reference
authorDavid A. Velasco <dvelasco@solidgear.es>
Wed, 18 Jun 2014 15:03:56 +0000 (17:03 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Wed, 18 Jun 2014 15:03:56 +0000 (17:03 +0200)
owncloud-android-library
src/com/owncloud/android/authentication/AuthenticatorActivity.java
src/com/owncloud/android/operations/DetectAuthenticationMethodOperation.java
src/com/owncloud/android/operations/GetServerInfoOperation.java
src/com/owncloud/android/services/OperationsService.java

index c01001b..179ef41 160000 (submodule)
@@ -1 +1 @@
-Subproject commit c01001b5a1b19ab4c6ff789730a6659b8f6bcbb5
+Subproject commit 179ef41f4c43c162a5fde2fe95594e9b70044b41
index 91ff58f..ce23dc6 100644 (file)
@@ -723,9 +723,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 +835,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 +892,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
@@ -1290,10 +1279,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
index 18d8cec..b90c25e 100644 (file)
@@ -64,7 +64,6 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
     }
     
     private Context mContext;
-    private String mWebDavUrl;
     
     /**
      * Constructor
@@ -72,9 +71,8 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
      * @param context       Android context of the caller.
      * @param webdavUrl
      */
-    public DetectAuthenticationMethodOperation(Context context, String webdavUrl) {
+    public DetectAuthenticationMethodOperation(Context context) {
         mContext = context;
-        mWebDavUrl = webdavUrl;
     }
     
 
index 1e6e8b0..7d42886 100644 (file)
@@ -53,7 +53,6 @@ public class GetServerInfoOperation extends RemoteOperation {
     private static final String TAG = GetServerInfoOperation.class.getSimpleName();
     
     private String mUrl;
-    private String mAuthTokenType;
     private Context mContext;
     
     private ServerInfo mResultData;
@@ -62,14 +61,11 @@ public class GetServerInfoOperation extends RemoteOperation {
      * Constructor.
      * 
      * @param url               URL to an ownCloud server.
-     * @param authTokenType     Identifies the authorization token supported by the caller;
-     *                          TODO ugly dependency, get rid of it. 
      * @param context           Android context; needed to check network state
      *                          TODO ugly dependency, get rid of it. 
      */
-    public GetServerInfoOperation(String url, String authTokenType, Context context) {
+    public GetServerInfoOperation(String url, Context context) {
         mUrl = trimWebdavSuffix(url);
-        mAuthTokenType = authTokenType;
         mContext = context;
         
         mResultData = new ServerInfo();
@@ -114,10 +110,8 @@ public class GetServerInfoOperation extends RemoteOperation {
        
     private RemoteOperationResult detectAuthorizationMethod(OwnCloudClient client) {
         Log_OC.d(TAG, "Trying empty authorization to detect authentication method");
-        String webdav_path = AccountUtils.getWebdavPath(mResultData.mVersion, mAuthTokenType);
-        String webdav_url = mResultData.mBaseUrl + webdav_path;
         DetectAuthenticationMethodOperation operation = 
-                new DetectAuthenticationMethodOperation(mContext, webdav_url);
+                new DetectAuthenticationMethodOperation(mContext);
         return operation.execute(client);
     }
     
index a1a9d62..2522749 100644 (file)
@@ -71,7 +71,6 @@ public class OperationsService extends Service {
     
     public static final String EXTRA_ACCOUNT = "ACCOUNT";
     public static final String EXTRA_SERVER_URL = "SERVER_URL";
-    public static final String EXTRA_AUTH_TOKEN_TYPE = "AUTH_TOKEN_TYPE";
     public static final String EXTRA_OAUTH2_QUERY_PARAMETERS = "OAUTH2_QUERY_PARAMETERS";
     public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
     public static final String EXTRA_SEND_INTENT = "SEND_INTENT";
@@ -331,10 +330,7 @@ public class OperationsService extends Service {
                         
                     } else if (action.equals(ACTION_GET_SERVER_INFO)) { 
                         // check OC server and get basic information from it
-                        String authTokenType = 
-                                operationIntent.getStringExtra(EXTRA_AUTH_TOKEN_TYPE);
-                        operation = new GetServerInfoOperation(
-                                serverUrl, authTokenType, OperationsService.this);
+                        operation = new GetServerInfoOperation(serverUrl, OperationsService.this);
                         
                     } else if (action.equals(ACTION_OAUTH2_GET_ACCESS_TOKEN)) {
                         /// GET ACCESS TOKEN to the OAuth server
@@ -349,7 +345,7 @@ public class OperationsService extends Service {
                     } else if (action.equals(ACTION_EXISTENCE_CHECK)) {
                         // Existence Check 
                         String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
-                        boolean successIfAbsent = operationIntent.getBooleanExtra(EXTRA_SUCCESS_IF_ABSENT, true);
+                        boolean successIfAbsent = operationIntent.getBooleanExtra(EXTRA_SUCCESS_IF_ABSENT, false);
                         operation = new ExistenceCheckRemoteOperation(remotePath, OperationsService.this, successIfAbsent);
                         
                     } else if (action.equals(ACTION_GET_USER_NAME)) {
@@ -475,16 +471,19 @@ public class OperationsService extends Service {
                                         getContentResolver());
                     } else {
                         OwnCloudCredentials credentials = null;
-                        if (mLastTarget.mUsername != null) {
+                        if (mLastTarget.mUsername != null && 
+                                mLastTarget.mUsername.length() > 0) {
                             credentials = OwnCloudCredentialsFactory.newBasicCredentials(
                                     mLastTarget.mUsername, 
                                     mLastTarget.mPassword);  // basic
                             
-                        } else if (mLastTarget.mAuthToken != null) {
+                        } else if (mLastTarget.mAuthToken != null && 
+                                mLastTarget.mAuthToken.length() > 0) {
                             credentials = OwnCloudCredentialsFactory.newBearerCredentials(
                                     mLastTarget.mAuthToken);  // bearer token
                             
-                        } else if (mLastTarget.mCookie != null) {
+                        } else if (mLastTarget.mCookie != null &&
+                                mLastTarget.mCookie.length() > 0) {
                             credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials(
                                     mLastTarget.mCookie); // SAML SSO
                         }