summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-07-08 11:33:57 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-07-08 11:33:57 +0200
commitef1113edf2cafaffc3668ea27b295d9a738f1a24 (patch)
tree8ed48e6f9e2f449aa1ea01cbfc1d691855c30641 /pdf-over-gui/src/main/java/at/asit
parentd4012ee29fe041885c01baea41d4ac9e40e2706a (diff)
downloadpdf-over-ef1113edf2cafaffc3668ea27b295d9a738f1a24.tar.gz
pdf-over-ef1113edf2cafaffc3668ea27b295d9a738f1a24.tar.bz2
pdf-over-ef1113edf2cafaffc3668ea27b295d9a738f1a24.zip
keystore configuration redesign for #68 and #69
(todo: trial-and-error + saving in memory)
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java1
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java141
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java88
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java5
5 files changed, 162 insertions, 75 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java
index e013b7f8..23d00c06 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java
@@ -16,7 +16,6 @@
package at.asit.pdfover.gui.cliarguments;
import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.signator.SignaturePosition;
/**
* CLI Argument to set the BKU to use
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 757c31d7..86a9f5e9 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
@@ -27,7 +27,10 @@ import java.security.cert.CertificateException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
+import java.util.Vector;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
@@ -56,6 +59,7 @@ import at.asit.pdfover.gui.exceptions.KeystoreDoesntExistException;
import at.asit.pdfover.gui.exceptions.KeystoreKeyPasswordException;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
+import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory.KeyStorePassStorageType;
import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
import at.asit.pdfover.gui.workflow.states.State;
import iaik.security.provider.IAIK;
@@ -77,16 +81,16 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
private Button btnBrowse;
private Label lblKeystoreType;
Combo cmbKeystoreType;
- private Label lblKeystoreStorePass;
- Text txtKeystoreStorePass;
private Button btnLoad;
private Label lblKeystoreAlias;
Combo cmbKeystoreAlias;
+ private Label lblKeystorePassStoreType;
+ Combo cmbKeystorePassStoreType;
+ private Label lblKeystoreStorePass;
+ Text txtKeystoreStorePass;
private Label lblKeystoreKeyPass;
Text txtKeystoreKeyPass;
- Map<String, String> keystoreTypes;
-
private KeyStore ks;
/**
@@ -129,24 +133,17 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
StateComposite.anchor(lblKeystoreType).top(txtKeystoreFile, 5).left(0,5).set();
StateComposite.setFontHeight(lblKeystoreType, Constants.TEXT_SIZE_NORMAL);
+ this.btnLoad = new Button(this.grpKeystore, SWT.NONE);
+ StateComposite.anchor(btnLoad).top(lblKeystoreType, 5).right(100,-5).set();
+ StateComposite.setFontHeight(btnLoad, Constants.TEXT_SIZE_BUTTON);
+
this.cmbKeystoreType = new Combo(grpKeystore, SWT.READ_ONLY);
- StateComposite.anchor(cmbKeystoreType).right(100, -5).top(lblKeystoreType, 5).left(0,15).set();
+ StateComposite.anchor(cmbKeystoreType).top(lblKeystoreType, 5).left(0,15).right(btnLoad, -5).set();
StateComposite.setFontHeight(cmbKeystoreType, Constants.TEXT_SIZE_NORMAL);
StateComposite.disableEventDefault(cmbKeystoreType, SWT.MouseVerticalWheel);
- this.lblKeystoreStorePass = new Label(this.grpKeystore, SWT.NONE);
- StateComposite.anchor(lblKeystoreStorePass).top(cmbKeystoreType, 5).left(0,5).set();
- StateComposite.setFontHeight(lblKeystoreStorePass, Constants.TEXT_SIZE_NORMAL);
-
- this.txtKeystoreStorePass = new Text(this.grpKeystore, SWT.BORDER | SWT.PASSWORD);
- this.btnLoad = new Button(this.grpKeystore, SWT.NONE);
- StateComposite.anchor(txtKeystoreStorePass).top(lblKeystoreStorePass, 5).left(0,15).right(btnLoad, -5).set();
- StateComposite.anchor(btnLoad).top(lblKeystoreStorePass, 5).right(100,-5).set();
- StateComposite.setFontHeight(txtKeystoreStorePass, Constants.TEXT_SIZE_NORMAL);
- StateComposite.setFontHeight(btnLoad, Constants.TEXT_SIZE_BUTTON);
-
this.lblKeystoreAlias = new Label(grpKeystore, SWT.NONE);
- StateComposite.anchor(lblKeystoreAlias).top(txtKeystoreStorePass, 5).left(0, 5).set();
+ StateComposite.anchor(lblKeystoreAlias).top(cmbKeystoreType, 5).left(0, 5).set();
StateComposite.setFontHeight(lblKeystoreAlias, Constants.TEXT_SIZE_NORMAL);
this.cmbKeystoreAlias = new Combo(grpKeystore, SWT.NONE);
@@ -154,11 +151,28 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
StateComposite.setFontHeight(cmbKeystoreAlias, Constants.TEXT_SIZE_NORMAL);
StateComposite.disableEventDefault(cmbKeystoreAlias, SWT.MouseVerticalWheel);
- this.lblKeystoreKeyPass = new Label(this.grpKeystore, SWT.NONE);
- StateComposite.anchor(lblKeystoreKeyPass).top(cmbKeystoreAlias, 5).left(0,5).set();
+ this.lblKeystorePassStoreType = new Label(this.grpKeystore, SWT.NONE);
+ StateComposite.anchor(lblKeystorePassStoreType).top(cmbKeystoreAlias, 5).left(0,5).set();
+ StateComposite.setFontHeight(lblKeystorePassStoreType, Constants.TEXT_SIZE_NORMAL);
+
+ this.cmbKeystorePassStoreType = new Combo(grpKeystore, SWT.READ_ONLY);
+ StateComposite.anchor(cmbKeystorePassStoreType).top(lblKeystorePassStoreType, 5).left(0,15).right(100,-5).set();
+ StateComposite.setFontHeight(cmbKeystorePassStoreType, Constants.TEXT_SIZE_NORMAL);
+ StateComposite.disableEventDefault(cmbKeystorePassStoreType, SWT.MouseVerticalWheel);
+
+ this.lblKeystoreStorePass = new Label(grpKeystore, SWT.NONE);
+ StateComposite.anchor(lblKeystoreStorePass).top(cmbKeystorePassStoreType, 5).left(0,5).set();
+ StateComposite.setFontHeight(lblKeystoreStorePass, Constants.TEXT_SIZE_NORMAL);
+
+ this.txtKeystoreStorePass = new Text(grpKeystore, SWT.BORDER | SWT.PASSWORD);
+ StateComposite.anchor(txtKeystoreStorePass).right(100, -5).top(lblKeystoreStorePass, 5).left(0,15).set();
+ StateComposite.setFontHeight(txtKeystoreStorePass, Constants.TEXT_SIZE_NORMAL);
+
+ this.lblKeystoreKeyPass = new Label(grpKeystore, SWT.NONE);
+ StateComposite.anchor(lblKeystoreKeyPass).top(txtKeystoreStorePass, 5).left(0,5).set();
StateComposite.setFontHeight(lblKeystoreKeyPass, Constants.TEXT_SIZE_NORMAL);
- this.txtKeystoreKeyPass = new Text(this.grpKeystore, SWT.BORDER | SWT.PASSWORD);
+ this.txtKeystoreKeyPass = new Text(grpKeystore, SWT.BORDER | SWT.PASSWORD);
StateComposite.anchor(txtKeystoreKeyPass).top(lblKeystoreKeyPass, 5).left(0,15).right(100,-5).set();
StateComposite.setFontHeight(txtKeystoreKeyPass, Constants.TEXT_SIZE_NORMAL);
@@ -251,16 +265,25 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
this.cmbKeystoreAlias.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
- performKeystoreAliasChanged(KeystoreConfigurationComposite.
- this.cmbKeystoreAlias.getText());
+ performKeystoreAliasChanged(KeystoreConfigurationComposite.this.cmbKeystoreAlias.getText());
+ }
+ });
+
+ this.cmbKeystorePassStoreType.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ performKeystorePassStorageTypeChanged(
+ keystorePassStorageTypeOptions.get(
+ KeystoreConfigurationComposite.this.cmbKeystorePassStoreType.getSelectionIndex()
+ ).getLeft()
+ );
}
});
this.txtKeystoreKeyPass.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
- performKeystoreKeyPassChanged(KeystoreConfigurationComposite.
- this.txtKeystoreKeyPass.getText());
+ performKeystoreKeyPassChanged(KeystoreConfigurationComposite.this.txtKeystoreKeyPass.getText());
}
});
@@ -291,12 +314,6 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
this.cmbKeystoreAlias.add(aliases.nextElement());
}
- private void initKeystoreTypes() {
- this.keystoreTypes = new HashMap<String, String>();
- this.keystoreTypes.put(Messages.getString("keystore_config.KeystoreType_PKCS12"), "PKCS12");
- this.keystoreTypes.put(Messages.getString("keystore_config.KeystoreType_JKS"), "JCEKS");
- }
-
/**
* @param fileName
*/
@@ -333,13 +350,34 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
}
}
+ protected void performKeystorePassStorageTypeChanged(KeyStorePassStorageType p) {
+ this.configurationContainer.keystorePassStorageType = p;
+ for (int i=0; i<keystorePassStorageTypeOptions.size(); ++i)
+ {
+ if (keystorePassStorageTypeOptions.get(i).getLeft() == p)
+ {
+ this.cmbKeystorePassStoreType.select(i);
+ break;
+ }
+ }
+
+ boolean showPasswordFields = (p == KeyStorePassStorageType.DISK);
+ this.lblKeystoreKeyPass.setVisible(showPasswordFields);
+ this.txtKeystoreKeyPass.setVisible(showPasswordFields);
+ this.lblKeystoreStorePass.setVisible(showPasswordFields);
+ this.txtKeystoreStorePass.setVisible(showPasswordFields);
+ }
+
/**
* @param storepass
*/
protected void performKeystoreStorePassChanged(String storepass) {
log.debug("Changed keystore store password");
this.configurationContainer.keystoreStorePass = storepass;
- this.txtKeystoreStorePass.setText(storepass);
+ if (storepass == null)
+ this.txtKeystoreStorePass.setText("");
+ else
+ this.txtKeystoreStorePass.setText(storepass);
}
/**
@@ -357,7 +395,10 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
protected void performKeystoreKeyPassChanged(String keypass) {
log.debug("Changed keystore key password");
this.configurationContainer.keystoreKeyPass = keypass;
- this.txtKeystoreKeyPass.setText(keypass);
+ if (keypass == null)
+ this.txtKeystoreKeyPass.setText("");
+ else
+ this.txtKeystoreKeyPass.setText(keypass);
}
/*
@@ -387,6 +428,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
config.keystoreFile = provider.getKeyStoreFilePersistent();
config.keystoreType = provider.getKeyStoreTypePersistent();
config.keystoreAlias = provider.getKeyStoreAliasPersistent();
+ config.keystorePassStorageType = provider.getKeyStorePassStorageType();
config.keystoreStorePass = provider.getKeyStoreStorePassPersistent();
config.keystoreKeyPass = provider.getKeyStoreKeyPassPersistent();
}
@@ -403,6 +445,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
String ks = config.keystoreFile;
performKeystoreFileChanged(ks);
performKeystoreTypeChanged(config.keystoreType);
+ performKeystorePassStorageTypeChanged(config.keystorePassStorageType);
performKeystoreStorePassChanged(config.keystoreStorePass);
try {
File ksf = new File(ks);
@@ -421,6 +464,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
store.setKeyStoreFile(config.keystoreFile);
store.setKeyStoreType(config.keystoreType);
store.setKeyStoreAlias(config.keystoreAlias);
+ store.setKeyStorePassStorageType(config.keystorePassStorageType);
store.setKeyStoreStorePass(config.keystoreStorePass);
store.setKeyStoreKeyPass(config.keystoreKeyPass);
}
@@ -469,11 +513,30 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
}
}
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
+ Map<String, String> keystoreTypes;
+ private void reloadKeystoreTypeStrings() {
+ this.keystoreTypes = new HashMap<String, String>();
+ this.keystoreTypes.put(Messages.getString("keystore_config.KeystoreType_PKCS12"), "PKCS12");
+ this.keystoreTypes.put(Messages.getString("keystore_config.KeystoreType_JKS"), "JCEKS");
+ }
+
+ Vector<Pair<KeyStorePassStorageType, String>> keystorePassStorageTypeOptions;
+ private void reloadKeystorePassStorageTypeStrings() {
+ keystorePassStorageTypeOptions = new Vector<Pair<KeyStorePassStorageType, String>>();
+ java.util.function.BiConsumer<KeyStorePassStorageType, String> add = (k,v) -> {
+ keystorePassStorageTypeOptions.add(new ImmutablePair<KeyStorePassStorageType,String>(k,Messages.getString(v)));
+ };
+ add.accept(null, "keystore_config.SaveToWhere.None");
+ add.accept(KeyStorePassStorageType.MEMORY, "keystore_config.SaveToWhere.Memory");
+ add.accept(KeyStorePassStorageType.DISK, "keystore_config.SaveToWhere.Disk");
+
+ int n = keystorePassStorageTypeOptions.size();
+ cmbKeystorePassStoreType.setVisibleItemCount(n);
+ cmbKeystorePassStoreType.setItems();
+ for (int i=0; i<n; ++i)
+ cmbKeystorePassStoreType.add(keystorePassStorageTypeOptions.get(i).getRight());
+ }
+
@Override
public void reloadResources() {
this.grpKeystore.setText(Messages.getString("keystore_config.Keystore_Title"));
@@ -481,7 +544,9 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
this.btnBrowse.setText(Messages.getString("common.browse"));
this.txtKeystoreFile.setToolTipText(Messages.getString("keystore_config.KeystoreFile_ToolTip"));
this.lblKeystoreType.setText(Messages.getString("keystore_config.KeystoreType"));
- initKeystoreTypes();
+ reloadKeystoreTypeStrings();
+ this.lblKeystorePassStoreType.setText(Messages.getString("keystore_config.SaveToWhere.Header"));
+ reloadKeystorePassStorageTypeStrings();
this.cmbKeystoreType.setItems(this.keystoreTypes.keySet().toArray(new String[0]));
this.lblKeystoreStorePass.setText(Messages.getString("keystore_config.KeystoreStorePass"));
this.txtKeystoreStorePass.setToolTipText(Messages.getString("keystore_config.KeystoreStorePass_ToolTip"));
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java
index f536ebb4..6102ebac 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java
@@ -143,10 +143,12 @@ public class ConfigurationDataInMemory {
public boolean autoPositionSignature = false;
/** Keystore signing options */
+ public enum KeyStorePassStorageType { MEMORY, DISK };
public Boolean keystoreEnabled = null;
public String keystoreFile = null;
public String keystoreType = null;
public String keystoreAlias = null;
+ public KeyStorePassStorageType keystorePassStorageType = null;
public String keystoreStorePass = null;
public String keystoreKeyPass = null;
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
index 44e328bb..1cfa72b3 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
@@ -33,6 +33,7 @@ import at.asit.pdfover.gui.bku.mobile.MobileBKUs;
import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
import at.asit.pdfover.gui.exceptions.InvalidPortException;
import at.asit.pdfover.gui.utils.LocaleSerializer;
+import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory.KeyStorePassStorageType;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.signator.BKUs;
@@ -230,8 +231,23 @@ public class ConfigurationManager {
setKeyStoreType(diskConfig.getProperty(Constants.CFG_KEYSTORE_TYPE));
setKeyStoreAlias(diskConfig.getProperty(Constants.CFG_KEYSTORE_ALIAS));
setKeyStoreStorePass(diskConfig.getProperty(Constants.CFG_KEYSTORE_STOREPASS));
- String keystoreKeyPass = diskConfig.getProperty(Constants.CFG_KEYSTORE_KEYPASS);
- setKeyStoreKeyPass(keystoreKeyPass);
+ setKeyStoreKeyPass(diskConfig.getProperty(Constants.CFG_KEYSTORE_KEYPASS));
+ String storeTypeOnDisk = diskConfig.getProperty(Constants.CFG_KEYSTORE_PASSSTORETYPE);
+ if (storeTypeOnDisk == null) /* auto-detect based on old config */
+ {
+ String oldKeyPass = getKeyStoreKeyPassPersistent();
+ String oldStorePass = getKeyStoreStorePassPersistent();
+ if ((oldKeyPass != null && !oldKeyPass.trim().isEmpty()) || (oldStorePass != null && !oldStorePass.trim().isEmpty())) /* previously stored password exists */
+ storeTypeOnDisk = "disk";
+ else
+ storeTypeOnDisk = "memory";
+ }
+ if ("disk".equals(storeTypeOnDisk))
+ setKeyStorePassStorageType(KeyStorePassStorageType.DISK);
+ else if ("memory".equals(storeTypeOnDisk))
+ setKeyStorePassStorageType(KeyStorePassStorageType.MEMORY);
+ else
+ setKeyStorePassStorageType(null);
// Set update check
String updateCheck = diskConfig.getProperty(Constants.CFG_UPDATE_CHECK);
@@ -330,12 +346,26 @@ public class ConfigurationManager {
String keystoreAlias = getKeyStoreAliasPersistent();
if (keystoreAlias != STRING_EMPTY)
props.setProperty(Constants.CFG_KEYSTORE_ALIAS, keystoreAlias);
- String keystoreStorePass = getKeyStoreStorePassPersistent();
- if (keystoreStorePass != STRING_EMPTY)
+
+ KeyStorePassStorageType keystorePassStorageType = getKeyStorePassStorageType();
+ if (keystorePassStorageType == null)
+ props.setProperty(Constants.CFG_KEYSTORE_PASSSTORETYPE, "none");
+ else if (keystorePassStorageType == KeyStorePassStorageType.MEMORY)
+ props.setProperty(Constants.CFG_KEYSTORE_PASSSTORETYPE, "memory");
+ else if (keystorePassStorageType == KeyStorePassStorageType.DISK)
+ props.setProperty(Constants.CFG_KEYSTORE_PASSSTORETYPE, "disk");
+
+ if (keystorePassStorageType == KeyStorePassStorageType.DISK)
+ {
+ String keystoreStorePass = getKeyStoreStorePassPersistent();
+ if (keystoreStorePass == null)
+ keystoreStorePass = STRING_EMPTY;
props.setProperty(Constants.CFG_KEYSTORE_STOREPASS, keystoreStorePass);
- String keystoreKeyPass = getKeyStoreKeyPassPersistent();
- if (keystoreKeyPass != STRING_EMPTY)
+ String keystoreKeyPass = getKeyStoreKeyPassPersistent();
+ if (keystoreKeyPass == null)
+ keystoreKeyPass = STRING_EMPTY;
props.setProperty(Constants.CFG_KEYSTORE_KEYPASS, keystoreKeyPass);
+ }
if (!getUpdateCheck())
props.setProperty(Constants.CFG_UPDATE_CHECK, Constants.FALSE);
@@ -839,64 +869,54 @@ public class ConfigurationManager {
return alias;
}
+ public void setKeyStorePassStorageType(KeyStorePassStorageType type) {
+ this.configuration.keystorePassStorageType = type;
+ }
+
+ public KeyStorePassStorageType getKeyStorePassStorageType() {
+ return this.configuration.keystorePassStorageType;
+ }
+
public void setKeyStoreStorePass(String storePass) {
- if (storePass == null || storePass.trim().isEmpty()) {
- this.configuration.keystoreStorePass = STRING_EMPTY;
- } else {
- this.configuration.keystoreStorePass = storePass;
- }
+ this.configuration.keystoreStorePass = storePass;
}
public void setKeyStoreStorePassOverlay(String storePass) {
- if (storePass == null || storePass.trim().isEmpty()) {
- this.configurationOverlay.keystoreStorePass = STRING_EMPTY;
- } else {
- this.configurationOverlay.keystoreStorePass = storePass;
- }
+ this.configurationOverlay.keystoreStorePass = storePass;
}
public String getKeyStoreStorePass() {
String storePass = this.configurationOverlay.keystoreStorePass;
if (storePass != null)
return storePass;
+ if (getKeyStorePassStorageType() != KeyStorePassStorageType.DISK)
+ return null;
return getKeyStoreStorePassPersistent();
}
public String getKeyStoreStorePassPersistent() {
- String storePass = this.configuration.keystoreStorePass;
- if (storePass == null)
- storePass = STRING_EMPTY;
- return storePass;
+ return this.configuration.keystoreStorePass;
}
public void setKeyStoreKeyPass(String keyPass) {
- if (keyPass == null || keyPass.trim().isEmpty()) {
- this.configuration.keystoreKeyPass = STRING_EMPTY;
- } else {
- this.configuration.keystoreKeyPass = keyPass;
- }
+ this.configuration.keystoreKeyPass = keyPass;
}
public void setKeyStoreKeyPassOverlay(String keyPass) {
- if (keyPass == null || keyPass.trim().isEmpty()) {
- this.configurationOverlay.keystoreKeyPass = STRING_EMPTY;
- } else {
- this.configurationOverlay.keystoreKeyPass = keyPass;
- }
+ this.configurationOverlay.keystoreKeyPass = keyPass;
}
public String getKeyStoreKeyPass() {
String keyPass = this.configurationOverlay.keystoreKeyPass;
if (keyPass != null)
return keyPass;
+ if (getKeyStorePassStorageType() != KeyStorePassStorageType.DISK)
+ return null;
return getKeyStoreKeyPassPersistent();
}
public String getKeyStoreKeyPassPersistent() {
- String keyPass = this.configuration.keystoreKeyPass;
- if (keyPass == null)
- keyPass = STRING_EMPTY;
- return keyPass;
+ return this.configuration.keystoreKeyPass;
}
public void setUpdateCheck(boolean checkUpdate) {
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java
index 2d64d160..94f6993c 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java
@@ -85,7 +85,8 @@ public class KSState extends State {
}
String alias = config.getKeyStoreAlias();
String storePass = config.getKeyStoreStorePass();
- if (storePass.isEmpty()) {
+ // TODO trial and error
+ if (storePass == null) {
PasswordInputDialog pwd = new PasswordInputDialog(
getStateMachine().getMainShell(),
Messages.getString("keystore_config.KeystoreStorePass"),
@@ -93,7 +94,7 @@ public class KSState extends State {
storePass = pwd.open();
}
String keyPass = config.getKeyStoreKeyPass();
- if (keyPass.isEmpty()) {
+ if (keyPass == null) {
PasswordInputDialog pwd = new PasswordInputDialog(
getStateMachine().getMainShell(),
Messages.getString("keystore_config.KeystoreKeyPass"),