Compare commits

...

53 Commits

Author SHA1 Message Date
Armin Schrenk
1fb987607c use single method to initialize JavaFX 2025-01-21 17:03:42 +01:00
Armin Schrenk
5d4066d29a fix test 2025-01-21 16:01:49 +01:00
Armin Schrenk
d3909134d5 actually use authentication 2025-01-21 15:55:47 +01:00
Armin Schrenk
fd9d1bf0cf fix unit test 2025-01-16 10:49:57 +01:00
Armin Schrenk
2f812377c3 bump integrations-win to 1.4.1 to fix jvm crashes 2025-01-16 10:31:38 +01:00
Armin Schrenk
ebce90eb74 weakValues are too agressive 2025-01-15 10:02:42 +01:00
Armin Schrenk
c888b52ebb rely on the cache directly after unlock and inject in the cache on keychain changes 2025-01-15 10:02:21 +01:00
Armin Schrenk
e422c7ce4b use caffeine for building a cache
(cherry picked from commit fc709eb700)
2025-01-15 09:38:50 +01:00
Armin Schrenk
41ad8d5dcc response in th ui to keychain impl change 2025-01-14 18:42:08 +01:00
Armin Schrenk
526c3973d6 bump dependencies to add biometric auth providers
* integrations-win to 1.4.0
* integrations-mac to 1.3.0
2025-01-14 15:42:10 +01:00
Armin Schrenk
dc16c961af only store password, if it is not already stored 2025-01-14 15:41:17 +01:00
Ralph Plawetzki
c54a603078 Merge branch 'develop' into 2ndfactor 2025-01-11 17:59:54 +01:00
Ralph Plawetzki
be59097a53 Merge branch 'develop' into 2ndfactor 2024-12-14 07:37:30 +01:00
Ralph Plawetzki
ccc4842839 Use widened integrations-api 2024-12-02 08:16:28 +01:00
Ralph Plawetzki
d95625faa1 Revert "Add CheckBox to enable Touch ID per vault"
This reverts commit cfa3093dd0.
2024-12-02 08:12:03 +01:00
Ralph Plawetzki
c5bfdf32a9 Revert "Save Touch ID setting per vault"
This reverts commit 10bce1fb06.
2024-12-02 08:12:03 +01:00
Ralph Plawetzki
0598681a23 Revert "Decide on Touch ID setting whether user needs"
This reverts commit 2194360c8a.
2024-12-02 08:12:03 +01:00
Ralph Plawetzki
3b8bff0d47 Revert "loadPassphraseForAuthenticatedUser is not needed to"
This reverts commit 2378227756.
2024-12-02 08:12:02 +01:00
Ralph Plawetzki
55051072cb Revert "Actually save preference on checkbox change"
This reverts commit 62827b69cc.
2024-12-02 08:12:02 +01:00
Ralph Plawetzki
6cb409eeaf Revert "Grab new API"
This reverts commit 9516928529.
2024-12-02 08:12:02 +01:00
Ralph Plawetzki
b38a350c48 Revert "Remove log statement used for testing"
This reverts commit 14ba852351.
2024-12-02 08:12:02 +01:00
Ralph Plawetzki
0e5857015a Revert "Change existing keychain entry"
This reverts commit 9cc863ae79.
2024-12-02 08:12:02 +01:00
Ralph Plawetzki
9e9aa20692 Revert "Disable feature for other platforms than Mac"
This reverts commit d8b798ff0f.
2024-12-02 08:12:01 +01:00
Ralph Plawetzki
ad49ca2cb4 Revert "Generalize naming"
This reverts commit 953aee560f.
2024-12-02 08:12:01 +01:00
Ralph Plawetzki
ba84da71f3 Revert "Code cleanups following coderabbitai recommendations"
This reverts commit af3779ba2e.
2024-12-02 08:12:01 +01:00
Ralph Plawetzki
5c34f59d09 Revert "Don't use SNAPSHOTS"
This reverts commit 175ed500a2.
2024-12-02 08:12:01 +01:00
Ralph Plawetzki
7499867665 Revert "Use overloaded method storePassword instead of a new one"
This reverts commit aa34ad52e6.
2024-12-02 08:12:00 +01:00
Ralph Plawetzki
7b293b8082 Revert "New, widened integrations-api"
This reverts commit 2f1b5109d6.
2024-12-02 08:12:00 +01:00
Ralph Plawetzki
46e8a13555 Revert "Improve thread handling"
This reverts commit c8075dbc19.
2024-12-02 08:11:01 +01:00
Ralph Plawetzki
63a3150ec3 Revert "Remove unneeded saving a keychain entry right after"
This reverts commit e8126e68ce.
2024-12-02 08:11:01 +01:00
Ralph Plawetzki
0a78987d30 Revert "Fix typo"
This reverts commit 78675c9638.
2024-12-02 08:11:00 +01:00
Ralph Plawetzki
929782c318 Revert "Fix doubled method due to merge error"
This reverts commit b5dbfd3209.
2024-12-02 08:11:00 +01:00
Ralph Plawetzki
97a0f9c435 Migrate keychain entries on Mac on provider change 2024-12-02 07:56:23 +01:00
Ralph Plawetzki
f7e65f4eec Add cryptomator.integrationsWin.windowsHelloKeychainPaths to Environment 2024-11-30 14:39:56 +01:00
Ralph Plawetzki
b3c56f3aab Add Windows Hello provider 2024-11-30 12:25:36 +01:00
Ralph Plawetzki
b5dbfd3209 Fix doubled method due to merge error 2024-11-24 18:14:26 +01:00
Ralph Plawetzki
78675c9638 Fix typo 2024-11-24 15:02:06 +01:00
Ralph Plawetzki
e8126e68ce Remove unneeded saving a keychain entry right after
it was loaded
2024-11-24 15:02:06 +01:00
Ralph Plawetzki
c8075dbc19 Improve thread handling 2024-11-24 15:02:05 +01:00
Ralph Plawetzki
2f1b5109d6 New, widened integrations-api 2024-11-24 15:01:44 +01:00
Ralph Plawetzki
aa34ad52e6 Use overloaded method storePassword instead of a new one 2024-11-24 15:00:54 +01:00
Ralph Plawetzki
175ed500a2 Don't use SNAPSHOTS 2024-11-24 14:57:16 +01:00
Ralph Plawetzki
af3779ba2e Code cleanups following coderabbitai recommendations 2024-11-24 14:56:38 +01:00
Ralph Plawetzki
953aee560f Generalize naming 2024-11-24 14:56:38 +01:00
Ralph Plawetzki
d8b798ff0f Disable feature for other platforms than Mac 2024-11-24 14:56:38 +01:00
Ralph Plawetzki
9cc863ae79 Change existing keychain entry 2024-11-24 14:56:38 +01:00
Ralph Plawetzki
14ba852351 Remove log statement used for testing 2024-11-24 14:56:37 +01:00
Ralph Plawetzki
9516928529 Grab new API 2024-11-24 14:56:30 +01:00
Ralph Plawetzki
62827b69cc Actually save preference on checkbox change 2024-11-24 14:48:32 +01:00
Ralph Plawetzki
2378227756 loadPassphraseForAuthenticatedUser is not needed to
load as an authenticated user; loadPassphrase is
sufficient
2024-11-24 14:48:32 +01:00
Ralph Plawetzki
2194360c8a Decide on Touch ID setting whether user needs
to authenticate on loading and storing a passphrase
2024-11-24 14:48:32 +01:00
Ralph Plawetzki
10bce1fb06 Save Touch ID setting per vault 2024-11-24 14:48:32 +01:00
Ralph Plawetzki
cfa3093dd0 Add CheckBox to enable Touch ID per vault 2024-11-24 14:48:31 +01:00
14 changed files with 126 additions and 47 deletions

