From 7be16d5f6a9e48137232d7bece96d30825229911 Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Mon, 12 Oct 2015 14:46:03 +0200 Subject: More specific error when keystore file does not exist --- .../gui/composites/KeystoreConfigurationComposite.java | 2 +- .../gui/exceptions/KeystoreDoesntExistException.java | 2 +- .../at/asit/pdfover/gui/workflow/states/KSState.java | 17 +++++++++++++++++ .../resources/at/asit/pdfover/gui/messages.properties | 1 + .../at/asit/pdfover/gui/messages_de.properties | 1 + 5 files changed, 21 insertions(+), 2 deletions(-) (limited to 'pdf-over-gui') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/KeystoreConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/KeystoreConfigurationComposite.java index 0596f708..6dda2956 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/KeystoreConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/KeystoreConfigurationComposite.java @@ -278,7 +278,7 @@ public class KeystoreConfigurationComposite extends BaseConfigurationComposite { } catch (FileNotFoundException ex) { log.error("Error loading keystore", ex); //$NON-NLS-1$ showErrorDialog(String.format(Messages.getString( - "error.FileNotExist"), f.getName())); //$NON-NLS-1$ + "error.KeyStoreFileNotExist"), f.getName())); //$NON-NLS-1$ } catch (NoSuchAlgorithmException ex) { log.error("Error loading keystore", ex); //$NON-NLS-1$ showErrorDialog(Messages.getString("error.KeyStore")); //$NON-NLS-1$ diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java index f0b4f8f0..7578d1c3 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java @@ -33,6 +33,6 @@ public class KeystoreDoesntExistException extends ResumableException { * @param resumeIndex The resume Index */ public KeystoreDoesntExistException(final File keystore, int resumeIndex) { - super(String.format(Messages.getString("error.FileNotExist"), keystore.getPath()), resumeIndex); //$NON-NLS-1$ + super(String.format(Messages.getString("error.KeyStoreFileNotExist"), keystore.getPath()), resumeIndex); //$NON-NLS-1$ } } 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 eaeba4c8..2e5c0d75 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 @@ -16,6 +16,8 @@ package at.asit.pdfover.gui.workflow.states; // Imports +import java.io.File; + import org.eclipse.swt.SWT; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,6 +68,21 @@ public class KSState extends State { try { String file = config.getKeyStoreFile(); + File f = new File(file); + if (!f.isFile()) { + log.error("Keystore not found"); //$NON-NLS-1$ + ErrorDialog dialog = new ErrorDialog( + getStateMachine().getGUIProvider().getMainShell(), + String.format(Messages.getString("error.KeyStoreFileNotExist"), f.getName()), //$NON-NLS-1$ + BUTTONS.RETRY_CANCEL); + if (dialog.open() != SWT.RETRY) { + //getStateMachine().exit(); + this.setNextState(new BKUSelectionState(getStateMachine())); + return; + } + this.run(); + return; + } String alias = config.getKeyStoreAlias(); String storePass = config.getKeyStoreStorePass(); if (storePass.isEmpty()) { diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties index ccb3872c..1ab34e0e 100644 --- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties +++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties @@ -122,6 +122,7 @@ error.InvalidPhoneNumber=Given phone number is invalid\! Example\: +436641234567 error.InvalidSettings=Invalid settings are still present. Please check your input. error.KeyStore=Error loading they keystore. Wrong password? error.KeyStoreAlias=Key alias %s not found in keystore +error.KeyStoreFileNotExist=Keystore file %s does not exist\! error.LocalBKU=Please check if a local CCE (citizen card environment) is running\n\nYou need a CCE to access your citizen card. Further information under www.buergerkarte.at error.MayNotBeAPDF=This may not be a PDF file error.NoTan=No TAN entered diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties index e584b353..edaa6deb 100644 --- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties +++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties @@ -122,6 +122,7 @@ error.InvalidPhoneNumber=Telefonnummer ung\u00FCltig\! Beispiel\: +4366412345678 error.InvalidSettings=Ung\u00FCltige Einstellungen vorhanden. Bitte \u00FCberpr\u00FCfen. error.KeyStore=Fehler beim Laden des KeyStores. Falsches Passwort? error.KeyStoreAlias=Key-Alias %s nicht im Keystore gefunden +error.KeyStoreFileNotExist=Keystore-Datei %s existiert nicht\! error.LocalBKU=Bitte pr\u00FCfen sie, ob Ihre lokale BKU (B\u00FCrgerkartenumgebung) l\u00E4uft\n\nSie ben\u00F6tigen eine BKU, um auf Ihre B\u00FCrgerkarte zuzugreifen. Weitere Informationen unter www.buergerkarte.at error.MayNotBeAPDF=Dies ist m\u00F6glicherweise keine PDF-Datei error.NoTan=Keine TAN eingeben -- cgit v1.2.3