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 --- .../pdfover/gui/workflow/StateMachineImpl.java | 26 ++++++++ .../java/at/asit/pdfover/gui/workflow/Status.java | 15 +++++ .../at/asit/pdfover/gui/workflow/StatusImpl.java | 22 ++++++ .../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 ++++ .../pdfover/gui/workflow/states/LocalBKUState.java | 2 +- .../gui/workflow/states/MobileBKUState.java | 2 +- .../pdfover/gui/workflow/states/OpenState.java | 56 ++++++++++++++++ .../gui/workflow/states/PositioningState.java | 1 - .../workflow/states/PrepareConfigurationState.java | 2 +- .../gui/workflow/states/PrepareSigningState.java | 3 + 15 files changed, 371 insertions(+), 10 deletions(-) (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/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 @@ -154,6 +154,9 @@ public class PrepareSigningState extends State { "SIG_NOTE", configuration.getSignatureNote()); //$NON-NLS-1$ } + this.state.signatureParameter + .setSearchForPlaceholderSignatures(getStateMachine().getStatus().isSearchForPlaceholderSignature()); + this.state.signatureParameter .setSignatureLanguage(configuration.getSignatureLocale() .getLanguage()); -- cgit v1.2.3