View File

@@ -130,6 +130,7 @@ jobs:
--java-options "-Dcryptomator.buildNumber=\"msi-${{ needs.get-version.outputs.revNum }}\""
--java-options "-Dcryptomator.integrationsWin.autoStartShellLinkName=\"Cryptomator\""
--java-options "-Dcryptomator.integrationsWin.keychainPaths=\"@{appdata}/Cryptomator/keychain.json;@{userhome}/AppData/Roaming/Cryptomator/keychain.json\""
--java-options "-Dcryptomator.integrationsWin.windowsHelloKeychainPaths=\"@{appdata}/Cryptomator/windowsHelloKeychain.json;@{userhome}/AppData/Roaming/Cryptomator/windowsHelloKeychain.json\""
--java-options "-Djavafx.verbose=${{ inputs.isDebug }}"
--resource-dir dist/win/resources
--icon dist/win/resources/Cryptomator.ico

View File

@@ -2,7 +2,7 @@
<configuration default="false" name="Cryptomator Windows" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="org.cryptomator.launcher.Cryptomator" />
<module name="cryptomator" />
<option name="VM_PARAMETERS" value="-Dcryptomator.settingsPath=&quot;@{appdata}/Cryptomator/settings.json;@{userhome}/AppData/Roaming/Cryptomator/settings.json&quot; -Dcryptomator.ipcSocketPath=&quot;@{localappdata}/Cryptomator/ipc.socket&quot; -Dcryptomator.logDir=&quot;@{localappdata}/Cryptomator&quot; -Dcryptomator.pluginDir=&quot;@{appdata}/Cryptomator/Plugins&quot; -Dcryptomator.integrationsWin.keychainPaths=&quot;@{appdata}/Cryptomator/keychain.json;@{userhome}/AppData/Roaming/Cryptomator/keychain.json&quot; -Dcryptomator.p12Path=&quot;@{appdata}/Cryptomator/key.p12;@{userhome}/AppData/Roaming/Cryptomator/key.p12&quot; -Dcryptomator.mountPointsDir=&quot;@{userhome}/Cryptomator&quot; -Dcryptomator.showTrayIcon=true -Xss2m -Xmx512m --enable-preview --enable-native-access=org.cryptomator.jfuse.win,org.cryptomator.integrations.win" />
<option name="VM_PARAMETERS" value="-Dcryptomator.settingsPath=&quot;@{appdata}/Cryptomator/settings.json;@{userhome}/AppData/Roaming/Cryptomator/settings.json&quot; -Dcryptomator.ipcSocketPath=&quot;@{localappdata}/Cryptomator/ipc.socket&quot; -Dcryptomator.logDir=&quot;@{localappdata}/Cryptomator&quot; -Dcryptomator.pluginDir=&quot;@{appdata}/Cryptomator/Plugins&quot; -Dcryptomator.integrationsWin.keychainPaths=&quot;@{appdata}/Cryptomator/keychain.json;@{userhome}/AppData/Roaming/Cryptomator/keychain.json&quot; -Dcryptomator.integrationsWin.windowsHelloKeychainPaths=&quot;@{appdata}/Cryptomator/windowsHelloKeychain.json;@{userhome}/AppData/Roaming/Cryptomator/windowsHelloKeychain.json&quot; -Dcryptomator.p12Path=&quot;@{appdata}/Cryptomator/key.p12;@{userhome}/AppData/Roaming/Cryptomator/key.p12&quot; -Dcryptomator.mountPointsDir=&quot;@{userhome}/Cryptomator&quot; -Dcryptomator.showTrayIcon=true -Xss2m -Xmx512m --enable-preview --enable-native-access=org.cryptomator.jfuse.win,org.cryptomator.integrations.win" />
<method v="2">
<option name="Make" enabled="true" />
</method>

