From e3dba1b10fbb8ed02f4b8c4b88883027509451d1 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Fri, 8 Jul 2022 14:19:39 +0200 Subject: sanitize config validation for #68 #69 --- .../asit/pdfover/gui/workflow/states/KSState.java | 25 ++++++++-------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow') 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 d8231e99..443f54af 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 @@ -19,7 +19,6 @@ package at.asit.pdfover.gui.workflow.states; import java.io.File; import java.security.Key; import java.security.KeyStore; -import java.security.KeyStoreException; import java.security.UnrecoverableKeyException; import org.eclipse.swt.SWT; @@ -99,11 +98,11 @@ public class KSState extends State { while (keyStore == null) { if (storePass == null) { - PasswordInputDialog pwd = new PasswordInputDialog( + storePass = new PasswordInputDialog( getStateMachine().getMainShell(), Messages.getString("keystore_config.KeystoreStorePass"), - Messages.getString("keystore.KeystoreStorePassEntry")); - storePass = pwd.open(); + Messages.getString("keystore.KeystoreStorePassEntry")).open(); + if (storePass == null) { this.setNextState(new BKUSelectionState(getStateMachine())); @@ -140,11 +139,11 @@ public class KSState extends State { String keyPass = config.getKeyStoreKeyPass(); while (key == null) { if (keyPass == null) { - PasswordInputDialog pwd = new PasswordInputDialog( + keyPass = new PasswordInputDialog( getStateMachine().getMainShell(), Messages.getString("keystore_config.KeystoreKeyPass"), - Messages.getString("keystore.KeystoreKeyPassEntry")); - keyPass = pwd.open(); + Messages.getString("keystore.KeystoreKeyPassEntry")).open(); + if (keyPass == null) { this.setNextState(new BKUSelectionState(getStateMachine())); @@ -184,16 +183,10 @@ public class KSState extends State { signingState.setKSSigner(file, alias, storePass, keyPass, type); } catch (SignatureException e) { log.error("Error loading keystore", e); - ErrorDialog dialog = new ErrorDialog( - getStateMachine().getMainShell(), - Messages.getString("error.KeyStore"), - BUTTONS.RETRY_CANCEL); - if (dialog.open() != SWT.RETRY) { - //getStateMachine().exit(); + if (askShouldRetry("error.KeyStore")) + this.run(); /* recurse */ + else this.setNextState(new BKUSelectionState(getStateMachine())); - return; - } - this.run(); return; } -- cgit v1.2.3