mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-18 10:41:26 +00:00
Wire disable all keyrings setting checkbox to the KeychainManager
This commit is contained in:
@@ -3,6 +3,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 org.cryptomator.common.settings.Settings;
|
||||
import org.cryptomator.integrations.keychain.KeychainAccessException;
|
||||
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
|
||||
|
||||
@@ -20,10 +21,12 @@ public class KeychainManager implements KeychainAccessProvider {
|
||||
|
||||
private final ObjectExpression<KeychainAccessProvider> keychain;
|
||||
private final LoadingCache<String, BooleanProperty> passphraseStoredProperties;
|
||||
private final Settings settings;
|
||||
|
||||
@Inject
|
||||
KeychainManager(ObjectExpression<KeychainAccessProvider> selectedKeychain) {
|
||||
KeychainManager(ObjectExpression<KeychainAccessProvider> selectedKeychain, Settings settings) {
|
||||
this.keychain = selectedKeychain;
|
||||
this.settings = settings;
|
||||
this.passphraseStoredProperties = CacheBuilder.newBuilder() //
|
||||
.weakValues() //
|
||||
.build(CacheLoader.from(this::createStoredPassphraseProperty));
|
||||
@@ -72,7 +75,7 @@ public class KeychainManager implements KeychainAccessProvider {
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return keychain.getValue() != null;
|
||||
return keychain.getValue() != null && !settings.disableAllKeyrings().get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,6 +66,7 @@ public class GeneralPreferencesController implements FxController {
|
||||
keychainBackendChoiceBox.setConverter(new KeychainProviderDisplayNameConverter());
|
||||
Bindings.bindBidirectional(settings.keychainProvider(), keychainBackendChoiceBox.valueProperty(), keychainSettingsConverter);
|
||||
disableAllKeyringsCheckbox.selectedProperty().bindBidirectional(settings.disableAllKeyrings());
|
||||
keychainBackendChoiceBox.disableProperty().bindBidirectional(settings.disableAllKeyrings());
|
||||
}
|
||||
|
||||
public boolean isAutoStartSupported() {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package org.cryptomator.common.keychain;
|
||||
|
||||
|
||||
import org.cryptomator.common.settings.Settings;
|
||||
import org.cryptomator.integrations.keychain.KeychainAccessException;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||
@@ -19,9 +21,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class KeychainManagerTest {
|
||||
|
||||
private static final Settings settings = Mockito.mock(Settings.class);
|
||||
@Test
|
||||
public void testStoreAndLoad() throws KeychainAccessException {
|
||||
KeychainManager keychainManager = new KeychainManager(new SimpleObjectProperty<>(new MapKeychainAccess()));
|
||||
KeychainManager keychainManager = new KeychainManager(new SimpleObjectProperty<>(new MapKeychainAccess()), settings);
|
||||
keychainManager.storePassphrase("test", "Test", "asd");
|
||||
Assertions.assertArrayEquals("asd".toCharArray(), keychainManager.loadPassphrase("test"));
|
||||
}
|
||||
@@ -39,7 +42,7 @@ public class KeychainManagerTest {
|
||||
|
||||
@Test
|
||||
public void testPropertyChangesWhenStoringPassword() throws KeychainAccessException, InterruptedException {
|
||||
KeychainManager keychainManager = new KeychainManager(new SimpleObjectProperty<>(new MapKeychainAccess()));
|
||||
KeychainManager keychainManager = new KeychainManager(new SimpleObjectProperty<>(new MapKeychainAccess()), settings);
|
||||
ReadOnlyBooleanProperty property = keychainManager.getPassphraseStoredProperty("test");
|
||||
Assertions.assertFalse(property.get());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user