;0--1.ipv6-literal.net;0--1.ipv6-literal.net:%DAV_PORT%\" /f");
proxyBypassScript.addEnv("DAV_PORT", String.valueOf(uri.getPort()));
mountResult = bypassProxyAndRetryMount(localhostMountScript, ipv6literaltMountScript, proxyBypassScript);
}
return new WindowsWebDavMount(driveLetter.charValue() == AUTO_ASSIGN_DRIVE_LETTER ? getDriveLetter(mountResult.getStdOut()) : driveLetter);
}
-
+
private CommandResult bypassProxyAndRetryMount(Script localhostMountScript, Script ipv6literalMountScript, Script proxyBypassScript) throws CommandFailedException {
CommandFailedException latestException = null;
for (int i = 0; i < MAX_MOUNT_ATTEMPTS; i++) {
@@ -109,18 +111,18 @@ final class WindowsWebDavMounter implements WebDavMounterStrategy {
throw new CommandFailedException("Failed to get a drive letter from net use output.");
}
}
-
+
private class WindowsWebDavMount extends AbstractWebDavMount {
private final Character driveLetter;
private final Script openExplorerScript;
private final Script unmountScript;
-
+
private WindowsWebDavMount(Character driveLetter) {
this.driveLetter = driveLetter;
this.openExplorerScript = fromLines("start explorer.exe " + driveLetter + ":");
this.unmountScript = fromLines("net use " + driveLetter + ": /delete").addEnv("DRIVE_LETTER", Character.toString(driveLetter));
}
-
+
@Override
public void unmount() throws CommandFailedException {
// only attempt unmount if user didn't unmount manually:
@@ -133,7 +135,7 @@ final class WindowsWebDavMounter implements WebDavMounterStrategy {
public void reveal() throws CommandFailedException {
openExplorerScript.execute();
}
-
+
private boolean isVolumeMounted() {
return driveLetters.getOccupiedDriveLetters().contains(driveLetter);
}
diff --git a/main/ui/src/main/java/org/cryptomator/ui/util/command/CommandResult.java b/main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/CommandResult.java
similarity index 96%
rename from main/ui/src/main/java/org/cryptomator/ui/util/command/CommandResult.java
rename to main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/CommandResult.java
index 466fab057..e5cbb6253 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/util/command/CommandResult.java
+++ b/main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/CommandResult.java
@@ -7,7 +7,7 @@
* Markus Kreusch
* Sebastian Stenzel - using Futures, lazy loading for out/err.
******************************************************************************/
-package org.cryptomator.ui.util.command;
+package org.cryptomator.frontend.webdav.mount.command;
import static java.lang.String.format;
@@ -15,7 +15,7 @@ import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.util.Strings;
-import org.cryptomator.ui.util.mount.CommandFailedException;
+import org.cryptomator.frontend.webdav.mount.CommandFailedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/main/ui/src/main/java/org/cryptomator/ui/util/command/CommandRunner.java b/main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/CommandRunner.java
similarity index 96%
rename from main/ui/src/main/java/org/cryptomator/ui/util/command/CommandRunner.java
rename to main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/CommandRunner.java
index 2c5cb69b0..d8e1af65b 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/util/command/CommandRunner.java
+++ b/main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/CommandRunner.java
@@ -7,7 +7,7 @@
* Markus Kreusch
* Sebastian Stenzel - Refactoring
******************************************************************************/
-package org.cryptomator.ui.util.command;
+package org.cryptomator.frontend.webdav.mount.command;
import static java.lang.String.format;
import static org.apache.commons.lang3.SystemUtils.IS_OS_UNIX;
@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.SystemUtils;
-import org.cryptomator.ui.util.mount.CommandFailedException;
+import org.cryptomator.frontend.webdav.mount.CommandFailedException;
/**
*
diff --git a/main/ui/src/main/java/org/cryptomator/ui/util/command/FutureCommandResult.java b/main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/FutureCommandResult.java
similarity index 95%
rename from main/ui/src/main/java/org/cryptomator/ui/util/command/FutureCommandResult.java
rename to main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/FutureCommandResult.java
index 6f907b4b6..6b0baff70 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/util/command/FutureCommandResult.java
+++ b/main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/FutureCommandResult.java
@@ -6,7 +6,7 @@
* Contributors:
* Sebastian Stenzel
******************************************************************************/
-package org.cryptomator.ui.util.command;
+package org.cryptomator.frontend.webdav.mount.command;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@@ -17,7 +17,7 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import org.cryptomator.ui.util.mount.CommandFailedException;
+import org.cryptomator.frontend.webdav.mount.CommandFailedException;
final class FutureCommandResult implements Future, Runnable {
diff --git a/main/ui/src/main/java/org/cryptomator/ui/util/command/Script.java b/main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/Script.java
similarity index 92%
rename from main/ui/src/main/java/org/cryptomator/ui/util/command/Script.java
rename to main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/Script.java
index 0fb1c78c1..dc3c2724c 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/util/command/Script.java
+++ b/main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/mount/command/Script.java
@@ -6,13 +6,13 @@
* Contributors:
* Markus Kreusch
******************************************************************************/
-package org.cryptomator.ui.util.command;
+package org.cryptomator.frontend.webdav.mount.command;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import org.cryptomator.ui.util.mount.CommandFailedException;
+import org.cryptomator.frontend.webdav.mount.CommandFailedException;
public final class Script {
diff --git a/main/frontend-webdav/src/test/java/org/cryptomator/webdav/server/InMemoryWebDavServer.java b/main/frontend-webdav/src/test/java/org/cryptomator/frontend/webdav/InMemoryWebDavServer.java
similarity index 94%
rename from main/frontend-webdav/src/test/java/org/cryptomator/webdav/server/InMemoryWebDavServer.java
rename to main/frontend-webdav/src/test/java/org/cryptomator/frontend/webdav/InMemoryWebDavServer.java
index 4f0cf64ff..e8c197868 100644
--- a/main/frontend-webdav/src/test/java/org/cryptomator/webdav/server/InMemoryWebDavServer.java
+++ b/main/frontend-webdav/src/test/java/org/cryptomator/frontend/webdav/InMemoryWebDavServer.java
@@ -6,8 +6,9 @@
* Contributors:
* Sebastian Stenzel - initial API and implementation
*******************************************************************************/
-package org.cryptomator.webdav.server;
+package org.cryptomator.frontend.webdav;
+import java.net.URI;
import java.nio.ByteBuffer;
import java.util.EnumSet;
@@ -27,7 +28,7 @@ public class InMemoryWebDavServer {
server.start();
FileSystem fileSystem = setupFilesystem();
- ServletContextHandler servlet = server.addServlet(fileSystem, "/foo");
+ ServletContextHandler servlet = server.addServlet(fileSystem, URI.create("http://localhost:8080/foo"));
servlet.addFilter(LoggingHttpFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
servlet.start();
diff --git a/main/frontend-webdav/src/test/java/org/cryptomator/webdav/server/NioWebDavServer.java b/main/frontend-webdav/src/test/java/org/cryptomator/frontend/webdav/NioWebDavServer.java
similarity index 96%
rename from main/frontend-webdav/src/test/java/org/cryptomator/webdav/server/NioWebDavServer.java
rename to main/frontend-webdav/src/test/java/org/cryptomator/frontend/webdav/NioWebDavServer.java
index 0ae5c837e..95ea25713 100644
--- a/main/frontend-webdav/src/test/java/org/cryptomator/webdav/server/NioWebDavServer.java
+++ b/main/frontend-webdav/src/test/java/org/cryptomator/frontend/webdav/NioWebDavServer.java
@@ -6,12 +6,13 @@
* Contributors:
* Sebastian Stenzel - initial API and implementation
*******************************************************************************/
-package org.cryptomator.webdav.server;
+package org.cryptomator.frontend.webdav;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
+import java.net.URI;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -36,7 +37,7 @@ public class NioWebDavServer {
server.start();
FileSystem fileSystem = setupFilesystem();
- ServletContextHandler servlet = server.addServlet(fileSystem, "/foo");
+ ServletContextHandler servlet = server.addServlet(fileSystem, URI.create("http://localhost:8080/foo"));
servlet.addFilter(LoggingHttpFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
servlet.start();
diff --git a/main/frontend-webdav/src/test/java/org/cryptomator/webdav/server/WebDavServerTest.java b/main/frontend-webdav/src/test/java/org/cryptomator/frontend/webdav/WebDavServerTest.java
similarity index 95%
rename from main/frontend-webdav/src/test/java/org/cryptomator/webdav/server/WebDavServerTest.java
rename to main/frontend-webdav/src/test/java/org/cryptomator/frontend/webdav/WebDavServerTest.java
index dd8385016..9287ea057 100644
--- a/main/frontend-webdav/src/test/java/org/cryptomator/webdav/server/WebDavServerTest.java
+++ b/main/frontend-webdav/src/test/java/org/cryptomator/frontend/webdav/WebDavServerTest.java
@@ -1,9 +1,10 @@
-package org.cryptomator.webdav.server;
+package org.cryptomator.frontend.webdav;
import static org.hamcrest.collection.IsArrayContaining.hasItemInArray;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.net.URI;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
@@ -49,7 +50,7 @@ public class WebDavServerTest {
@Before
public void startServlet() throws Exception {
fs = new InMemoryFileSystem();
- servlet = SERVER.addServlet(fs, "/test");
+ servlet = SERVER.addServlet(fs, URI.create("http://localhost:" + SERVER.getPort() + "/test"));
servlet.start();
servletRoot = "http://localhost:" + SERVER.getPort() + "/test";
}
diff --git a/main/pom.xml b/main/pom.xml
index e96527d02..8a701a90d 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -52,19 +52,18 @@
+
+ org.cryptomator
+ commons
+ ${project.version}
+
org.cryptomator
commons-test
${project.version}
test
-
-
-
- org.cryptomator
- commons
- ${project.version}
-
+
org.cryptomator
filesystem-api
@@ -91,22 +90,18 @@
filesystem-crypto
${project.version}
+
+
+ org.cryptomator
+ frontend-api
+ ${project.version}
+
+
+ org.cryptomator
+ frontend-webdav
+ ${project.version}
+
-
- org.cryptomator
- core
- ${project.version}
-
-
- org.cryptomator
- crypto-api
- ${project.version}
-
-
- org.cryptomator
- crypto-aes
- ${project.version}
-
org.cryptomator
ui
@@ -259,10 +254,8 @@
filesystem-nameshortening
filesystem-crypto
filesystem-invariants-tests
+ frontend-api
frontend-webdav
- crypto-api
- crypto-aes
- core
ui
diff --git a/main/ui/pom.xml b/main/ui/pom.xml
index a7951aab3..4d8d263af 100644
--- a/main/ui/pom.xml
+++ b/main/ui/pom.xml
@@ -20,11 +20,23 @@
org.cryptomator
- core
+ filesystem-api
org.cryptomator
- crypto-aes
+ filesystem-nio
+
+
+ org.cryptomator
+ filesystem-crypto
+
+
+ org.cryptomator
+ frontend-api
+
+
+ org.cryptomator
+ frontend-webdav
diff --git a/main/ui/src/main/java/org/cryptomator/ui/CryptomatorModule.java b/main/ui/src/main/java/org/cryptomator/ui/CryptomatorModule.java
index 34299fd2f..6afe035cb 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/CryptomatorModule.java
+++ b/main/ui/src/main/java/org/cryptomator/ui/CryptomatorModule.java
@@ -7,18 +7,17 @@ import java.util.concurrent.Executors;
import javax.inject.Named;
import javax.inject.Singleton;
-import org.cryptomator.crypto.Cryptor;
-import org.cryptomator.crypto.SamplingCryptorDecorator;
-import org.cryptomator.crypto.aes256.CryptoModule;
+import org.cryptomator.filesystem.crypto.CryptoFileSystemModule;
+import org.cryptomator.frontend.FrontendFactory;
+import org.cryptomator.frontend.webdav.WebDavServer;
+import org.cryptomator.frontend.webdav.mount.WebDavMounter;
+import org.cryptomator.frontend.webdav.mount.WebDavMounterProvider;
import org.cryptomator.ui.model.VaultObjectMapperProvider;
import org.cryptomator.ui.settings.Settings;
import org.cryptomator.ui.settings.SettingsProvider;
import org.cryptomator.ui.util.DeferredCloser;
import org.cryptomator.ui.util.DeferredCloser.Closer;
import org.cryptomator.ui.util.SemVerComparator;
-import org.cryptomator.ui.util.mount.WebDavMounter;
-import org.cryptomator.ui.util.mount.WebDavMounterProvider;
-import org.cryptomator.webdav.WebDavServer;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -26,7 +25,7 @@ import dagger.Module;
import dagger.Provides;
import javafx.application.Application;
-@Module(includes = CryptoModule.class)
+@Module(includes = CryptoFileSystemModule.class)
class CryptomatorModule {
private final Application application;
@@ -83,18 +82,11 @@ class CryptomatorModule {
@Provides
@Singleton
- WebDavServer provideWebDavServer() {
- final WebDavServer webDavServer = new WebDavServer();
+ FrontendFactory provideFrontendFactory(WebDavServer webDavServer) {
webDavServer.start();
return closeLater(webDavServer, WebDavServer::stop);
}
- @Provides
- @Named("SamplingCryptor")
- Cryptor provideCryptor(Cryptor cryptor) {
- return SamplingCryptorDecorator.decorate(cryptor);
- }
-
private T closeLater(T object, Closer closer) {
return deferredCloser.closeLater(object, closer).get().get();
}
diff --git a/main/ui/src/main/java/org/cryptomator/ui/controllers/ChangePasswordController.java b/main/ui/src/main/java/org/cryptomator/ui/controllers/ChangePasswordController.java
index 97c6d8426..1673a49aa 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/controllers/ChangePasswordController.java
+++ b/main/ui/src/main/java/org/cryptomator/ui/controllers/ChangePasswordController.java
@@ -1,28 +1,17 @@
package org.cryptomator.ui.controllers;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.nio.file.StandardOpenOption;
import java.util.ResourceBundle;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.cryptomator.crypto.exceptions.UnsupportedKeyLengthException;
-import org.cryptomator.crypto.exceptions.UnsupportedVaultException;
-import org.cryptomator.crypto.exceptions.WrongPasswordException;
import org.cryptomator.ui.controls.SecPasswordField;
import org.cryptomator.ui.model.Vault;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javafx.application.Application;
-import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
@@ -107,75 +96,80 @@ public class ChangePasswordController extends AbstractFXMLViewController {
@FXML
private void didClickChangePasswordButton(ActionEvent event) {
- downloadsPageLink.setVisible(false);
- final Path masterKeyPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_FILE);
- final Path masterKeyBackupPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_BACKUP_FILE);
-
- // decrypt with old password:
- final CharSequence oldPassword = oldPasswordField.getCharacters();
- try (final InputStream masterKeyInputStream = Files.newInputStream(masterKeyPath, StandardOpenOption.READ)) {
- vault.getCryptor().decryptMasterKey(masterKeyInputStream, oldPassword);
- Files.copy(masterKeyPath, masterKeyBackupPath, StandardCopyOption.REPLACE_EXISTING);
- } catch (IOException ex) {
- messageText.setText(resourceBundle.getString("changePassword.errorMessage.decryptionFailed"));
- LOG.error("Decryption failed for technical reasons.", ex);
- newPasswordField.swipe();
- retypePasswordField.swipe();
- return;
- } catch (WrongPasswordException e) {
- messageText.setText(resourceBundle.getString("changePassword.errorMessage.wrongPassword"));
- newPasswordField.swipe();
- retypePasswordField.swipe();
- Platform.runLater(oldPasswordField::requestFocus);
- return;
- } catch (UnsupportedKeyLengthException ex) {
- messageText.setText(resourceBundle.getString("changePassword.errorMessage.unsupportedKeyLengthInstallJCE"));
- LOG.warn("Unsupported Key-Length. Please install Oracle Java Cryptography Extension (JCE).", ex);
- newPasswordField.swipe();
- retypePasswordField.swipe();
- return;
- } catch (UnsupportedVaultException e) {
- downloadsPageLink.setVisible(true);
- if (e.isVaultOlderThanSoftware()) {
- messageText.setText(resourceBundle.getString("changePassword.errorMessage.unsupportedVersion.vaultOlderThanSoftware") + " ");
- } else if (e.isSoftwareOlderThanVault()) {
- messageText.setText(resourceBundle.getString("changePassword.errorMessage.unsupportedVersion.softwareOlderThanVault") + " ");
- }
- newPasswordField.swipe();
- retypePasswordField.swipe();
- return;
- } finally {
- oldPasswordField.swipe();
- }
-
- // when we reach this line, decryption was successful.
-
- // encrypt with new password:
- final CharSequence newPassword = newPasswordField.getCharacters();
- try (final OutputStream masterKeyOutputStream = Files.newOutputStream(masterKeyPath, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.SYNC)) {
- vault.getCryptor().encryptMasterKey(masterKeyOutputStream, newPassword);
- messageText.setText(resourceBundle.getString("changePassword.infoMessage.success"));
- Platform.runLater(this::didChangePassword);
- // At this point the backup is still using the old password.
- // It will be changed as soon as the user unlocks the vault the next time.
- // This way he can still restore the old password, if he doesn't remember the new one.
- } catch (IOException ex) {
- LOG.error("Re-encryption failed for technical reasons. Restoring Backup.", ex);
- this.restoreBackupQuietly();
- } finally {
- newPasswordField.swipe();
- retypePasswordField.swipe();
- }
+ throw new UnsupportedOperationException("TODO");
+ /*
+ * downloadsPageLink.setVisible(false);
+ * final Path masterKeyPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_FILE);
+ * final Path masterKeyBackupPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_BACKUP_FILE);
+ *
+ * // decrypt with old password:
+ * final CharSequence oldPassword = oldPasswordField.getCharacters();
+ * try (final InputStream masterKeyInputStream = Files.newInputStream(masterKeyPath, StandardOpenOption.READ)) {
+ * vault.getCryptor().decryptMasterKey(masterKeyInputStream, oldPassword);
+ * Files.copy(masterKeyPath, masterKeyBackupPath, StandardCopyOption.REPLACE_EXISTING);
+ * } catch (IOException ex) {
+ * messageText.setText(resourceBundle.getString("changePassword.errorMessage.decryptionFailed"));
+ * LOG.error("Decryption failed for technical reasons.", ex);
+ * newPasswordField.swipe();
+ * retypePasswordField.swipe();
+ * return;
+ * } catch (WrongPasswordException e) {
+ * messageText.setText(resourceBundle.getString("changePassword.errorMessage.wrongPassword"));
+ * newPasswordField.swipe();
+ * retypePasswordField.swipe();
+ * Platform.runLater(oldPasswordField::requestFocus);
+ * return;
+ * } catch (UnsupportedKeyLengthException ex) {
+ * messageText.setText(resourceBundle.getString("changePassword.errorMessage.unsupportedKeyLengthInstallJCE"));
+ * LOG.warn("Unsupported Key-Length. Please install Oracle Java Cryptography Extension (JCE).", ex);
+ * newPasswordField.swipe();
+ * retypePasswordField.swipe();
+ * return;
+ * } catch (UnsupportedVaultException e) {
+ * downloadsPageLink.setVisible(true);
+ * if (e.isVaultOlderThanSoftware()) {
+ * messageText.setText(resourceBundle.getString("changePassword.errorMessage.unsupportedVersion.vaultOlderThanSoftware") + " ");
+ * } else if (e.isSoftwareOlderThanVault()) {
+ * messageText.setText(resourceBundle.getString("changePassword.errorMessage.unsupportedVersion.softwareOlderThanVault") + " ");
+ * }
+ * newPasswordField.swipe();
+ * retypePasswordField.swipe();
+ * return;
+ * } finally {
+ * oldPasswordField.swipe();
+ * }
+ *
+ * // when we reach this line, decryption was successful.
+ *
+ * // encrypt with new password:
+ * final CharSequence newPassword = newPasswordField.getCharacters();
+ * try (final OutputStream masterKeyOutputStream = Files.newOutputStream(masterKeyPath, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.SYNC)) {
+ * vault.getCryptor().encryptMasterKey(masterKeyOutputStream, newPassword);
+ * messageText.setText(resourceBundle.getString("changePassword.infoMessage.success"));
+ * Platform.runLater(this::didChangePassword);
+ * // At this point the backup is still using the old password.
+ * // It will be changed as soon as the user unlocks the vault the next time.
+ * // This way he can still restore the old password, if he doesn't remember the new one.
+ * } catch (IOException ex) {
+ * LOG.error("Re-encryption failed for technical reasons. Restoring Backup.", ex);
+ * this.restoreBackupQuietly();
+ * } finally {
+ * newPasswordField.swipe();
+ * retypePasswordField.swipe();
+ * }
+ */
}
private void restoreBackupQuietly() {
- final Path masterKeyPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_FILE);
- final Path masterKeyBackupPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_BACKUP_FILE);
- try {
- Files.copy(masterKeyBackupPath, masterKeyPath, StandardCopyOption.REPLACE_EXISTING);
- } catch (IOException ex) {
- LOG.error("Restoring Backup failed.", ex);
- }
+ /*
+ * final Path masterKeyPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_FILE);
+ * final Path masterKeyBackupPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_BACKUP_FILE);
+ * try {
+ * Files.copy(masterKeyBackupPath, masterKeyPath, StandardCopyOption.REPLACE_EXISTING);
+ * } catch (IOException ex) {
+ * LOG.error("Restoring Backup failed.", ex);
+ * }
+ */
}
private void didChangePassword() {
diff --git a/main/ui/src/main/java/org/cryptomator/ui/controllers/InitializeController.java b/main/ui/src/main/java/org/cryptomator/ui/controllers/InitializeController.java
index cdb297f1d..df135ce0c 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/controllers/InitializeController.java
+++ b/main/ui/src/main/java/org/cryptomator/ui/controllers/InitializeController.java
@@ -9,14 +9,8 @@
package org.cryptomator.ui.controllers;
import java.io.IOException;
-import java.io.OutputStream;
import java.net.URL;
import java.nio.file.FileAlreadyExistsException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.InvalidPathException;
-import java.nio.file.Path;
-import java.nio.file.StandardOpenOption;
import java.util.ResourceBundle;
import javax.inject.Inject;
@@ -90,23 +84,11 @@ public class InitializeController extends AbstractFXMLViewController {
@FXML
protected void initializeVault(ActionEvent event) {
setControlsDisabled(true);
- final Path masterKeyPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_FILE);
- final CharSequence password = passwordField.getCharacters();
- try (OutputStream masterKeyOutputStream = Files.newOutputStream(masterKeyPath, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW)) {
- vault.getCryptor().randomizeMasterKey();
- vault.getCryptor().encryptMasterKey(masterKeyOutputStream, password);
- final String dataRootDir = vault.getCryptor().encryptDirectoryPath("", FileSystems.getDefault().getSeparator());
- final Path dataRootPath = vault.getPath().resolve("d").resolve(dataRootDir);
- final Path metadataPath = vault.getPath().resolve("m");
- Files.createDirectories(dataRootPath);
- Files.createDirectories(metadataPath);
- if (listener != null) {
- listener.didInitialize(this);
- }
+ final CharSequence passphrase = passwordField.getCharacters();
+ try {
+ vault.create(passphrase);
} catch (FileAlreadyExistsException ex) {
messageLabel.setText(resourceBundle.getString("initialize.messageLabel.alreadyInitialized"));
- } catch (InvalidPathException ex) {
- messageLabel.setText(resourceBundle.getString("initialize.messageLabel.invalidPath"));
} catch (IOException ex) {
LOG.error("I/O Exception", ex);
} finally {
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 616f96a8c..2dc2e270c 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
@@ -8,31 +8,22 @@
******************************************************************************/
package org.cryptomator.ui.controllers;
-import java.io.IOException;
-import java.io.InputStream;
import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.nio.file.StandardOpenOption;
import java.util.Comparator;
import java.util.ResourceBundle;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.inject.Inject;
-import javax.security.auth.DestroyFailedException;
import org.apache.commons.lang3.CharUtils;
import org.apache.commons.lang3.SystemUtils;
-import org.cryptomator.crypto.exceptions.UnsupportedKeyLengthException;
-import org.cryptomator.crypto.exceptions.UnsupportedVaultException;
-import org.cryptomator.crypto.exceptions.WrongPasswordException;
+import org.cryptomator.crypto.engine.InvalidPassphraseException;
+import org.cryptomator.frontend.FrontendCreationFailedException;
+import org.cryptomator.frontend.webdav.mount.WindowsDriveLetters;
import org.cryptomator.ui.controls.SecPasswordField;
import org.cryptomator.ui.model.Vault;
import org.cryptomator.ui.util.FXThreads;
-import org.cryptomator.ui.util.mount.CommandFailedException;
-import org.cryptomator.ui.util.mount.WindowsDriveLetters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -258,49 +249,30 @@ public class UnlockController extends AbstractFXMLViewController {
setControlsDisabled(true);
progressIndicator.setVisible(true);
downloadsPageLink.setVisible(false);
- final Path masterKeyPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_FILE);
- final Path masterKeyBackupPath = vault.getPath().resolve(Vault.VAULT_MASTERKEY_BACKUP_FILE);
final CharSequence password = passwordField.getCharacters();
- try (final InputStream masterKeyInputStream = Files.newInputStream(masterKeyPath, StandardOpenOption.READ)) {
- vault.getCryptor().decryptMasterKey(masterKeyInputStream, password);
- if (!vault.startServer()) {
- messageText.setText(resourceBundle.getString("unlock.messageLabel.startServerFailed"));
- vault.getCryptor().destroy();
- return;
- }
- // at this point we know for sure, that the masterkey can be decrypted, so lets make a backup:
- Files.copy(masterKeyPath, masterKeyBackupPath, StandardCopyOption.REPLACE_EXISTING);
- vault.setUnlocked(true);
- final Future futureMount = exec.submit(vault::mount);
+ try {
+ vault.activateFrontend(password);
+ Future futureMount = exec.submit(vault::mount);
FXThreads.runOnMainThreadWhenFinished(exec, futureMount, this::unlockAndMountFinished);
- } catch (IOException ex) {
- setControlsDisabled(false);
- progressIndicator.setVisible(false);
- messageText.setText(resourceBundle.getString("unlock.errorMessage.decryptionFailed"));
- LOG.error("Decryption failed for technical reasons.", ex);
- } catch (WrongPasswordException e) {
+ } catch (InvalidPassphraseException e) {
setControlsDisabled(false);
progressIndicator.setVisible(false);
messageText.setText(resourceBundle.getString("unlock.errorMessage.wrongPassword"));
Platform.runLater(passwordField::requestFocus);
- } catch (UnsupportedKeyLengthException ex) {
+ } catch (FrontendCreationFailedException ex) {
setControlsDisabled(false);
progressIndicator.setVisible(false);
- messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedKeyLengthInstallJCE"));
- LOG.warn("Unsupported Key-Length. Please install Oracle Java Cryptography Extension (JCE).", ex);
- } catch (UnsupportedVaultException e) {
- setControlsDisabled(false);
- progressIndicator.setVisible(false);
- downloadsPageLink.setVisible(true);
- if (e.isVaultOlderThanSoftware()) {
- messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedVersion.vaultOlderThanSoftware") + " ");
- } else if (e.isSoftwareOlderThanVault()) {
- messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedVersion.softwareOlderThanVault") + " ");
- }
- } catch (DestroyFailedException e) {
- setControlsDisabled(false);
- progressIndicator.setVisible(false);
- LOG.error("Destruction of cryptor threw an exception.", e);
+ messageText.setText(resourceBundle.getString("unlock.errorMessage.decryptionFailed"));
+ LOG.error("Decryption failed for technical reasons.", ex);
+ // } catch (UnsupportedVaultException e) {
+ // setControlsDisabled(false);
+ // progressIndicator.setVisible(false);
+ // downloadsPageLink.setVisible(true);
+ // if (e.isVaultOlderThanSoftware()) {
+ // messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedVersion.vaultOlderThanSoftware") + " ");
+ // } else if (e.isSoftwareOlderThanVault()) {
+ // messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedVersion.softwareOlderThanVault") + " ");
+ // }
} finally {
passwordField.swipe();
}
@@ -317,18 +289,9 @@ public class UnlockController extends AbstractFXMLViewController {
progressIndicator.setVisible(false);
setControlsDisabled(false);
if (vault.isUnlocked() && !mountSuccess) {
- exec.submit(() -> {
- vault.stopServer();
- vault.setUnlocked(false);
- });
+ exec.submit(vault::deactivateFrontend);
} else if (vault.isUnlocked() && mountSuccess) {
- exec.submit(() -> {
- try {
- vault.reveal();
- } catch (CommandFailedException e) {
- LOG.error("Failed to reveal mounted vault", e);
- }
- });
+ exec.submit(vault::reveal);
}
if (mountSuccess && listener != null) {
listener.didUnlock(this);
diff --git a/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockedController.java b/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockedController.java
index 2bed56759..34c2e1826 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockedController.java
+++ b/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockedController.java
@@ -15,10 +15,8 @@ import java.util.concurrent.ExecutorService;
import javax.inject.Inject;
import javax.inject.Provider;
-import org.cryptomator.crypto.CryptorIOSampling;
import org.cryptomator.ui.model.Vault;
import org.cryptomator.ui.util.ActiveWindowStyleSupport;
-import org.cryptomator.ui.util.mount.CommandFailedException;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
@@ -30,7 +28,6 @@ import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
-import javafx.scene.chart.XYChart.Data;
import javafx.scene.chart.XYChart.Series;
import javafx.scene.control.Label;
import javafx.stage.Stage;
@@ -81,30 +78,21 @@ public class UnlockedController extends AbstractFXMLViewController {
@FXML
private void didClickRevealVault(ActionEvent event) {
- exec.submit(() -> {
- try {
- vault.reveal();
- } catch (CommandFailedException e) {
- Platform.runLater(() -> {
- messageLabel.setText(resourceBundle.getString("unlocked.label.revealFailed"));
- });
- }
- });
+ exec.submit(vault::reveal);
}
@FXML
private void didClickCloseVault(ActionEvent event) {
exec.submit(() -> {
- try {
- vault.unmount();
- } catch (CommandFailedException e) {
- Platform.runLater(() -> {
- messageLabel.setText(resourceBundle.getString("unlocked.label.unmountFailed"));
- });
- return;
- }
- vault.stopServer();
- vault.setUnlocked(false);
+ // try {
+ vault.unmount();
+ // } catch (CommandFailedException e) {
+ // Platform.runLater(() -> {
+ // messageLabel.setText(resourceBundle.getString("unlocked.label.unmountFailed"));
+ // });
+ // return;
+ // }
+ vault.deactivateFrontend();
if (listener != null) {
Platform.runLater(() -> {
listener.didLock(this);
@@ -129,7 +117,7 @@ public class UnlockedController extends AbstractFXMLViewController {
// IO Graph
// ****************************************
- private void startIoSampling(final CryptorIOSampling sampler) {
+ private void startIoSampling(final Object sampler) {
final Series decryptedBytes = new Series<>();
decryptedBytes.setName("decrypted");
final Series encryptedBytes = new Series<>();
@@ -156,14 +144,14 @@ public class UnlockedController extends AbstractFXMLViewController {
private static final double BYTES_TO_MEGABYTES_FACTOR = 1.0 / IO_SAMPLING_INTERVAL / 1024.0 / 1024.0;
private static final double SMOOTHING_FACTOR = 0.3;
private static final long EFFECTIVELY_ZERO = 100000; // 100kb
- private final CryptorIOSampling sampler;
+ private final Object sampler;
private final Series decryptedBytes;
private final Series encryptedBytes;
- private int step = 0;
- private long oldDecBytes = 0;
- private long oldEncBytes = 0;
+ private final int step = 0;
+ private final long oldDecBytes = 0;
+ private final long oldEncBytes = 0;
- public IoSamplingAnimationHandler(CryptorIOSampling sampler, Series decryptedBytes, Series encryptedBytes) {
+ public IoSamplingAnimationHandler(Object sampler, Series decryptedBytes, Series encryptedBytes) {
this.sampler = sampler;
this.decryptedBytes = decryptedBytes;
this.encryptedBytes = encryptedBytes;
@@ -171,28 +159,30 @@ public class UnlockedController extends AbstractFXMLViewController {
@Override
public void handle(ActionEvent event) {
- step++;
-
- final long decBytes = sampler.pollDecryptedBytes(true);
- final double smoothedDecBytes = oldDecBytes + SMOOTHING_FACTOR * (decBytes - oldDecBytes);
- final double smoothedDecMb = smoothedDecBytes * BYTES_TO_MEGABYTES_FACTOR;
- oldDecBytes = smoothedDecBytes > EFFECTIVELY_ZERO ? (long) smoothedDecBytes : 0l;
- decryptedBytes.getData().add(new Data(step, smoothedDecMb));
- if (decryptedBytes.getData().size() > IO_SAMPLING_STEPS) {
- decryptedBytes.getData().remove(0);
- }
-
- final long encBytes = sampler.pollEncryptedBytes(true);
- final double smoothedEncBytes = oldEncBytes + SMOOTHING_FACTOR * (encBytes - oldEncBytes);
- final double smoothedEncMb = smoothedEncBytes * BYTES_TO_MEGABYTES_FACTOR;
- oldEncBytes = smoothedEncBytes > EFFECTIVELY_ZERO ? (long) smoothedEncBytes : 0l;
- encryptedBytes.getData().add(new Data(step, smoothedEncMb));
- if (encryptedBytes.getData().size() > IO_SAMPLING_STEPS) {
- encryptedBytes.getData().remove(0);
- }
-
- xAxis.setLowerBound(step - IO_SAMPLING_STEPS);
- xAxis.setUpperBound(step);
+ /*
+ * step++;
+ *
+ * final long decBytes = sampler.pollDecryptedBytes(true);
+ * final double smoothedDecBytes = oldDecBytes + SMOOTHING_FACTOR * (decBytes - oldDecBytes);
+ * final double smoothedDecMb = smoothedDecBytes * BYTES_TO_MEGABYTES_FACTOR;
+ * oldDecBytes = smoothedDecBytes > EFFECTIVELY_ZERO ? (long) smoothedDecBytes : 0l;
+ * decryptedBytes.getData().add(new Data(step, smoothedDecMb));
+ * if (decryptedBytes.getData().size() > IO_SAMPLING_STEPS) {
+ * decryptedBytes.getData().remove(0);
+ * }
+ *
+ * final long encBytes = sampler.pollEncryptedBytes(true);
+ * final double smoothedEncBytes = oldEncBytes + SMOOTHING_FACTOR * (encBytes - oldEncBytes);
+ * final double smoothedEncMb = smoothedEncBytes * BYTES_TO_MEGABYTES_FACTOR;
+ * oldEncBytes = smoothedEncBytes > EFFECTIVELY_ZERO ? (long) smoothedEncBytes : 0l;
+ * encryptedBytes.getData().add(new Data(step, smoothedEncMb));
+ * if (encryptedBytes.getData().size() > IO_SAMPLING_STEPS) {
+ * encryptedBytes.getData().remove(0);
+ * }
+ *
+ * xAxis.setLowerBound(step - IO_SAMPLING_STEPS);
+ * xAxis.setUpperBound(step);
+ */
}
}
@@ -216,12 +206,14 @@ public class UnlockedController extends AbstractFXMLViewController {
});
// sample crypto-throughput:
- stopIoSampling();
- if (vault.getCryptor() instanceof CryptorIOSampling) {
- startIoSampling((CryptorIOSampling) vault.getCryptor());
- } else {
- ioGraph.setVisible(false);
- }
+ /*
+ * stopIoSampling();
+ * if (vault.getCryptor() instanceof CryptorIOSampling) {
+ * startIoSampling((CryptorIOSampling) vault.getCryptor());
+ * } else {
+ * ioGraph.setVisible(false);
+ * }
+ */
}
public LockListener getListener() {
diff --git a/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java b/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java
index 455a58a66..f3361e5f9 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java
+++ b/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java
@@ -2,6 +2,8 @@ package org.cryptomator.ui.model;
import java.io.IOException;
import java.io.Serializable;
+import java.io.UncheckedIOException;
+import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.Normalizer;
@@ -11,62 +13,58 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import javax.security.auth.DestroyFailedException;
-
import org.apache.commons.lang3.CharUtils;
import org.apache.commons.lang3.StringUtils;
-import org.cryptomator.crypto.Cryptor;
+import org.cryptomator.filesystem.FileSystem;
+import org.cryptomator.filesystem.crypto.CryptoFileSystemDelegate;
+import org.cryptomator.filesystem.crypto.CryptoFileSystemFactory;
+import org.cryptomator.filesystem.nio.NioFileSystem;
+import org.cryptomator.frontend.Frontend;
+import org.cryptomator.frontend.Frontend.MountParam;
+import org.cryptomator.frontend.FrontendCreationFailedException;
+import org.cryptomator.frontend.FrontendFactory;
import org.cryptomator.ui.util.DeferredClosable;
import org.cryptomator.ui.util.DeferredCloser;
import org.cryptomator.ui.util.FXThreads;
-import org.cryptomator.ui.util.mount.CommandFailedException;
-import org.cryptomator.ui.util.mount.WebDavMount;
-import org.cryptomator.ui.util.mount.WebDavMounter;
-import org.cryptomator.ui.util.mount.WebDavMounter.MountParam;
-import org.cryptomator.webdav.WebDavServer;
-import org.cryptomator.webdav.WebDavServer.ServletLifeCycleAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableMap;
+import dagger.Lazy;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
-public class Vault implements Serializable {
+public class Vault implements Serializable, CryptoFileSystemDelegate {
private static final long serialVersionUID = 3754487289683599469L;
- private static final Logger LOG = LoggerFactory.getLogger(Vault.class);
+ @Deprecated
public static final String VAULT_FILE_EXTENSION = ".cryptomator";
+
+ @Deprecated
public static final String VAULT_MASTERKEY_FILE = "masterkey.cryptomator";
- public static final String VAULT_MASTERKEY_BACKUP_FILE = "masterkey.cryptomator.bkup";
private final Path path;
- private final WebDavServer server;
- private final Cryptor cryptor;
- private final WebDavMounter mounter;
+ private final Lazy frontendFactory;
private final DeferredCloser closer;
+ private final CryptoFileSystemFactory cryptoFileSystemFactory;
private final ObjectProperty unlocked = new SimpleObjectProperty(this, "unlocked", Boolean.FALSE);
private final ObservableList namesOfResourcesWithInvalidMac = FXThreads.observableListOnMainThread(FXCollections.observableArrayList());
private final Set whitelistedResourcesWithInvalidMac = new HashSet<>();
private String mountName;
private Character winDriveLetter;
- private DeferredClosable webDavServlet = DeferredClosable.empty();
- private DeferredClosable webDavMount = DeferredClosable.empty();
+ private DeferredClosable filesystemFrontend = DeferredClosable.empty();
/**
* Package private constructor, use {@link VaultFactory}.
*/
- Vault(final Path vaultDirectoryPath, final WebDavServer server, final Cryptor cryptor, final WebDavMounter mounter, final DeferredCloser closer) {
+ Vault(Path vaultDirectoryPath, Lazy frontendFactory, CryptoFileSystemFactory cryptoFileSystemFactory, DeferredCloser closer) {
this.path = vaultDirectoryPath;
- this.server = server;
- this.cryptor = cryptor;
- this.mounter = mounter;
+ this.frontendFactory = frontendFactory;
this.closer = closer;
+ this.cryptoFileSystemFactory = cryptoFileSystemFactory;
try {
setMountName(getName());
@@ -84,35 +82,34 @@ public class Vault implements Serializable {
return Files.isRegularFile(masterKeyPath);
}
- public synchronized boolean startServer() {
- namesOfResourcesWithInvalidMac.clear();
- whitelistedResourcesWithInvalidMac.clear();
- Optional o = webDavServlet.get();
- if (o.isPresent() && o.get().isRunning()) {
- return false;
+ public void create(CharSequence passphrase) throws IOException {
+ try {
+ FileSystem fs = NioFileSystem.rootedAt(path);
+ if (fs.children().count() > 0) {
+ throw new FileAlreadyExistsException(null, null, "Vault location not empty.");
+ }
+ cryptoFileSystemFactory.get(fs, passphrase, this);
+ } catch (UncheckedIOException e) {
+ throw new IOException(e);
}
- ServletLifeCycleAdapter servlet = server.createServlet(path, cryptor, namesOfResourcesWithInvalidMac, whitelistedResourcesWithInvalidMac, mountName);
- if (servlet.start()) {
- webDavServlet = closer.closeLater(servlet);
- return true;
- }
- return false;
}
- public void stopServer() {
+ public synchronized void activateFrontend(CharSequence passphrase) throws FrontendCreationFailedException {
try {
- unmount();
- } catch (CommandFailedException e) {
- LOG.warn("Unmounting failed. Locking anyway...", e);
+ FileSystem fs = NioFileSystem.rootedAt(path);
+ FileSystem cryptoFs = cryptoFileSystemFactory.get(fs, passphrase, this);
+ String contextPath = StringUtils.prependIfMissing(mountName, "/");
+ Frontend frontend = frontendFactory.get().create(cryptoFs, contextPath);
+ filesystemFrontend = closer.closeLater(frontend);
+ setUnlocked(true);
+ } catch (UncheckedIOException e) {
+ throw new FrontendCreationFailedException(e);
}
- webDavServlet.close();
- try {
- cryptor.destroy();
- } catch (DestroyFailedException e) {
- LOG.error("Destruction of cryptor throw an exception.", e);
- }
- whitelistedResourcesWithInvalidMac.clear();
- namesOfResourcesWithInvalidMac.clear();
+ }
+
+ public synchronized void deactivateFrontend() {
+ filesystemFrontend.close();
+ setUnlocked(false);
}
private Map> getMountParams() {
@@ -123,32 +120,35 @@ public class Vault implements Serializable {
}
public Boolean mount() {
- final ServletLifeCycleAdapter servlet = webDavServlet.get().orElse(null);
- if (servlet == null || !servlet.isRunning()) {
- return false;
- }
- try {
- webDavMount = closer.closeLater(mounter.mount(servlet.getServletUri(), getMountParams()));
- return true;
- } catch (CommandFailedException e) {
- LOG.warn("mount failed", e);
+ // TODO exception handling
+ Frontend frontend = filesystemFrontend.get().orElse(null);
+ if (frontend == null) {
return false;
+ } else {
+ return frontend.mount(getMountParams());
}
}
- public void reveal() throws CommandFailedException {
- final WebDavMount mnt = webDavMount.get().orElse(null);
- if (mnt != null) {
- mnt.reveal();
- }
+ public void reveal() {
+ // TODO exception handling
+ filesystemFrontend.get().ifPresent(Frontend::reveal);
}
- public void unmount() throws CommandFailedException {
- final WebDavMount mnt = webDavMount.get().orElse(null);
- if (mnt != null) {
- mnt.unmount();
- }
- webDavMount = DeferredClosable.empty();
+ public void unmount() {
+ // TODO exception handling
+ filesystemFrontend.get().ifPresent(Frontend::unmount);
+ }
+
+ /* Delegate Methods */
+
+ @Override
+ public void authenticationFailed(String cleartextPath) {
+ namesOfResourcesWithInvalidMac.add(cleartextPath);
+ }
+
+ @Override
+ public boolean shouldSkipAuthentication(String cleartextPath) {
+ return namesOfResourcesWithInvalidMac.contains(cleartextPath);
}
/* Getter/Setter */
@@ -164,9 +164,9 @@ public class Vault implements Serializable {
return StringUtils.removeEnd(path.getFileName().toString(), VAULT_FILE_EXTENSION);
}
- public Cryptor getCryptor() {
- return cryptor;
- }
+ // public Cryptor getCryptor() {
+ // return cryptor;
+ // }
public ObjectProperty unlockedProperty() {
return unlocked;
diff --git a/main/ui/src/main/java/org/cryptomator/ui/model/VaultFactory.java b/main/ui/src/main/java/org/cryptomator/ui/model/VaultFactory.java
index 17ee6f891..9f050b02f 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/model/VaultFactory.java
+++ b/main/ui/src/main/java/org/cryptomator/ui/model/VaultFactory.java
@@ -3,33 +3,31 @@ package org.cryptomator.ui.model;
import java.nio.file.Path;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Provider;
import javax.inject.Singleton;
-import org.cryptomator.crypto.Cryptor;
+import org.cryptomator.filesystem.crypto.CryptoFileSystemFactory;
+import org.cryptomator.frontend.FrontendFactory;
+import org.cryptomator.frontend.webdav.mount.WebDavMounter;
import org.cryptomator.ui.util.DeferredCloser;
-import org.cryptomator.ui.util.mount.WebDavMounter;
-import org.cryptomator.webdav.WebDavServer;
+
+import dagger.Lazy;
@Singleton
public class VaultFactory {
- private final WebDavServer server;
- private final Provider cryptorProvider;
- private final WebDavMounter mounter;
+ private final Lazy frontendFactory;
+ private final CryptoFileSystemFactory cryptoFileSystemFactory;
private final DeferredCloser closer;
@Inject
- public VaultFactory(WebDavServer server, @Named("SamplingCryptor") Provider cryptorProvider, WebDavMounter mounter, DeferredCloser closer) {
- this.server = server;
- this.cryptorProvider = cryptorProvider;
- this.mounter = mounter;
+ public VaultFactory(Lazy frontendFactory, CryptoFileSystemFactory cryptoFileSystemFactory, WebDavMounter mounter, DeferredCloser closer) {
+ this.frontendFactory = frontendFactory;
+ this.cryptoFileSystemFactory = cryptoFileSystemFactory;
this.closer = closer;
}
public Vault createVault(Path path) {
- return new Vault(path, server, cryptorProvider.get(), mounter, closer);
+ return new Vault(path, frontendFactory, cryptoFileSystemFactory, closer);
}
}