From bcda16b647216ace72625f4a8ab70d17bbac87d3 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Thu, 30 Nov 2023 15:47:17 +0100 Subject: [PATCH] removes unused/unnecessary dependencies --- pom.xml | 13 ---------- src/main/java/module-info.java | 2 -- .../keychain/KDEWalletKeychainAccess.java | 10 +++---- .../revealpath/DBusSendRevealPathService.java | 5 ++-- .../org/cryptomator/linux/util/CheckUtil.java | 26 +++++++++++++++++++ 5 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 src/main/java/org/cryptomator/linux/util/CheckUtil.java diff --git a/pom.xml b/pom.xml index 9df6b0f..f499a46 100644 --- a/pom.xml +++ b/pom.xml @@ -44,9 +44,7 @@ 2.0.0-alpha 1.3.3 1.3.6 - 32.1.3-jre 2.0.9 - 3.13.0 5.10.1 @@ -67,11 +65,6 @@ slf4j-api ${slf4j.version} - - com.google.guava - guava - ${guava.version} - de.swiesend secret-service @@ -82,12 +75,6 @@ kdewallet ${kdewallet.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - org.purejava diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 6116212..9ec0149 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -9,8 +9,6 @@ module org.cryptomator.integrations.linux { requires org.cryptomator.integrations.api; requires org.slf4j; - requires com.google.common; - requires org.apache.commons.lang3; requires org.freedesktop.dbus; requires org.purejava.appindicator; requires org.purejava.kwallet; diff --git a/src/main/java/org/cryptomator/linux/keychain/KDEWalletKeychainAccess.java b/src/main/java/org/cryptomator/linux/keychain/KDEWalletKeychainAccess.java index 5478199..4d168d0 100644 --- a/src/main/java/org/cryptomator/linux/keychain/KDEWalletKeychainAccess.java +++ b/src/main/java/org/cryptomator/linux/keychain/KDEWalletKeychainAccess.java @@ -1,10 +1,10 @@ package org.cryptomator.linux.keychain; -import com.google.common.base.Preconditions; import org.cryptomator.integrations.common.OperatingSystem; import org.cryptomator.integrations.common.Priority; import org.cryptomator.integrations.keychain.KeychainAccessException; import org.cryptomator.integrations.keychain.KeychainAccessProvider; +import org.cryptomator.linux.util.CheckUtil; import org.freedesktop.dbus.connections.impl.DBusConnection; import org.freedesktop.dbus.connections.impl.DBusConnectionBuilder; import org.freedesktop.dbus.exceptions.DBusConnectionException; @@ -49,25 +49,25 @@ public boolean isLocked() { @Override public void storePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException { - Preconditions.checkState(wallet.isPresent(), "Keychain not supported."); + CheckUtil.checkState(wallet.isPresent(), "Keychain not supported."); wallet.get().storePassphrase(key, passphrase); } @Override public char[] loadPassphrase(String key) throws KeychainAccessException { - Preconditions.checkState(wallet.isPresent(), "Keychain not supported."); + CheckUtil.checkState(wallet.isPresent(), "Keychain not supported."); return wallet.get().loadPassphrase(key); } @Override public void deletePassphrase(String key) throws KeychainAccessException { - Preconditions.checkState(wallet.isPresent(), "Keychain not supported."); + CheckUtil.checkState(wallet.isPresent(), "Keychain not supported."); wallet.get().deletePassphrase(key); } @Override public void changePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException { - Preconditions.checkState(wallet.isPresent(), "Keychain not supported."); + CheckUtil.checkState(wallet.isPresent(), "Keychain not supported."); wallet.get().changePassphrase(key, passphrase); } diff --git a/src/main/java/org/cryptomator/linux/revealpath/DBusSendRevealPathService.java b/src/main/java/org/cryptomator/linux/revealpath/DBusSendRevealPathService.java index 533a8e5..39529ff 100644 --- a/src/main/java/org/cryptomator/linux/revealpath/DBusSendRevealPathService.java +++ b/src/main/java/org/cryptomator/linux/revealpath/DBusSendRevealPathService.java @@ -1,6 +1,5 @@ package org.cryptomator.linux.revealpath; -import com.google.common.base.Preconditions; import org.cryptomator.integrations.revealpath.RevealFailedException; import org.cryptomator.integrations.revealpath.RevealPathService; @@ -91,7 +90,9 @@ public boolean isSupported() { * @throws IOException if the Inputer reader on the process output cannot be created */ private boolean parseOutputForFileManagerInterface(Process fileManager1Process) throws IOException { - Preconditions.checkState(!fileManager1Process.isAlive()); + if( fileManager1Process.isAlive()) { + throw new IllegalArgumentException("Process " + fileManager1Process + " must be terminated to read output."); + } try (var reader = fileManager1Process.inputReader(StandardCharsets.UTF_8)) { return reader.lines().map(String::trim).anyMatch(FILEMANAGER1_XML_ELEMENT::equals); } diff --git a/src/main/java/org/cryptomator/linux/util/CheckUtil.java b/src/main/java/org/cryptomator/linux/util/CheckUtil.java new file mode 100644 index 0000000..02cc829 --- /dev/null +++ b/src/main/java/org/cryptomator/linux/util/CheckUtil.java @@ -0,0 +1,26 @@ +package org.cryptomator.linux.util; + +public class CheckUtil { + + + /** + * Ensures the truth of an expression involving the state of the calling instance, but not + * involving any parameters to the calling method. + * + * @param expression a boolean expression + * @param errorMessage the exception message to use if the check fails; will be converted to a + * string using {@link String#valueOf(Object)} + * @throws IllegalStateException if {@code expression} is false + */ + public static void checkState(boolean expression, String errorMessage) { + if (!expression) { + throw new IllegalStateException(errorMessage); + } + } + + public static void checkState(boolean expression) { + if (!expression) { + throw new IllegalStateException(); + } + } +}