~exprez135/cryptomator-libre

241eb8bed5b27efc8271be3eba7a58faf8e27cff — Martin Beyer 1 year, 6 months ago 842a0d6
Implements #1182 By adding a button to forget the saved password

M main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java => main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java +1 -0
@@ 26,6 26,7 @@ public enum FontAwesome5Icon {
	INFO_CIRCLE("\uF05A"), //
	KEY("\uF084"), //
	LINK("\uF0C1"), //
	UNLINK("\uf127"),
	LOCK("\uF023"), //
	LOCK_OPEN("\uF3C1"), //
	MAGIC("\uF0D0"), //

M main/ui/src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java => main/ui/src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java +30 -1
@@ 1,13 1,19 @@
package org.cryptomator.ui.vaultoptions;

import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanExpression;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.fxml.FXML;
import javafx.stage.Stage;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.keychain.KeychainAccessException;
import org.cryptomator.keychain.KeychainManager;
import org.cryptomator.ui.changepassword.ChangePasswordComponent;
import org.cryptomator.ui.common.FxController;
import org.cryptomator.ui.recoverykey.RecoveryKeyComponent;

import javax.inject.Inject;
import java.util.Optional;

@VaultOptionsScoped
public class MasterkeyOptionsController implements FxController {


@@ 16,13 22,20 @@ public class MasterkeyOptionsController implements FxController {
	private final Stage window;
	private final ChangePasswordComponent.Builder changePasswordWindow;
	private final RecoveryKeyComponent.Builder recoveryKeyWindow;
	private final Optional<KeychainManager> keychainManagerOptional;
	private final BooleanExpression passwordSaved;


	@Inject
	MasterkeyOptionsController(@VaultOptionsWindow Vault vault, @VaultOptionsWindow Stage window, ChangePasswordComponent.Builder changePasswordWindow, RecoveryKeyComponent.Builder recoveryKeyWindow) {
	MasterkeyOptionsController(@VaultOptionsWindow Vault vault, @VaultOptionsWindow Stage window, ChangePasswordComponent.Builder changePasswordWindow, RecoveryKeyComponent.Builder recoveryKeyWindow, Optional<KeychainManager> keychainManagerOptional) {
		this.vault = vault;
		this.window = window;
		this.changePasswordWindow = changePasswordWindow;
		this.recoveryKeyWindow = recoveryKeyWindow;
		this.keychainManagerOptional = keychainManagerOptional;
		if (keychainManagerOptional.isPresent()) {
			this.passwordSaved = Bindings.createBooleanBinding(this::isPasswordSaved, keychainManagerOptional.get().getPassphraseStoredProperty(vault.getId()));
		} else this.passwordSaved = new SimpleBooleanProperty(false);
	}

	@FXML


@@ 39,4 52,20 @@ public class MasterkeyOptionsController implements FxController {
	public void showRecoverVaultDialogue() {
		recoveryKeyWindow.vault(vault).owner(window).build().showRecoveryKeyRecoverWindow();
	}

	@FXML
	public void removePasswordFromKeychain() throws KeychainAccessException {
		keychainManagerOptional.get().deletePassphrase(vault.getId());
		window.close();
	}

	public BooleanExpression passwordSavedProperty() {
		return passwordSaved;
	}

	public boolean isPasswordSaved() {
		if (keychainManagerOptional.isPresent() && vault != null) {
			return keychainManagerOptional.get().getPassphraseStoredProperty(vault.getId()).get();
		} else return false;
	}
}

M main/ui/src/main/resources/fxml/vault_options_masterkey.fxml => main/ui/src/main/resources/fxml/vault_options_masterkey.fxml +13 -7
@@ 16,14 16,20 @@
		<Insets topRightBottomLeft="12"/>
	</padding>
	<children>
		<Button text="%vaultOptions.masterkey.changePasswordBtn" onAction="#changePassword" contentDisplay="LEFT">
			<graphic>
				<FontAwesome5IconView glyph="KEY"/>
			</graphic>
		</Button>
		
		<HBox spacing="6" alignment="CENTER">
			<Button text="%vaultOptions.masterkey.changePasswordBtn" onAction="#changePassword" contentDisplay="LEFT">
				<graphic>
					<FontAwesome5IconView glyph="KEY"/>
				</graphic>
			</Button>
			<Button text="%vaultOptions.masterkey.forgetSavedPasswordBtn" onAction="#removePasswordFromKeychain" contentDisplay="LEFT" visible="${controller.passwordSaved}" managed="${controller.passwordSaved}">
				<graphic>
					<FontAwesome5IconView glyph="UNLINK"/>
				</graphic>
			</Button>
		</HBox>
		<Region VBox.vgrow="ALWAYS"/>
		

		<Label maxWidth="-Infinity" text="%vaultOptions.masterkey.recoveryKeyExpanation" wrapText="true"/>
		<HBox spacing="6" alignment="CENTER">
			<Button text="%vaultOptions.masterkey.showRecoveryKeyBtn" onAction="#showRecoveryKey" contentDisplay="LEFT">

M main/ui/src/main/resources/i18n/strings.properties => main/ui/src/main/resources/i18n/strings.properties +1 -0
@@ 229,6 229,7 @@ vaultOptions.mount.mountPoint.directoryPickerTitle=Pick an empty directory
## Master Key
vaultOptions.masterkey=Password
vaultOptions.masterkey.changePasswordBtn=Change Password
vaultOptions.masterkey.forgetSavedPasswordBtn=Forget saved Password
vaultOptions.masterkey.recoveryKeyExpanation=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=Recover Password