Skip to content

Commit

Permalink
Merge branch 'develop' into release/1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Dec 5, 2023
2 parents 1805df1 + 91e82fa commit 7663ccb
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 45 deletions.
19 changes: 16 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,27 @@ updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
day: "monday"
time: "06:00"
timezone: "UTC"
timezone: "Etc/UTC"
groups:
maven-dependencies:
java-test-dependencies:
patterns:
- "org.junit.jupiter:*"
maven-build-plugins:
patterns:
- "org.apache.maven.plugins:*"
- "org.owasp:dependency-check-maven"
- "org.sonatype.plugins:nexus-staging-maven-plugin"
java-production-dependencies:
patterns:
- "*"
exclude-patterns:
- "org.junit.jupiter:*"
- "org.apache.maven.plugins:*"
- "org.owasp:dependency-check-maven"
- "org.sonatype.plugins:nexus-staging-maven-plugin"

- package-ecosystem: "github-actions"
directory: "/" # even for `.github/workflows`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ jobs:
analyse:
name: Analyse
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
# dependeabot has on push events only read-only access, but codeql requires write access
if: ${{ !(github.actor == 'dependabot[bot]' && contains(fromJSON('["push"]'), github.event_name)) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: "refs/tags/${{ github.event.inputs.tag }}"
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/') # only allow publishing tagged versions
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
Expand Down
21 changes: 4 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,15 @@

<api.version>1.3.0</api.version>
<secret-service.version>2.0.0-alpha</secret-service.version>
<kdewallet.version>1.3.2</kdewallet.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.0</junit.version>
<junit.version>5.10.1</junit.version>

<!-- build plugin dependencies -->
<dependency-check.version>8.4.0</dependency-check.version>
<dependency-check.version>8.4.2</dependency-check.version>
<nexus-staging.version>1.6.8</nexus-staging.version>
</properties>

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 Expand Up @@ -118,7 +105,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</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 Expand Up @@ -95,11 +95,7 @@ private static DBusConnection getNewConnection() throws DBusException {
} catch (DBusConnectionException | DBusExecutionException de) {
LOG.warn("Connecting to SESSION bus failed.", de);
LOG.warn("Falling back to SYSTEM DBus");
try {
return DBusConnectionBuilder.forSystemBus().build();
} catch (DBusException e) {
throw e;
}
return DBusConnectionBuilder.forSystemBus().build();
}
}

Expand Down Expand Up @@ -144,7 +140,7 @@ public char[] loadPassphrase(String key) throws KeychainAccessException {
} else {
LOG.debug("loadPassphrase: wallet is closed.");
}
return (password.equals("")) ? null : password.toCharArray();
return (password.isEmpty()) ? null : password.toCharArray();
} catch (RuntimeException e) {
throw new KeychainAccessException("Loading the passphrase failed.", e);
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class AppindicatorTrayMenuController implements TrayMenuController {
private static final Arena ARENA = Arena.global();
private MemorySegment indicator;
private MemorySegment menu = gtk_menu_new();
private Optional<String> svgSourcePath;

@CheckAvailability
public static boolean isAvailable() {
Expand All @@ -48,9 +47,9 @@ public void showTrayIcon(Consumer<TrayIconLoader> iconLoader, Runnable runnable,

private void showTrayIconWithSVG(String s) {
try (var arena = Arena.ofConfined()) {
svgSourcePath = Optional.ofNullable(System.getProperty(SVG_SOURCE_PROPERTY));
var svgSourcePath = System.getProperty(SVG_SOURCE_PROPERTY);
// flatpak
if (svgSourcePath.isEmpty()) {
if (svgSourcePath != null) {
indicator = app_indicator_new(arena.allocateUtf8String(APP_INDICATOR_ID),
arena.allocateUtf8String(s),
APP_INDICATOR_CATEGORY_APPLICATION_STATUS());
Expand All @@ -60,7 +59,7 @@ private void showTrayIconWithSVG(String s) {
arena.allocateUtf8String(s),
APP_INDICATOR_CATEGORY_APPLICATION_STATUS(),
// find tray icons theme in mounted AppImage / installed on system by ppa
arena.allocateUtf8String(svgSourcePath.get()));
arena.allocateUtf8String(svgSourcePath));
}
}
}
Expand Down Expand Up @@ -105,7 +104,7 @@ private void addChildren(MemorySegment menu, List<TrayMenuItem> items) {
}
gtk_menu_shell_append(menu, gtkMenuItem);
}
case SeparatorItem separatorItem -> {
case SeparatorItem _ -> {
var gtkSeparator = gtk_menu_item_new();
gtk_menu_shell_append(menu, gtkSeparator);
}
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 7663ccb

Please sign in to comment.