From 8de65ef83cb3d85199cd3ddbde403f8e8bb19d74 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Tue, 19 Sep 2023 10:50:39 +0200 Subject: [PATCH 01/16] add dependabot config --- .github/dependabot.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..505ccc1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,22 @@ +version: 2 +updates: + - package-ecosystem: "maven" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "06:00" + timezone: "UTC" + groups: + maven-dependencies: + patterns: + - "*" + + - package-ecosystem: "github-actions" + directory: "/" # even for `.github/workflows` + schedule: + interval: "monthly" + groups: + github-actions: + patterns: + - "*" \ No newline at end of file From 01cd33b55690cd6f675e31755cd641b1e2f678fe Mon Sep 17 00:00:00 2001 From: Ralph Plawetzki Date: Thu, 21 Sep 2023 15:24:12 +0200 Subject: [PATCH 02/16] Update to appindicator based on JDK 21 --- .github/workflows/build.yml | 2 +- .github/workflows/publish-central.yml | 2 +- .github/workflows/publish-github.yml | 2 +- .idea/misc.xml | 2 +- pom.xml | 4 ++-- .../linux/tray/AppindicatorTrayMenuController.java | 14 ++++++-------- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index feb2e11..f670643 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 20 + java-version: 21 cache: 'maven' - name: Ensure to use tagged version if: startsWith(github.ref, 'refs/tags/') diff --git a/.github/workflows/publish-central.yml b/.github/workflows/publish-central.yml index d9121a2..4798137 100644 --- a/.github/workflows/publish-central.yml +++ b/.github/workflows/publish-central.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 20 + java-version: 21 cache: 'maven' server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml server-username: MAVEN_USERNAME # env variable for username in deploy diff --git a/.github/workflows/publish-github.yml b/.github/workflows/publish-github.yml index c0af882..991171f 100644 --- a/.github/workflows/publish-github.yml +++ b/.github/workflows/publish-github.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 20 + java-version: 21 cache: 'maven' gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase diff --git a/.idea/misc.xml b/.idea/misc.xml index 8c0cac2..ae1fcde 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2d8ba79..7b1cdd1 100644 --- a/pom.xml +++ b/pom.xml @@ -36,14 +36,14 @@ UTF-8 - 20 + 21 1.3.0 1.8.1-jdk17 1.3.2 - 1.3.4 + 1.3.6 32.0.0-jre 1.7.36 3.12.0 diff --git a/src/main/java/org/cryptomator/linux/tray/AppindicatorTrayMenuController.java b/src/main/java/org/cryptomator/linux/tray/AppindicatorTrayMenuController.java index 3fd8ea2..66daabc 100644 --- a/src/main/java/org/cryptomator/linux/tray/AppindicatorTrayMenuController.java +++ b/src/main/java/org/cryptomator/linux/tray/AppindicatorTrayMenuController.java @@ -1,6 +1,5 @@ package org.cryptomator.linux.tray; -import org.apache.commons.lang3.StringUtils; import org.cryptomator.integrations.common.CheckAvailability; import org.cryptomator.integrations.common.OperatingSystem; import org.cryptomator.integrations.common.Priority; @@ -16,7 +15,6 @@ import java.lang.foreign.Arena; import java.lang.foreign.MemorySegment; -import java.lang.foreign.SegmentScope; import java.util.List; import java.util.Optional; import java.util.function.Consumer; @@ -30,7 +28,7 @@ public class AppindicatorTrayMenuController implements TrayMenuController { private static final String APP_INDICATOR_ID = "org.cryptomator.Cryptomator"; private static final String SVG_SOURCE_PROPERTY = "cryptomator.integrationsLinux.trayIconsDir"; - private static final SegmentScope SCOPE = SegmentScope.global(); + private static final Arena ARENA = Arena.global(); private MemorySegment indicator; private MemorySegment menu = gtk_menu_new(); private Optional svgSourcePath; @@ -49,7 +47,7 @@ public void showTrayIcon(Consumer iconLoader, Runnable runnable, } private void showTrayIconWithSVG(String s) { - try (var arena = Arena.openConfined()) { + try (var arena = Arena.ofConfined()) { svgSourcePath = Optional.ofNullable(System.getProperty(SVG_SOURCE_PROPERTY)); // flatpak if (svgSourcePath.isEmpty()) { @@ -74,7 +72,7 @@ public void updateTrayIcon(Consumer iconLoader) { } private void updateTrayIconWithSVG(String s) { - try (var arena = Arena.openConfined()) { + try (var arena = Arena.ofConfined()) { app_indicator_set_icon(indicator, arena.allocateUtf8String(s)); } } @@ -97,11 +95,11 @@ private void addChildren(MemorySegment menu, List items) { switch (item) { case ActionItem a -> { var gtkMenuItem = gtk_menu_item_new(); - try (var arena = Arena.openConfined()) { + try (var arena = Arena.ofConfined()) { gtk_menu_item_set_label(gtkMenuItem, arena.allocateUtf8String(a.title())); g_signal_connect_object(gtkMenuItem, arena.allocateUtf8String("activate"), - GCallback.allocate(new ActionItemCallback(a), SCOPE), + GCallback.allocate(new ActionItemCallback(a), ARENA), menu, 0); } @@ -114,7 +112,7 @@ private void addChildren(MemorySegment menu, List items) { case SubMenuItem s -> { var gtkMenuItem = gtk_menu_item_new(); var gtkSubmenu = gtk_menu_new(); - try (var arena = Arena.openConfined()) { + try (var arena = Arena.ofConfined()) { gtk_menu_item_set_label(gtkMenuItem, arena.allocateUtf8String(s.title())); } addChildren(gtkSubmenu, s.items()); From 7fbd19876bb52c4227a52af01a98498a7137f843 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Mon, 25 Sep 2023 10:21:10 +0200 Subject: [PATCH 03/16] bump java version of codeql action --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index cc951ea..7cdeccf 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 20 + java-version: 21 cache: 'maven' - name: Initialize CodeQL uses: github/codeql-action/init@v2 From 6103e19afad65e8bc006217dd649ad5fb9bff7e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 08:40:57 +0000 Subject: [PATCH 04/16] Bump the github-actions group with 1 update (#27) --- .github/workflows/build.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/publish-central.yml | 2 +- .github/workflows/publish-github.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f670643..1a0570b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-java@v3 with: distribution: 'zulu' diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7cdeccf..c034e1b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 2 - uses: actions/setup-java@v3 diff --git a/.github/workflows/publish-central.yml b/.github/workflows/publish-central.yml index 4798137..82a7b01 100644 --- a/.github/workflows/publish-central.yml +++ b/.github/workflows/publish-central.yml @@ -10,7 +10,7 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: "refs/tags/${{ github.event.inputs.tag }}" - uses: actions/setup-java@v3 diff --git a/.github/workflows/publish-github.yml b/.github/workflows/publish-github.yml index 991171f..8233d08 100644 --- a/.github/workflows/publish-github.yml +++ b/.github/workflows/publish-github.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') # only allow publishing tagged versions steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-java@v3 with: distribution: 'zulu' From bb85ace5778b0e6ea891c59f7738782a574d93f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 08:41:49 +0000 Subject: [PATCH 05/16] Bump the maven-dependencies group with 13 updates (#31) --- pom.xml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 7b1cdd1..a8c1b13 100644 --- a/pom.xml +++ b/pom.xml @@ -44,15 +44,15 @@ 1.8.1-jdk17 1.3.2 1.3.6 - 32.0.0-jre - 1.7.36 - 3.12.0 + 32.1.2-jre + 2.0.9 + 3.13.0 - 5.8.2 + 5.10.0 - 8.2.1 + 8.4.0 1.6.8 @@ -107,7 +107,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.9.0 + 3.11.0 ${project.jdk.version} @@ -118,12 +118,12 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 + 3.1.2 org.apache.maven.plugins maven-enforcer-plugin - 3.0.0 + 3.4.1 check-preconditions @@ -144,7 +144,7 @@ maven-source-plugin - 3.2.1 + 3.3.0 attach-sources @@ -156,7 +156,7 @@ maven-javadoc-plugin - 3.3.1 + 3.6.0 attach-javadocs @@ -248,7 +248,7 @@ maven-gpg-plugin - 3.0.1 + 3.1.0 sign-artifacts @@ -283,7 +283,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.13 true ossrh @@ -309,7 +309,7 @@ org.apache.maven.plugins maven-deploy-plugin - 3.1.0 + 3.1.1 From 5e789bdfce0f4636d54249c156bdd44b10edfe07 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Mon, 25 Sep 2023 10:42:49 +0200 Subject: [PATCH 06/16] prepare 1.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a8c1b13..7cb68c4 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.cryptomator integrations-linux - 1.4.0-SNAPSHOT + 1.4.0 integrations-linux Provides optional Linux services used by Cryptomator From 1020ab328c9bd3894f6f1524315572ab4c1af842 Mon Sep 17 00:00:00 2001 From: Ralph Plawetzki Date: Tue, 3 Oct 2023 18:37:17 +0200 Subject: [PATCH 07/16] Update to secret service 2.0.0-alpha --- pom.xml | 2 +- src/main/java/module-info.java | 2 +- .../linux/keychain/SecretServiceKeychainAccess.java | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index a8c1b13..e89be47 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ 1.3.0 - 1.8.1-jdk17 + 2.0.0-alpha 1.3.2 1.3.6 32.1.2-jre diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index a649eb4..6116212 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -14,7 +14,7 @@ requires org.freedesktop.dbus; requires org.purejava.appindicator; requires org.purejava.kwallet; - requires secret.service; + requires de.swiesend.secretservice; provides KeychainAccessProvider with SecretServiceKeychainAccess, KDEWalletKeychainAccess; provides RevealPathService with DBusSendRevealPathService; diff --git a/src/main/java/org/cryptomator/linux/keychain/SecretServiceKeychainAccess.java b/src/main/java/org/cryptomator/linux/keychain/SecretServiceKeychainAccess.java index d499b52..d52df08 100644 --- a/src/main/java/org/cryptomator/linux/keychain/SecretServiceKeychainAccess.java +++ b/src/main/java/org/cryptomator/linux/keychain/SecretServiceKeychainAccess.java @@ -1,12 +1,11 @@ package org.cryptomator.linux.keychain; +import de.swiesend.secretservice.simple.SimpleCollection; 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.freedesktop.dbus.exceptions.DBusConnectionException; import org.freedesktop.dbus.exceptions.DBusExecutionException; -import org.freedesktop.secret.simple.SimpleCollection; import java.io.IOException; import java.util.List; From 4affc0271bdcd0a390440a88320faca63c8fdcba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 13:32:08 +0000 Subject: [PATCH 08/16] Bump the maven-dependencies group with 1 update (#33) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a8c1b13..c12c873 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ 1.8.1-jdk17 1.3.2 1.3.6 - 32.1.2-jre + 32.1.3-jre 2.0.9 3.13.0 From f905b6b4f872e1340f08202bfc2f41406ef73d23 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 09:27:29 +0000 Subject: [PATCH 09/16] Bump the maven-dependencies group with 2 updates (#36) --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 93dab7c..2230a40 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,7 @@ 5.10.0 - 8.4.0 + 8.4.2 1.6.8 @@ -118,7 +118,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.1.2 + 3.2.1 org.apache.maven.plugins From 384e454ce939c9adc34a336ab9be69f2c67a34c1 Mon Sep 17 00:00:00 2001 From: Ralph Plawetzki Date: Mon, 30 Oct 2023 19:27:36 +0100 Subject: [PATCH 10/16] Update kdewallet to 1.3.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2230a40..a991bfc 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ 1.3.0 2.0.0-alpha - 1.3.2 + 1.3.3 1.3.6 32.1.3-jre 2.0.9 From 3073f2c623cbec297ac55c71fd8d16b1b047c7c8 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Tue, 28 Nov 2023 18:55:24 +0100 Subject: [PATCH 11/16] reduce and split up dependency update check --- .github/dependabot.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 505ccc1..78fd9bb 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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` From 0da3cee1d28e1dfd0baaf8488192410696e4f023 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:09:53 +0000 Subject: [PATCH 12/16] Bump the java-test-dependencies group with 1 update (#46) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a991bfc..9df6b0f 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ 3.13.0 - 5.10.0 + 5.10.1 8.4.2 From 6c00398ffc2e3c1bae8a6712fe85dba1d0bf8b81 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Wed, 29 Nov 2023 16:50:16 +0100 Subject: [PATCH 13/16] deactivate codeql run on dependabot commits --- .github/workflows/codeql-analysis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c034e1b..cc74a5d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,7 +13,8 @@ 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: From bcda16b647216ace72625f4a8ab70d17bbac87d3 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Thu, 30 Nov 2023 15:47:17 +0100 Subject: [PATCH 14/16] 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(); + } + } +} From 0f6a4260b6de8a1a968398e2c8de9805257f7dfe Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Thu, 30 Nov 2023 15:47:36 +0100 Subject: [PATCH 15/16] clean up code --- .../linux/keychain/KDEWalletKeychainAccess.java | 8 ++------ .../linux/tray/AppindicatorTrayMenuController.java | 9 ++++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/cryptomator/linux/keychain/KDEWalletKeychainAccess.java b/src/main/java/org/cryptomator/linux/keychain/KDEWalletKeychainAccess.java index 4d168d0..52e0771 100644 --- a/src/main/java/org/cryptomator/linux/keychain/KDEWalletKeychainAccess.java +++ b/src/main/java/org/cryptomator/linux/keychain/KDEWalletKeychainAccess.java @@ -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(); } } @@ -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); } diff --git a/src/main/java/org/cryptomator/linux/tray/AppindicatorTrayMenuController.java b/src/main/java/org/cryptomator/linux/tray/AppindicatorTrayMenuController.java index 66daabc..573d178 100644 --- a/src/main/java/org/cryptomator/linux/tray/AppindicatorTrayMenuController.java +++ b/src/main/java/org/cryptomator/linux/tray/AppindicatorTrayMenuController.java @@ -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 svgSourcePath; @CheckAvailability public static boolean isAvailable() { @@ -48,9 +47,9 @@ public void showTrayIcon(Consumer 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()); @@ -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)); } } } @@ -105,7 +104,7 @@ private void addChildren(MemorySegment menu, List items) { } gtk_menu_shell_append(menu, gtkMenuItem); } - case SeparatorItem separatorItem -> { + case SeparatorItem _ -> { var gtkSeparator = gtk_menu_item_new(); gtk_menu_shell_append(menu, gtkSeparator); } From 91e82fa89672898520a9d20362593bc6386e98b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 08:53:18 +0000 Subject: [PATCH 16/16] Bump the github-actions group with 1 update (#50) --- .github/workflows/build.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/publish-central.yml | 2 +- .github/workflows/publish-github.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1a0570b..115aa2e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index cc74a5d..d587876 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 2 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 21 diff --git a/.github/workflows/publish-central.yml b/.github/workflows/publish-central.yml index 82a7b01..7e8c25d 100644 --- a/.github/workflows/publish-central.yml +++ b/.github/workflows/publish-central.yml @@ -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 diff --git a/.github/workflows/publish-github.yml b/.github/workflows/publish-github.yml index 8233d08..2caf761 100644 --- a/.github/workflows/publish-github.yml +++ b/.github/workflows/publish-github.yml @@ -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