From 438ade110692b2c555c494021f866915b7405811 Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Sun, 27 Nov 2016 14:28:44 +0100 Subject: [PATCH] fixes #382 --- .../ui/controllers/UnlockController.java | 34 +++++++++++++++++++ main/ui/src/main/resources/fxml/unlock.fxml | 2 +- .../ui/src/main/resources/localization/en.txt | 3 ++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java b/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java index a8d241431..72341c74f 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java @@ -30,6 +30,7 @@ import org.cryptomator.ui.model.Vault; import org.cryptomator.ui.settings.Localization; import org.cryptomator.ui.settings.Settings; import org.cryptomator.ui.util.AsyncTaskService; +import org.cryptomator.ui.util.DialogBuilderUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,7 +41,9 @@ import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.scene.control.Alert; import javafx.scene.control.Button; +import javafx.scene.control.ButtonType; import javafx.scene.control.CheckBox; import javafx.scene.control.ChoiceBox; import javafx.scene.control.Hyperlink; @@ -276,6 +279,37 @@ public class UnlockController extends LocalizedFXMLViewController { } } + // **************************************** + // Save password checkbox + // **************************************** + + @FXML + private void didClickSavePasswordCheckbox(ActionEvent event) { + if (!savePassword.isSelected() && hasStoredPassword()) { + Alert confirmDialog = DialogBuilderUtil.buildConfirmationDialog( // + localization.getString("unlock.savePassword.delete.confirmation.title"), // + localization.getString("unlock.savePassword.delete.confirmation.header"), // + localization.getString("unlock.savePassword.delete.confirmation.content"), // + SystemUtils.IS_OS_MAC_OSX ? ButtonType.CANCEL : ButtonType.OK); + + Optional choice = confirmDialog.showAndWait(); + if (ButtonType.OK.equals(choice.get())) { + keychainAccess.get().deletePassphrase(vault.getId()); + } else if (ButtonType.CANCEL.equals(choice.get())) { + savePassword.setSelected(true); + } + } + } + + private boolean hasStoredPassword() { + char[] storedPw = keychainAccess.get().loadPassphrase(vault.getId()); + boolean hasPw = (storedPw != null); + if (storedPw != null) { + Arrays.fill(storedPw, ' '); + } + return hasPw; + } + // **************************************** // Unlock button // **************************************** diff --git a/main/ui/src/main/resources/fxml/unlock.fxml b/main/ui/src/main/resources/fxml/unlock.fxml index 0a8ea2fb8..cd27081da 100644 --- a/main/ui/src/main/resources/fxml/unlock.fxml +++ b/main/ui/src/main/resources/fxml/unlock.fxml @@ -69,7 +69,7 @@