diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-08-01 14:15:02 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-08-01 14:15:02 +0200 |
commit | d728b114cad24e7de563e1d06daa89c2aa634e42 (patch) | |
tree | 1306a1b2dcb7024e385d874b56a6e0025e49dfd0 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration | |
parent | 308e897e4a9a73f3242f1815b109ab2aa28c69cf (diff) | |
download | pdf-over-d728b114cad24e7de563e1d06daa89c2aa634e42.tar.gz pdf-over-d728b114cad24e7de563e1d06daa89c2aa634e42.tar.bz2 pdf-over-d728b114cad24e7de563e1d06daa89c2aa634e42.zip |
do not prompt for keystore password on config save
cf. #68
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java index 4b2499e6..37d11691 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java @@ -530,48 +530,31 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { // Fall through case 1: try { - loadKeystore(); + if (config.keystoreStorePass != null) /* don't cause password prompts, just silently accept if there is no saved password */ + loadKeystore(); } catch (Exception e) { throw new CantLoadKeystoreException(e, 4); //skip next checks } // Fall through case 2: { - String alias = config.keystoreAlias; - if (!this.ks.containsAlias(alias)) - throw new KeystoreAliasDoesntExistException(alias, 4); //skip next check - if (!this.ks.isKeyEntry(alias)) - throw new KeystoreAliasNoKeyException(alias, 4); //skip next check + if (this.ks != null) + { + String alias = config.keystoreAlias; + if (!this.ks.containsAlias(alias)) + throw new KeystoreAliasDoesntExistException(alias, 4); //skip next check + if (!this.ks.isKeyEntry(alias)) + throw new KeystoreAliasNoKeyException(alias, 4); //skip next check + } } // Fall through case 3: try { String alias = config.keystoreAlias; String keypass = config.keystoreKeyPass; - if (keypass != null) + if ((this.ks != null) && (keypass != null)) { /* if no keypass is specified, this will happen at signature time */ - Key key = null; - while (key == null) - { - if (keypass == null) - { - keypass = new PasswordInputDialog( - getShell(), - Messages.getString("keystore_config.KeystoreKeyPass"), - Messages.getString("keystore.KeystoreKeyPassEntry")).open(); - - if (keypass == null) - throw new UnrecoverableKeyException("User cancelled password input"); - } - - try { - key = this.ks.getKey(alias, keypass.toCharArray()); - } catch (UnrecoverableKeyException ex) { - new ErrorDialog(getShell(), Messages.getString("error.KeyStoreKeyPass"), BUTTONS.OK).open(); - keypass = null; - } - } - config.keystoreKeyPass = keypass; + this.ks.getKey(alias, keypass.toCharArray()); } } catch (Exception e) { throw new KeystoreKeyPasswordException(4); |