Loading library/src/main/java/com/nextcloud/common/NextcloudClient.kt +6 −7 Original line number Diff line number Diff line Loading @@ -48,8 +48,6 @@ import okhttp3.OkHttpClient import okhttp3.Request import org.apache.commons.httpclient.HttpStatus import java.io.IOException import java.net.MalformedURLException import java.net.URL import java.net.InetSocketAddress import java.net.Proxy import java.util.concurrent.TimeUnit Loading Loading @@ -126,7 +124,8 @@ class NextcloudClient private constructor( @Suppress("TooGenericExceptionCaught") fun <T> execute(remoteOperation: RemoteOperation<T>): RemoteOperationResult<T> { val result = try { val result = try { remoteOperation.run(this) } catch (ex: Exception) { RemoteOperationResult(ex) Loading library/src/main/java/com/nextcloud/common/PlainClient.kt +1 −1 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ package com.nextcloud.common import android.content.Context import android.text.TextUtils import com.owncloud.android.lib.common.OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT_LONG import com.owncloud.android.lib.common.network.AdvancedX509KeyManager import com.owncloud.android.lib.common.OwnCloudClientManagerFactory import com.owncloud.android.lib.common.network.AdvancedX509KeyManager import com.owncloud.android.lib.common.network.AdvancedX509TrustManager import com.owncloud.android.lib.common.network.NetworkUtils import com.owncloud.android.lib.common.utils.Log_OC Loading library/src/main/java/com/owncloud/android/lib/common/network/AdvancedX509KeyManager.java +25 −12 Original line number Diff line number Diff line Loading @@ -23,6 +23,10 @@ THE SOFTWARE. */ package com.owncloud.android.lib.common.network; import static android.Manifest.permission.POST_NOTIFICATIONS; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static com.owncloud.android.lib.common.network.AdvancedX509KeyManager.AKMAlias.Type.KEYCHAIN; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; Loading @@ -37,6 +41,12 @@ import android.security.KeyChainException; import android.util.SparseArray; import android.webkit.ClientCertRequest; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.core.app.ActivityCompat; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import com.owncloud.android.lib.R; import com.owncloud.android.lib.common.utils.Log_OC; Loading @@ -57,6 +67,7 @@ import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.LinkedList; import java.util.List; Loading @@ -66,17 +77,9 @@ import java.util.Set; import javax.net.ssl.X509ExtendedKeyManager; import javax.net.ssl.X509KeyManager; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.core.app.ActivityCompat; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import okhttp3.HttpUrl; import static android.Manifest.permission.POST_NOTIFICATIONS; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static com.owncloud.android.lib.common.network.AdvancedX509KeyManager.AKMAlias.Type.KEYCHAIN; /** * AdvancedX509KeyManager is an implementation of X509KeyManager that handles key management, * as well as user interaction to select an TLS client certificate, and also persist the selection. Loading Loading @@ -563,6 +566,7 @@ public class AdvancedX509KeyManager * @param port port of connection * @return decision object with result of user interaction */ @SuppressFBWarnings({"UW", "WA"}) private @NonNull AKMDecision interactClientCert(@NonNull final String hostname, final int port) { Log_OC.d(TAG, "interactClientCert(hostname=" + hostname + ", port=" + port + ")"); Loading Loading @@ -657,6 +661,10 @@ public class AdvancedX509KeyManager return prefix; } /** * @throws IllegalArgumentException if prefix is unknown */ @SuppressFBWarnings("DRE") public static Type parse(String prefix) throws IllegalArgumentException { for (Type type : Type.values()) { if (type.getPrefix().equals(prefix)) { Loading Loading @@ -728,10 +736,10 @@ public class AdvancedX509KeyManager constructedAlias.append(type.getPrefix()); constructedAlias.append(alias); if (hostname != null) { constructedAlias.append(":"); constructedAlias.append(':'); constructedAlias.append(hostname); if (port != null) { constructedAlias.append(":"); constructedAlias.append(':'); constructedAlias.append(port); } } Loading @@ -749,6 +757,11 @@ public class AdvancedX509KeyManager Objects.equals(port, other.port); } @Override public int hashCode() { return Objects.hash(type, alias, hostname, port); } /** * @param filter AKMAlias object used as filter * @return true if each non-null field of filter equals the same field of this instance; false otherwise Loading Loading @@ -821,7 +834,7 @@ public class AdvancedX509KeyManager } public static Set<KeyType> parse(Iterable<String> keyTypes) { Set<KeyType> keyTypeSet = new HashSet<>(); EnumSet<KeyType> keyTypeSet = EnumSet.noneOf(KeyType.class); if (keyTypes != null) { for (String keyType : keyTypes) { keyTypeSet.add(parse(keyType)); Loading library/src/test/java/com/owncloud/android/lib/common/network/AdvancedX509KeyManagerTests.kt +0 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,6 @@ private const val HOST_SAME = "hostname" private const val HOST_OTHER = "hostname1" class AdvancedX509KeyManagerTests { @Test fun testAKMAliasMatches() { val akmAlias1 = AKMAlias(AKMAlias.Type.KEYCHAIN, ALIAS_SAME, HOST_SAME, PORT_SAME) Loading Loading
library/src/main/java/com/nextcloud/common/NextcloudClient.kt +6 −7 Original line number Diff line number Diff line Loading @@ -48,8 +48,6 @@ import okhttp3.OkHttpClient import okhttp3.Request import org.apache.commons.httpclient.HttpStatus import java.io.IOException import java.net.MalformedURLException import java.net.URL import java.net.InetSocketAddress import java.net.Proxy import java.util.concurrent.TimeUnit Loading Loading @@ -126,7 +124,8 @@ class NextcloudClient private constructor( @Suppress("TooGenericExceptionCaught") fun <T> execute(remoteOperation: RemoteOperation<T>): RemoteOperationResult<T> { val result = try { val result = try { remoteOperation.run(this) } catch (ex: Exception) { RemoteOperationResult(ex) Loading
library/src/main/java/com/nextcloud/common/PlainClient.kt +1 −1 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ package com.nextcloud.common import android.content.Context import android.text.TextUtils import com.owncloud.android.lib.common.OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT_LONG import com.owncloud.android.lib.common.network.AdvancedX509KeyManager import com.owncloud.android.lib.common.OwnCloudClientManagerFactory import com.owncloud.android.lib.common.network.AdvancedX509KeyManager import com.owncloud.android.lib.common.network.AdvancedX509TrustManager import com.owncloud.android.lib.common.network.NetworkUtils import com.owncloud.android.lib.common.utils.Log_OC Loading
library/src/main/java/com/owncloud/android/lib/common/network/AdvancedX509KeyManager.java +25 −12 Original line number Diff line number Diff line Loading @@ -23,6 +23,10 @@ THE SOFTWARE. */ package com.owncloud.android.lib.common.network; import static android.Manifest.permission.POST_NOTIFICATIONS; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static com.owncloud.android.lib.common.network.AdvancedX509KeyManager.AKMAlias.Type.KEYCHAIN; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; Loading @@ -37,6 +41,12 @@ import android.security.KeyChainException; import android.util.SparseArray; import android.webkit.ClientCertRequest; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.core.app.ActivityCompat; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import com.owncloud.android.lib.R; import com.owncloud.android.lib.common.utils.Log_OC; Loading @@ -57,6 +67,7 @@ import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.LinkedList; import java.util.List; Loading @@ -66,17 +77,9 @@ import java.util.Set; import javax.net.ssl.X509ExtendedKeyManager; import javax.net.ssl.X509KeyManager; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.core.app.ActivityCompat; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import okhttp3.HttpUrl; import static android.Manifest.permission.POST_NOTIFICATIONS; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static com.owncloud.android.lib.common.network.AdvancedX509KeyManager.AKMAlias.Type.KEYCHAIN; /** * AdvancedX509KeyManager is an implementation of X509KeyManager that handles key management, * as well as user interaction to select an TLS client certificate, and also persist the selection. Loading Loading @@ -563,6 +566,7 @@ public class AdvancedX509KeyManager * @param port port of connection * @return decision object with result of user interaction */ @SuppressFBWarnings({"UW", "WA"}) private @NonNull AKMDecision interactClientCert(@NonNull final String hostname, final int port) { Log_OC.d(TAG, "interactClientCert(hostname=" + hostname + ", port=" + port + ")"); Loading Loading @@ -657,6 +661,10 @@ public class AdvancedX509KeyManager return prefix; } /** * @throws IllegalArgumentException if prefix is unknown */ @SuppressFBWarnings("DRE") public static Type parse(String prefix) throws IllegalArgumentException { for (Type type : Type.values()) { if (type.getPrefix().equals(prefix)) { Loading Loading @@ -728,10 +736,10 @@ public class AdvancedX509KeyManager constructedAlias.append(type.getPrefix()); constructedAlias.append(alias); if (hostname != null) { constructedAlias.append(":"); constructedAlias.append(':'); constructedAlias.append(hostname); if (port != null) { constructedAlias.append(":"); constructedAlias.append(':'); constructedAlias.append(port); } } Loading @@ -749,6 +757,11 @@ public class AdvancedX509KeyManager Objects.equals(port, other.port); } @Override public int hashCode() { return Objects.hash(type, alias, hostname, port); } /** * @param filter AKMAlias object used as filter * @return true if each non-null field of filter equals the same field of this instance; false otherwise Loading Loading @@ -821,7 +834,7 @@ public class AdvancedX509KeyManager } public static Set<KeyType> parse(Iterable<String> keyTypes) { Set<KeyType> keyTypeSet = new HashSet<>(); EnumSet<KeyType> keyTypeSet = EnumSet.noneOf(KeyType.class); if (keyTypes != null) { for (String keyType : keyTypes) { keyTypeSet.add(parse(keyType)); Loading
library/src/test/java/com/owncloud/android/lib/common/network/AdvancedX509KeyManagerTests.kt +0 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,6 @@ private const val HOST_SAME = "hostname" private const val HOST_OTHER = "hostname1" class AdvancedX509KeyManagerTests { @Test fun testAKMAliasMatches() { val akmAlias1 = AKMAlias(AKMAlias.Type.KEYCHAIN, ALIAS_SAME, HOST_SAME, PORT_SAME) Loading