mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-08-20 14:16:01 +00:00
fixes #526
This commit is contained in:
@@ -48,7 +48,7 @@ public final class LazyInitializer {
|
|||||||
try {
|
try {
|
||||||
return reference.updateAndGet(invokeFactoryIfNull(factory));
|
return reference.updateAndGet(invokeFactoryIfNull(factory));
|
||||||
} catch (InitializationException e) {
|
} catch (InitializationException e) {
|
||||||
Throwables.throwIfUnchecked(e);
|
Throwables.throwIfUnchecked(e.getCause());
|
||||||
Throwables.throwIfInstanceOf(e.getCause(), exceptionType);
|
Throwables.throwIfInstanceOf(e.getCause(), exceptionType);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,6 @@ public final class LazyInitializer {
|
|||||||
try {
|
try {
|
||||||
return factory.get();
|
return factory.get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.throwIfUnchecked(e); // don't catch unchecked exceptions
|
|
||||||
throw new InitializationException(e);
|
throw new InitializationException(e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.cryptomator.ui.controllers;
|
package org.cryptomator.ui.controllers;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -372,6 +373,9 @@ public class UnlockController implements ViewController {
|
|||||||
}).onError(ServerLifecycleException.class, e -> {
|
}).onError(ServerLifecycleException.class, e -> {
|
||||||
LOG.error("Unlock failed for technical reasons.", e);
|
LOG.error("Unlock failed for technical reasons.", e);
|
||||||
messageText.setText(localization.getString("unlock.errorMessage.unlockFailed"));
|
messageText.setText(localization.getString("unlock.errorMessage.unlockFailed"));
|
||||||
|
}).onError(IOException.class, e -> {
|
||||||
|
LOG.error("Unlock failed for technical reasons.", e);
|
||||||
|
messageText.setText(localization.getString("unlock.errorMessage.unlockFailed"));
|
||||||
}).andFinally(() -> {
|
}).andFinally(() -> {
|
||||||
if (!savePassword.isSelected()) {
|
if (!savePassword.isSelected()) {
|
||||||
passwordField.swipe();
|
passwordField.swipe();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.cryptomator.ui.model;
|
package org.cryptomator.ui.model;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -74,7 +75,7 @@ public class AutoUnlocker {
|
|||||||
try {
|
try {
|
||||||
vault.unlock(CharBuffer.wrap(storedPw));
|
vault.unlock(CharBuffer.wrap(storedPw));
|
||||||
mountSilently(vault);
|
mountSilently(vault);
|
||||||
} catch (CryptoException e) {
|
} catch (IOException | CryptoException e) {
|
||||||
LOG.error("Auto unlock failed.", e);
|
LOG.error("Auto unlock failed.", e);
|
||||||
} finally {
|
} finally {
|
||||||
Arrays.fill(storedPw, ' ');
|
Arrays.fill(storedPw, ' ');
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.nio.file.DirectoryStream;
|
|||||||
import java.nio.file.FileAlreadyExistsException;
|
import java.nio.file.FileAlreadyExistsException;
|
||||||
import java.nio.file.FileSystem;
|
import java.nio.file.FileSystem;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.NoSuchFileException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -84,11 +85,11 @@ public class Vault {
|
|||||||
// Commands
|
// Commands
|
||||||
// ********************************************************************************/
|
// ********************************************************************************/
|
||||||
|
|
||||||
private CryptoFileSystem getCryptoFileSystem(CharSequence passphrase) throws IOException, InvalidPassphraseException, CryptoException {
|
private CryptoFileSystem getCryptoFileSystem(CharSequence passphrase) throws NoSuchFileException, IOException, InvalidPassphraseException, CryptoException {
|
||||||
return LazyInitializer.initializeLazily(cryptoFileSystem, () -> unlockCryptoFileSystem(passphrase), IOException.class);
|
return LazyInitializer.initializeLazily(cryptoFileSystem, () -> unlockCryptoFileSystem(passphrase), IOException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CryptoFileSystem unlockCryptoFileSystem(CharSequence passphrase) throws IOException, InvalidPassphraseException, CryptoException {
|
private CryptoFileSystem unlockCryptoFileSystem(CharSequence passphrase) throws NoSuchFileException, IOException, InvalidPassphraseException, CryptoException {
|
||||||
CryptoFileSystemProperties fsProps = CryptoFileSystemProperties.cryptoFileSystemProperties() //
|
CryptoFileSystemProperties fsProps = CryptoFileSystemProperties.cryptoFileSystemProperties() //
|
||||||
.withPassphrase(passphrase) //
|
.withPassphrase(passphrase) //
|
||||||
.withFlags() //
|
.withFlags() //
|
||||||
@@ -116,20 +117,16 @@ public class Vault {
|
|||||||
CryptoFileSystemProvider.changePassphrase(getPath(), MASTERKEY_FILENAME, oldPassphrase, newPassphrase);
|
CryptoFileSystemProvider.changePassphrase(getPath(), MASTERKEY_FILENAME, oldPassphrase, newPassphrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void unlock(CharSequence passphrase) throws InvalidPassphraseException, ServerLifecycleException {
|
public synchronized void unlock(CharSequence passphrase) throws ServerLifecycleException, CryptoException, IOException {
|
||||||
try {
|
FileSystem fs = getCryptoFileSystem(passphrase);
|
||||||
FileSystem fs = getCryptoFileSystem(passphrase);
|
if (!server.isRunning()) {
|
||||||
if (!server.isRunning()) {
|
server.start();
|
||||||
server.start();
|
|
||||||
}
|
|
||||||
servlet = server.createWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.mountName().get());
|
|
||||||
servlet.start();
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
state.set(State.UNLOCKED);
|
|
||||||
});
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.error("Unable to provide filesystem", e);
|
|
||||||
}
|
}
|
||||||
|
servlet = server.createWebDavServlet(fs.getPath("/"), vaultSettings.getId() + "/" + vaultSettings.mountName().get());
|
||||||
|
servlet.start();
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
state.set(State.UNLOCKED);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void mount() throws CommandFailedException {
|
public synchronized void mount() throws CommandFailedException {
|
||||||
|
|||||||
Reference in New Issue
Block a user