From 38edbd260a788ef0982a9c609ce9f8244c4a6e82 Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Fri, 26 May 2023 19:56:59 +0200 Subject: [PATCH] Removed unused privateKey field from BaseLink --- src/org/kde/kdeconnect/Backends/BaseLink.java | 6 ------ src/org/kde/kdeconnect/Device.java | 13 ------------- 2 files changed, 19 deletions(-) diff --git a/src/org/kde/kdeconnect/Backends/BaseLink.java b/src/org/kde/kdeconnect/Backends/BaseLink.java index 6bfe9288..0f974eb0 100644 --- a/src/org/kde/kdeconnect/Backends/BaseLink.java +++ b/src/org/kde/kdeconnect/Backends/BaseLink.java @@ -15,7 +15,6 @@ import org.kde.kdeconnect.Device; import org.kde.kdeconnect.NetworkPacket; import java.io.IOException; -import java.security.PrivateKey; import java.util.ArrayList; @@ -29,7 +28,6 @@ public abstract class BaseLink { private final BaseLinkProvider linkProvider; private final String deviceId; private final ArrayList receivers = new ArrayList<>(); - protected PrivateKey privateKey; protected BaseLink(@NonNull Context context, @NonNull String deviceId, @NonNull BaseLinkProvider linkProvider) { this.context = context; @@ -45,10 +43,6 @@ public abstract class BaseLink { return deviceId; } - public void setPrivateKey(@NonNull PrivateKey key) { - privateKey = key; - } - public BaseLinkProvider getLinkProvider() { return linkProvider; } diff --git a/src/org/kde/kdeconnect/Device.java b/src/org/kde/kdeconnect/Device.java index 88b8349d..59dcc0ff 100644 --- a/src/org/kde/kdeconnect/Device.java +++ b/src/org/kde/kdeconnect/Device.java @@ -14,7 +14,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; import android.graphics.drawable.Drawable; -import android.preference.PreferenceManager; import android.util.Base64; import android.util.Log; @@ -39,10 +38,7 @@ import org.kde.kdeconnect.UserInterface.MainActivity; import org.kde.kdeconnect_tp.R; import java.io.IOException; -import java.security.KeyFactory; -import java.security.PrivateKey; import java.security.cert.Certificate; -import java.security.spec.PKCS8EncodedKeySpec; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -462,15 +458,6 @@ public class Device implements BaseLink.PacketReceiver { } } - try { - SharedPreferences globalSettings = PreferenceManager.getDefaultSharedPreferences(context); - byte[] privateKeyBytes = Base64.decode(globalSettings.getString("privateKey", ""), 0); - PrivateKey privateKey = KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(privateKeyBytes)); - link.setPrivateKey(privateKey); - } catch (Exception e) { - Log.e("KDE/Device", "Exception reading our own private key", e); //Should not happen - } - Log.i("KDE/Device", "addLink " + link.getLinkProvider().getName() + " -> " + getName() + " active links: " + links.size()); if (!pairingHandlers.containsKey(link.getName())) {