View File

@@ -2,7 +2,7 @@
<configuration default="false" name="Cryptomator Windows Dev" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="org.cryptomator.launcher.Cryptomator" />
<module name="cryptomator" />
<option name="VM_PARAMETERS" value="-Dcryptomator.settingsPath=&quot;@{appdata}/Cryptomator-Dev/settings.json;@{userhome}/AppData/Roaming/Cryptomator-Dev/settings.json&quot; -Dcryptomator.ipcSocketPath=&quot;@{localappdata}/Cryptomator-Dev/ipc.socket&quot; -Dcryptomator.logDir=&quot;@{localappdata}/Cryptomator-Dev&quot; -Dcryptomator.pluginDir=&quot;@{appdata}/Cryptomator-Dev/Plugins&quot; -Dcryptomator.integrationsWin.keychainPaths=&quot;@{appdata}/Cryptomator-Dev/keychain.json;@{userhome}/AppData/Roaming/Cryptomator-Dev/keychain.json&quot; -Dcryptomator.p12Path=&quot;@{appdata}/Cryptomator-Dev/key.p12;@{userhome}/AppData/Roaming/Cryptomator-Dev/key.p12&quot; -Dcryptomator.mountPointsDir=&quot;@{userhome}/Cryptomator-Dev&quot; -Dcryptomator.showTrayIcon=true -Xss2m -Xmx512m --enable-preview --enable-native-access=org.cryptomator.jfuse.win,org.cryptomator.integrations.win" />
<option name="VM_PARAMETERS" value="-Dcryptomator.settingsPath=&quot;@{appdata}/Cryptomator-Dev/settings.json;@{userhome}/AppData/Roaming/Cryptomator-Dev/settings.json&quot; -Dcryptomator.ipcSocketPath=&quot;@{localappdata}/Cryptomator-Dev/ipc.socket&quot; -Dcryptomator.logDir=&quot;@{localappdata}/Cryptomator-Dev&quot; -Dcryptomator.pluginDir=&quot;@{appdata}/Cryptomator-Dev/Plugins&quot; -Dcryptomator.integrationsWin.keychainPaths=&quot;@{appdata}/Cryptomator-Dev/keychain.json;@{userhome}/AppData/Roaming/Cryptomator-Dev/keychain.json&quot; -Dcryptomator.integrationsWin.windowsHelloKeychainPaths=&quot;@{appdata}/Cryptomator-Dev/windowsHelloKeychain.json;@{userhome}/AppData/Roaming/Cryptomator-Dev/windowsHelloKeychain.json&quot; -Dcryptomator.p12Path=&quot;@{appdata}/Cryptomator-Dev/key.p12;@{userhome}/AppData/Roaming/Cryptomator-Dev/key.p12&quot; -Dcryptomator.mountPointsDir=&quot;@{userhome}/Cryptomator-Dev&quot; -Dcryptomator.showTrayIcon=true -Xss2m -Xmx512m --enable-preview --enable-native-access=org.cryptomator.jfuse.win,org.cryptomator.integrations.win" />
<method v="2">
<option name="Make" enabled="true" />
</method>

