|
@@ -1,14 +1,19 @@
|
|
|
package org.cryptomator.ui.mainwindow;
|
|
|
|
|
|
+import javafx.beans.binding.BooleanExpression;
|
|
|
import javafx.beans.property.ObjectProperty;
|
|
|
import javafx.beans.property.ReadOnlyObjectProperty;
|
|
|
+import javafx.beans.property.SimpleBooleanProperty;
|
|
|
import javafx.fxml.FXML;
|
|
|
import org.cryptomator.common.vaults.Vault;
|
|
|
+import org.cryptomator.keychain.KeychainManager;
|
|
|
import org.cryptomator.ui.common.FxController;
|
|
|
import org.cryptomator.ui.fxapp.FxApplication;
|
|
|
import org.cryptomator.ui.vaultoptions.VaultOptionsComponent;
|
|
|
+import org.fxmisc.easybind.EasyBind;
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
@MainWindowScoped
|
|
|
public class VaultDetailLockedController implements FxController {
|
|
@@ -16,12 +21,20 @@ public class VaultDetailLockedController implements FxController {
|
|
|
private final ReadOnlyObjectProperty<Vault> vault;
|
|
|
private final FxApplication application;
|
|
|
private final VaultOptionsComponent.Builder vaultOptionsWindow;
|
|
|
+ private final Optional<KeychainManager> keychainManagerOptional;
|
|
|
+ private final BooleanExpression passwordSaved;
|
|
|
|
|
|
@Inject
|
|
|
- VaultDetailLockedController(ObjectProperty<Vault> vault, FxApplication application, VaultOptionsComponent.Builder vaultOptionsWindow) {
|
|
|
+ VaultDetailLockedController(ObjectProperty<Vault> vault, FxApplication application, VaultOptionsComponent.Builder vaultOptionsWindow, Optional<KeychainManager> keychainManagerOptional) {
|
|
|
this.vault = vault;
|
|
|
this.application = application;
|
|
|
this.vaultOptionsWindow = vaultOptionsWindow;
|
|
|
+ this.keychainManagerOptional = keychainManagerOptional;
|
|
|
+ if (keychainManagerOptional.isPresent()) {
|
|
|
+ this.passwordSaved = BooleanExpression.booleanExpression(EasyBind.select(vault).selectObject(v -> keychainManagerOptional.get().getPassphraseStoredProperty(v.getId())));
|
|
|
+ } else {
|
|
|
+ this.passwordSaved = new SimpleBooleanProperty(false);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@FXML
|
|
@@ -33,7 +46,7 @@ public class VaultDetailLockedController implements FxController {
|
|
|
public void showVaultOptions() {
|
|
|
vaultOptionsWindow.vault(vault.get()).build().showVaultOptionsWindow();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
public ReadOnlyObjectProperty<Vault> vaultProperty() {
|
|
@@ -43,4 +56,14 @@ public class VaultDetailLockedController implements FxController {
|
|
|
public Vault getVault() {
|
|
|
return vault.get();
|
|
|
}
|
|
|
+
|
|
|
+ public BooleanExpression passwordSavedProperty() {
|
|
|
+ return passwordSaved;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isPasswordSaved() {
|
|
|
+ if (keychainManagerOptional.isPresent() && vault.get() != null) {
|
|
|
+ return keychainManagerOptional.get().getPassphraseStoredProperty(vault.get().getId()).get();
|
|
|
+ } else return false;
|
|
|
+ }
|
|
|
}
|