Skip to content

Commit

Permalink
removes unused/unnecessary dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Nov 30, 2023
1 parent 6c00398 commit bcda16b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
13 changes: 0 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
<secret-service.version>2.0.0-alpha</secret-service.version>
<kdewallet.version>1.3.3</kdewallet.version>
<appindicator.version>1.3.6</appindicator.version>
<guava.version>32.1.3-jre</guava.version>
<slf4j.version>2.0.9</slf4j.version>
<commons-lang3.version>3.13.0</commons-lang3.version>

<!-- test dependencies -->
<junit.version>5.10.1</junit.version>
Expand All @@ -67,11 +65,6 @@
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>de.swiesend</groupId>
<artifactId>secret-service</artifactId>
Expand All @@ -82,12 +75,6 @@
<artifactId>kdewallet</artifactId>
<version>${kdewallet.version}</version>
</dependency>
<!-- Apache Commons -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<!-- Java bindings for appindicator -->
<dependency>
<groupId>org.purejava</groupId>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/org/cryptomator/linux/util/CheckUtil.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
}

0 comments on commit bcda16b

Please sign in to comment.