10
pom.xml
View File

@@ -35,8 +35,8 @@
<!-- cryptomator dependencies -->
<cryptomator.cryptofs.version>2.7.1</cryptomator.cryptofs.version>
<cryptomator.integrations.version>1.4.0</cryptomator.integrations.version>
<cryptomator.integrations.win.version>1.3.0</cryptomator.integrations.win.version>
<cryptomator.integrations.mac.version>1.2.4</cryptomator.integrations.mac.version>
<cryptomator.integrations.win.version>1.4.1</cryptomator.integrations.win.version>
<cryptomator.integrations.mac.version>1.3.0</cryptomator.integrations.mac.version>
<cryptomator.integrations.linux.version>1.5.1</cryptomator.integrations.linux.version>
<cryptomator.fuse.version>5.0.2</cryptomator.fuse.version>
<cryptomator.webdav.version>2.0.7</cryptomator.webdav.version>
@@ -201,6 +201,12 @@
<version>2.0.1</version>
</dependency>
<!-- Caffeine -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>3.1.8</version>
</dependency>
<!-- JUnit / Mockito / Hamcrest -->
<dependency>
<groupId>org.junit.jupiter</groupId>

View File

@@ -51,6 +51,7 @@ open module org.cryptomator.desktop {
requires jakarta.inject;
requires static javax.inject;
requires java.compiler;
requires com.github.benmanes.caffeine;
uses org.cryptomator.common.locationpresets.LocationPresetsProvider;

View File

@@ -0,0 +1,20 @@
package org.cryptomator;
import javafx.application.Platform;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class JavaFXUtil {
public static boolean startPlatform() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
try {
Platform.startup(latch::countDown);
} catch (IllegalStateException e) {
//already initialized
latch.countDown();
}
return latch.await(5, TimeUnit.SECONDS);
}
}

View File

