diff --git a/library/build.gradle b/library/build.gradle index 75674482a..c1b373230 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -138,7 +138,7 @@ android { } defaultConfig { - minSdkVersion 14 + minSdkVersion 19 targetSdkVersion 35 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/library/src/main/java/com/nextcloud/common/OkHttpCredentialsUtil.kt b/library/src/main/java/com/nextcloud/common/OkHttpCredentialsUtil.kt deleted file mode 100644 index 9f22b37d5..000000000 --- a/library/src/main/java/com/nextcloud/common/OkHttpCredentialsUtil.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Nextcloud Android Library - * - * SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2021 Álvaro Brey - * SPDX-License-Identifier: MIT - */ -package com.nextcloud.common - -import android.os.Build -import okhttp3.Credentials -import java.nio.charset.StandardCharsets - -object OkHttpCredentialsUtil { - /** - * Builds basic OKHttp credentials string, using UTF_8 if available - */ - @JvmStatic - fun basic( - username: String, - password: String - ): String = - when { - Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT -> - Credentials.basic(username, password, StandardCharsets.UTF_8) - else -> Credentials.basic(username, password) - } -} diff --git a/library/src/main/java/com/owncloud/android/lib/common/OwnCloudAnonymousCredentials.java b/library/src/main/java/com/owncloud/android/lib/common/OwnCloudAnonymousCredentials.java index 2012e697e..c28062644 100644 --- a/library/src/main/java/com/owncloud/android/lib/common/OwnCloudAnonymousCredentials.java +++ b/library/src/main/java/com/owncloud/android/lib/common/OwnCloudAnonymousCredentials.java @@ -10,7 +10,9 @@ import android.os.Parcel; -import com.nextcloud.common.OkHttpCredentialsUtil; +import java.nio.charset.StandardCharsets; + +import okhttp3.Credentials; public class OwnCloudAnonymousCredentials implements OwnCloudCredentials { @@ -35,7 +37,7 @@ public boolean authTokenExpires() { @Override public String toOkHttpCredentials() { - return OkHttpCredentialsUtil.basic(getUsername(), getAuthToken()); + return Credentials.basic(getUsername(), getAuthToken(), StandardCharsets.UTF_8); } @Override diff --git a/library/src/main/java/com/owncloud/android/lib/common/OwnCloudBasicCredentials.java b/library/src/main/java/com/owncloud/android/lib/common/OwnCloudBasicCredentials.java index df5b87c1b..ea0b46222 100644 --- a/library/src/main/java/com/owncloud/android/lib/common/OwnCloudBasicCredentials.java +++ b/library/src/main/java/com/owncloud/android/lib/common/OwnCloudBasicCredentials.java @@ -14,15 +14,16 @@ import android.os.Parcel; -import com.nextcloud.common.OkHttpCredentialsUtil; - import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.auth.AuthPolicy; import org.apache.commons.httpclient.auth.AuthScope; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import okhttp3.Credentials; + public class OwnCloudBasicCredentials implements OwnCloudCredentials { private String username; @@ -59,11 +60,9 @@ public boolean authTokenExpires() { @Override public String toOkHttpCredentials() { - return OkHttpCredentialsUtil.basic(username, authToken); + return Credentials.basic(username, authToken, StandardCharsets.UTF_8); } - - /* * Autogenerated Parcelable interface */ diff --git a/library/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java b/library/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java index 42cfdff9b..61e5e8d47 100644 --- a/library/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java +++ b/library/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java @@ -23,7 +23,6 @@ import android.os.Bundle; import com.nextcloud.common.NextcloudClient; -import com.nextcloud.common.OkHttpCredentialsUtil; import com.nextcloud.common.User; import com.owncloud.android.lib.common.accounts.AccountTypeUtils; import com.owncloud.android.lib.common.accounts.AccountUtils; @@ -32,8 +31,11 @@ import com.owncloud.android.lib.common.utils.Log_OC; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; +import okhttp3.Credentials; + public class OwnCloudClientFactory { final private static String TAG = OwnCloudClientFactory.class.getSimpleName(); @@ -223,7 +225,7 @@ public static NextcloudClient createNextcloudClient(Account account, Context app return createNextcloudClient(baseUri, userId, - OkHttpCredentialsUtil.basic(username, password), + Credentials.basic(username, password, StandardCharsets.UTF_8), appContext, true); } diff --git a/sample_client/build.gradle b/sample_client/build.gradle index 951b1a1b8..11194545d 100644 --- a/sample_client/build.gradle +++ b/sample_client/build.gradle @@ -41,7 +41,7 @@ android { } defaultConfig { - minSdkVersion 14 + minSdkVersion 19 targetSdkVersion 35 multiDexEnabled true