From c1d04c110f717521d0f6bed3e57fdcd39b5d0498 Mon Sep 17 00:00:00 2001 From: Bianca Schnalzer Date: Mon, 7 Aug 2017 08:13:09 +0200 Subject: Certificate Download Server + Searching for Placeholder --- .../gui/workflow/config/ConfigManipulator.java | 17 +++++ .../gui/workflow/config/ConfigProvider.java | 63 +++++++++++++++-- .../gui/workflow/config/ConfigProviderImpl.java | 78 ++++++++++++++++++++++ .../workflow/config/ConfigurationContainer.java | 32 +++++++++ .../config/ConfigurationContainerImpl.java | 49 ++++++++++++++ .../workflow/config/PersistentConfigProvider.java | 13 ++++ 6 files changed, 246 insertions(+), 6 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config') 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(); } -- cgit v1.2.3