@@ -23,6 +23,7 @@ public class Environment {
private static final String SETTINGS_PATH_PROP_NAME = "cryptomator.settingsPath";
private static final String IPC_SOCKET_PATH_PROP_NAME = "cryptomator.ipcSocketPath";
private static final String KEYCHAIN_PATHS_PROP_NAME = "cryptomator.integrationsWin.keychainPaths";
private static final String WINDOWS_HELLO_KEYCHAIN_PATHS_PROP_NAME = "cryptomator.integrationsWin.windowsHelloKeychainPaths";
private static final String P12_PATH_PROP_NAME = "cryptomator.p12Path";
private static final String LOG_DIR_PROP_NAME = "cryptomator.logDir";
private static final String LOOPBACK_ALIAS_PROP_NAME = "cryptomator.loopbackAlias";
@@ -45,6 +46,7 @@ public class Environment {
logCryptomatorSystemProperty(SETTINGS_PATH_PROP_NAME);
logCryptomatorSystemProperty(IPC_SOCKET_PATH_PROP_NAME);
logCryptomatorSystemProperty(KEYCHAIN_PATHS_PROP_NAME);
logCryptomatorSystemProperty(WINDOWS_HELLO_KEYCHAIN_PATHS_PROP_NAME);
logCryptomatorSystemProperty(P12_PATH_PROP_NAME);
logCryptomatorSystemProperty(LOG_DIR_PROP_NAME);
logCryptomatorSystemProperty(LOOPBACK_ALIAS_PROP_NAME);
@@ -85,6 +87,10 @@ public class Environment {
return getPaths(KEYCHAIN_PATHS_PROP_NAME);
}
public Stream<Path> getWindowsHelloKeychainPath() {
return getPaths(WINDOWS_HELLO_KEYCHAIN_PATHS_PROP_NAME);
}
public Stream<Path> getP12Path() {
return getPaths(P12_PATH_PROP_NAME);
}

View File

@@ -1,8 +1,7 @@
package org.cryptomator.common.keychain;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import org.cryptomator.integrations.keychain.KeychainAccessException;
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
@@ -24,9 +23,9 @@ public class KeychainManager implements KeychainAccessProvider {
@Inject
KeychainManager(ObjectExpression<KeychainAccessProvider> selectedKeychain) {
this.keychain = selectedKeychain;
this.passphraseStoredProperties = CacheBuilder.newBuilder() //
.weakValues() //
.build(CacheLoader.from(this::createStoredPassphraseProperty));
this.passphraseStoredProperties = Caffeine.newBuilder() //
.softValues() //
.build(this::createStoredPassphraseProperty);
keychain.addListener(ignored -> passphraseStoredProperties.invalidateAll());
}
@@ -44,8 +43,13 @@ public class KeychainManager implements KeychainAccessProvider {
}
@Override
public void storePassphrase(String key, String displayName, CharSequence passphrase, boolean ignored) throws KeychainAccessException {
getKeychainOrFail().storePassphrase(key, displayName, passphrase);
public void storePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException {
storePassphrase(key, displayName, passphrase, true); //TODO: currently only TouchID is using this parameter, so this is okayish
}
@Override
public void storePassphrase(String key, String displayName, CharSequence passphrase, boolean requireOsAuthentication) throws KeychainAccessException {
getKeychainOrFail().storePassphrase(key, displayName, passphrase, requireOsAuthentication);
setPassphraseStored(key, true);
}
@@ -102,13 +106,11 @@ public class KeychainManager implements KeychainAccessProvider {
}
private void setPassphraseStored(String key, boolean value) {
BooleanProperty property = passphraseStoredProperties.getIfPresent(key);
if (property != null) {
if (Platform.isFxApplicationThread()) {
property.set(value);
} else {
Platform.runLater(() -> property.set(value));
}
BooleanProperty property = passphraseStoredProperties.get(key, _ -> new SimpleBooleanProperty(value));
if (Platform.isFxApplicationThread()) {
property.set(value);
} else {
Platform.runLater(() -> property.set(value));
}
}
@@ -124,7 +126,7 @@ public class KeychainManager implements KeychainAccessProvider {
* @see #isPassphraseStored(String)
*/
public ReadOnlyBooleanProperty getPassphraseStoredProperty(String key) {
return passphraseStoredProperties.getUnchecked(key);
return passphraseStoredProperties.get(key);
}
private BooleanProperty createStoredPassphraseProperty(String key) {
@@ -135,4 +137,8 @@ public class KeychainManager implements KeychainAccessProvider {
}
}
public ObjectExpression<KeychainAccessProvider> getKeychainImplementation() {
return this.keychain;
}
}

View File

@@ -112,12 +112,12 @@ public class MasterkeyFileLoadingStrategy implements KeyLoadingStrategy {
}
private void savePasswordToSystemkeychain(Passphrase passphrase) {
if (keychain.isSupported()) {
try {
try {
if (keychain.isSupported() && !keychain.getPassphraseStoredProperty(vault.getId()).getValue()) {
keychain.storePassphrase(vault.getId(), vault.getDisplayName(), passphrase);
} catch (KeychainAccessException e) {
LOG.error("Failed to store passphrase in system keychain.", e);
}
} catch (KeychainAccessException e) {
LOG.error("Failed to store passphrase in system keychain.", e);
}
}

View File

@@ -8,9 +8,9 @@ import org.cryptomator.ui.vaultoptions.SelectedVaultOptionsTab;
import org.cryptomator.ui.vaultoptions.VaultOptionsComponent;
import javax.inject.Inject;
import javafx.beans.binding.Bindings;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.stage.Stage;
@@ -21,7 +21,6 @@ public class VaultDetailLockedController implements FxController {
private final ReadOnlyObjectProperty<Vault> vault;
private final FxApplicationWindows appWindows;
private final VaultOptionsComponent.Factory vaultOptionsWindow;
private final KeychainManager keychain;
private final Stage mainWindow;
private final ObservableValue<Boolean> passwordSaved;
@@ -30,13 +29,11 @@ public class VaultDetailLockedController implements FxController {
this.vault = vault;
this.appWindows = appWindows;
this.vaultOptionsWindow = vaultOptionsWindow;
this.keychain = keychain;
this.mainWindow = mainWindow;
if (keychain.isSupported() && !keychain.isLocked()) {
this.passwordSaved = vault.flatMap(v -> keychain.getPassphraseStoredProperty(v.getId())).orElse(false);
} else {
this.passwordSaved = new SimpleBooleanProperty(false);
}
this.passwordSaved = Bindings.createBooleanBinding(() -> {
var v = vault.get();
return v != null && keychain.getPassphraseStoredProperty(v.getId()).getValue();
}, vault, keychain.getKeychainImplementation());
}
@FXML

View File

@@ -1,10 +1,14 @@
package org.cryptomator.ui.preferences;
import org.apache.commons.lang3.SystemUtils;
import org.cryptomator.common.Environment;
import org.cryptomator.common.Passphrase;
import org.cryptomator.common.keychain.KeychainManager;
import org.cryptomator.common.settings.Settings;
import org.cryptomator.integrations.autostart.AutoStartProvider;
import org.cryptomator.integrations.autostart.ToggleAutoStartFailedException;
import org.cryptomator.integrations.common.NamedServiceProvider;
import org.cryptomator.integrations.keychain.KeychainAccessException;
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
import org.cryptomator.integrations.quickaccess.QuickAccessService;
import org.cryptomator.ui.common.FxController;
@@ -14,6 +18,7 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javafx.application.Application;
import javafx.beans.Observable;
import javafx.beans.binding.Bindings;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
@@ -36,6 +41,7 @@ public class GeneralPreferencesController implements FxController {
private final Application application;
private final Environment environment;
private final List<KeychainAccessProvider> keychainAccessProviders;
private final KeychainManager keychain;
private final FxApplicationWindows appWindows;
public CheckBox useKeychainCheckbox;
public ChoiceBox<KeychainAccessProvider> keychainBackendChoiceBox;
@@ -48,11 +54,12 @@ public class GeneralPreferencesController implements FxController {
public ToggleGroup nodeOrientation;
@Inject
GeneralPreferencesController(@PreferencesWindow Stage window, Settings settings, Optional<AutoStartProvider> autoStartProvider, List<KeychainAccessProvider> keychainAccessProviders, Application application, Environment environment, FxApplicationWindows appWindows) {
GeneralPreferencesController(@PreferencesWindow Stage window, Settings settings, Optional<AutoStartProvider> autoStartProvider, List<KeychainAccessProvider> keychainAccessProviders, KeychainManager keychain, Application application, Environment environment, FxApplicationWindows appWindows) {
this.window = window;
this.settings = settings;
this.autoStartProvider = autoStartProvider;
this.keychainAccessProviders = keychainAccessProviders;
this.keychain = keychain;
this.quickAccessServices = QuickAccessService.get().toList();
this.application = application;
this.environment = environment;
@@ -73,6 +80,7 @@ public class GeneralPreferencesController implements FxController {
Bindings.bindBidirectional(settings.keychainProvider, keychainBackendChoiceBox.valueProperty(), keychainSettingsConverter);
useKeychainCheckbox.selectedProperty().bindBidirectional(settings.useKeychain);
keychainBackendChoiceBox.disableProperty().bind(useKeychainCheckbox.selectedProperty().not());
keychainBackendChoiceBox.valueProperty().addListener(this::migrateKeychainEntriesOnMac);
useQuickAccessCheckbox.selectedProperty().bindBidirectional(settings.useQuickAccess);
var quickAccessSettingsConverter = new ServiceToSettingsConverter<>(quickAccessServices);
@@ -83,6 +91,35 @@ public class GeneralPreferencesController implements FxController {
quickAccessServiceChoiceBox.disableProperty().bind(useQuickAccessCheckbox.selectedProperty().not());
}
public void migrateKeychainEntriesOnMac(Observable observable) {
if (!SystemUtils.IS_OS_MAC) {
return;
}
var provider = keychainBackendChoiceBox.getSelectionModel().getSelectedItem();
var providerId = "org.cryptomator.macos.keychain.MacSystemKeychainAccess";
var isSystemKeychain = provider.getClass().getName().equals(providerId);
List<String> vaults = settings.directories.stream()
.map(vault -> vault.id)
.toList();
if (!vaults.isEmpty()) {
LOG.info("Migrating keychain entries for vaults: {}", vaults);
}
for (String vaultId :vaults) {
try {
if (keychain.isPassphraseStored(vaultId)) {
var passphrase = keychain.loadPassphrase(vaultId);
keychain.deletePassphrase(vaultId);
keychain.storePassphrase(vaultId, vaultId, new Passphrase(passphrase), !isSystemKeychain);
}
} catch (KeychainAccessException e) {
LOG.error("Failed to migrate keychain entries.", e);
}
}
}
public boolean isAutoStartSupported() {
return autoStartProvider.isPresent();
}

View File

@@ -121,6 +121,13 @@ public class EnvironmentTest {
env.getKeychainPath();
Mockito.verify(env).getPaths("cryptomator.integrationsWin.keychainPaths");
}
@Test
public void testWindowsHelloKeychainPath() {
Mockito.doReturn(Stream.of()).when(env).getPaths(Mockito.anyString());
env.getWindowsHelloKeychainPath();
Mockito.verify(env).getPaths("cryptomator.integrationsWin.windowsHelloKeychainPaths");
}
}
}

View File

@@ -1,6 +1,7 @@
package org.cryptomator.common.keychain;
import org.cryptomator.JavaFXUtil;
import org.cryptomator.integrations.keychain.KeychainAccessException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
@@ -19,6 +20,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class KeychainManagerTest {
@BeforeAll
public static void startup() throws InterruptedException {
var isRunning = JavaFXUtil.startPlatform();
Assumptions.assumeTrue(isRunning);
}
@Test
public void testStoreAndLoad() throws KeychainAccessException {
KeychainManager keychainManager = new KeychainManager(new SimpleObjectProperty<>(new MapKeychainAccess()));
@@ -27,15 +34,7 @@ public class KeychainManagerTest {
}
@Nested
public static class WhenObservingProperties {
@BeforeAll
public static void startup() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
Platform.startup(latch::countDown);
var javafxStarted = latch.await(5, TimeUnit.SECONDS);
Assumptions.assumeTrue(javafxStarted);
}
public class WhenObservingProperties {
@Test
public void testPropertyChangesWhenStoringPassword() throws KeychainAccessException, InterruptedException {
@@ -43,7 +42,7 @@ public class KeychainManagerTest {
ReadOnlyBooleanProperty property = keychainManager.getPassphraseStoredProperty("test");
Assertions.assertFalse(property.get());
keychainManager.storePassphrase("test", null,"bar");
keychainManager.storePassphrase("test", null, "bar");
AtomicBoolean result = new AtomicBoolean(false);
CountDownLatch latch = new CountDownLatch(1);

View File

@@ -1,5 +1,6 @@
package org.cryptomator.ui.controls;
import org.cryptomator.JavaFXUtil;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
@@ -18,10 +19,8 @@ public class SecurePasswordFieldTest {
@BeforeAll
public static void initJavaFx() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
Platform.startup(latch::countDown);
var javafxStarted = latch.await(5, TimeUnit.SECONDS);
Assumptions.assumeTrue(javafxStarted);
var isRunning = JavaFXUtil.startPlatform();
Assumptions.assumeTrue(isRunning);
}
@Nested