This commit is contained in:
Sebastian Stenzel
2019-01-31 15:37:01 +01:00
parent c78d4c2d0e
commit 528005a623
4 changed files with 30 additions and 15 deletions

View File

@@ -40,7 +40,6 @@ import org.cryptomator.frontend.webdav.ServerLifecycleException;
import org.cryptomator.keychain.KeychainAccess;
import org.cryptomator.ui.controls.SecPasswordField;
import org.cryptomator.ui.l10n.Localization;
import org.cryptomator.ui.model.InvalidSettingsException;
import org.cryptomator.ui.model.Vault;
import org.cryptomator.ui.model.WindowsDriveLetters;
import org.cryptomator.ui.util.DialogBuilderUtil;
@@ -51,6 +50,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.NotDirectoryException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Objects;
@@ -401,10 +402,6 @@ public class UnlockController implements ViewController {
messageText.setText(null);
downloadsPageLink.setVisible(false);
listener.ifPresent(lstnr -> lstnr.didUnlock(vault));
}).onError(InvalidSettingsException.class, e -> {
messageText.setText(localization.getString("unlock.errorMessage.invalidMountPath"));
advancedOptions.setVisible(true);
customMountPathField.setStyle("-fx-border-color: red;");
}).onError(InvalidPassphraseException.class, e -> {
messageText.setText(localization.getString("unlock.errorMessage.wrongPassword"));
passwordField.selectAll();
@@ -423,6 +420,16 @@ public class UnlockController implements ViewController {
}).onError(ServerLifecycleException.class, e -> {
LOG.error("Unlock failed for technical reasons.", e);
messageText.setText(localization.getString("unlock.errorMessage.unlockFailed"));
}).onError(NotDirectoryException.class, e -> {
LOG.error("Mount point not a directory.", e);
advancedOptions.setVisible(true);
customMountPathField.setStyle("-fx-border-color: red;");
showUnlockFailedErrorDialog("unlock.failedDialog.content.mountPathNonExisting");
}).onError(DirectoryNotEmptyException.class, e -> {
LOG.error("Mount point not empty.", e);
advancedOptions.setVisible(true);
customMountPathField.setStyle("-fx-border-color: red;");
showUnlockFailedErrorDialog("unlock.failedDialog.content.mountPathNotEmpty");
}).onError(Exception.class, e -> {
LOG.error("Unlock failed for technical reasons.", e);
messageText.setText(localization.getString("unlock.errorMessage.unlockFailed"));
@@ -438,6 +445,14 @@ public class UnlockController implements ViewController {
}).runOnce(executor);
}
private void showUnlockFailedErrorDialog(String localizableContentKey) {
String title = localization.getString("unlock.failedDialog.title");
String header = localization.getString("unlock.failedDialog.header");
String content = localization.getString(localizableContentKey);
Alert alert = DialogBuilderUtil.buildErrorDialog(title, header, content, ButtonType.OK);
alert.show();
}
/* callback */
public void setListener(UnlockListener listener) {

View File

@@ -1,5 +0,0 @@
package org.cryptomator.ui.model;
public class InvalidSettingsException extends RuntimeException {
}

View File

@@ -35,6 +35,7 @@ import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.NotDirectoryException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
@@ -97,11 +98,11 @@ public class Vault {
CryptoFileSystemProvider.changePassphrase(getPath(), MASTERKEY_FILENAME, oldPassphrase, newPassphrase);
}
public synchronized void unlock(CharSequence passphrase) throws InvalidSettingsException, CryptoException, IOException, Volume.VolumeException {
public synchronized void unlock(CharSequence passphrase) throws CryptoException, IOException, Volume.VolumeException {
Platform.runLater(() -> state.set(State.PROCESSING));
try {
if (vaultSettings.usesIndividualMountPath().and(vaultSettings.individualMountPath().isEmpty()).get()) {
throw new InvalidSettingsException();
if (vaultSettings.usesIndividualMountPath().get() && vaultSettings.individualMountPath().get().isEmpty()) {
throw new NotDirectoryException("");
}
CryptoFileSystem fs = getCryptoFileSystem(passphrase);
volume = volumeProvider.get();

View File

@@ -88,8 +88,6 @@ unlock.savePassword.delete.confirmation.content=The saved password of this vault
unlock.choicebox.winDriveLetter.auto=Assign automatically
unlock.pendingMessage.unlocking=Unlocking vault...
unlock.errorMessage.wrongPassword=Wrong password
unlock.errorMessage.wrongPassword=Wrong Password
unlock.errorMessage.invalidMountPath=Use of custom mount path selected, but no path given.
unlock.errorMessage.unlockFailed=Unlock failed. See log file for details.
unlock.errorMessage.unsupportedVersion.vaultOlderThanSoftware=Unsupported vault. This vault has been created with an older version of Cryptomator.
unlock.errorMessage.unsupportedVersion.softwareOlderThanVault=Unsupported vault. This vault has been created with a newer version of Cryptomator.
@@ -99,6 +97,12 @@ unlock.successLabel.vaultCreated=Vault was successfully created.
unlock.successLabel.passwordChanged=Password was successfully changed.
unlock.successLabel.upgraded=Cryptomator was successfully upgraded.
unlock.failedDialog.title=Unlock failed
unlock.failedDialog.header=Unlock failed
unlock.failedDialog.content.mountPathNonExisting=Mount point does not exist.
unlock.failedDialog.content.mountPathNotEmpty=Mount point is not empty.
# change_password.fxml
changePassword.label.oldPassword=Old Password
changePassword.label.newPassword=New Password