Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 80671c76 authored by tobiasKaminsky's avatar tobiasKaminsky
Browse files

Revert "remove version dependency as NC can this in all supported version"

This reverts commit 5ff61fcc.
parent 7c0f0b51
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import android.accounts.OperationCanceledException;
import android.content.Context;

import com.owncloud.android.lib.common.accounts.AccountUtils;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import java.io.IOException;

@@ -28,7 +29,18 @@ public class DynamicSessionManager implements OwnCloudClientManager {
            throws AccountUtils.AccountNotFoundException,
            OperationCanceledException, AuthenticatorException, IOException {

        OwnCloudVersion ownCloudVersion = null;
        if (account.getSavedAccount() != null) {
            ownCloudVersion = AccountUtils.getServerVersionForAccount(
                    account.getSavedAccount(), context
            );
        }

        if (ownCloudVersion != null && ownCloudVersion.isPreemptiveAuthenticationPreferred()) {
            return mSingleSessionManager.getClientFor(account, context);
        } else {
            return mSimpleFactoryManager.getClientFor(account, context);
        }
    }

    @Override
+10 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.owncloud.android.lib.common.accounts.AccountUtils;
import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
import com.owncloud.android.lib.common.network.NetworkUtils;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import java.io.IOException;
import java.security.GeneralSecurityException;
@@ -110,7 +111,11 @@ public class OwnCloudClientFactory {
            		AccountTypeUtils.getAuthTokenTypePass(account.type), 
            		false);

            OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password);
            OwnCloudVersion version = AccountUtils.getServerVersionForAccount(account, appContext);

            OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials(
                    username, password, (version != null && version.isPreemptiveAuthenticationPreferred()));

            client.setCredentials(credentials);
        }
        
@@ -183,7 +188,10 @@ public class OwnCloudClientFactory {
            Bundle result = future.getResult();
            String password = result.getString(AccountManager.KEY_AUTHTOKEN);

            OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password);
            OwnCloudVersion version = AccountUtils.getServerVersionForAccount(account, appContext);
            OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials(
                    username, password, (version != null && version.isPreemptiveAuthenticationPreferred()));

            client.setCredentials(credentials);
        }
        
+5 −1
Original line number Diff line number Diff line
@@ -31,7 +31,11 @@ public class OwnCloudCredentialsFactory {
	private static OwnCloudAnonymousCredentials sAnonymousCredentials;

	public static OwnCloudCredentials newBasicCredentials(String username, String password) {
		return new OwnCloudBasicCredentials(username, password, true);
		return new OwnCloudBasicCredentials(username, password);
	}

    public static OwnCloudCredentials newBasicCredentials(String username, String password, boolean preemptiveMode) {
        return new OwnCloudBasicCredentials(username, password, preemptiveMode);
    }

    public static OwnCloudCredentials newBearerCredentials(String authToken) {
+2 −1
Original line number Diff line number Diff line
@@ -231,7 +231,8 @@ public class AccountUtils {
					AccountTypeUtils.getAuthTokenTypePass(account.type),
					false);

			credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password);
			credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password,
					version.isPreemptiveAuthenticationPreferred());
		}
        
        return credentials;
+4 −0
Original line number Diff line number Diff line
@@ -174,6 +174,10 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
        return (mVersion >= MINIMUM_VERSION_WITH_NOT_RESHAREABLE_FEDERATED);
    }

    public boolean isPreemptiveAuthenticationPreferred() {
        return (mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING);
    }

    public boolean isSelfSupported() {
        return (mVersion >= MINIMUM_VERSION_FOR_SELF_API);
    }