mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-22 04:31:27 +00:00
implemented unlock/reveal/lock
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
<!-- dependency versions -->
|
||||
<cryptomator.cryptolib.version>1.0.9</cryptomator.cryptolib.version>
|
||||
<cryptomator.cryptofs.version>1.0.1</cryptomator.cryptofs.version>
|
||||
<cryptomator.webdav.version>0.2.3</cryptomator.webdav.version>
|
||||
<cryptomator.webdav.version>0.3.0-SNAPSHOT</cryptomator.webdav.version>
|
||||
<cryptomator.jni.version>1.0.0</cryptomator.jni.version>
|
||||
<log4j.version>2.1</log4j.version>
|
||||
<slf4j.version>1.7.7</slf4j.version>
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.cryptolib.api.InvalidPassphraseException;
|
||||
import org.cryptomator.cryptolib.api.UnsupportedVaultFormatException;
|
||||
import org.cryptomator.frontend.webdav.ServerLifecycleException;
|
||||
import org.cryptomator.frontend.webdav.mount.Mounter.CommandFailedException;
|
||||
import org.cryptomator.keychain.KeychainAccess;
|
||||
import org.cryptomator.ui.controls.SecPasswordField;
|
||||
import org.cryptomator.ui.model.Vault;
|
||||
@@ -350,7 +351,7 @@ public class UnlockController extends LocalizedFXMLViewController {
|
||||
messageText.setText(localization.getString("unlock.errorMessage.unauthenticVersionMac"));
|
||||
}
|
||||
});
|
||||
} catch (ServerLifecycleException e) {
|
||||
} catch (ServerLifecycleException | CommandFailedException e) {
|
||||
LOG.error("Unlock failed for technical reasons.", e);
|
||||
Platform.runLater(() -> {
|
||||
messageText.setText(localization.getString("unlock.errorMessage.mountingFailed"));
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@@ -27,6 +28,9 @@ import org.cryptomator.cryptofs.CryptoFileSystemProperties;
|
||||
import org.cryptomator.cryptofs.CryptoFileSystemProvider;
|
||||
import org.cryptomator.cryptolib.api.InvalidPassphraseException;
|
||||
import org.cryptomator.frontend.webdav.WebDavServer;
|
||||
import org.cryptomator.frontend.webdav.mount.Mounter.CommandFailedException;
|
||||
import org.cryptomator.frontend.webdav.mount.Mounter.Mount;
|
||||
import org.cryptomator.frontend.webdav.servlet.WebDavServletController;
|
||||
import org.cryptomator.ui.model.VaultModule.PerVault;
|
||||
import org.cryptomator.ui.settings.VaultSettings;
|
||||
import org.cryptomator.ui.util.DeferredCloser;
|
||||
@@ -54,6 +58,9 @@ public class Vault {
|
||||
private final BooleanProperty mounted = new SimpleBooleanProperty();
|
||||
private final AtomicReference<CryptoFileSystem> cryptoFileSystem = new AtomicReference<>();
|
||||
|
||||
private WebDavServletController servlet;
|
||||
private Mount mount;
|
||||
|
||||
@Inject
|
||||
Vault(VaultSettings vaultSettings, WebDavServer server, DeferredCloser closer) {
|
||||
this.vaultSettings = vaultSettings;
|
||||
@@ -93,32 +100,48 @@ public class Vault {
|
||||
if (!server.isRunning()) {
|
||||
server.start();
|
||||
}
|
||||
server.startWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.getMountName());
|
||||
servlet = server.createWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.getMountName());
|
||||
servlet.start();
|
||||
unlockSuccess = true;
|
||||
|
||||
mount = servlet.mount(Collections.emptyMap());
|
||||
mountSuccess = true;
|
||||
} catch (IOException e) {
|
||||
LOG.error("Unable to provide frontend", e);
|
||||
LOG.error("Unable to provide filesystem", e);
|
||||
} catch (CommandFailedException e) {
|
||||
LOG.error("Unable to mount filesystem", e);
|
||||
} finally {
|
||||
// unlocked is a observable property and should only be changed by the FX application thread
|
||||
final boolean finalUnlockSuccess = unlockSuccess;
|
||||
final boolean finalMountSuccess = mountSuccess;
|
||||
Platform.runLater(() -> {
|
||||
unlocked.set(unlockSuccess);
|
||||
mounted.set(mountSuccess);
|
||||
unlocked.set(finalUnlockSuccess);
|
||||
mounted.set(finalMountSuccess);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void deactivateFrontend() throws Exception {
|
||||
if (mount != null) {
|
||||
mount.unmount();
|
||||
}
|
||||
if (servlet != null) {
|
||||
servlet.stop();
|
||||
}
|
||||
CryptoFileSystem fs = cryptoFileSystem.getAndSet(null);
|
||||
if (fs != null) {
|
||||
fs.close();
|
||||
}
|
||||
// TODO overheadhunter remove servlet from server
|
||||
Platform.runLater(() -> {
|
||||
mounted.set(false);
|
||||
unlocked.set(false);
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized void reveal() {
|
||||
// TODO overheadhunter implement mounting utility in webdav-nio-adapter
|
||||
public void reveal() throws CommandFailedException {
|
||||
if (mount != null) {
|
||||
mount.reveal();
|
||||
}
|
||||
}
|
||||
|
||||
// ******************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user