Merge pull request #1823 from purejava/feature/displayName

Pass the name of the vault on storing and changing a passphrase
This commit is contained in:
Sebastian Stenzel
2021-12-02 09:00:03 +01:00
committed by GitHub
4 changed files with 17 additions and 3 deletions

View File

@@ -28,7 +28,7 @@
<!-- cryptomator dependencies -->
<cryptomator.cryptofs.version>2.3.0</cryptomator.cryptofs.version>
<cryptomator.integrations.version>1.0.0</cryptomator.integrations.version>
<cryptomator.integrations.version>1.1.0-beta1</cryptomator.integrations.version>
<cryptomator.integrations.win.version>1.0.0</cryptomator.integrations.win.version>
<cryptomator.integrations.mac.version>1.0.0</cryptomator.integrations.mac.version>
<cryptomator.integrations.linux.version>1.0.1</cryptomator.integrations.linux.version>

View File

@@ -49,6 +49,12 @@ public class KeychainManager implements KeychainAccessProvider {
setPassphraseStored(key, true);
}
@Override
public void storePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException {
getKeychainOrFail().storePassphrase(key, displayName, passphrase);
setPassphraseStored(key, true);
}
@Override
public char[] loadPassphrase(String key) throws KeychainAccessException {
char[] passphrase = getKeychainOrFail().loadPassphrase(key);
@@ -70,6 +76,14 @@ public class KeychainManager implements KeychainAccessProvider {
}
}
@Override
public void changePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException {
if (isPassphraseStored(key)) {
getKeychainOrFail().changePassphrase(key, displayName, passphrase);
setPassphraseStored(key, true);
}
}
@Override
public boolean isSupported() {
return keychain.getValue() != null;

View File

@@ -102,7 +102,7 @@ public class ChangePasswordController implements FxController {
private void updatePasswordInSystemkeychain() {
if (keychain.isSupported() && !keychain.isLocked()) {
try {
keychain.changePassphrase(vault.getId(), newPasswordController.passwordField.getCharacters());
keychain.changePassphrase(vault.getId(), vault.getDisplayName(), newPasswordController.passwordField.getCharacters());
LOG.info("Successfully updated password in system keychain for {}", vault.getDisplayName());
} catch (KeychainAccessException e) {
LOG.error("Failed to update password in system keychain.", e);

View File

@@ -47,7 +47,7 @@ class MasterkeyFileLoadingFinisher {
private void savePasswordToSystemkeychain() {
if (keychain.isSupported()) {
try {
keychain.storePassphrase(vault.getId(), CharBuffer.wrap(enteredPassword.get()));
keychain.storePassphrase(vault.getId(), vault.getDisplayName(), CharBuffer.wrap(enteredPassword.get()));
} catch (KeychainAccessException e) {
LOG.error("Failed to store passphrase in system keychain.", e);
}