summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src
diff options
context:
space:
mode:
authorBianca Schnalzer <bianca.schnalzer@egiz.gv.at>2017-08-07 08:13:09 +0200
committerBianca Schnalzer <bianca.schnalzer@egiz.gv.at>2017-08-07 08:13:09 +0200
commitc1d04c110f717521d0f6bed3e57fdcd39b5d0498 (patch)
tree4e37dc1fda02f8c78961527d418f262e8442a4cf /pdf-over-gui/src
parent59fe25941355ef5cf58ea1c1436e276f604cfab7 (diff)
downloadpdf-over-c1d04c110f717521d0f6bed3e57fdcd39b5d0498.tar.gz
pdf-over-c1d04c110f717521d0f6bed3e57fdcd39b5d0498.tar.bz2
pdf-over-c1d04c110f717521d0f6bed3e57fdcd39b5d0498.zip
Certificate Download Server + Searching for Placeholder
Diffstat (limited to 'pdf-over-gui/src')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java83
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java48
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java43
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java1
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java55
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java52
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java187
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java26
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java15
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java22
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java17
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java63
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java78
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java32
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java49
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java13
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java56
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java1
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java3
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties4
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties4
24 files changed, 785 insertions, 73 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
index 9528ac4d..d29e99e4 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
@@ -68,7 +68,10 @@ public class Constants {
/** The signature placeholder cache properties file name */
public static final String PLACEHOLDER_CACHE_PROPS_FILENAME = ".placeholder.properties"; //$NON-NLS-1$
- /** The minimum PDF-AS configuration version (older ones will be backed up and updated */
+ /**
+ * The minimum PDF-AS configuration version (older ones will be backed up
+ * and updated
+ */
public static final String MIN_PDF_AS_CONFIG_VERSION = "4.1.0"; //$NON-NLS-1$
/** The configuration backup filename */
@@ -107,23 +110,24 @@ public class Constants {
/** False */
public static final String FALSE = "false"; //$NON-NLS-1$
-
/* Configuration parameters */
/** The bku config parameter */
public static final String CFG_BKU = "BKU"; //$NON-NLS-1$
- /** The value for the Signature position in the configuration file
- * values for this entry are:
+ /**
+ * The value for the Signature position in the configuration file values for
+ * this entry are:
*
* x=vx;y=vy;p=vp or auto
*
- * vx:= float value
- * vy:= float value
- * vp:= integer value
+ * vx:= float value vy:= float value vp:= integer value
*/
public static final String CFG_SIGNATURE_POSITION = "SIGNATURE_POSITION"; //$NON-NLS-1$
+ /** The use marker parameter (true/false) */
+ public static final String CFG_USE_MARKER = "USE_MARKER"; //$NON-NLS-1$
+
/** The signature placeholder transparency config parameter (0-255) */
public static final String CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY = "SIGNATURE_PLACEHOLDER_TRANSPARENCY"; //$NON-NLS-1$
@@ -195,7 +199,9 @@ public class Constants {
/** The theme */
public static final String CFG_THEME = "THEME"; //$NON-NLS-1$
-
+
+ /** Download URL for accepted Certificates*/
+ public static final String CFG_DOWNLOAD_URL="DOWNLOAD_URL"; //$NON-NLS-1$
/* Theme constants */
@@ -207,10 +213,10 @@ public class Constants {
/** The used theme */
public static final Themes THEME = getTheme();
+
private static Themes getTheme() {
File f = new File(CONFIG_DIRECTORY + File.separatorChar + DEFAULT_CONFIG_FILENAME);
- if (f.canRead())
- {
+ if (f.canRead()) {
try {
Properties config = new Properties();
config.load(new FileInputStream(f));
@@ -235,35 +241,37 @@ public class Constants {
public static final Color MAINBAR_ACTIVE_BACK_LIGHT = getMainbarActiveBackLight();
private static Color getMainbarActiveBackLight() {
switch (THEME) {
- default:
- case DEFAULT:
- return new Color(display, 0xB4, 0xCD, 0xEC);
- case GEMPLUSH:
- return new Color(display, 0xEC, 0xAD, 0xE7);
+ default:
+ case DEFAULT:
+ return new Color(display, 0xB4, 0xCD, 0xEC);
+ case GEMPLUSH:
+ return new Color(display, 0xEC, 0xAD, 0xE7);
}
}
/** Main bar active background - dark end of gradient */
public static final Color MAINBAR_ACTIVE_BACK_DARK = getMainbarActiveBackDark();
+
private static Color getMainbarActiveBackDark() {
switch (THEME) {
- default:
- case DEFAULT:
- return new Color(display, 0x6B, 0xA5, 0xD9);
- case GEMPLUSH:
- return new Color(display, 0xD9, 0x53, 0x9C);
+ default:
+ case DEFAULT:
+ return new Color(display, 0x6B, 0xA5, 0xD9);
+ case GEMPLUSH:
+ return new Color(display, 0xD9, 0x53, 0x9C);
}
}
/** Main bar inactive background */
public static final Color MAINBAR_INACTIVE_BACK = getMainbarInactiveBack();
+
private static Color getMainbarInactiveBack() {
switch (THEME) {
- default:
- case DEFAULT:
- return new Color(display, 0xD4, 0xE7, 0xF1);
- case GEMPLUSH:
- return new Color(display, 0xF1, 0xD1, 0xE8);
+ default:
+ case DEFAULT:
+ return new Color(display, 0xD4, 0xE7, 0xF1);
+ case GEMPLUSH:
+ return new Color(display, 0xF1, 0xD1, 0xE8);
}
}
@@ -275,7 +283,7 @@ public class Constants {
/** Drop background color */
public static final Color DROP_BACK = new Color(display, 0xFF, 0xFF, 0xFF);
-
+
/** Drop border color */
public static final Color DROP_BORDER_COLOR = MAINBAR_ACTIVE_BACK_LIGHT;
@@ -291,7 +299,6 @@ public class Constants {
/** Big text size */
public static final int TEXT_SIZE_BIG = 14;
-
/* Resources */
/** Shell icon resource */
@@ -299,13 +306,14 @@ public class Constants {
/** Config image resource */
public static final String RES_IMG_CONFIG = getResImgConfig();
+
private static String getResImgConfig() {
switch (THEME) {
- default:
- case DEFAULT:
- return "/img/config.png"; //$NON-NLS-1$
- case GEMPLUSH:
- return "/img/config_p.png"; //$NON-NLS-1$
+ default:
+ case DEFAULT:
+ return "/img/config.png"; //$NON-NLS-1$
+ case GEMPLUSH:
+ return "/img/config_p.png"; //$NON-NLS-1$
}
}
@@ -332,4 +340,15 @@ public class Constants {
/** Accepted certificate list resource */
public static final String RES_CERT_LIST = RES_CERT_PATH + "certificates.xml"; //$NON-NLS-1$
+
+ /** Accepted certificate list config */
+ public static final String RES_CERT_PATH_ADDED = CONFIG_DIRECTORY + "/certificates/tobeadded/"; //$NON-NLS-1$
+
+ /** Accepted certificate list resource */
+ public static final String RES_CERT_LIST_ADDED = RES_CERT_PATH_ADDED + "certificates.xml"; //$NON-NLS-1$
+
+ /** Download URL for accepted certificates */
+ public static final String CERTIFICATE_DOWNLOAD_XML_URL = "https://www.buergerkarte.at/trust/"; //$NON-NLS-1$
+
+ public static final String CERTIFICATE_XML_FILE = "certificates.xml"; //$NON-NLS-1$
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
index 5d634f39..06150aa2 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
@@ -15,20 +15,39 @@
*/
package at.asit.pdfover.gui;
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
//Imports
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import javax.security.auth.login.Configuration;
import javax.swing.JOptionPane;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import org.apache.log4j.PropertyConfigurator;
import org.eclipse.swt.SWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
import at.asit.pdfover.gui.exceptions.InitializationException;
+import at.asit.pdfover.gui.utils.CertificateDownloadSource;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.utils.SWTLoader;
import at.asit.pdfover.gui.workflow.StateMachineImpl;
+import at.asit.pdfover.gui.workflow.config.ConfigProvider;
+import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl;
/**
* Main entry point for production
@@ -39,11 +58,13 @@ public class Main {
* SLF4J Logger instance
**/
private static final Logger log = LoggerFactory.getLogger(Main.class);
-
+ private static URL url=null;
+
/**
* @param args
+ * @throws IOException
*/
- public static void main(String[] args) {
+ public static void main(String[] args) throws IOException {
log.debug("Loading SWT libraries"); //$NON-NLS-1$
try {
SWTLoader.loadSWT();
@@ -57,24 +78,39 @@ public class Main {
log.info("===== Starting " + Constants.APP_NAME_VERSION + " ====="); //$NON-NLS-1$ //$NON-NLS-2$
File configDir = new File(Constants.CONFIG_DIRECTORY);
- if(!configDir.exists()) {
+
+ if (!configDir.exists()) {
+ try {
+ FileOutputStream fis = new FileOutputStream(new File(Constants.RES_CERT_LIST_ADDED));
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
configDir.mkdir();
}
+
File log4j = new File(configDir.getAbsolutePath() + File.separator + Constants.DEFAULT_LOG4J_FILENAME);
- if(log4j.exists()) {
+ if (log4j.exists()) {
PropertyConfigurator.configureAndWatch(log4j.getAbsolutePath());
}
-
+
+
log.debug("SWT version: " + SWT.getVersion()); //$NON-NLS-1$
StateMachineImpl stateMachine = new StateMachineImpl(args);
-
+
log.debug("Starting stateMachine ..."); //$NON-NLS-1$
stateMachine.start();
+ //Download Certificates//
+ CertificateDownloadSource.getAcceptedCertificates();
+
log.debug("Ended stateMachine ..."); //$NON-NLS-1$
+
// Workaround for remaining AWT-Shutdown thread on OSX
System.exit(0);
}
+
+
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java
index 427afad5..82d6f07d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java
@@ -15,9 +15,9 @@
*/
package at.asit.pdfover.gui.bku;
-// Imports
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
+// Imports
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.http.client.config.CookieSpecs;
import org.slf4j.Logger;
@@ -35,6 +35,30 @@ public class BKUHelper {
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(BKUHelper.class);
+ /* public static HttpClient getHttpClient(boolean useProxy) {
+ HttpClient client = new HttpClient();
+ client.getParams().setParameter("http.useragent", //$NON-NLS-1$
+ Constants.USER_AGENT_STRING);
+
+ if (useProxy) {
+ String host = System.getProperty("http.proxyHost"); //$NON-NLS-1$
+ String port = System.getProperty("http.proxyPort"); //$NON-NLS-1$
+ if (host != null && !host.isEmpty() &&
+ port != null && !port.isEmpty()) {
+ int p = Integer.parseInt(port);
+ client.getHostConfiguration().setProxy(host, p);
+ String user = System.getProperty("http.proxyUser"); //$NON-NLS-1$
+ String pass = System.getProperty("http.proxyPassword"); //$NON-NLS-1$
+ if (user != null && !user.isEmpty() && pass != null) {
+ client.getState().setProxyCredentials(new AuthScope(host, p),
+ new UsernamePasswordCredentials(user, pass));
+ }
+ }
+ }
+
+ return client;
+ }*/
+
/**
* Get a HTTP Client instance
*
@@ -42,25 +66,23 @@ public class BKUHelper {
* whether to use a potentially set proxy
* @return the HttpClient
*/
+ @SuppressWarnings("deprecation")
public static HttpClient getHttpClient(boolean useProxy) {
HttpClient client = new HttpClient();
client.getParams().setParameter("http.useragent", //$NON-NLS-1$
Constants.USER_AGENT_STRING);
- client.getParams().setParameter("http.protocol.cookie-policy", CookieSpecs.BROWSER_COMPATIBILITY);
+
+ client.getParams().setParameter("http.protocol.cookie-policy", CookieSpecs.BROWSER_COMPATIBILITY); //$NON-NLS-1$
if (useProxy) {
- String host = System.getProperty("http.proxyHost");
- // $NON-NLS-1$
- String port = System.getProperty("http.proxyPort");
- // $NON-NLS-1$
+ String host = System.getProperty("http.proxyHost");//$NON-NLS-1$
+ String port = System.getProperty("http.proxyPort");//$NON-NLS-1$
if (host != null && !host.isEmpty() && port != null && !port.isEmpty()) {
int p = Integer.parseInt(port);
client.getHostConfiguration().setProxy(host, p);
- String user = System.getProperty("http.proxyUser");
- // $NON-NLS-1$
- String pass = System.getProperty("http.proxyPassword");
- // $NON-NLS-1$
+ String user = System.getProperty("http.proxyUser");//$NON-NLS-1$
+ String pass = System.getProperty("http.proxyPassword");//$NON-NLS-1$
if (user != null && !user.isEmpty() && pass != null) {
client.getState().setProxyCredentials(new AuthScope(host, p),
new UsernamePasswordCredentials(user, pass));
@@ -69,6 +91,7 @@ public class BKUHelper {
}
return client;
+
}
/**
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
index eb1b57d6..1c88499a 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
@@ -18,6 +18,7 @@ package at.asit.pdfover.gui.bku;
// Imports
import java.io.IOException;
+
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java
index bceb59fb..ec4b674b 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java
@@ -15,12 +15,15 @@
*/
package at.asit.pdfover.gui.bku.mobile;
+import java.io.File;
+import java.io.FileInputStream;
// Imports
import java.security.KeyStore;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Arrays;
+import java.util.List;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
@@ -82,7 +85,7 @@ public class SimpleXMLTrustManager implements X509TrustManager {
}
/*
- * A-Trust Certificates
+ *Certificates
*/
KeyStore myKeyStore = KeyStore.getInstance(KeyStore
@@ -93,16 +96,25 @@ public class SimpleXMLTrustManager implements X509TrustManager {
Document doc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
.parse(this.getClass().getResourceAsStream(Constants.RES_CERT_LIST));
-
+
+
+ File added_cert = new File(Constants.RES_CERT_LIST_ADDED);
+
+ Document doc_added = DocumentBuilderFactory.newInstance()
+ .newDocumentBuilder()
+ .parse(added_cert);
+
+ Node certificates_added = doc_added.getFirstChild();
Node certificates = doc.getFirstChild();
- if (!certificates.getNodeName().equals("certificates")) { //$NON-NLS-1$
+ if (!certificates.getNodeName().equals("certificates") && !certificates_added.getNodeName().equals("certificates")) { //$NON-NLS-1$
throw new Exception(
"Used certificates xml is invalid! no certificates node"); //$NON-NLS-1$
}
+ NodeList certificates_added_list = certificates_added.getChildNodes();
NodeList certificateList = certificates.getChildNodes();
-
+
for (int i = 0; i < certificateList.getLength(); i++) {
try {
@@ -117,7 +129,7 @@ public class SimpleXMLTrustManager implements X509TrustManager {
continue;
}
- String certResource = Constants.RES_CERT_PATH + certificateNode.getTextContent();
+ String certResource = Constants.RES_CERT_PATH_ADDED + certificateNode.getTextContent();
X509Certificate cert = (X509Certificate) CertificateFactory
.getInstance("X509"). //$NON-NLS-1$
@@ -133,6 +145,39 @@ public class SimpleXMLTrustManager implements X509TrustManager {
log.error("Failed to load certificate [" + "]", ex); //$NON-NLS-1$ //$NON-NLS-2$
}
}
+
+ for (int i = 0; i < certificates_added_list.getLength(); i++) {
+ try {
+
+ Node certificateNode = certificates_added_list.item(i);
+
+ if (certificateNode.getNodeName().equals("#text")) { //$NON-NLS-1$
+ continue; // Ignore dummy text node ..
+ }
+
+ if (!certificateNode.getNodeName().equals("certificate")) { //$NON-NLS-1$
+ log.warn("Ignoring XML node: " + certificateNode.getNodeName()); //$NON-NLS-1$
+ continue;
+ }
+
+ String certResource = Constants.RES_CERT_PATH_ADDED + certificateNode.getTextContent();
+
+ FileInputStream addedNode = new FileInputStream(certResource);
+
+ X509Certificate cert = (X509Certificate) CertificateFactory
+ .getInstance("X509"). //$NON-NLS-1$
+ generateCertificate(
+ addedNode);
+
+ myKeyStore.setCertificateEntry(certificateNode.getTextContent(), cert);
+
+ log.debug("Loaded certificate : " + certResource); //$NON-NLS-1$
+
+ } catch (Exception ex) {
+ log.error("Failed to load certificate [" + "]", ex); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
tmf.init(myKeyStore);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
index b9021094..34626f82 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
@@ -81,6 +81,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
private Group grpSignatur;
Button btnAutomatischePositionierung;
Button btnPdfACompat;
+ Button btnPlatzhalterVerwenden;
private Label lblTransparenz;
private Label lblTransparenzLinks;
private Label lblTransparenzRechts;
@@ -174,11 +175,30 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
}
});
+ this.btnPlatzhalterVerwenden = new Button(this.grpSignatur, SWT.CHECK);
+ FormData fd_btnPlatzhalterVerwenden = new FormData();
+ fd_btnPlatzhalterVerwenden.right = new FormAttachment(100, -5);
+ fd_btnPlatzhalterVerwenden.top = new FormAttachment(this.btnAutomatischePositionierung, 5);
+ fd_btnPlatzhalterVerwenden.left = new FormAttachment(0, 5);
+ this.btnPlatzhalterVerwenden.setLayoutData(fd_btnPlatzhalterVerwenden);
+
+ FontData[] fD_btnPlatzhalterVerwenden = this.btnPlatzhalterVerwenden.getFont().getFontData();
+ fD_btnPlatzhalterVerwenden[0].setHeight(Constants.TEXT_SIZE_BUTTON);
+ this.btnPlatzhalterVerwenden.setFont(new Font(Display.getCurrent(), fD_btnPlatzhalterVerwenden[0]));
+
+ this.btnPlatzhalterVerwenden.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ AdvancedConfigurationComposite.this.performUseMarkerSelection(
+ AdvancedConfigurationComposite.this.btnPlatzhalterVerwenden.getSelection());
+ }
+ });
+
this.btnPdfACompat = new Button(this.grpSignatur, SWT.CHECK);
FormData fd_btnPdfACompat = new FormData();
fd_btnPdfACompat.right = new FormAttachment(100, -5);
fd_btnPdfACompat.top = new FormAttachment(
- this.btnAutomatischePositionierung, 5);
+ this.btnPlatzhalterVerwenden, 5);
fd_btnPdfACompat.left = new FormAttachment(0, 5);
this.btnPdfACompat
.setLayoutData(fd_btnPdfACompat);
@@ -836,6 +856,11 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.btnAutomatischePositionierung.setSelection(automatic);
}
+ void performUseMarkerSelection(boolean useMarker) {
+ this.configurationContainer.setUseMarker(useMarker);
+ this.btnPlatzhalterVerwenden.setSelection(useMarker);
+ }
+
void performPdfACompatSelection(boolean compat) {
this.configurationContainer.setSignaturePdfACompat(compat);
this.btnPdfACompat.setSelection(compat);
@@ -973,6 +998,9 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
public void initConfiguration(PersistentConfigProvider provider) {
this.configurationContainer.setDefaultSignaturePosition(
provider.getDefaultSignaturePositionPersistent());
+ this.configurationContainer.setUseMarker(provider.getUseMarker());
+ this.configurationContainer.setDownloadURL(
+ provider.getDownloadURL());
this.configurationContainer.setSignaturePdfACompat(
provider.getSignaturePdfACompat());
this.configurationContainer.setPlaceholderTransparency(
@@ -1021,6 +1049,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
SignaturePosition pos = this.configurationContainer
.getDefaultSignaturePosition();
performPositionSelection(pos != null && pos.useAutoPositioning());
+ performUseMarkerSelection(this.configurationContainer.getUseMarker());
this.sclTransparenz.setSelection(this.configurationContainer
.getPlaceholderTransparency());
performLocaleSelectionChanged(this.configurationContainer.getLocale());
@@ -1038,15 +1067,15 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.txtProxyHost.setText(host);
}
-// String user = this.configurationContainer.getProxyUser();
-// if (user != null) {
-// this.txtProxyUser.setText(user);
-// }
-//
-// String pass = this.configurationContainer.getProxyPass();
-// if (pass != null) {
-// this.txtProxyPass.setText(pass);
-// }
+ /*String user = this.configurationContainer.getProxyUser();
+ if (user != null) {
+ this.txtProxyUser.setText(user);
+ }
+
+ String pass = this.configurationContainer.getProxyPass();
+ if (pass != null) {
+ this.txtProxyPass.setText(pass);
+ }*/
}
@@ -1058,6 +1087,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
PersistentConfigProvider provider) {
store.setDefaultSignaturePosition(
this.configurationContainer.getDefaultSignaturePosition());
+ store.setUseMarker(this.configurationContainer.getUseMarker());
store.setSignaturePdfACompat(
this.configurationContainer.getSignaturePdfACompat());
store.setPlaceholderTransparency(
@@ -1157,6 +1187,8 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
.getString("advanced_config.AutoPosition")); //$NON-NLS-1$
this.btnAutomatischePositionierung.setToolTipText(Messages
.getString("advanced_config.AutoPosition_ToolTip")); //$NON-NLS-1$
+ this.btnPlatzhalterVerwenden.setText(Messages.getString("advanced_config.UseMarker")); //$NON-NLS-1$
+ this.btnPlatzhalterVerwenden.setToolTipText(Messages.getString("advanced_config.UseMarker_ToolTip")); //$NON-NLS-1$
this.btnPdfACompat.setText(Messages
.getString("advanced_config.PdfACompat")); //$NON-NLS-1$
this.btnPdfACompat.setToolTipText(Messages
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java
new file mode 100644
index 00000000..ecd31472
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java
@@ -0,0 +1,187 @@
+package at.asit.pdfover.gui.utils;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+//Imports
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+
+import javax.security.auth.login.Configuration;
+import javax.swing.JOptionPane;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.apache.log4j.PropertyConfigurator;
+import org.eclipse.swt.SWT;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import at.asit.pdfover.gui.Constants;
+import at.asit.pdfover.gui.exceptions.InitializationException;
+import at.asit.pdfover.gui.utils.Messages;
+import at.asit.pdfover.gui.utils.SWTLoader;
+import at.asit.pdfover.gui.workflow.StateMachineImpl;
+import at.asit.pdfover.gui.workflow.config.ConfigProvider;
+import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl;
+
+
+/**
+ * Download of accepted certificates
+ */
+public class CertificateDownloadSource {
+
+ /**
+ * SLF4J Logger instance
+ **/
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory.getLogger(CertificateDownloadSource.class);
+ private static URL url=null;
+
+ /**
+ *
+ */
+ public static void getAcceptedCertificates()
+ {
+ try {
+
+ ConfigProviderImpl cpi = new ConfigProviderImpl();
+
+ String url= cpi.getDownloadURL();
+ if (url.equals(null) || url.equals("")) //$NON-NLS-1$
+ {
+ url = Constants.CERTIFICATE_DOWNLOAD_XML_URL+Constants.CERTIFICATE_XML_FILE;
+
+ }
+ else
+ {
+ url+=Constants.CERTIFICATE_XML_FILE;
+ }
+ log.info("===== Starting to download accepted certificate =====");
+
+
+ BufferedInputStream bis = new BufferedInputStream(new URL(url).openStream());
+ FileOutputStream fis2 = new FileOutputStream(new File(Constants.RES_CERT_LIST_ADDED));
+ byte[] buffer = new byte[1024];
+ int count = 0;
+ while ((count = bis.read(buffer, 0, 1024)) != -1) {
+ fis2.write(buffer, 0, count);
+ }
+ fis2.close();
+ bis.close();
+ downloadCertificatesFromServer();
+
+ } catch (IOException e) {
+ File f = new File(Constants.RES_CERT_LIST_ADDED);
+ e.printStackTrace();}
+
+
+
+
+ // downloadCertificatesFromServer();
+
+ }
+
+ /**
+ * Download accepted Certificates from Server
+ */
+ public static void downloadCertificatesFromServer()
+ {
+
+ BufferedReader br = null;
+ FileReader fr = null;
+
+ try {
+ File added_cert = new File(Constants.RES_CERT_LIST_ADDED);
+
+
+ Document doc_added = DocumentBuilderFactory.newInstance()
+ .newDocumentBuilder()
+ .parse(added_cert);
+
+
+ Node certificates_added = doc_added.getFirstChild();
+ NodeList certificates_added_list = certificates_added.getChildNodes();
+
+ //identify the certificate that has to be downloaded
+ for (int i = 0; i < certificates_added_list.getLength(); i++) {
+ try {
+
+ Node certificateNode = certificates_added_list.item(i);
+
+ if (certificateNode.getNodeName().equals("#text")) { //$NON-NLS-1$
+ continue; // Ignore dummy text node ..
+ }
+
+ if (!certificateNode.getNodeName().equals("certificate")) { //$NON-NLS-1$
+ log.warn("Ignoring XML node: " + certificateNode.getNodeName()); //$NON-NLS-1$
+ continue;
+ }
+
+ ConfigProviderImpl cpi = new ConfigProviderImpl();
+
+ String certResource = cpi.getDownloadURL().toString() + certificateNode.getTextContent();
+
+ //String certResource = Constants.CERTIFICATE_DOWNLOAD_XML_URL + certificateNode.getTextContent();
+ BufferedInputStream bis = new BufferedInputStream(new URL(certResource).openStream());
+ FileOutputStream fis = new FileOutputStream(new File(Constants.RES_CERT_PATH_ADDED+certificateNode.getTextContent()));
+ byte[] buffer = new byte[1024];
+ int count=0;
+ while((count = bis.read(buffer,0,1024)) != -1)
+ {
+ fis.write(buffer, 0, count);
+ }
+ fis.close();
+ bis.close();
+
+
+ } catch (Exception ex) {
+ log.error("Failed to load certificate [" + "]", ex); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+
+
+
+
+ } catch (IOException e) {
+
+ e.printStackTrace();
+
+ } catch (SAXException e) {
+
+ e.printStackTrace();
+ } catch (ParserConfigurationException e) {
+
+ e.printStackTrace();
+ } finally {
+
+ try {
+
+ if (br != null)
+ br.close();
+
+ if (fr != null)
+ fr.close();
+
+ } catch (IOException ex) {
+
+ ex.printStackTrace();
+
+ }
+
+ }
+
+ }
+
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
index b506a182..b2367a85 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java
@@ -15,6 +15,9 @@
*/
package at.asit.pdfover.gui.workflow;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
//Imports
import java.lang.reflect.Constructor;
@@ -24,9 +27,11 @@ import org.eclipse.swt.widgets.Shell;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import at.asit.pdfover.gui.Constants;
import at.asit.pdfover.gui.MainWindow;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
+import at.asit.pdfover.gui.utils.CertificateDownloadSource;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.workflow.config.ConfigManipulator;
import at.asit.pdfover.gui.workflow.config.ConfigOverlayManipulator;
@@ -248,8 +253,29 @@ public class StateMachineImpl implements StateMachine, GUIProvider {
* Workflow main entrance point
*/
public void start() {
+
// Call update to start processing ...
update();
+
+ try {
+ File certificates = new File (Constants.RES_CERT_LIST_ADDED);
+ if (!certificates.exists())
+ {
+
+ FileOutputStream fis = new FileOutputStream(new File(Constants.RES_CERT_LIST_ADDED));
+ CertificateDownloadSource.getAcceptedCertificates();
+
+
+ }
+ else
+ {
+ CertificateDownloadSource.getAcceptedCertificates();
+ }
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
// if a user interaction is required we have a shell ...
Shell shell = nonCreatingGetShell();
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java
index 984dc509..f5b078ed 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java
@@ -105,4 +105,19 @@ public interface Status {
* @return the sign result
*/
public SignResult getSignResult();
+
+ /**
+ * Checks if search for placeholder signature-flag is on.
+ *
+ * @return true, if is search for placeholder signature
+ */
+ public boolean isSearchForPlaceholderSignature();
+
+ /**
+ * Sets the search for placeholder signature-flag.
+ *
+ * @param value
+ * the new search for placeholder signature
+ */
+ public void setSearchForPlaceholderSignature(boolean value);
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java
index d2618320..7cc94c62 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java
@@ -53,6 +53,7 @@ public class StatusImpl implements Status {
private MainWindowBehavior behavior;
+ private boolean searchForPlacehoderSignature = false;
/**
* Constructor
@@ -181,4 +182,25 @@ public class StatusImpl implements Status {
public SignResult getSignResult() {
return this.signResult;
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.workflow.Status#getConfiguration()
+ */
+ @Override
+ public boolean isSearchForPlaceholderSignature() {
+ return this.searchForPlacehoderSignature;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.asit.pdfover.gui.workflow.Status#setSearchForPlaceholderSignature(
+ * boolean)
+ */
+ public void setSearchForPlaceholderSignature(boolean value) {
+ this.searchForPlacehoderSignature = value;
+ }
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java
index f28358b8..14de050f 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java
@@ -170,4 +170,21 @@ public interface ConfigManipulator {
* @throws IOException
*/
public void saveCurrentConfiguration() throws IOException;
+
+
+ /**
+ * Sets whether to use an existing signaturemarker.
+ *
+ * @param useMarker
+ * whether to use an existing signaturemarker
+ */
+ public void setUseMarker(boolean useMarker);
+
+ /**
+ * @param downloadURL
+ * @param Sets the DownloadURL for Certificates
+ */
+ public void setDefaultDownloadURL(String downloadURL);
}
+
+
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java
index d00860e5..a5180593 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java
@@ -34,185 +34,236 @@ public interface ConfigProvider {
*/
public static final String SIGN_POS_REGEX = "(x=(\\d\\.?\\d?);y=(\\d\\.?\\d?);p=(\\d))|(auto)|(x=(\\d\\.?\\d?);y=(\\d\\.?\\d?))"; //$NON-NLS-1$
-
/**
* Loads the configuration from a configuration file
- * @param configSource the configuration file
- * @throws IOException
+ *
+ * @param configSource
+ * the configuration file
+ * @throws IOException
*/
public void loadConfiguration(InputStream configSource) throws IOException;
/**
* Gets the configuration file
+ *
* @return the configuration file
*/
public String getConfigurationFile();
/**
* Gets the configuration directory
+ *
* @return the configuration directory
*/
public String getConfigurationDirectory();
/**
* Gets the default Mobile number
+ *
* @return the default mobile number
*/
public String getDefaultMobileNumber();
/**
* Gets the password to use for Mobile BKU
+ *
* @return the password
*/
public String getDefaultMobilePassword();
/**
* Gets the filename of the default emblem
+ *
* @return the emblem
*/
public String getDefaultEmblem();
-
+
/**
* Gets the proxy host
+ *
* @return the proxy hostname or ip address
*/
public String getProxyHost();
/**
* Gets the proxy port
+ *
* @return the proxy port
*/
public int getProxyPort();
/**
* Gets the proxy username
+ *
* @return the proxy username
*/
public String getProxyUser();
/**
* Gets the proxy password
+ *
* @return the proxy password
*/
public String getProxyPass();
/**
* Get the default configured BKU
+ *
* @return the default configured BKU
*/
public BKUs getDefaultBKU();
/**
* Get the default configured SignaturePosition
- * @return the default configured SignaturePosition or null if not configured
+ *
+ * @return the default configured SignaturePosition or null if not
+ * configured
*/
public SignaturePosition getDefaultSignaturePosition();
/**
* Get the transparency of the signature placeholder
+ *
* @return the transparency of the signature placeholder
*/
public int getPlaceholderTransparency();
/**
* Gets the default output folder for signed documents
- * @return the default output folder
+ *
+ * @return the default output folder
*/
public String getDefaultOutputFolder();
/**
* Gets the mobile BKU URL
+ *
* @return the mobile BKU URL
*/
public String getMobileBKUURL();
/**
* Gets the mobile BKU type
+ *
* @return the mobile BKU type
*/
public MobileBKUs getMobileBKUType();
/**
* Gets the mobile BKU BASE64 setting
+ *
* @return the mobile BKU BASE64 setting
*/
public boolean getMobileBKUBase64();
/**
* Get the signature note text to use
+ *
* @return the signature note text
*/
public String getSignatureNote();
/**
* Gets the configured locale
+ *
* @return the configured locale
*/
public Locale getLocale();
/**
* Gets the configured locale
+ *
* @return the configured locale
*/
public Locale getSignatureLocale();
/**
* Get the signature PDF/A compatibility setting
+ *
* @return the signature PDF/A compatibility setting
*/
public boolean getSignaturePdfACompat();
/**
* Gets whether keystore signing is enabled
+ *
* @return whether keystore signing is enabled
*/
public Boolean getKeyStoreEnabled();
/**
* Gets the keystore file
+ *
* @return the keystore file
*/
public String getKeyStoreFile();
/**
* Gets the keystore type
+ *
* @return the keystore type
*/
public String getKeyStoreType();
/**
* Gets the keystore alias
+ *
* @return the keystore alias
*/
public String getKeyStoreAlias();
/**
* Gets the keystore store password
+ *
* @return the keystore store password
*/
public String getKeyStoreStorePass();
/**
* Gets the keystore key password
+ *
* @return the keystore key password
*/
public String getKeyStoreKeyPass();
/**
* Gets whether to automatically check for application updates
+ *
* @return whether to automatically check for application updates
*/
public boolean getUpdateCheck();
/**
* Gets the configured MainWindow size
+ *
* @return the configured MainWindow size
*/
public Point getMainWindowSize();
/**
* Gets whether to skip the finish screen
+ *
* @return whether to skip the finish screen
*/
public boolean getSkipFinish();
+
+ /**
+ * @param downloadURL
+ * @param Sets the DownloadURL for Certificates
+ */
+ public void setDownloadURL(String downloadURL);
+
+ /**
+ * @return downloadURL for accepted Certificates
+ */
+ public String getDownloadURL();
+
+
+
+ /**
+ * Gets whether to use signature markers.
+ *
+ * @return whether to use a signature maker
+ */
+ public boolean getUseMarker();
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
index 99fd9747..8242cd03 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
@@ -112,6 +112,10 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
// Set Output Folder
setDefaultOutputFolder(config
.getProperty(Constants.CFG_OUTPUT_FOLDER));
+
+ // Set Default Certificate Download URL
+ setDefaultDownloadURL(config
+ .getProperty(Constants.CFG_DOWNLOAD_URL));
String localeString = config.getProperty(Constants.CFG_LOCALE);
@@ -127,6 +131,10 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
setSignatureLocale(signatureTargetLocale);
}
+ String useMarker = config.getProperty(Constants.CFG_USE_MARKER);
+ if(null != useMarker)
+ setUseMarker(useMarker.equalsIgnoreCase(Constants.TRUE));
+
String compat = config.getProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT);
if (compat != null)
setSignaturePdfACompat(compat.equalsIgnoreCase(Constants.TRUE));
@@ -138,6 +146,14 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
this.configuration.setMobileBKUURL(bkuUrl);
}
+ String downloadURL = config
+ .getProperty(Constants.CFG_DOWNLOAD_URL);
+
+ if (downloadURL != null && !downloadURL.isEmpty()) {
+ this.configuration.setDownloadURL(downloadURL);
+ }
+
+
String bkuType = config
.getProperty(Constants.CFG_MOBILE_BKU_TYPE);
@@ -327,6 +343,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
props.setProperty(Constants.CFG_PROXY_PASS, proxyPass);
props.setProperty(Constants.CFG_EMBLEM, getDefaultEmblemPersistent());
+ props.setProperty(Constants.CFG_DOWNLOAD_URL, getDownloadURL());
props.setProperty(Constants.CFG_SIGNATURE_NOTE, getSignatureNote());
props.setProperty(Constants.CFG_MOBILE_NUMBER, getDefaultMobileNumberPersistent());
props.setProperty(Constants.CFG_OUTPUT_FOLDER, getDefaultOutputFolderPersistent());
@@ -346,6 +363,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
props.setProperty(Constants.CFG_SIGNATURE_LOCALE, LocaleSerializer.getParsableString(signatureLocale));
}
+ if (getUseMarker())
+ props.setProperty(Constants.CFG_USE_MARKER, Constants.TRUE);
+
if (getSignaturePdfACompat())
props.setProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT, Constants.TRUE);
@@ -394,6 +414,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
if (!getUpdateCheck())
props.setProperty(Constants.CFG_UPDATE_CHECK, Constants.FALSE);
+
FileOutputStream outputstream = new FileOutputStream(configFile, false);
@@ -729,6 +750,24 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
emblem = STRING_EMPTY;
return emblem;
}
+
+ @Override
+ public String getDownloadURL() {
+ String downloadURL="";
+ try
+ {
+ downloadURL = this.configuration.getDownloadURL();
+ if (downloadURL.isEmpty()||downloadURL == null)
+ {downloadURL = Constants.CERTIFICATE_DOWNLOAD_XML_URL;
+ }
+ return downloadURL;
+ } catch (NullPointerException npe){
+ String message = npe.getMessage();
+ downloadURL = Constants.CERTIFICATE_DOWNLOAD_XML_URL;
+
+ }
+ return downloadURL;
+ }
/**
* Sets the proxy host
@@ -945,6 +984,16 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
}
}
+
+ @Override
+ public void setDefaultDownloadURL(String downloadURL) {
+ if (downloadURL == null || downloadURL.trim().isEmpty()) {
+ this.configuration.setDownloadURL(Constants.CERTIFICATE_DOWNLOAD_XML_URL+Constants.CERTIFICATE_XML_FILE);
+ } else {
+ this.configuration.setDownloadURL(downloadURL);
+ }
+ }/*
+
/* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultOutputFolderOverlay(java.lang.String)
*/
@@ -1416,4 +1465,33 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
public void setSkipFinishOverlay(boolean skipFinish) {
this.configurationOverlay.setSkipFinish(skipFinish);
}
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigManipulator#setDownloadURL(java.lang.String)
+ */
+ @Override
+ public void setDownloadURL(String downloadURL) {
+ this.configuration.setDownloadURL(downloadURL);
+
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.workflow.config.ConfigProvider#getUseMarker()
+ */
+ @Override
+ public boolean getUseMarker() {
+ return this.configurationOverlay.getUseMarker();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.workflow.config.ConfigManipulator#setUseMarker(
+ * boolean)
+ */
+ @Override
+ public void setUseMarker(boolean useMarker) {
+ this.configurationOverlay.setUseMarker(useMarker);
+ }
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java
index 95429296..807ee1a6 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java
@@ -152,6 +152,10 @@ public interface ConfigurationContainer {
* @return the default BKU
*/
public BKUs getDefaultBKU();
+
+
+
+
/**
* Sets the default BKU
@@ -361,4 +365,32 @@ public interface ConfigurationContainer {
* @param skipFinish whether to skip the finish screen
*/
public void setSkipFinish(boolean skipFinish);
+
+
+ /**
+ * Gets theCertificate-Download URL
+ * @return the Certificate-Download URL
+ */
+ public String getDownloadURL();
+
+ /**
+ * Sets the Certificate-Download URL
+ * @param downloadURL
+ */
+ public void setDownloadURL(String downloadURL);
+
+ /**
+ * Gets whether to use an existing signature marker.
+ *
+ * @return whether to use an existing signature marker
+ */
+ public boolean getUseMarker();
+
+ /**
+ * Sets whether to use an existing signature marker.
+ *
+ * @param useMarker
+ * whether to use an existing signature marker
+ */
+ public void setUseMarker(boolean useMarker);
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java
index 7ae29f41..a06dbc0b 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java
@@ -132,6 +132,13 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
/** Whether to skip the output state */
protected boolean skipFinish = false;
+
+ /** Default Download URL for certificates*/
+ protected String downloadURL = null;
+
+
+ /** Whether to use an existing signature marker. */
+ protected boolean useMarker = false;
/* (non-Javadoc)
* @see at.asit.pdfover.gui.composites.ConfigurationContainer#getEmblem()
@@ -636,4 +643,46 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
public void setSkipFinish(boolean skipFinish) {
this.skipFinish = skipFinish;
}
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setDownloadURL(java.lang.String)
+ */
+ @Override
+ public void setDownloadURL(String downloadURL) {
+ this.downloadURL = downloadURL;
+
+
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getDownloadURL()
+ */
+ @Override
+ public String getDownloadURL() {
+ return this.downloadURL;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getUseMarker()
+ */
+ @Override
+ public boolean getUseMarker() {
+ return this.useMarker;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setUseMarker(
+ * boolean)
+ */
+ @Override
+ public void setUseMarker(boolean useMarker) {
+ this.useMarker = useMarker;
+ }
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java
index cf355f34..78d196fc 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java
@@ -180,4 +180,17 @@ public interface PersistentConfigProvider {
* @return the configured MainWindow size
*/
public Point getMainWindowSize();
+
+ /**
+ * Gets the configured Download URL for certificates
+ * @return the configured download URL
+ */
+ public String getDownloadURL();
+
+ /**
+ * Gets whether to use an existing singature marker.
+ *
+ * @return whether to use an existing singature marker
+ */
+ public boolean getUseMarker();
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
index eaccae5d..b229b58a 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
@@ -104,7 +104,7 @@ public class LocalBKUState extends State {
public void run() {
try {
- HttpClient client = BKUHelper.getHttpClient();
+ HttpClient client = (HttpClient) BKUHelper.getHttpClient();
PostMethod method = new PostMethod(Constants.LOCAL_BKU_URL);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
index bd88b48d..2b9bbe06 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
@@ -66,7 +66,7 @@ public class MobileBKUState extends State {
case IAIK:
this.status = new IAIKStatus(provider);
this.handler = new IAIKHandler(this,
- stateMachine.getGUIProvider().getMainShell());
+ stateMachine.getGUIProvider().getMainShell());
break;
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
index b77809ed..b2a7cb50 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
@@ -15,17 +15,26 @@
*/
package at.asit.pdfover.gui.workflow.states;
+import java.io.IOException;
+
+import org.apache.pdfbox.pdmodel.PDDocument;
//Imports
import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.MainWindowBehavior;
import at.asit.pdfover.gui.composites.DataSourceSelectComposite;
+import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.Status;
import at.asit.pdfover.gui.workflow.config.ConfigProvider;
+import at.asit.pdfover.signator.SignaturePosition;
+import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
+import at.gv.egiz.pdfas.lib.impl.pdfbox.placeholder.SignaturePlaceholderExtractor;
+import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
/**
* Selects the data source for the signature process.
@@ -82,6 +91,53 @@ public class OpenState extends State {
}
}
log.debug("Got Datasource: " + getStateMachine().getStatus().getDocument().getAbsolutePath()); //$NON-NLS-1$
+
+ // scan for signature placeholders
+ // - see if we want to scan for placeholders in the settings
+ if (getStateMachine().getConfigProvider().getUseMarker()) {
+ try {
+ // - scan for placeholders
+ PDDocument pddocument = PDDocument.load(getStateMachine().getStatus().getDocument());
+ SignaturePlaceholderData signaturePlaceholderData = SignaturePlaceholderExtractor.extract(pddocument,
+ "1", 3);
+
+ if (null != signaturePlaceholderData) {
+ log.debug("we got a position", signaturePlaceholderData.getId()); //$NON-NLS-1$
+ // create a dialog with ok and cancel buttons and a question
+ // icon
+ MessageBox dialog = new MessageBox(getStateMachine().getGUIProvider().getMainShell(),
+ SWT.ICON_QUESTION | SWT.YES | SWT.NO);
+ dialog.setText(Messages.getString("dataSourceSelection.usePlaceholderTitle")); //$NON-NLS-1$
+ dialog.setMessage(Messages.getString("dataSourceSelection.usePlaceholderText")); //$NON-NLS-1$
+
+ // open dialog and await user selection
+ if (SWT.YES == dialog.open()) {
+ // if the user chooses to use the signature placeholder
+ // - fill the position information so that we skip to
+ // the
+ // next stages without breaking stuff
+ SignaturePosition position = new SignaturePosition(
+ signaturePlaceholderData.getTablePos().getPosX(),
+ signaturePlaceholderData.getTablePos().getPosY(),
+ signaturePlaceholderData.getTablePos().getPage());
+ status.setSignaturePosition(position);
+
+ getStateMachine().getStatus().setSearchForPlaceholderSignature(true);
+ } else {
+ getStateMachine().getStatus().setSearchForPlaceholderSignature(false);
+ }
+ }
+ } catch (PdfAsException e) {
+ // fail silently. In case we got here no dialog has been shown.
+ // Just
+ // proceed with the usual process.
+ } catch (IOException e) {
+ // fail silently. In case we got here no dialog has been shown.
+ // Just
+ // proceed with the usual process.
+ }
+ }
+
this.setNextState(new PositioningState(getStateMachine()));
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
index 32b335a7..4d73c068 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
@@ -43,7 +43,6 @@ import at.asit.pdfover.signator.SignaturePosition;
import com.sun.pdfview.PDFFile;
import com.sun.pdfview.decrypt.PDFAuthenticationFailureException;
-
/**
* Decides where to position the signature block
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
index b1af315e..e9ff0b25 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
@@ -457,7 +457,7 @@ public class PrepareConfigurationState extends State {
new Thread(new Runnable() {
@Override
public void run() {
- HttpClient client = BKUHelper.getHttpClient();
+ HttpClient client = (HttpClient) BKUHelper.getHttpClient();
GetMethod method = new GetMethod(Constants.CURRENT_RELEASE_URL);
try {
client.executeMethod(method);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
index 155073d6..4a914046 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
@@ -155,6 +155,9 @@ public class PrepareSigningState extends State {
}
this.state.signatureParameter
+ .setSearchForPlaceholderSignatures(getStateMachine().getStatus().isSearchForPlaceholderSignature());
+
+ this.state.signatureParameter
.setSignatureLanguage(configuration.getSignatureLocale()
.getLanguage());
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 baf5ee6c..16062baf 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
@@ -42,6 +42,8 @@ advanced_config.Signature_Title=Si&gnature
advanced_config.UpdateCheck=Automatically check for updates
advanced_config.UpdateCheck_Title=Updates
advanced_config.UpdateCheck_ToolTip=Shows a notification when a new version is available
+advanced_config.UseMarker=Search for signature markers
+advanced_config.UseMarker_ToolTip=Activate this option to scan the document for signature markers. In case there is a marker available, you will be asked whether to automatically position your signature according to the marker.
argument.error.output=is not a directory
argument.help.autopos=Enables automatic signature positioning
argument.help.bku=Select the CCE to use. Possible values are\: LOCAL, MOBILE, KS. Example\: -b MOBILE
@@ -106,6 +108,8 @@ config.Simple=Basi&c
dataSourceSelection.DropLabel=Drag document here
dataSourceSelection.DropLabel2=or...
dataSourceSelection.browse=&Browse for PDF on your computer
+dataSourceSelection.usePlaceholderTitle=Info
+dataSourceSelection.usePlaceholderText=A marker has been found where the creator of the document wants you to put your signature. Do you want to use it?
error.CmdLineArgs=Error parsing the command-line arguments\:
error.Details=Details
error.EnteredReferenceValue=You entered the reference value\!
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 506abebd..f6b8500f 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
@@ -42,6 +42,8 @@ advanced_config.Signature_Title=Si&gnatur
advanced_config.UpdateCheck=Automatisch auf Updates \u00FCberpr\u00FCfen
advanced_config.UpdateCheck_Title=Updates
advanced_config.UpdateCheck_ToolTip=Zeigt eine Benachrichtigung, wenn eine neue Version verf\u00FCgbar ist
+advanced_config.UseMarker=Nach Signaturplatzhaltern suchen
+advanced_config.UseMarker_ToolTip=Aktivieren Sie diese Option, um das Dokument nach Signaturplatzhaltern zu durchsuchen. Sollte ein Platzhatler gefunden werden werden Sie gefragt ob Sie die Signatur in den Platzhalter einf\u00FCgen wollen.
argument.error.output=ist kein Ordner
argument.help.autopos=Aktiviert automatische Positionierung der Signatur
argument.help.bku=W\u00E4hlen Sie die BKU. G\u00FCltige Werte\: LOCAL, MOBILE, KS. Bsp.\: -b MOBILE
@@ -106,6 +108,8 @@ config.Simple=&Einfach
dataSourceSelection.DropLabel=Dokument hierher ziehen
dataSourceSelection.DropLabel2=oder...
dataSourceSelection.browse=&Durchsuchen um ein Dokument zu w\u00E4hlen
+dataSourceSelection.usePlaceholderTitle=Info
+dataSourceSelection.usePlaceholderText=Im vorliegenden Dokument wurde ein Signaturplatzhalter gefunden. Soll dieser verwendet werden?
error.CmdLineArgs=Fehler bei den Befehlszeilen-Parametern\:
error.Details=Details
error.EnteredReferenceValue=Sie haben den Vergleichswert eingegeben\!