summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java18
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/KeystoreConfigurationComposite.java473
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/CantLoadKeystoreException.java36
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java38
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties18
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties20
6 files changed, 529 insertions, 74 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
index 77b1bd98..ed85f77b 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
@@ -287,6 +287,10 @@ public class ConfigurationComposite extends StateComposite {
// not needed at the moment
this.advancedConfigComposite.setSigner(getSigner());
}
+ if (this.keystoreConfigComposite != null) {
+ // not needed at the moment
+ this.keystoreConfigComposite.setSigner(getSigner());
+ }
}
private class AboutComposite extends StateComposite {
@@ -300,20 +304,6 @@ public class ConfigurationComposite extends StateComposite {
setLayout(new FormLayout());
- /*Group grpAbout = new Group(this, SWT.NONE | SWT.RESIZE);
- FormData fd_grpAbout = new FormData();
- fd_grpAbout.right = new FormAttachment(100, -5);
- fd_grpAbout.left = new FormAttachment(0, 5);
- fd_grpAbout.top = new FormAttachment(0, 5);
- grpAbout.setLayoutData(fd_grpAbout);
- grpAbout.setLayout(new FillLayout());
-
- FontData[] fD_grpAbout = grpAbout.getFont()
- .getFontData();
- fD_grpAbout[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- grpAbout.setFont(new Font(Display.getCurrent(),
- fD_grpAbout[0]));*/
-
this.lnkAbout = new Link(this, SWT.WRAP);
FormData fd_lnkAbout = new FormData();
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 aa42a7bb..24170e24 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
@@ -17,39 +17,29 @@ package at.asit.pdfover.gui.composites;
// Imports
import java.io.File;
-import java.util.Locale;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.dnd.DropTargetAdapter;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
@@ -61,18 +51,15 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.Constants;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.controls.ErrorMarker;
-import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
-import at.asit.pdfover.gui.exceptions.InvalidNumberException;
-import at.asit.pdfover.gui.exceptions.PDFOverGUIException;
+import at.asit.pdfover.gui.exceptions.CantLoadKeystoreException;
+import at.asit.pdfover.gui.exceptions.KeystoreDoesntExistException;
+import at.asit.pdfover.gui.exceptions.OutputfolderDoesntExistException;
+import at.asit.pdfover.gui.exceptions.OutputfolderNotADirectoryException;
import at.asit.pdfover.gui.utils.Messages;
-import at.asit.pdfover.gui.utils.SignaturePlaceholderCache;
import at.asit.pdfover.gui.workflow.config.ConfigManipulator;
import at.asit.pdfover.gui.workflow.config.ConfigurationContainer;
import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider;
import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.pdfover.signator.FileNameEmblem;
-import at.asit.pdfover.signator.SignatureParameter;
/**
*
@@ -86,6 +73,21 @@ public class KeystoreConfigurationComposite extends BaseConfigurationComposite {
.getLogger(KeystoreConfigurationComposite.class);
private Group grpKeystore;
+ private Label lblKeystoreFile;
+ Text txtKeystoreFile;
+ private Button btnBrowse;
+ private Label lblKeystoreType;
+ Combo cmbKeystoreType;
+ private Label lblKeystoreStorePass;
+ Text txtKeystoreStorePass;
+ private Button btnLoad;
+ private Label lblKeystoreAlias;
+ Combo cmbKeystoreAlias;
+ private Label lblKeystoreKeyPass;
+ Text txtKeystoreKeyPass;
+
+ private Map<String, String> keystoreTypes;
+ private Map<String, String> keystoreTypes_i;
/**
* @param parent
@@ -100,56 +102,363 @@ public class KeystoreConfigurationComposite extends BaseConfigurationComposite {
setLayout(new FormLayout());
this.grpKeystore = new Group(this, SWT.NONE | SWT.RESIZE);
+ FormLayout layout = new FormLayout();
+ layout.marginHeight = 10;
+ layout.marginWidth = 5;
+ this.grpKeystore.setLayout(layout);
FormData fd_grpKeystore = new FormData();
- fd_grpKeystore.right = new FormAttachment(100, -5);
- fd_grpKeystore.left = new FormAttachment(0, 5);
fd_grpKeystore.top = new FormAttachment(0, 5);
+ fd_grpKeystore.left = new FormAttachment(0, 5);
+ fd_grpKeystore.right = new FormAttachment(100, -5);
this.grpKeystore.setLayoutData(fd_grpKeystore);
- this.grpKeystore.setLayout(new GridLayout(2, false));
- FontData[] fD_grpKeystore = this.grpKeystore.getFont()
- .getFontData();
+ FontData[] fD_grpKeystore = this.grpKeystore.getFont().getFontData();
fD_grpKeystore[0].setHeight(Constants.TEXT_SIZE_NORMAL);
this.grpKeystore.setFont(new Font(Display.getCurrent(),
fD_grpKeystore[0]));
+ this.lblKeystoreFile = new Label(this.grpKeystore, SWT.NONE);
+ FormData fd_lblKeystoreFile = new FormData();
+ fd_lblKeystoreFile.top = new FormAttachment(0);
+ fd_lblKeystoreFile.left = new FormAttachment(0, 5);
+ this.lblKeystoreFile.setLayoutData(fd_lblKeystoreFile);
+
+ FontData[] fD_lblKeystoreFile = this.lblKeystoreFile.getFont()
+ .getFontData();
+ fD_lblKeystoreFile[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lblKeystoreFile.setFont(new Font(Display.getCurrent(),
+ fD_lblKeystoreFile[0]));
+
+ this.txtKeystoreFile = new Text(this.grpKeystore, SWT.BORDER);
+ FormData fd_txtKeystoreFile = new FormData();
+ fd_txtKeystoreFile.top = new FormAttachment(this.lblKeystoreFile, 5);
+ fd_txtKeystoreFile.left = new FormAttachment(0, 15);
+ this.txtKeystoreFile.setLayoutData(fd_txtKeystoreFile);
+
+ FontData[] fD_txtKeystoreFile = this.txtKeystoreFile.getFont()
+ .getFontData();
+ fD_txtKeystoreFile[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.txtKeystoreFile.setFont(new Font(Display.getCurrent(),
+ fD_txtKeystoreFile[0]));
+
+ this.txtKeystoreFile.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ performKeystoreFileChanged(KeystoreConfigurationComposite.this.
+ txtKeystoreFile.getText());
+ }
+ });
+
+ this.btnBrowse = new Button(this.grpKeystore, SWT.NONE);
+ fd_txtKeystoreFile.right = new FormAttachment(this.btnBrowse, -5);
+
+ FontData[] fD_btnBrowse = this.btnBrowse.getFont().getFontData();
+ fD_btnBrowse[0].setHeight(Constants.TEXT_SIZE_BUTTON);
+ this.btnBrowse.setFont(new Font(Display.getCurrent(), fD_btnBrowse[0]));
+
+ FormData fd_btnBrowse = new FormData();
+ fd_btnBrowse.top = new FormAttachment(this.lblKeystoreFile, 5);
+ fd_btnBrowse.right = new FormAttachment(100, -5);
+ this.btnBrowse.setLayoutData(fd_btnBrowse);
+
+ this.btnBrowse.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog dialog = new FileDialog(
+ KeystoreConfigurationComposite.this.getShell(), SWT.OPEN);
+ dialog.setFilterExtensions(new String[] {
+ "*.p12;*.pkcs12;*.pfx;*.ks;*.jks", "*.p12;*.pkcs12;*.pfx;", "*.ks;*.jks*.", "*" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ dialog.setFilterNames(new String[] {
+ Messages.getString("common.KeystoreExtension_Description"), //$NON-NLS-1$
+ Messages.getString("common.PKCS12Extension_Description"), //$NON-NLS-1$
+ Messages.getString("common.KSExtension_Description"), //$NON-NLS-1$
+ Messages.getString("common.AllExtension_Description") }); //$NON-NLS-1$
+ String fileName = dialog.open();
+ File file = null;
+ if (fileName != null) {
+ file = new File(fileName);
+ if (file.exists()) {
+ performKeystoreFileChanged(fileName);
+ }
+ }
+ }
+ });
+
+ this.lblKeystoreType = new Label(this.grpKeystore, SWT.NONE);
+ FormData fd_lblKeystoreType = new FormData();
+ fd_lblKeystoreType.top = new FormAttachment(this.txtKeystoreFile, 5);
+ fd_lblKeystoreType.left = new FormAttachment(0, 5);
+ this.lblKeystoreType.setLayoutData(fd_lblKeystoreType);
+
+ FontData[] fD_lblKeystoreType = this.lblKeystoreType.getFont()
+ .getFontData();
+ fD_lblKeystoreType[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lblKeystoreType.setFont(new Font(Display.getCurrent(),
+ fD_lblKeystoreType[0]));
+
+ this.cmbKeystoreType = new Combo(this.grpKeystore, SWT.READ_ONLY);
+ FormData fd_cmbKeystoreType = new FormData();
+ fd_cmbKeystoreType.right = new FormAttachment(100, -5);
+ fd_cmbKeystoreType.top = new FormAttachment(this.lblKeystoreType, 5);
+ fd_cmbKeystoreType.left = new FormAttachment(0, 15);
+ this.cmbKeystoreType.setLayoutData(fd_cmbKeystoreType);
+
+ FontData[] fD_cmbKeystoreType = this.cmbKeystoreType.getFont()
+ .getFontData();
+ fD_cmbKeystoreType[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.cmbKeystoreType.setFont(new Font(Display.getCurrent(),
+ fD_cmbKeystoreType[0]));
+
+ initKeystoreTypes();
+ this.cmbKeystoreType.setItems(this.keystoreTypes.keySet().toArray(new String[0]));
+ this.cmbKeystoreType.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ performKeystoreTypeChanged(
+ KeystoreConfigurationComposite.this.cmbKeystoreType.getItem(
+ KeystoreConfigurationComposite.this.cmbKeystoreType.getSelectionIndex()));
+ }
+ });
+
+ this.lblKeystoreStorePass = new Label(this.grpKeystore, SWT.NONE);
+ FormData fd_lblKeystoreStorePass = new FormData();
+ fd_lblKeystoreStorePass.top = new FormAttachment(this.cmbKeystoreType, 5);
+ fd_lblKeystoreStorePass.left = new FormAttachment(0, 5);
+ this.lblKeystoreStorePass.setLayoutData(fd_lblKeystoreStorePass);
+
+ FontData[] fD_lblKeystoreStorePass = this.lblKeystoreStorePass.getFont()
+ .getFontData();
+ fD_lblKeystoreStorePass[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lblKeystoreStorePass.setFont(new Font(Display.getCurrent(),
+ fD_lblKeystoreStorePass[0]));
+
+ this.txtKeystoreStorePass = new Text(this.grpKeystore, SWT.BORDER | SWT.PASSWORD);
+ FormData fd_txtKeystoreStorePass = new FormData();
+ fd_txtKeystoreStorePass.top = new FormAttachment(this.lblKeystoreStorePass, 5);
+ fd_txtKeystoreStorePass.left = new FormAttachment(0, 15);
+ this.txtKeystoreStorePass.setLayoutData(fd_txtKeystoreStorePass);
+
+ FontData[] fD_txtKeystoreStorePass = this.txtKeystoreStorePass.getFont()
+ .getFontData();
+ fD_txtKeystoreStorePass[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.txtKeystoreStorePass.setFont(new Font(Display.getCurrent(),
+ fD_txtKeystoreStorePass[0]));
+
+ this.txtKeystoreStorePass.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ performKeystoreStorePassChanged(KeystoreConfigurationComposite.
+ this.txtKeystoreStorePass.getText());
+ }
+ });
+
+ this.btnLoad = new Button(this.grpKeystore, SWT.NONE);
+ fd_txtKeystoreStorePass.right = new FormAttachment(this.btnLoad, -5);
+
+ FontData[] fD_btnLoad = this.btnLoad.getFont().getFontData();
+ fD_btnLoad[0].setHeight(Constants.TEXT_SIZE_BUTTON);
+ this.btnLoad.setFont(new Font(Display.getCurrent(), fD_btnLoad[0]));
+
+ FormData fd_btnLoad = new FormData();
+ fd_btnLoad.top = new FormAttachment(this.lblKeystoreStorePass, 5);
+ fd_btnLoad.right = new FormAttachment(100, -5);
+ this.btnLoad.setLayoutData(fd_btnLoad);
+
+ this.btnLoad.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ File f = new File(KeystoreConfigurationComposite.this
+ .configurationContainer.getKeyStoreFile());
+ try {
+ loadKeystore();
+ } catch (KeyStoreException ex) {
+ log.error("Error loading keystore", ex); //$NON-NLS-1$
+ showErrorDialog(Messages.getString("error.KeyStore")); //$NON-NLS-1$
+ } catch (FileNotFoundException ex) {
+ log.error("Error loading keystore", ex); //$NON-NLS-1$
+ showErrorDialog(String.format(Messages.getString(
+ "error.FileNotExist"), 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$
+ } catch (CertificateException ex) {
+ log.error("Error loading keystore", ex); //$NON-NLS-1$
+ showErrorDialog(Messages.getString("error.KeyStore")); //$NON-NLS-1$
+ } catch (IOException ex) {
+ log.error("Error loading keystore", ex); //$NON-NLS-1$
+ showErrorDialog(Messages.getString("error.KeyStore")); //$NON-NLS-1$
+ }
+
+ }
+ });
+
+ this.lblKeystoreAlias = new Label(this.grpKeystore, SWT.NONE);
+ FormData fd_lblKeystoreAlias = new FormData();
+ fd_lblKeystoreAlias.top = new FormAttachment(this.txtKeystoreStorePass, 5);
+ fd_lblKeystoreAlias.left = new FormAttachment(0, 5);
+ this.lblKeystoreAlias.setLayoutData(fd_lblKeystoreAlias);
+
+ FontData[] fD_lblKeystoreAlias = this.lblKeystoreAlias.getFont()
+ .getFontData();
+ fD_lblKeystoreAlias[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lblKeystoreAlias.setFont(new Font(Display.getCurrent(),
+ fD_lblKeystoreAlias[0]));
+
+ this.cmbKeystoreAlias = new Combo(this.grpKeystore, SWT.READ_ONLY);
+ FormData fd_cmbKeystoreAlias = new FormData();
+ fd_cmbKeystoreAlias.right = new FormAttachment(100, -5);
+ fd_cmbKeystoreAlias.top = new FormAttachment(this.lblKeystoreAlias, 5);
+ fd_cmbKeystoreAlias.left = new FormAttachment(0, 15);
+ this.cmbKeystoreAlias.setLayoutData(fd_cmbKeystoreAlias);
+
+ FontData[] fD_cmbKeystoreAlias = this.cmbKeystoreAlias.getFont()
+ .getFontData();
+ fD_cmbKeystoreAlias[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.cmbKeystoreAlias.setFont(new Font(Display.getCurrent(),
+ fD_cmbKeystoreAlias[0]));
+
+ this.cmbKeystoreAlias.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ performKeystoreAliasChanged(
+ KeystoreConfigurationComposite.this.cmbKeystoreAlias.getItem(
+ KeystoreConfigurationComposite.this.cmbKeystoreAlias.getSelectionIndex()));
+ }
+ });
+
+ this.lblKeystoreKeyPass = new Label(this.grpKeystore, SWT.NONE);
+ FormData fd_lblKeystoreKeyPass = new FormData();
+ fd_lblKeystoreKeyPass.top = new FormAttachment(this.cmbKeystoreAlias, 5);
+ fd_lblKeystoreKeyPass.left = new FormAttachment(0, 5);
+ this.lblKeystoreKeyPass.setLayoutData(fd_lblKeystoreKeyPass);
+
+ FontData[] fD_lblKeystoreKeyPass = this.lblKeystoreKeyPass.getFont()
+ .getFontData();
+ fD_lblKeystoreKeyPass[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lblKeystoreKeyPass.setFont(new Font(Display.getCurrent(),
+ fD_lblKeystoreKeyPass[0]));
+
+ this.txtKeystoreKeyPass = new Text(this.grpKeystore, SWT.BORDER | SWT.PASSWORD);
+ FormData fd_txtKeystoreKeyPass = new FormData();
+ fd_txtKeystoreKeyPass.top = new FormAttachment(this.lblKeystoreKeyPass, 5);
+ fd_txtKeystoreKeyPass.left = new FormAttachment(0, 15);
+ fd_txtKeystoreKeyPass.right = new FormAttachment(100, -5);
+ this.txtKeystoreKeyPass.setLayoutData(fd_txtKeystoreKeyPass);
+
+ FontData[] fD_txtKeystoreKeyPass = this.txtKeystoreKeyPass.getFont()
+ .getFontData();
+ fD_txtKeystoreKeyPass[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.txtKeystoreKeyPass.setFont(new Font(Display.getCurrent(),
+ fD_txtKeystoreKeyPass[0]));
+
+ this.txtKeystoreKeyPass.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ performKeystoreKeyPassChanged(KeystoreConfigurationComposite.
+ this.txtKeystoreKeyPass.getText());
+ }
+ });
+
// Load localized strings
reloadResources();
}
+ void showErrorDialog(String error) {
+ ErrorDialog e = new ErrorDialog(getShell(), error, BUTTONS.OK);
+ e.open();
+ }
+
+ void loadKeystore() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
+ ConfigurationContainer config =
+ KeystoreConfigurationComposite.this.configurationContainer;
+ File f = new File(config.getKeyStoreFile());
+ KeyStore ks = KeyStore.getInstance(config.getKeyStoreType());
+ FileInputStream fis = new FileInputStream(f);
+ ks.load(fis, config.getKeyStoreStorePass().toCharArray());
+ this.cmbKeystoreAlias.removeAll();
+ Enumeration<String> aliases = ks.aliases();
+ while (aliases.hasMoreElements())
+ this.cmbKeystoreAlias.add(aliases.nextElement());
+ }
+
+ private void initKeystoreTypes() {
+ this.keystoreTypes = new HashMap<String, String>();
+ this.keystoreTypes_i = new HashMap<String, String>();
+ this.keystoreTypes.put(Messages.getString("keystore_config.KeystoreType_PKCS12"), "PKCS12"); //$NON-NLS-1$ //$NON-NLS-2$
+ this.keystoreTypes_i.put("PKCS12", Messages.getString("keystore_config.KeystoreType_PKCS12")); //$NON-NLS-1$ //$NON-NLS-2$
+ this.keystoreTypes.put(Messages.getString("keystore_config.KeystoreType_JKS"), "JCEKS"); //$NON-NLS-1$ //$NON-NLS-2$
+ this.keystoreTypes_i.put("JCEKS", Messages.getString("keystore_config.KeystoreType_JKS")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
/**
- *
+ * @param fileName
*/
- private final class KeystoreFileBrowser extends SelectionAdapter {
- /**
- *
- */
- public KeystoreFileBrowser() {
- // Nothing to do
+ protected void performKeystoreFileChanged(String fileName) {
+ log.debug("Selected keystore file: " + fileName); //$NON-NLS-1$
+ this.configurationContainer.setKeyStoreFile(fileName);
+ KeystoreConfigurationComposite.this.txtKeystoreFile.setText(fileName);
+ int i = fileName.lastIndexOf('.');
+ if (i > 0) {
+ String ext = fileName.substring(i+1);
+ if (
+ ext.equalsIgnoreCase("p12") || //$NON-NLS-1$
+ ext.equalsIgnoreCase("pkcs12") || //$NON-NLS-1$
+ ext.equalsIgnoreCase("pfx")) //$NON-NLS-1$
+ performKeystoreTypeChanged(this.keystoreTypes_i.get("PKCS12")); //$NON-NLS-1$
+ else if (
+ ext.equalsIgnoreCase("ks") || //$NON-NLS-1$
+ ext.equalsIgnoreCase("jks")) //$NON-NLS-1$
+ performKeystoreTypeChanged(this.keystoreTypes_i.get("JCEKS")); //$NON-NLS-1$
}
+ }
- @Override
- public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(
- KeystoreConfigurationComposite.this.getShell(), SWT.OPEN);
- dialog.setFilterExtensions(new String[] {
- "*.p12;*.pkcs12;*.ks;*.jks", "*.p12;*.pkcs12", "*.ks;*.jks*.", "*" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- dialog.setFilterNames(new String[] {
- Messages.getString("common.KeystoreExtension_Description"), //$NON-NLS-1$
- Messages.getString("common.PKCS12Extension_Description"), //$NON-NLS-1$
- Messages.getString("common.KSExtension_Description"), //$NON-NLS-1$
- Messages.getString("common.AllExtension_Description") }); //$NON-NLS-1$
- String fileName = dialog.open();
- File file = null;
- if (fileName != null) {
- file = new File(fileName);
- if (file.exists()) {
- //processEmblemChanged(fileName);
- }
+ /**
+ * @param type
+ */
+ protected void performKeystoreTypeChanged(String type) {
+ log.debug("Selected keystore type: " + type); //$NON-NLS-1$
+ this.configurationContainer.setKeyStoreType(
+ this.keystoreTypes.get(type));
+ for (int i = 0; i < this.cmbKeystoreType.getItemCount(); ++i) {
+ if (this.cmbKeystoreType.getItem(i).equals(type)) {
+ this.cmbKeystoreType.select(i);
+ break;
}
}
}
+ /**
+ * @param storepass
+ */
+ protected void performKeystoreStorePassChanged(String storepass) {
+ log.debug("Changed keystore store password"); //$NON-NLS-1$
+ this.configurationContainer.setKeyStoreStorePass(storepass);
+ this.txtKeystoreStorePass.setText(storepass);
+ }
+
+ /**
+ * @param alias
+ */
+ protected void performKeystoreAliasChanged(String alias) {
+ log.debug("Selected keystore alias: " + alias); //$NON-NLS-1$
+ this.configurationContainer.setKeyStoreAlias(alias);
+ for (int i = 0; i < this.cmbKeystoreAlias.getItemCount(); ++i) {
+ if (this.cmbKeystoreAlias.getItem(i).equals(alias)) {
+ this.cmbKeystoreAlias.select(i);
+ break;
+ }
+ }
+ }
+
+ /**
+ * @param keypass
+ */
+ protected void performKeystoreKeyPassChanged(String keypass) {
+ log.debug("Changed keystore key password"); //$NON-NLS-1$
+ this.configurationContainer.setKeyStoreKeyPass(keypass);
+ this.txtKeystoreKeyPass.setText(keypass);
+ }
+
/*
* (non-Javadoc)
*
@@ -158,6 +467,7 @@ public class KeystoreConfigurationComposite extends BaseConfigurationComposite {
*/
@Override
protected void signerChanged() {
+ // Nothing to do here (yet)
}
/*
@@ -196,6 +506,21 @@ public class KeystoreConfigurationComposite extends BaseConfigurationComposite {
@Override
public void loadConfiguration() {
// Initialize form fields from configuration Container
+ performKeystoreFileChanged(
+ this.configurationContainer.getKeyStoreFile());
+ performKeystoreTypeChanged(
+ this.configurationContainer.getKeyStoreType());
+ performKeystoreStorePassChanged(
+ this.configurationContainer.getKeyStoreStorePass());
+ try {
+ loadKeystore();
+ } catch (Exception e) {
+ log.error("Error loading keystore", e); //$NON-NLS-1$
+ }
+ performKeystoreAliasChanged(
+ this.configurationContainer.getKeyStoreAlias());
+ performKeystoreKeyPassChanged(
+ this.configurationContainer.getKeyStoreKeyPass());
}
/* (non-Javadoc)
@@ -220,6 +545,20 @@ public class KeystoreConfigurationComposite extends BaseConfigurationComposite {
*/
@Override
public void validateSettings(int resumeFrom) throws Exception {
+ switch (resumeFrom) {
+ case 0:
+ File f = new File(this.configurationContainer.getKeyStoreFile());
+ if (!f.exists() || !f.isFile())
+ throw new KeystoreDoesntExistException(f, 2); //skip next check
+ // Fall through
+ case 1:
+ try {
+ loadKeystore();
+ } catch (Exception e) {
+ throw new CantLoadKeystoreException(e, 2);
+ }
+ // Fall through
+ }
}
/*
@@ -231,5 +570,25 @@ public class KeystoreConfigurationComposite extends BaseConfigurationComposite {
public void reloadResources() {
this.grpKeystore.setText(Messages
.getString("keystore_config.Keystore_Title")); //$NON-NLS-1$
+ this.lblKeystoreFile.setText(Messages
+ .getString("keystore_config.KeystoreFile")); //$NON-NLS-1$
+ this.btnBrowse.setText(Messages.getString("common.browse")); //$NON-NLS-1$
+ this.txtKeystoreFile.setToolTipText(Messages
+ .getString("keystore_config.KeystoreFile_ToolTip")); //$NON-NLS-1$
+ this.lblKeystoreType.setText(Messages
+ .getString("keystore_config.KeystoreType")); //$NON-NLS-1$
+ this.lblKeystoreStorePass.setText(Messages
+ .getString("keystore_config.KeystoreStorePass")); //$NON-NLS-1$
+ this.txtKeystoreStorePass.setToolTipText(Messages
+ .getString("keystore_config.KeystoreStorePass_ToolTip")); //$NON-NLS-1$
+ this.btnLoad.setText(Messages.getString("keystore_config.Load")); //$NON-NLS-1$
+ this.btnLoad.setToolTipText(Messages
+ .getString("keystore_config.Load_ToolTip")); //$NON-NLS-1$
+ this.lblKeystoreAlias.setText(Messages
+ .getString("keystore_config.KeystoreAlias")); //$NON-NLS-1$
+ this.lblKeystoreKeyPass.setText(Messages
+ .getString("keystore_config.KeystoreKeyPass")); //$NON-NLS-1$
+ this.txtKeystoreKeyPass.setToolTipText(Messages
+ .getString("keystore_config.KeystoreKeyPass_ToolTip")); //$NON-NLS-1$
}
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/CantLoadKeystoreException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/CantLoadKeystoreException.java
new file mode 100644
index 00000000..cb13c804
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/CantLoadKeystoreException.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.exceptions;
+
+import at.asit.pdfover.gui.utils.Messages;
+
+/**
+ *
+ */
+public class CantLoadKeystoreException extends ResumableException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7554121273052104624L;
+
+ /**
+ * @param resumeIndex The resume Index
+ * @param cause The original exception
+ */
+ public CantLoadKeystoreException(Throwable cause, int resumeIndex) {
+ super(Messages.getString("error.KeyStore"), cause, resumeIndex); //$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
new file mode 100644
index 00000000..f0b4f8f0
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.exceptions;
+
+import java.io.File;
+
+import at.asit.pdfover.gui.utils.Messages;
+
+/**
+ *
+ */
+public class KeystoreDoesntExistException extends ResumableException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8213496549933275086L;
+
+ /**
+ * @param keystore The keystore file
+ * @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$
+ }
+}
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 b987b77a..52ae3d6a 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
@@ -110,7 +110,7 @@ error.InvalidBKU=Invalid CCE selection. Please check.
error.InvalidLocale=Locale not valid
error.InvalidPhoneNumber=Given phone number is invalid\! Example\: +43664123456789
error.InvalidSettings=Invalid settings are still present. Please check your input.
-error.KeyStore=Error loading they keystore
+error.KeyStore=Error loading they keystore. Wrong password?
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
@@ -134,7 +134,23 @@ exception.PasswordTooLong=Given password is too long\!
exception.PasswordTooShort=Given password is too short\!
exception.PathNotDirectory=Path %s does not denote a directory\!
exception.PathNotExist=Path %s does not exist\!
+keystore.KeystoreStorePassEntry=Please enter keystore password:
+keystore.KeystoreKeyPassEntry=Please enter key password:
keystore_config.Keystore_Title=Keystore
+keystore_config.KeystoreAlias=Key alias
+keystore_config.KeystoreFile=Keystore file
+keystore_config.KeystoreFile_ToolTip=Path to the keystore file
+keystore_config.KeystoreFile.Dialog=Choose the keystore
+keystore_config.KeystoreFile.Dialog_Title=Keystore selection
+keystore_config.KeystoreKeyPass=Key password
+keystore_config.KeystoreKeyPass_ToolTip=Warning: The password is stored in plain text. Leave empty to get prompted for password during signing.
+keystore_config.KeystoreStorePass=Keystore password
+keystore_config.KeystoreStorePass_ToolTip=Warning: The password is stored in plain text. Leave empty to get prompted for password during signing.
+keystore_config.KeystoreType=Keystore type
+keystore_config.KeystoreType_JKS=Java keystore
+keystore_config.KeystoreType_PKCS12=PKCS12
+keystore_config.Load=Load keystore
+keystore_config.Load_Tooltip=Load keystore to show available key aliases
main.about=About %s
main.configuration=Configuration
main.done=Finish
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 613f1ee5..8c02616a 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
@@ -16,7 +16,7 @@ advanced_config.LocaleSelection_Title=S&prachauswahl
advanced_config.LocaleSelection_ToolTip=W\u00E4hlen Sie die Sprache f\u00FCr das Benutzerinterface
advanced_config.OutputFolder=Standard-Ausgabeordner\:
advanced_config.OutputFolder.Dialog=W\u00E4hlen Sie einen Ordner
-advanced_config.OutputFolder.Dialog_Title=Ausgabeordner W\u00E4hlen
+advanced_config.OutputFolder.Dialog_Title=Ausgabeordner w\u00E4hlen
advanced_config.OutputFolder_Title=Ausgabe&ort
advanced_config.OutputFolder_ToolTip=W\u00E4hlen Sie einen Ordner, in dem signierte Dokumente automatisch abgelegt werden (deaktivert, wenn das Feld leer ist; ein einzelner Punkt (".") w\u00E4hlt das Verzeichnis des Ursprungsdokuments)
advanced_config.PdfACompat=PDF/A-Kompatibilit\u00E4t
@@ -110,7 +110,7 @@ error.InvalidBKU=Ung\u00FCltige BKU-Auswahl. Bitte \u00FCberpr\u00FCfen.
error.InvalidLocale=Ung\u00FCltige Sprache
error.InvalidPhoneNumber=Telefonnummer ung\u00FCltig\! Beispiel\: +43664123456789
error.InvalidSettings=Ung\u00FCltige Einstellungen vorhanden. Bitte \u00FCberpr\u00FCfen.
-error.KeyStore=Fehler beim Laden des KeyStores
+error.KeyStore=Fehler beim Laden des KeyStores. Falsches Passwort?
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
@@ -134,7 +134,23 @@ exception.PasswordTooLong=Eingegebenes Passwort ist zu lange\!
exception.PasswordTooShort=Eingegebenes Passwort ist zu kurz\!
exception.PathNotDirectory=Pfad %s ist kein g\u00FCltiger Ordner\!
exception.PathNotExist=Pfad %s existiert nicht\!
+keystore.KeystoreStorePassEntry=Keystore-Passwort eingeben:
+keystore.KeystoreKeyPassEntry=Schl\u00FCssel-Passwort eingeben:
keystore_config.Keystore_Title=Keystore
+keystore_config.KeystoreAlias=Schl\u00FCssel-Alias
+keystore_config.KeystoreFile=Keystore-Datei
+keystore_config.KeystoreFile_ToolTip=Pfad zur Keystore-Datei
+keystore_config.KeystoreFile.Dialog=W\u00E4hlen Sie den Keystore
+keystore_config.KeystoreFile.Dialog_Title=Keystore w\u00E4hlen
+keystore_config.KeystoreKeyPass=Schl\u00FCssel-Passwort
+keystore_config.KeystoreKeyPass_ToolTip=Achtung: das Passwort wird im Klartext gespeichert. Leer lassen, um beim Signieren zur Eingabe aufgefordert zu werden.
+keystore_config.KeystoreStorePass=Keystore-Passwort
+keystore_config.KeystoreStorePass_ToolTip=Achtung: das Passwort wird im Klartext gespeichert. Leer lassen, um beim Signieren zur Eingabe aufgefordert zu werden.
+keystore_config.KeystoreType=Keystore-Typ
+keystore_config.KeystoreType_JKS=Java-Keystore
+keystore_config.KeystoreType_PKCS12=PKCS12
+keystore_config.Load=Keystore laden
+keystore_config.Load_ToolTip=Keystore laden, um die verf\u00FCgbaren Schl\u00FCssel-Aliases anzuzeigen
main.about=\u00DCber %s
main.configuration=Konfiguration
main.done=Fertig