Browse Source

Add disable all keyrings setting checkbox
and connect it to the settings file

Ralph Plawetzki 2 years ago
parent
commit
ec794cdca2

+ 5 - 1
src/main/java/org/cryptomator/common/settings/VaultSettings.java

@@ -32,6 +32,7 @@ public class VaultSettings {
 
 	public static final boolean DEFAULT_UNLOCK_AFTER_STARTUP = false;
 	public static final boolean DEFAULT_REVEAL_AFTER_MOUNT = true;
+	public static final boolean DEFAULT_DISABLE_ALL_KEYRINGS = false;
 	public static final boolean DEFAULT_USES_INDIVIDUAL_MOUNTPATH = false;
 	public static final boolean DEFAULT_USES_READONLY_MODE = false;
 	public static final String DEFAULT_MOUNT_FLAGS = "";
@@ -48,6 +49,7 @@ public class VaultSettings {
 	private final StringProperty winDriveLetter = new SimpleStringProperty();
 	private final BooleanProperty unlockAfterStartup = new SimpleBooleanProperty(DEFAULT_UNLOCK_AFTER_STARTUP);
 	private final BooleanProperty revealAfterMount = new SimpleBooleanProperty(DEFAULT_REVEAL_AFTER_MOUNT);
+	private final BooleanProperty disableAllKeyrings = new SimpleBooleanProperty(DEFAULT_DISABLE_ALL_KEYRINGS);
 	private final BooleanProperty useCustomMountPath = new SimpleBooleanProperty(DEFAULT_USES_INDIVIDUAL_MOUNTPATH);
 	private final StringProperty customMountPath = new SimpleStringProperty();
 	private final BooleanProperty usesReadOnlyMode = new SimpleBooleanProperty(DEFAULT_USES_READONLY_MODE);
@@ -64,7 +66,7 @@ public class VaultSettings {
 	}
 
 	Observable[] observables() {
-		return new Observable[]{path, displayName, winDriveLetter, unlockAfterStartup, revealAfterMount, useCustomMountPath, customMountPath, usesReadOnlyMode, mountFlags, maxCleartextFilenameLength, actionAfterUnlock, autoLockWhenIdle, autoLockIdleSeconds};
+		return new Observable[]{path, displayName, winDriveLetter, unlockAfterStartup, revealAfterMount, disableAllKeyrings, useCustomMountPath, customMountPath, usesReadOnlyMode, mountFlags, maxCleartextFilenameLength, actionAfterUnlock, autoLockWhenIdle, autoLockIdleSeconds};
 	}
 
 	public static VaultSettings withRandomId() {
@@ -129,6 +131,8 @@ public class VaultSettings {
 		return revealAfterMount;
 	}
 
+	public BooleanProperty disableAllKeyrings() {return disableAllKeyrings; }
+
 	public BooleanProperty useCustomMountPath() {
 		return useCustomMountPath;
 	}

+ 4 - 0
src/main/java/org/cryptomator/common/settings/VaultSettingsJsonAdapter.java

@@ -33,6 +33,7 @@ class VaultSettingsJsonAdapter {
 		out.name("actionAfterUnlock").value(value.actionAfterUnlock().get().name());
 		out.name("autoLockWhenIdle").value(value.autoLockWhenIdle().get());
 		out.name("autoLockIdleSeconds").value(value.autoLockIdleSeconds().get());
+		out.name("disableAllKeyrings").value(value.disableAllKeyrings().get());
 		out.endObject();
 	}
 
@@ -52,6 +53,7 @@ class VaultSettingsJsonAdapter {
 		WhenUnlocked actionAfterUnlock = VaultSettings.DEFAULT_ACTION_AFTER_UNLOCK;
 		boolean autoLockWhenIdle = VaultSettings.DEFAULT_AUTOLOCK_WHEN_IDLE;
 		int autoLockIdleSeconds = VaultSettings.DEFAULT_AUTOLOCK_IDLE_SECONDS;
+		boolean disableAllKeyrings = VaultSettings.DEFAULT_DISABLE_ALL_KEYRINGS;
 
 		in.beginObject();
 		while (in.hasNext()) {
@@ -72,6 +74,7 @@ class VaultSettingsJsonAdapter {
 				case "actionAfterUnlock" -> actionAfterUnlock = parseActionAfterUnlock(in.nextString());
 				case "autoLockWhenIdle" -> autoLockWhenIdle = in.nextBoolean();
 				case "autoLockIdleSeconds" -> autoLockIdleSeconds = in.nextInt();
+				case "disableAllKeyrings" -> disableAllKeyrings = in.nextBoolean();
 				default -> {
 					LOG.warn("Unsupported vault setting found in JSON: {}", name);
 					in.skipValue();
@@ -98,6 +101,7 @@ class VaultSettingsJsonAdapter {
 		vaultSettings.actionAfterUnlock().set(actionAfterUnlock);
 		vaultSettings.autoLockWhenIdle().set(autoLockWhenIdle);
 		vaultSettings.autoLockIdleSeconds().set(autoLockIdleSeconds);
+		vaultSettings.disableAllKeyrings().set(disableAllKeyrings);
 		return vaultSettings;
 	}
 

+ 7 - 5
src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java

@@ -2,31 +2,28 @@ package org.cryptomator.ui.vaultoptions;
 
 import org.cryptomator.common.keychain.KeychainManager;
 import org.cryptomator.common.vaults.Vault;
-import org.cryptomator.integrations.keychain.KeychainAccessException;
 import org.cryptomator.ui.changepassword.ChangePasswordComponent;
 import org.cryptomator.ui.common.FxController;
 import org.cryptomator.ui.forgetPassword.ForgetPasswordComponent;
 import org.cryptomator.ui.recoverykey.RecoveryKeyComponent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
 import javafx.beans.binding.Bindings;
 import javafx.beans.binding.BooleanExpression;
 import javafx.beans.property.SimpleBooleanProperty;
 import javafx.fxml.FXML;
+import javafx.scene.control.CheckBox;
 import javafx.stage.Stage;
 
 @VaultOptionsScoped
 public class MasterkeyOptionsController implements FxController {
 
-	private static final Logger LOG = LoggerFactory.getLogger(MasterkeyOptionsController.class);
-
 	private final Vault vault;
 	private final Stage window;
 	private final ChangePasswordComponent.Builder changePasswordWindow;
 	private final RecoveryKeyComponent.Builder recoveryKeyWindow;
 	private final ForgetPasswordComponent.Builder forgetPasswordWindow;
+	public CheckBox disableAllKeyringsCheckbox;
 	private final KeychainManager keychain;
 	private final BooleanExpression passwordSaved;
 
@@ -46,6 +43,11 @@ public class MasterkeyOptionsController implements FxController {
 		}
 	}
 
+	@FXML
+	public void initialize() {
+		this.disableAllKeyringsCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().disableAllKeyrings());
+	}
+
 	@FXML
 	public void changePassword() {
 		changePasswordWindow.vault(vault).owner(window).build().showChangePasswordWindow();

+ 4 - 0
src/main/resources/fxml/vault_options_masterkey.fxml

@@ -6,6 +6,7 @@
 <?import javafx.scene.control.Label?>
 <?import javafx.scene.layout.Region?>
 <?import javafx.scene.layout.VBox?>
+<?import javafx.scene.control.CheckBox?>
 <VBox xmlns:fx="http://javafx.com/fxml"
 	  xmlns="http://javafx.com/javafx"
 	  fx:controller="org.cryptomator.ui.vaultoptions.MasterkeyOptionsController"
@@ -28,6 +29,9 @@
 				</graphic>
 			</Button>
 		</VBox>
+
+		<CheckBox text="%vaultOptions.masterkey.disableAllKeyrings" fx:id="disableAllKeyringsCheckbox"/>
+
 		<Region VBox.vgrow="ALWAYS"/>
 		<Label maxWidth="-Infinity" text="%vaultOptions.masterkey.recoveryKeyExplanation" wrapText="true"/>
 		<VBox spacing="6" alignment="CENTER">

+ 1 - 0
src/main/resources/i18n/strings.properties

@@ -390,6 +390,7 @@ vaultOptions.mount.mountPoint.directoryPickerTitle=Pick an empty directory
 vaultOptions.masterkey=Password
 vaultOptions.masterkey.changePasswordBtn=Change Password
 vaultOptions.masterkey.forgetSavedPasswordBtn=Forget Saved Password
+vaultOptions.masterkey.disableAllKeyrings=Disable all keyrings
 vaultOptions.masterkey.recoveryKeyExplanation=A recovery key is your only means to restore access to a vault if you lose your password.
 vaultOptions.masterkey.showRecoveryKeyBtn=Display Recovery Key
 vaultOptions.masterkey.recoverPasswordBtn=Reset Password