|
@@ -1,14 +1,16 @@
|
|
|
package org.cryptomator.ui.recoverykey;
|
|
|
|
|
|
+import dagger.Lazy;
|
|
|
import javafx.beans.property.ReadOnlyStringProperty;
|
|
|
-import javafx.beans.property.SimpleStringProperty;
|
|
|
import javafx.beans.property.StringProperty;
|
|
|
import javafx.fxml.FXML;
|
|
|
+import javafx.scene.Scene;
|
|
|
import javafx.stage.Stage;
|
|
|
import org.cryptomator.common.vaults.Vault;
|
|
|
-import org.cryptomator.cryptofs.CryptoFileSystemProvider;
|
|
|
import org.cryptomator.cryptolib.api.InvalidPassphraseException;
|
|
|
import org.cryptomator.ui.common.FxController;
|
|
|
+import org.cryptomator.ui.common.FxmlFile;
|
|
|
+import org.cryptomator.ui.common.FxmlScene;
|
|
|
import org.cryptomator.ui.common.Tasks;
|
|
|
import org.cryptomator.ui.controls.NiceSecurePasswordField;
|
|
|
import org.slf4j.Logger;
|
|
@@ -17,7 +19,6 @@ import org.slf4j.LoggerFactory;
|
|
|
import javax.annotation.Nullable;
|
|
|
import javax.inject.Inject;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
|
@RecoveryKeyScoped
|
|
@@ -26,28 +27,21 @@ public class RecoveryKeyCreationController implements FxController {
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(RecoveryKeyCreationController.class);
|
|
|
|
|
|
private final Stage window;
|
|
|
+ private final Lazy<Scene> successScene;
|
|
|
private final Vault vault;
|
|
|
private final ExecutorService executor;
|
|
|
- private final CharSequence prefilledPassword;
|
|
|
private final RecoveryKeyFactory recoveryKeyFactory;
|
|
|
- private final StringProperty recoveryKey;
|
|
|
+ private final StringProperty recoveryKeyProperty;
|
|
|
public NiceSecurePasswordField passwordField;
|
|
|
|
|
|
@Inject
|
|
|
- public RecoveryKeyCreationController(@RecoveryKeyWindow Stage window, @RecoveryKeyWindow Vault vault, RecoveryKeyFactory recoveryKeyFactory, ExecutorService executor, @Nullable CharSequence prefilledPassword) {
|
|
|
+ public RecoveryKeyCreationController(@RecoveryKeyWindow Stage window, @FxmlScene(FxmlFile.RECOVERYKEY_DISPLAY) Lazy<Scene> successScene, @RecoveryKeyWindow Vault vault, RecoveryKeyFactory recoveryKeyFactory, ExecutorService executor, @RecoveryKeyWindow StringProperty recoveryKey) {
|
|
|
this.window = window;
|
|
|
+ this.successScene = successScene;
|
|
|
this.vault = vault;
|
|
|
this.executor = executor;
|
|
|
- this.prefilledPassword = prefilledPassword;
|
|
|
this.recoveryKeyFactory = recoveryKeyFactory;
|
|
|
- this.recoveryKey = new SimpleStringProperty();
|
|
|
- }
|
|
|
-
|
|
|
- @FXML
|
|
|
- public void initialize() {
|
|
|
- if (prefilledPassword != null) {
|
|
|
- passwordField.setPassword(prefilledPassword);
|
|
|
- }
|
|
|
+ this.recoveryKeyProperty = recoveryKey;
|
|
|
}
|
|
|
|
|
|
@FXML
|
|
@@ -55,7 +49,8 @@ public class RecoveryKeyCreationController implements FxController {
|
|
|
Tasks.create(() -> {
|
|
|
return recoveryKeyFactory.createRecoveryKey(vault.getPath(), passwordField.getCharacters());
|
|
|
}).onSuccess(result -> {
|
|
|
- recoveryKey.set(result);
|
|
|
+ recoveryKeyProperty.set(result);
|
|
|
+ window.setScene(successScene.get());
|
|
|
}).onError(IOException.class, e -> {
|
|
|
LOG.error("Creation of recovery key failed.", e);
|
|
|
}).onError(InvalidPassphraseException.class, e -> {
|
|
@@ -67,14 +62,5 @@ public class RecoveryKeyCreationController implements FxController {
|
|
|
public void close() {
|
|
|
window.close();
|
|
|
}
|
|
|
-
|
|
|
- /* Getter/Setter */
|
|
|
|
|
|
- public ReadOnlyStringProperty recoveryKeyProperty() {
|
|
|
- return recoveryKey;
|
|
|
- }
|
|
|
-
|
|
|
- public String getRecoveryKey() {
|
|
|
- return recoveryKey.get();
|
|
|
- }
|
|
|
}
|