From 277999112e08cfe3b5a89918319e385bc5e25109 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Fri, 24 Feb 2017 16:48:15 +0100 Subject: [PATCH] Updated dependencies --- .../WindowsProtectedKeychainAccessTest.java | 2 +- main/pom.xml | 30 +++++----- .../ui/controllers/UnlockController.java | 3 +- .../ui/controllers/UnlockedController.java | 3 +- .../java/org/cryptomator/ui/model/Vault.java | 58 ++++++++++++------- 5 files changed, 58 insertions(+), 38 deletions(-) diff --git a/main/keychain/src/test/java/org/cryptomator/keychain/WindowsProtectedKeychainAccessTest.java b/main/keychain/src/test/java/org/cryptomator/keychain/WindowsProtectedKeychainAccessTest.java index 9b3fd94e8..da6ec67e2 100644 --- a/main/keychain/src/test/java/org/cryptomator/keychain/WindowsProtectedKeychainAccessTest.java +++ b/main/keychain/src/test/java/org/cryptomator/keychain/WindowsProtectedKeychainAccessTest.java @@ -31,7 +31,7 @@ public class WindowsProtectedKeychainAccessTest { WinFunctions winFunctions = Mockito.mock(WinFunctions.class); WinDataProtection winDataProtection = Mockito.mock(WinDataProtection.class); Mockito.when(winFunctions.dataProtection()).thenReturn(winDataProtection); - Answer answerReturningFirstArg = invocation -> invocation.getArgumentAt(0, byte[].class).clone(); + Answer answerReturningFirstArg = invocation -> ((byte[]) invocation.getArgument(0)).clone(); Mockito.when(winDataProtection.protect(Mockito.any(), Mockito.any())).thenAnswer(answerReturningFirstArg); Mockito.when(winDataProtection.unprotect(Mockito.any(), Mockito.any())).thenAnswer(answerReturningFirstArg); keychain = new WindowsProtectedKeychainAccess(Optional.of(winFunctions)); diff --git a/main/pom.xml b/main/pom.xml index a53f15157..1056ecc4e 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -27,22 +27,25 @@ UTF-8 - 1.0.9 - 1.1.0-SNAPSHOT - 0.3.0-SNAPSHOT + 1.1.0 + 1.1.0 + 0.4.0-SNAPSHOT 1.0.0 2.1 - 1.7.7 + 1.7.22 4.12 4.12.1 1.3 2.4 4.0 - 3.4 + 3.5 1.10 3.1 - 1.10.19 - 2.6.1 + 2.7.9 + 2.8 + 1.0.3 + 21.0 + 2.8.0 @@ -159,14 +162,14 @@ org.fxmisc.easybind easybind - 1.0.3 + ${easybind.version} com.google.guava guava - 19.0 + ${guava.version} @@ -186,7 +189,7 @@ com.google.code.gson gson - 2.8.0 + ${gson.version} @@ -267,8 +270,8 @@ - org.apache.maven.plugins maven-dependency-plugin + 3.0.0 copy-libs @@ -285,7 +288,7 @@ org.jacoco jacoco-maven-plugin - 0.7.7.201606060606 + 0.7.9 prepare-agent @@ -305,9 +308,8 @@ - org.apache.maven.plugins maven-compiler-plugin - 3.2 + 3.6.1 1.8 1.8 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 117f53f4c..d4ec76929 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 @@ -317,7 +317,8 @@ public class UnlockController extends LocalizedFXMLViewController { private void unlock(CharSequence password) { try { - vault.activateFrontend(password); + vault.unlock(password); + vault.mount(); vault.reveal(); Platform.runLater(() -> { messageText.setText(null); 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 c2c578e7d..533b03c51 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 @@ -105,7 +105,8 @@ public class UnlockedController extends LocalizedFXMLViewController { @FXML private void didClickLockVault(ActionEvent event) { asyncTaskService.asyncTaskOf(() -> { - vault.get().deactivateFrontend(); + vault.get().unmount(); + vault.get().lock(); }).onSuccess(() -> { listener.ifPresent(listener -> listener.didLock(this)); }).onError(Exception.class, () -> { 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 e933f1eef..03e39fb04 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 @@ -16,7 +16,8 @@ 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.HashMap; +import java.util.Map; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; @@ -33,8 +34,10 @@ 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.mount.Mounter.MountParam; import org.cryptomator.frontend.webdav.servlet.WebDavServletController; import org.cryptomator.ui.model.VaultModule.PerVault; +import org.cryptomator.ui.settings.Settings; import org.cryptomator.ui.settings.VaultSettings; import org.cryptomator.ui.util.DeferredCloser; import org.fxmisc.easybind.EasyBind; @@ -52,6 +55,7 @@ public class Vault { private static final Logger LOG = LoggerFactory.getLogger(Vault.class); private static final String MASTERKEY_FILENAME = "masterkey.cryptomator"; + private final Settings settings; private final VaultSettings vaultSettings; private final WebDavServer server; private final DeferredCloser closer; @@ -63,7 +67,8 @@ public class Vault { private Mount mount; @Inject - Vault(VaultSettings vaultSettings, WebDavServer server, DeferredCloser closer) { + Vault(Settings settings, VaultSettings vaultSettings, WebDavServer server, DeferredCloser closer) { + this.settings = settings; this.vaultSettings = vaultSettings; this.server = server; this.closer = closer; @@ -106,9 +111,7 @@ public class Vault { CryptoFileSystemProvider.changePassphrase(getPath(), MASTERKEY_FILENAME, oldPassphrase, newPassphrase); } - public synchronized void activateFrontend(CharSequence passphrase) { - boolean unlockSuccess = false; - boolean mountSuccess = false; + public synchronized void unlock(CharSequence passphrase) { try { FileSystem fs = getCryptoFileSystem(passphrase); if (!server.isRunning()) { @@ -116,29 +119,43 @@ public class Vault { } servlet = server.createWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.mountName().get()); servlet.start(); - unlockSuccess = true; - - mount = servlet.mount(Collections.emptyMap()); - mountSuccess = true; + Platform.runLater(() -> { + unlocked.set(true); + }); } catch (IOException 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(finalUnlockSuccess); - mounted.set(finalMountSuccess); - }); } } - public synchronized void deactivateFrontend() throws Exception { + public synchronized void mount() { + if (servlet == null) { + throw new IllegalStateException("Mounting requires unlocked WebDAV servlet."); + } + + Map mountOptions = new HashMap<>(); + mountOptions.put(MountParam.WIN_DRIVE_LETTER, vaultSettings.winDriveLetter().get()); + mountOptions.put(MountParam.PREFERRED_GVFS_SCHEME, settings.preferredGvfsScheme().get()); + + try { + mount = servlet.mount(mountOptions); + Platform.runLater(() -> { + mounted.set(true); + }); + } catch (CommandFailedException e) { + LOG.error("Unable to mount filesystem", e); + } + } + + public synchronized void unmount() throws Exception { if (mount != null) { mount.unmount(); } + Platform.runLater(() -> { + mounted.set(false); + }); + } + + public synchronized void lock() throws Exception { if (servlet != null) { servlet.stop(); } @@ -147,7 +164,6 @@ public class Vault { fs.close(); } Platform.runLater(() -> { - mounted.set(false); unlocked.set(false); }); }