addressed some issues identified during code review

This commit is contained in:
Sebastian Stenzel
2021-04-23 10:24:31 +02:00
parent 69c63702f2
commit 34995088ba
7 changed files with 10 additions and 17 deletions
@@ -31,13 +31,13 @@ import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.security.SecureRandom;
import static org.cryptomator.common.Constants.MASTERKEY_BACKUP_SUFFIX;
import static org.cryptomator.common.Constants.MASTERKEY_FILENAME;
@ChangePasswordScoped
public class ChangePasswordController implements FxController {
private static final Logger LOG = LoggerFactory.getLogger(ChangePasswordController.class);
private static final String MASTERKEY_BACKUP_SUFFIX = ".bkup";
private final Stage window;
private final Vault vault;
@@ -14,28 +14,21 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import static org.cryptomator.common.Constants.MASTERKEY_BACKUP_SUFFIX;
import static org.cryptomator.common.Constants.MASTERKEY_FILENAME;
import static org.cryptomator.common.Constants.PEPPER;
@Singleton
public class RecoveryKeyFactory {
private static final String MASTERKEY_BACKUP_SUFFIX = ".bkup";
private final WordEncoder wordEncoder;
private final SecureRandom csprng;
private final MasterkeyFileAccess masterkeyFileAccess;
@Inject
public RecoveryKeyFactory(WordEncoder wordEncoder, SecureRandom csprng, MasterkeyFileAccess masterkeyFileAccess) {
public RecoveryKeyFactory(WordEncoder wordEncoder, MasterkeyFileAccess masterkeyFileAccess) {
this.wordEncoder = wordEncoder;
this.csprng = csprng;
this.masterkeyFileAccess = masterkeyFileAccess;
}
@@ -92,6 +85,7 @@ public class RecoveryKeyFactory {
Path masterkeyPath = vaultPath.resolve(MASTERKEY_FILENAME);
if (Files.exists(masterkeyPath)) {
byte[] oldMasterkeyBytes = Files.readAllBytes(masterkeyPath);
// TODO: deduplicate with ChangePasswordController:
Path backupKeyPath = vaultPath.resolve(MASTERKEY_FILENAME + MasterkeyBackupHelper.generateFileIdSuffix(oldMasterkeyBytes) + MASTERKEY_BACKUP_SUFFIX);
Files.move(masterkeyPath, backupKeyPath, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
}
@@ -26,7 +26,7 @@
<FontAwesome5IconView styleClass="glyph-icon-white" glyph="FILE" glyphSize="24"/>
</StackPane>
<VBox spacing="6">
<Label text="Could not find the masterkey file for this vault at its expected location. Please choose the key file manually." wrapText="true" HBox.hgrow="ALWAYS"/>
<Label text="%unlock.chooseMasterkey.prompt" wrapText="true" HBox.hgrow="ALWAYS"/>
</VBox>
</HBox>
@@ -101,6 +101,7 @@ unlock.passwordPrompt=Enter password for "%s":
unlock.savePassword=Remember Password
unlock.unlockBtn=Unlock
##
unlock.chooseMasterkey.prompt=Could not find the masterkey file for this vault at its expected location. Please choose the key file manually.
unlock.chooseMasterkey.filePickerTitle=Select Masterkey File
## Success
unlock.success.message=Unlocked "%s" successfully! Your vault is now accessible via its virtual drive.