From 834b83efb6e57e926c2f09be52be59de64a3ad2b Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:37:42 +0000 Subject: Refactoring: create config package git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@423 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../pdfover/gui/workflow/ConfigManipulator.java | 113 --- .../gui/workflow/ConfigOverlayManipulator.java | 73 -- .../asit/pdfover/gui/workflow/ConfigProvider.java | 146 ---- .../pdfover/gui/workflow/ConfigProviderImpl.java | 903 --------------------- .../gui/workflow/ConfigurationContainer.java | 233 ------ .../gui/workflow/ConfigurationContainerImpl.java | 420 ---------- .../gui/workflow/PersistentConfigProvider.java | 123 --- .../at/asit/pdfover/gui/workflow/StateMachine.java | 4 + .../pdfover/gui/workflow/StateMachineImpl.java | 5 + .../gui/workflow/config/ConfigManipulator.java | 113 +++ .../workflow/config/ConfigOverlayManipulator.java | 73 ++ .../gui/workflow/config/ConfigProvider.java | 146 ++++ .../gui/workflow/config/ConfigProviderImpl.java | 903 +++++++++++++++++++++ .../workflow/config/ConfigurationContainer.java | 233 ++++++ .../config/ConfigurationContainerImpl.java | 420 ++++++++++ .../workflow/config/PersistentConfigProvider.java | 123 +++ .../gui/workflow/states/BKUSelectionState.java | 2 +- .../pdfover/gui/workflow/states/OpenState.java | 2 +- .../pdfover/gui/workflow/states/OutputState.java | 2 +- .../gui/workflow/states/PrepareSigningState.java | 2 +- .../workflow/states/mobilebku/ATrustStatus.java | 2 +- .../gui/workflow/states/mobilebku/IAIKStatus.java | 2 +- 22 files changed, 2026 insertions(+), 2017 deletions(-) delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigOverlayManipulator.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PersistentConfigProvider.java create mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java create mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java create mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java create mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java create mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java create mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java create mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java (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/ConfigManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java deleted file mode 100644 index 80754f4b..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.gui.workflow; - -import java.io.IOException; -import java.util.Locale; - -import org.eclipse.swt.graphics.Point; - -import at.asit.pdfover.signator.BKUs; -import at.asit.pdfover.signator.SignaturePosition; - -/** - * An interface for setting the configuration - */ -public interface ConfigManipulator { - /** - * Sets the default bku type - * @param bku the bku type - */ - public void setDefaultBKU(BKUs bku); - - /** - * Sets the default signature position - * @param signaturePosition the default signature position - */ - public void setDefaultSignaturePosition(SignaturePosition signaturePosition); - - /** - * Sets the signature placeholder transparency - * @param transparency the signature placeholder transparency - */ - void setPlaceholderTransparency(int transparency); - - /** - * Sets the default mobile number - * @param number the default mobile number - */ - public void setDefaultMobileNumber(String number); - - /** - * Sets the default password - * @param password the default password - */ - public void setDefaultMobilePassword(String password); - - /** - * Sets the default emblem - * @param emblem the default emblem - */ - public void setDefaultEmblem(String emblem); - - /** - * Sets the proxy host - * @param host the proxy host - */ - public void setProxyHost(String host); - - /** - * Sets the proxy port - * @param port the proxy port - */ - public void setProxyPort(int port); - - /** - * Sets the default output folder - * @param outputFolder the default output folder - */ - public void setDefaultOutputFolder(String outputFolder); - - /** - * Sets the signature note text - * @param note the signature note text - */ - public void setSignatureNote(String note); - - /** - * Sets the locale to be used - * @param locale the locale - */ - public void setLocale(Locale locale); - - /** - * Sets the signature locale to be used - * @param locale the signature locale - */ - public void setSignLocale(Locale locale); - - /** - * Sets the default main window size - * @param size a Point describing the size - */ - public void setMainWindowSize(Point size); - - /** - * Saves the current configuration to the current configuration file - * @throws IOException - */ - public void saveCurrentConfiguration() throws IOException; -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigOverlayManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigOverlayManipulator.java deleted file mode 100644 index a31309f3..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigOverlayManipulator.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.gui.workflow; - -import at.asit.pdfover.signator.BKUs; - -/** - * An interface for setting the configuration overlay - * - * This overlay overrides the actual configuration but will not be saved - */ -public interface ConfigOverlayManipulator { - /** - * Sets the default bku type - * @param bku the bku type - */ - public void setDefaultBKUOverlay(BKUs bku); - - /** - * Sets the default mobile number - * @param number the default mobile number - */ - public void setDefaultMobileNumberOverlay(String number); - - /** - * Sets the default password - * @param password the default password - */ - public void setDefaultMobilePasswordOverlay(String password); - - /** - * Sets the default emblem - * @param emblem the default emblem - */ - public void setDefaultEmblemOverlay(String emblem); - - /** - * Sets the proxy host - * @param host the proxy host - */ - public void setProxyHostOverlay(String host); - - /** - * Sets the proxy port - * @param port the proxy port - */ - public void setProxyPortOverlay(int port); - - /** - * Sets the default output folder - * @param outputFolder the default output folder - */ - public void setDefaultOutputFolderOverlay(String outputFolder); - - /** - * Sets the configuration file - * @param configurationFile - */ - public void setConfigurationFile(String configurationFile); -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java deleted file mode 100644 index 9f88573a..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.gui.workflow; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Locale; - -import org.eclipse.swt.graphics.Point; - -import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs; -import at.asit.pdfover.signator.BKUs; -import at.asit.pdfover.signator.SignaturePosition; - -/** - * An interface for reading the configuration - */ -public interface ConfigProvider { - /** - * RegEx for parsing signature position - */ - 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$ - - - /** - * 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(); - - /** - * 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 - */ - 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 - */ - 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(); - - /** - * 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 getSignLocale(); - - /** - * Gets the configured MainWindow size - * @return the configured MainWindow size - */ - public Point getMainWindowSize(); - - /** - * Loads the configuration from a configuration file - * @param configSource the configuration file - * @throws IOException - */ - public void loadConfiguration(InputStream configSource) throws IOException; -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java deleted file mode 100644 index ec0be92d..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java +++ /dev/null @@ -1,903 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.gui.workflow; - -// Imports -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Locale; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.swt.graphics.Point; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.Constants; -import at.asit.pdfover.gui.exceptions.InvalidEmblemFile; -import at.asit.pdfover.gui.exceptions.InvalidNumberException; -import at.asit.pdfover.gui.exceptions.InvalidPortException; -import at.asit.pdfover.gui.utils.LocaleSerializer; -import at.asit.pdfover.gui.utils.Messages; -import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs; -import at.asit.pdfover.signator.BKUs; -import at.asit.pdfover.signator.SignaturePosition; - -/** - * Implementation of the configuration provider and manipulator - */ -public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, - ConfigOverlayManipulator, PersistentConfigProvider { - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(ConfigProviderImpl.class); - - /** - * An empty property entry - */ - private static final String STRING_EMPTY = ""; //$NON-NLS-1$ - - private String configurationFile = Constants.DEFAULT_CONFIG_FILENAME; - - private ConfigurationContainer configuration; - - private ConfigurationContainer configurationOverlay; - - /** - * Constructor - */ - public ConfigProviderImpl() { - this.configuration = new ConfigurationContainerImpl(); - this.configurationOverlay = new ConfigurationContainerImpl(); - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigProvider#loadConfiguration(java.io - * .InputStream) - */ - @Override - public void loadConfiguration(InputStream configSource) throws IOException { - - Properties config = new Properties(); - - config.load(configSource); - - // Set Emblem - this.setDefaultEmblem(config - .getProperty(Constants.CFG_EMBLEM)); - - // Set Mobile Phone Number - this.setDefaultMobileNumber(config - .getProperty(Constants.CFG_MOBILE_NUMBER)); - - // Set signature note - this.setSignatureNote(config - .getProperty(Constants.CFG_SIGNATURE_NOTE)); - - // Set Proxy Host - this.setProxyHost(config - .getProperty(Constants.CFG_PROXY_HOST)); - - // Set Output Folder - this.setDefaultOutputFolder(config - .getProperty(Constants.CFG_OUTPUT_FOLDER)); - - String localeString = config.getProperty(Constants.CFG_LOCALE); - - Locale targetLocale = LocaleSerializer.parseFromString(localeString); - if (targetLocale != null) { - this.setLocale(targetLocale); - } - - String signlocalString = config.getProperty(Constants.CFG_SIGN_LOCALE); - - Locale signtargetLocale = LocaleSerializer.parseFromString(signlocalString); - if (signtargetLocale != null) { - this.setSignLocale(signtargetLocale); - } - - String bkuUrl = config - .getProperty(Constants.CFG_MOBILE_BKU_URL); - - if (bkuUrl != null && !bkuUrl.isEmpty()) { - this.configuration.setMobileBKUURL(bkuUrl); - } - - String bkuType = config - .getProperty(Constants.CFG_MOBILE_BKU_TYPE); - - if (bkuType != null && !bkuType.isEmpty()) { - try { - this.configuration.setMobileBKUType(MobileBKUs.valueOf( - bkuType.trim().toUpperCase())); - } catch (IllegalArgumentException e) { - log.error("Invalid BKU type: " + bkuType); //$NON-NLS-1$ - this.configuration.setMobileBKUType(Constants.DEFAULT_MOBILE_BKU_TYPE); - } - } - - // Set Proxy Port - String proxyPortString = config - .getProperty(Constants.CFG_PROXY_PORT); - - if (proxyPortString != null && !proxyPortString.trim().isEmpty()) { - int port = Integer.parseInt(proxyPortString); - - if (port > 0 && port <= 0xFFFF) { - this.setProxyPort(port); - } else { - log.warn("Proxy port is out of range!: " + port); //$NON-NLS-1$ - } - } - - // Set Default BKU - String bkuString = config.getProperty(Constants.CFG_BKU); - BKUs defaultBKU = BKUs.NONE; - if (bkuString != null) { - try { - defaultBKU = BKUs.valueOf(bkuString); - } catch (IllegalArgumentException ex) { - log.error("Invalid BKU config value " + bkuString + " using none!"); //$NON-NLS-1$ //$NON-NLS-2$ - defaultBKU = BKUs.NONE; - } catch (NullPointerException ex) { - log.error("Invalid BKU config value " + bkuString + " using none!"); //$NON-NLS-1$ //$NON-NLS-2$ - defaultBKU = BKUs.NONE; - } - } - this.setDefaultBKU(defaultBKU); - - // Set Signature placeholder transparency - int transparency = Constants.DEFAULT_SIGNATURE_PLACEHOLDER_TRANSPARENCY; - String trans = config.getProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY); - if (trans != null) { - try { - transparency = Integer.parseInt(trans); - } catch (NumberFormatException e) { - log.debug("Couldn't parse placeholder transparency", e); //$NON-NLS-1$ - // ignore parsing exception - } - } - this.setPlaceholderTransparency(transparency); - - // Set MainWindow size - int width = Constants.DEFAULT_MAINWINDOW_WIDTH; - int height = Constants.DEFAULT_MAINWINDOW_HEIGHT; - String size = config.getProperty(Constants.CFG_MAINWINDOW_SIZE); - parse: { - if (size == null) - break parse; - int pos = size.indexOf(','); - if (pos <= 0) - break parse; - - try { - width = Integer.parseInt(size.substring(0, pos).trim()); - height = Integer.parseInt(size.substring(pos + 1).trim()); - } catch (NumberFormatException e) { - log.debug("Couldn't parse main window size", e); //$NON-NLS-1$ - // ignore parsing exception - } - } - this.configuration.setMainWindowSize(new Point(width, height)); - - // Set Signature Position - String signaturePosition = config - .getProperty(Constants.CFG_SIGNATURE_POSITION); - - SignaturePosition position = null; - - if (signaturePosition != null && !signaturePosition.trim().isEmpty()) { - - signaturePosition = signaturePosition.trim().toLowerCase(); - - Pattern pattern = Pattern.compile(SIGN_POS_REGEX); - - Matcher matcher = pattern.matcher(signaturePosition); - - if (matcher.matches()) { - if (matcher.groupCount() == 8) { - if (matcher.group(1) != null) { - // we have format: x=..;y=..;p=... - try { - // group 2 = x value - float x = Float.parseFloat(matcher.group(2)); - - // group 3 = y value - float y = Float.parseFloat(matcher.group(3)); - - // group 4 = p value - int p = Integer.parseInt(matcher.group(3)); - - position = new SignaturePosition(x, y, p); - } catch (NumberFormatException ex) { - log.error( - "Signature Position read from config failed: Not a valid number", ex); //$NON-NLS-1$ - } - } else if (matcher.group(5) != null) { - // we have format auto - position = new SignaturePosition(); - } else if (matcher.group(6) != null) { - // we have format x=...;y=...; - // group 7 = x value - float x = Float.parseFloat(matcher.group(7)); - - // group 8 = y value - float y = Float.parseFloat(matcher.group(8)); - - position = new SignaturePosition(x, y); - } - } else { - log.error("Signature Position read from config failed: wrong group Count!"); //$NON-NLS-1$ - } - } else { - log.error("Signature Position read from config failed: not matching string"); //$NON-NLS-1$ - } - - } - - this.setDefaultSignaturePosition(position); - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigManipulator#saveCurrentConfiguration() - */ - @Override - public void saveCurrentConfiguration() throws IOException { - String filename = this.getConfigurationFile(); - - File configFile = new File(this.getConfigurationDirectory() - + File.separator + filename); - - Properties props = new Properties(); - props.clear(); - - props.setProperty(Constants.CFG_BKU, this.getDefaultBKUPersistent().toString()); - props.setProperty(Constants.CFG_PROXY_HOST, this.getProxyHostPersistent()); - props.setProperty(Constants.CFG_PROXY_PORT, - Integer.toString(getProxyPortPersistent())); - props.setProperty(Constants.CFG_EMBLEM, this.getDefaultEmblemPersistent()); - props.setProperty(Constants.CFG_SIGNATURE_NOTE, this.getSignatureNote()); - props.setProperty(Constants.CFG_MOBILE_NUMBER, this.getDefaultMobileNumberPersistent()); - props.setProperty(Constants.CFG_OUTPUT_FOLDER, this.getDefaultOutputFolderPersistent()); - props.setProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY, - Integer.toString(getPlaceholderTransparency())); - - Point size = this.configuration.getMainWindowSize(); - props.setProperty(Constants.CFG_MAINWINDOW_SIZE, size.x + "," + size.y); //$NON-NLS-1$ - - Locale configLocale = getLocale(); - if(configLocale != null) { - props.setProperty(Constants.CFG_LOCALE, LocaleSerializer.getParsableString(configLocale)); - } - - Locale signLocale = this.getSignLocale(); - if(signLocale != null) { - props.setProperty(Constants.CFG_SIGN_LOCALE, LocaleSerializer.getParsableString(signLocale)); - } - - SignaturePosition pos = getDefaultSignaturePosition(); - - if (pos == null) { - props.setProperty(Constants.CFG_SIGNATURE_POSITION, ""); //$NON-NLS-1$ - } else if (pos.useAutoPositioning()) { - props.setProperty(Constants.CFG_SIGNATURE_POSITION, "auto"); //$NON-NLS-1$ - } else { - props.setProperty(Constants.CFG_SIGNATURE_POSITION, - String.format((Locale) null, "x=%f;y=%f;p=%d", //$NON-NLS-1$ - pos.getX(), pos.getY(), pos.getPage())); - } - - String mobileBKUURL = getMobileBKUURL(); - if (!mobileBKUURL.equals(Constants.DEFAULT_MOBILE_BKU_URL)) - props.setProperty(Constants.CFG_MOBILE_BKU_URL, mobileBKUURL); - - MobileBKUs mobileBKUType = getMobileBKUType(); - if (mobileBKUType != Constants.DEFAULT_MOBILE_BKU_TYPE) - props.setProperty(Constants.CFG_MOBILE_BKU_TYPE, mobileBKUType.toString()); - - if (Constants.THEME != Constants.Themes.DEFAULT) - props.setProperty(Constants.CFG_THEME, Constants.THEME.name()); - - FileOutputStream outputstream = new FileOutputStream(configFile, false); - - props.store(outputstream, "Configuration file was generated!"); //$NON-NLS-1$ - - log.info("Configuration file saved to " + configFile.getAbsolutePath()); //$NON-NLS-1$ - } - - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationDirectory() - */ - @Override - public String getConfigurationDirectory() { - return Constants.CONFIG_DIRECTORY; - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigManipulator#setConfigurationFile(java - * .lang.String) - */ - @Override - public void setConfigurationFile(String configurationFile) { - this.configurationFile = configurationFile; - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationFile() - */ - @Override - public String getConfigurationFile() { - return this.configurationFile; - } - - /** - * Sets the default bku type - * - * @param bku - * the bku type - */ - @Override - public void setDefaultBKU(BKUs bku) { - this.configuration.setDefaultBKU(bku); - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultBKUOverlay(at.asit.pdfover.signator.BKUs) - */ - @Override - public void setDefaultBKUOverlay(BKUs bku) { - this.configurationOverlay.setDefaultBKU(bku); - - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultBKU() - */ - @Override - public BKUs getDefaultBKU() { - BKUs bku = this.configurationOverlay.getDefaultBKU(); - if (bku == BKUs.NONE) - bku = getDefaultBKUPersistent(); - return bku; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getDefaultBKUPersistent() - */ - @Override - public BKUs getDefaultBKUPersistent() { - return this.configuration.getDefaultBKU(); - } - - /** - * Sets the default signature position - * - * @param signaturePosition - * the default signature position - */ - @Override - public void setDefaultSignaturePosition(SignaturePosition signaturePosition) { - this.configuration.setDefaultSignaturePosition(signaturePosition); - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultSignaturePosition() - */ - @Override - public SignaturePosition getDefaultSignaturePosition() { - return this.configuration.getDefaultSignaturePosition(); - } - - /** - * Sets the signature placeholder transparency - * - * @param transparency - * the signature placeholder transparency - */ - @Override - public void setPlaceholderTransparency(int transparency) { - this.configuration.setPlaceholderTransparency(transparency); - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigProvider#getPlaceholderTransparency() - */ - @Override - public int getPlaceholderTransparency() { - return this.configuration.getPlaceholderTransparency(); - } - - /** - * Sets the default mobile number - * - * @param number - * the default mobile number - */ - @Override - public void setDefaultMobileNumber(String number) { - try { - if (number == null || number.trim().isEmpty()) { - this.configuration.setMobileNumber(STRING_EMPTY); - } else { - this.configuration.setMobileNumber(number); - } - } catch (InvalidNumberException e) { - log.error("Error setting mobile number", e); //$NON-NLS-1$ - try { - this.configuration.setMobileNumber(STRING_EMPTY); - } catch (InvalidNumberException e1) { - // Ignore - } - } - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultMobileNumberOverlay(java.lang.String) - */ - @Override - public void setDefaultMobileNumberOverlay(String number) { - try { - if (number == null || number.trim().isEmpty()) { - this.configurationOverlay.setMobileNumber(STRING_EMPTY); - } else { - this.configurationOverlay.setMobileNumber(number); - } - } catch (InvalidNumberException e) { - log.error("Error setting mobile number", e); //$NON-NLS-1$ - try { - this.configurationOverlay.setMobileNumber(STRING_EMPTY); - } catch (InvalidNumberException e1) { - // Ignore - } - } - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultMobileNumber() - */ - @Override - public String getDefaultMobileNumber() { - String number = this.configurationOverlay.getMobileNumber(); - if (number == null) - number = getDefaultMobileNumberPersistent(); - return number; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getDefaultMobileNumberPersistent() - */ - @Override - public String getDefaultMobileNumberPersistent() { - String number = this.configuration.getMobileNumber(); - if (number == null) - number = STRING_EMPTY; - return number; - } - - /** - * Sets the default mobile password - * - * @param password - * the default password - */ - @Override - public void setDefaultMobilePassword(String password) { - if (password == null || password.trim().isEmpty()) { - this.configuration.setMobilePassword(STRING_EMPTY); - } else { - this.configuration.setMobilePassword(password); - } - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultMobilePasswordOverlay(java.lang.String) - */ - @Override - public void setDefaultMobilePasswordOverlay(String password) { - if (password == null || password.trim().isEmpty()) { - this.configurationOverlay.setMobilePassword(STRING_EMPTY); - } else { - this.configurationOverlay.setMobilePassword(password); - } - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultPassword() - */ - @Override - public String getDefaultMobilePassword() { - String password = this.configurationOverlay.getMobilePassword(); - if (password == null) - password = getDefaultMobilePasswordPersistent(); - return password; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getDefaultMobilePasswordPersistent() - */ - @Override - public String getDefaultMobilePasswordPersistent() { - String password = this.configuration.getMobilePassword(); - if (password == null) - password = STRING_EMPTY; - return password; - } - - /** - * Sets the default emblem - * - * @param emblem - * the default emblem - */ - @Override - public void setDefaultEmblem(String emblem) { - try { - if (emblem == null || emblem.trim().isEmpty()) { - this.configuration.setEmblem(STRING_EMPTY); - } else { - this.configuration.setEmblem(emblem); - } - } catch (InvalidEmblemFile e) { - log.error("Error setting emblem file", e); //$NON-NLS-1$ - try { - this.configuration.setEmblem(STRING_EMPTY); - } catch (InvalidEmblemFile e1) { - // Ignore - } - } - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultEmblemOverlay(java.lang.String) - */ - @Override - public void setDefaultEmblemOverlay(String emblem) { - try { - if (emblem == null || emblem.trim().isEmpty()) { - this.configurationOverlay.setEmblem(STRING_EMPTY); - } else { - this.configurationOverlay.setEmblem(emblem); - } - } catch (InvalidEmblemFile e) { - log.error("Error setting emblem file", e); //$NON-NLS-1$ - try { - this.configurationOverlay.setEmblem(STRING_EMPTY); - } catch (InvalidEmblemFile e1) { - // Ignore - } - } - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultEmblem() - */ - @Override - public String getDefaultEmblem() { - String emblem = this.configurationOverlay.getEmblem(); - if (emblem == null) - emblem = getDefaultEmblemPersistent(); - return emblem; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getDefaultEmblemPersistent() - */ - @Override - public String getDefaultEmblemPersistent() { - String emblem = this.configuration.getEmblem(); - if (emblem == null) - emblem = STRING_EMPTY; - return emblem; - } - - /** - * Sets the proxy host - * - * @param host - * the proxy host - */ - @Override - public void setProxyHost(String host) { - if (host == null || host.trim().isEmpty()) { - this.configuration.setProxyHost(STRING_EMPTY); - } else { - this.configuration.setProxyHost(host); - } - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setProxyHostOverlay(java.lang.String) - */ - @Override - public void setProxyHostOverlay(String host) { - if (host == null || host.trim().isEmpty()) { - this.configurationOverlay.setProxyHost(STRING_EMPTY); - } else { - this.configurationOverlay.setProxyHost(host); - } - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getProxyHost() - */ - @Override - public String getProxyHost() { - String host = this.configurationOverlay.getProxyHost(); - if (host == null) - host = getProxyHostPersistent(); - return host; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getProxyHostPersistent() - */ - @Override - public String getProxyHostPersistent() { - String host = this.configuration.getProxyHost(); - if (host == null) - host = STRING_EMPTY; - return host; - } - - /** - * Sets the proxy port - * - * @param port - * the proxy port - */ - @Override - public void setProxyPort(int port) { - try { - this.configuration.setProxyPort(port); - } catch (InvalidPortException e) { - log.error("Error setting proxy port" , e); //$NON-NLS-1$ - // ignore - } - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setProxyPortOverlay(int) - */ - @Override - public void setProxyPortOverlay(int port) { - try { - this.configurationOverlay.setProxyPort(port); - } catch (InvalidPortException e) { - log.error("Error setting proxy port" , e); //$NON-NLS-1$ - // ignore - } - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getProxyPort() - */ - @Override - public int getProxyPort() { - int port = this.configurationOverlay.getProxyPort(); - if (port == -1) - port = getProxyPortPersistent(); - return port; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getProxyPortPersistent() - */ - @Override - public int getProxyPortPersistent() { - return this.configuration.getProxyPort(); - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigManipulator#setDefaultOutputFolder - * (java.lang.String) - */ - @Override - public void setDefaultOutputFolder(String outputFolder) { - if (outputFolder == null || outputFolder.trim().isEmpty()) { - this.configuration.setOutputFolder(STRING_EMPTY); - } else { - this.configuration.setOutputFolder(outputFolder); - } - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultOutputFolderOverlay(java.lang.String) - */ - @Override - public void setDefaultOutputFolderOverlay(String outputFolder) { - if (outputFolder == null || outputFolder.trim().isEmpty()) { - this.configurationOverlay.setOutputFolder(STRING_EMPTY); - } else { - this.configurationOverlay.setOutputFolder(outputFolder); - } - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultOutputFolder() - */ - @Override - public String getDefaultOutputFolder() { - String outputFolder = this.configurationOverlay.getOutputFolder(); - if (outputFolder == null) - outputFolder = getDefaultOutputFolderPersistent(); - return outputFolder; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getDefaultOutputFolderPersistent() - */ - @Override - public String getDefaultOutputFolderPersistent() { - String outputFolder = this.configuration.getOutputFolder(); - if (outputFolder == null) - outputFolder = STRING_EMPTY; - return outputFolder; - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getMobileBKUURL() - */ - @Override - public String getMobileBKUURL() { - return this.configuration.getMobileBKUURL(); - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getMobileBKUType() - */ - @Override - public MobileBKUs getMobileBKUType() { - return this.configuration.getMobileBKUType(); - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.ConfigManipulator#setSignatureNote(java. - * lang.String) - */ - @Override - public void setSignatureNote(String note) { - if (note == null || note.trim().isEmpty()) { - this.configuration.setSignatureNote(STRING_EMPTY); - } else { - this.configuration.setSignatureNote(note); - } - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getSignatureNote() - */ - @Override - public String getSignatureNote() { - String note = this.configuration.getSignatureNote(); - if (note == null) - note = STRING_EMPTY; - return note; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setLocale(java.util.Locale) - */ - @Override - public void setLocale(Locale locale) { - if(locale == null) { - this.configuration.setLocale(Messages.getDefaultLocale()); - } else { - this.configuration.setLocale(locale); - Locale.setDefault(locale); - Messages.setLocale(locale); - } - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getConfigLocale() - */ - @Override - public Locale getLocale() { - Locale locale = this.configuration.getLocale(); - if (locale == null) - locale = Messages.getDefaultLocale(); - return locale; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setSignLocale(java.util.Locale) - */ - @Override - public void setSignLocale(Locale locale) { - if(locale == null) { - this.configuration.setSignLocale(Messages.getDefaultLocale()); - } else { - this.configuration.setSignLocale(locale); - } - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getSignLocale() - */ - @Override - public Locale getSignLocale() { - Locale locale = this.configuration.getSignLocale(); - if (locale == null) - locale = Messages.getDefaultLocale(); - return locale; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setMainWindowSize(org.eclipse.swt.graphics.Point) - */ - @Override - public void setMainWindowSize(Point size) { - this.configuration.setMainWindowSize(size); - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getMainWindowSize() - */ - @Override - public Point getMainWindowSize() { - return this.configuration.getMainWindowSize(); - } -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java deleted file mode 100644 index 0f068f64..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainer.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.gui.workflow; - -import java.util.Locale; - -import org.eclipse.swt.graphics.Point; - -import at.asit.pdfover.gui.exceptions.InvalidEmblemFile; -import at.asit.pdfover.gui.exceptions.InvalidNumberException; -import at.asit.pdfover.gui.exceptions.InvalidPortException; -import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs; -import at.asit.pdfover.signator.BKUs; -import at.asit.pdfover.signator.SignaturePosition; - -/** - * - */ -public interface ConfigurationContainer { - /** - * Gets the configured emblem - * @return the configured emblem - */ - public String getEmblem(); - - /** - * Sets the emblem - * @param emblem the emblem - * @throws InvalidEmblemFile - */ - public void setEmblem(String emblem) throws InvalidEmblemFile; - - /** - * Gets the mobile phone number - * @return the mobile phone number - */ - public String getMobileNumber(); - - /** - * Sets the mobile phone number - * @param number the mobile phone number - * @throws InvalidNumberException - */ - public void setMobileNumber(String number) throws InvalidNumberException; - - /** - * Gets the mobile phone number - * @return the mobile phone number - */ - public String getMobilePassword(); - - /** - * Sets the mobile phone password - * @param password the mobile phone password - */ - public void setMobilePassword(String password); - - /** - * Gets the proxy host - * @return the proxy host - */ - public String getProxyHost(); - - /** - * Sets the proxy host - * @param host the proxy host - */ - public void setProxyHost(String host); - - /** - * Gets the signature note - * @return the signature note - */ - public String getSignatureNote(); - - /** - * Sets the signature note - * @param note the signature note - */ - public void setSignatureNote(String note); - - /** - * Gets the proxy port - * - * if port is -1 no port is selected - * - * @return the proxy port - */ - public int getProxyPort(); - - /** - * Sets the proxy port - * - * set to -1 for no port - * - * @param port the proxy port - * @throws InvalidPortException - */ - public void setProxyPort(int port) throws InvalidPortException; - - /** - * Gets the automatic position - * @return the automatic position - */ - public boolean getAutomaticPosition(); - - /** - * Sets the automatic position - * @param automatic the automatic position - */ - public void setAutomaticPosition(boolean automatic); - - /** - * Gets the transparency of the placeholder - * @return transparency of the placeholder (0-255) - */ - public int getPlaceholderTransparency(); - - /** - * Sets the transparency of the placeholder - * @param transparency transparency of the placeholder (0-255) - */ - public void setPlaceholderTransparency(int transparency); - - /** - * Gets the default BKU - * @return the default BKU - */ - public BKUs getDefaultBKU(); - - /** - * Sets the default BKU - * @param defaultBKU the default BKU - */ - public void setDefaultBKU(BKUs defaultBKU); - - /** - * Gets the default output folder - * @return the default output folder - */ - public String getOutputFolder(); - - /** - * Sets the default output folder - * @param folder the default output folder - */ - public void setOutputFolder(String folder); - - /** - * Gets the locale - * @return the locale - */ - public Locale getLocale(); - - /** - * Sets the locale - * @param locale the locale - */ - public void setLocale(Locale locale); - - /** - * Gets the signature locale - * @return the signature locale - */ - public Locale getSignLocale(); - - /** - * Sets the signature locale - * @param locale the signature locale - */ - public void setSignLocale(Locale locale); - - /** - * Gets the mobile BKU URL - * @return the mobile BKU URL - */ - public String getMobileBKUURL(); - - /** - * Sets the mobile BKU URL - * @param bkuUrl the mobile BKU URL - */ - public void setMobileBKUURL(String bkuUrl); - - /** - * Gets the mobile BKU type - * @return the mobile BKU type - */ - public MobileBKUs getMobileBKUType(); - - /** - * Sets the mobile BKU type - * @param bkuType the mobile BKU type - */ - public void setMobileBKUType(MobileBKUs bkuType); - - /** - * Gets the default signature position - * @return the default signature position - */ - public SignaturePosition getDefaultSignaturePosition(); - - /** - * Gets the default signature position - * @param signaturePosition the default signature position - */ - public void setDefaultSignaturePosition(SignaturePosition signaturePosition); - - /** - * Gets the main window size - * @return the main window size - */ - public Point getMainWindowSize(); - - /** - * Sets the main window size - * @param size the main window size - */ - public void setMainWindowSize(Point size); -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java deleted file mode 100644 index 03bfc221..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.gui.workflow; - -// Imports -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Locale; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Display; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.Constants; -import at.asit.pdfover.gui.exceptions.InvalidEmblemFile; -import at.asit.pdfover.gui.exceptions.InvalidNumberException; -import at.asit.pdfover.gui.exceptions.InvalidPortException; -import at.asit.pdfover.gui.utils.Messages; -import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHelper; -import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs; -import at.asit.pdfover.signator.BKUs; -import at.asit.pdfover.signator.SignaturePosition; - -/** - * - */ -public class ConfigurationContainerImpl implements ConfigurationContainer { - /** - * SLF4J Logger instance - **/ - @SuppressWarnings("unused") - private static final Logger log = LoggerFactory - .getLogger(ConfigurationContainerImpl.class); - - - /** the emblem File */ - protected String emblemFile = null; - - /** The mobile phone number */ - protected String mobileNumber = null; - - /** The mobile phone password */ - protected String mobilePassword = null; - - /** Holds the proxy Host */ - protected String proxyHost = null; - - /** Holds the signatureNote */ - protected String signatureNote = null; - - /** Holds the proxy port number */ - protected int proxyPort = -1; - - /** Holds the locale */ - protected Locale locale = null; - - /** Holds the signature locale */ - protected Locale signLocale = null; - - /** Holds the output folder */ - protected String folder = null; - - /** Holds the default BKU to use */ - protected BKUs defaultBKU = BKUs.NONE; - - /** Holds the automatic positioning value */ - protected boolean automaticPositioning = false; - - /** Holds the transparency of the signature placeholder */ - protected int placeholderTransparency = Constants.DEFAULT_SIGNATURE_PLACEHOLDER_TRANSPARENCY; - - /** Holds the mobile BKU URL */ - protected String mobileBKUURL = Constants.DEFAULT_MOBILE_BKU_URL; - - /** Holds the mobile BKU type */ - protected MobileBKUs mobileBKUType = Constants.DEFAULT_MOBILE_BKU_TYPE; - - /** Holds the main window size */ - protected Point mainWindowSize = null; - - /** Holds the default signature position */ - protected SignaturePosition defaultSignaturePosition = null; - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getEmblem() - */ - @Override - public String getEmblem() { - return this.emblemFile; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setEmblem(java.lang.String) - */ - @Override - public void setEmblem(String emblemFile) throws InvalidEmblemFile { - if (emblemFile == null || emblemFile.trim().isEmpty()) { - // Ok to set no file ... - } else { - File imageFile = new File(emblemFile); - if (!imageFile.exists()) { - throw new InvalidEmblemFile(imageFile, - new FileNotFoundException(emblemFile)); - } - - try { - Image img = new Image(Display.getDefault(), new ImageData( - emblemFile)); - - img.dispose(); - } catch (Exception ex) { - throw new InvalidEmblemFile(imageFile, ex); - } - } - - this.emblemFile = emblemFile; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getNumber() - */ - @Override - public String getMobileNumber() { - return this.mobileNumber; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setNumber(java.lang.String) - */ - @Override - public void setMobileNumber(String number) throws InvalidNumberException { - if(number == null || number.trim().isEmpty()) { - this.mobileNumber = null; - return; - } - try { - this.mobileNumber = MobileBKUHelper.normalizeMobileNumber(number); - } catch (InvalidNumberException e) { - throw new InvalidNumberException(Messages.getString("error.InvalidPhoneNumber")); //$NON-NLS-1$ - } - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getDefaultMobilePassword() - */ - @Override - public String getMobilePassword() { - return this.mobilePassword; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setDefaultMobilePassword(java.lang.String) - */ - @Override - public void setMobilePassword(String password) { - this.mobilePassword = password; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getProxyHost() - */ - @Override - public String getProxyHost() { - return this.proxyHost; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setProxyHost(java.lang.String) - */ - @Override - public void setProxyHost(String host) { - this.proxyHost = host; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getProxyPort() - */ - @Override - public int getProxyPort() { - return this.proxyPort; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setProxyPort(int) - */ - @Override - public void setProxyPort(int port) throws InvalidPortException { - if(port > 0 && port <= 0xFFFF) { - this.proxyPort = port; - return; - } - if(port == -1) { - this.proxyPort = -1; - return; - } - throw new InvalidPortException(port); - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getAutomaticPosition() - */ - @Override - public boolean getAutomaticPosition() { - return this.automaticPositioning; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setAutomaticPosition(boolean) - */ - @Override - public void setAutomaticPosition(boolean automatic) { - this.automaticPositioning = automatic; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getPlaceholderTransparency() - */ - @Override - public int getPlaceholderTransparency() { - return this.placeholderTransparency; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setPlaceholderTransparency(int) - */ - @Override - public void setPlaceholderTransparency(int transparency) { - this.placeholderTransparency = transparency; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getBKUSelection() - */ - @Override - public BKUs getDefaultBKU() { - return this.defaultBKU; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setBKUSelection(at.asit.pdfover.signator.BKUs) - */ - @Override - public void setDefaultBKU(BKUs bkuSelection) { - this.defaultBKU = bkuSelection; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getOutputFolder() - */ - @Override - public String getOutputFolder() { - return this.folder; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setOutputFolder(java.lang.String) - */ - @Override - public void setOutputFolder(String folder) { - this.folder = folder; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getSignatureNote() - */ - @Override - public String getSignatureNote() { - return this.signatureNote; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignatureNote(java.lang.String) - */ - @Override - public void setSignatureNote(String note) { - this.signatureNote = note; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getLocale() - */ - @Override - public Locale getLocale() { - return this.locale; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setLocale(java.util.Locale) - */ - @Override - public void setLocale(Locale locale) { - this.locale = locale; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getSignLocale() - */ - @Override - public Locale getSignLocale() { - return this.signLocale; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignLocale(java.util.Locale) - */ - @Override - public void setSignLocale(Locale locale) { - this.signLocale = locale; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getMobileBkURL() - */ - @Override - public String getMobileBKUURL() { - return this.mobileBKUURL; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setMobileBkURL(java.lang.String) - */ - @Override - public void setMobileBKUURL(String bkuUrl) { - this.mobileBKUURL = bkuUrl; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getMobileBKUType() - */ - @Override - public MobileBKUs getMobileBKUType() { - return this.mobileBKUType; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setMobileBKUType(at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs) - */ - @Override - public void setMobileBKUType(MobileBKUs bkuType) { - this.mobileBKUType = bkuType; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getSignaturePosition() - */ - @Override - public SignaturePosition getDefaultSignaturePosition() { - return this.defaultSignaturePosition; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignaturePosition(at.asit.pdfover.signator.SignaturePosition) - */ - @Override - public void setDefaultSignaturePosition(SignaturePosition signaturePosition) { - this.defaultSignaturePosition = signaturePosition; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getMainWindowSize() - */ - @Override - public Point getMainWindowSize() { - return this.mainWindowSize; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setMainWindowSize(org.eclipse.swt.graphics.Point) - */ - @Override - public void setMainWindowSize(Point size) { - this.mainWindowSize = size; - } -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PersistentConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PersistentConfigProvider.java deleted file mode 100644 index a0469d0d..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PersistentConfigProvider.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.gui.workflow; - -import java.util.Locale; - -import org.eclipse.swt.graphics.Point; - -import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs; -import at.asit.pdfover.signator.BKUs; -import at.asit.pdfover.signator.SignaturePosition; - -/** - * An interface for reading the persistent configuration - * - * This reads the configuration that will be saved - */ -public interface PersistentConfigProvider { - /** - * Get the default configured BKU - * @return the default configured BKU - */ - public BKUs getDefaultBKUPersistent(); - - /** - * Gets the default Mobile number - * @return the default mobile number - */ - public String getDefaultMobileNumberPersistent(); - - /** - * Gets the password to use for Mobile BKU - * @return the password - */ - public String getDefaultMobilePasswordPersistent(); - - /** - * Gets the filename of the default emblem - * @return the emblem - */ - public String getDefaultEmblemPersistent(); - - /** - * Gets the proxy host - * @return the proxy hostname or ip address - */ - public String getProxyHostPersistent(); - - /** - * Gets the proxy port - * @return the proxy port - */ - public int getProxyPortPersistent(); - - /** - * Gets the default output folder for signed documents - * @return the default output folder - */ - public String getDefaultOutputFolderPersistent(); - - // Declare the other configuration getters for convenience - - /** - * Get the default configured SignaturePosition - * @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 mobile BKU URL - * @return the mobile BKU URL - */ - public String getMobileBKUURL(); - - /** - * Gets the mobile BKU type - * @return the mobile BKU type - */ - public MobileBKUs getMobileBKUType(); - - /** - * 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 getSignLocale(); - - /** - * Gets the configured MainWindow size - * @return the configured MainWindow size - */ - public Point getMainWindowSize(); -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java index a054daaf..6075ffee 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java @@ -15,6 +15,10 @@ */ package at.asit.pdfover.gui.workflow; +import at.asit.pdfover.gui.workflow.config.ConfigManipulator; +import at.asit.pdfover.gui.workflow.config.ConfigOverlayManipulator; +import at.asit.pdfover.gui.workflow.config.ConfigProvider; +import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider; import at.asit.pdfover.gui.workflow.states.State; /** 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 1da947f9..324e9a30 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 @@ -28,6 +28,11 @@ import at.asit.pdfover.gui.MainWindow; import at.asit.pdfover.gui.controls.ErrorDialog; import at.asit.pdfover.gui.controls.Dialog.BUTTONS; import at.asit.pdfover.gui.utils.Messages; +import at.asit.pdfover.gui.workflow.config.ConfigManipulator; +import at.asit.pdfover.gui.workflow.config.ConfigOverlayManipulator; +import at.asit.pdfover.gui.workflow.config.ConfigProvider; +import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider; import at.asit.pdfover.gui.workflow.states.PrepareConfigurationState; import at.asit.pdfover.gui.workflow.states.State; 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 new file mode 100644 index 00000000..58b9e453 --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java @@ -0,0 +1,113 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.workflow.config; + +import java.io.IOException; +import java.util.Locale; + +import org.eclipse.swt.graphics.Point; + +import at.asit.pdfover.signator.BKUs; +import at.asit.pdfover.signator.SignaturePosition; + +/** + * An interface for setting the configuration + */ +public interface ConfigManipulator { + /** + * Sets the default bku type + * @param bku the bku type + */ + public void setDefaultBKU(BKUs bku); + + /** + * Sets the default signature position + * @param signaturePosition the default signature position + */ + public void setDefaultSignaturePosition(SignaturePosition signaturePosition); + + /** + * Sets the signature placeholder transparency + * @param transparency the signature placeholder transparency + */ + void setPlaceholderTransparency(int transparency); + + /** + * Sets the default mobile number + * @param number the default mobile number + */ + public void setDefaultMobileNumber(String number); + + /** + * Sets the default password + * @param password the default password + */ + public void setDefaultMobilePassword(String password); + + /** + * Sets the default emblem + * @param emblem the default emblem + */ + public void setDefaultEmblem(String emblem); + + /** + * Sets the proxy host + * @param host the proxy host + */ + public void setProxyHost(String host); + + /** + * Sets the proxy port + * @param port the proxy port + */ + public void setProxyPort(int port); + + /** + * Sets the default output folder + * @param outputFolder the default output folder + */ + public void setDefaultOutputFolder(String outputFolder); + + /** + * Sets the signature note text + * @param note the signature note text + */ + public void setSignatureNote(String note); + + /** + * Sets the locale to be used + * @param locale the locale + */ + public void setLocale(Locale locale); + + /** + * Sets the signature locale to be used + * @param locale the signature locale + */ + public void setSignLocale(Locale locale); + + /** + * Sets the default main window size + * @param size a Point describing the size + */ + public void setMainWindowSize(Point size); + + /** + * Saves the current configuration to the current configuration file + * @throws IOException + */ + public void saveCurrentConfiguration() throws IOException; +} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java new file mode 100644 index 00000000..cc134229 --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java @@ -0,0 +1,73 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.workflow.config; + +import at.asit.pdfover.signator.BKUs; + +/** + * An interface for setting the configuration overlay + * + * This overlay overrides the actual configuration but will not be saved + */ +public interface ConfigOverlayManipulator { + /** + * Sets the default bku type + * @param bku the bku type + */ + public void setDefaultBKUOverlay(BKUs bku); + + /** + * Sets the default mobile number + * @param number the default mobile number + */ + public void setDefaultMobileNumberOverlay(String number); + + /** + * Sets the default password + * @param password the default password + */ + public void setDefaultMobilePasswordOverlay(String password); + + /** + * Sets the default emblem + * @param emblem the default emblem + */ + public void setDefaultEmblemOverlay(String emblem); + + /** + * Sets the proxy host + * @param host the proxy host + */ + public void setProxyHostOverlay(String host); + + /** + * Sets the proxy port + * @param port the proxy port + */ + public void setProxyPortOverlay(int port); + + /** + * Sets the default output folder + * @param outputFolder the default output folder + */ + public void setDefaultOutputFolderOverlay(String outputFolder); + + /** + * Sets the configuration file + * @param configurationFile + */ + public void setConfigurationFile(String configurationFile); +} 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 new file mode 100644 index 00000000..bfa5ce15 --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java @@ -0,0 +1,146 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.workflow.config; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Locale; + +import org.eclipse.swt.graphics.Point; + +import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs; +import at.asit.pdfover.signator.BKUs; +import at.asit.pdfover.signator.SignaturePosition; + +/** + * An interface for reading the configuration + */ +public interface ConfigProvider { + /** + * RegEx for parsing signature position + */ + 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$ + + + /** + * 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(); + + /** + * 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 + */ + 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 + */ + 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(); + + /** + * 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 getSignLocale(); + + /** + * Gets the configured MainWindow size + * @return the configured MainWindow size + */ + public Point getMainWindowSize(); + + /** + * Loads the configuration from a configuration file + * @param configSource the configuration file + * @throws IOException + */ + public void loadConfiguration(InputStream configSource) throws IOException; +} 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 new file mode 100644 index 00000000..52865222 --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java @@ -0,0 +1,903 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.workflow.config; + +// Imports +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Locale; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.swt.graphics.Point; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.Constants; +import at.asit.pdfover.gui.exceptions.InvalidEmblemFile; +import at.asit.pdfover.gui.exceptions.InvalidNumberException; +import at.asit.pdfover.gui.exceptions.InvalidPortException; +import at.asit.pdfover.gui.utils.LocaleSerializer; +import at.asit.pdfover.gui.utils.Messages; +import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs; +import at.asit.pdfover.signator.BKUs; +import at.asit.pdfover.signator.SignaturePosition; + +/** + * Implementation of the configuration provider and manipulator + */ +public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, + ConfigOverlayManipulator, PersistentConfigProvider { + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(ConfigProviderImpl.class); + + /** + * An empty property entry + */ + private static final String STRING_EMPTY = ""; //$NON-NLS-1$ + + private String configurationFile = Constants.DEFAULT_CONFIG_FILENAME; + + private ConfigurationContainer configuration; + + private ConfigurationContainer configurationOverlay; + + /** + * Constructor + */ + public ConfigProviderImpl() { + this.configuration = new ConfigurationContainerImpl(); + this.configurationOverlay = new ConfigurationContainerImpl(); + } + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigProvider#loadConfiguration(java.io + * .InputStream) + */ + @Override + public void loadConfiguration(InputStream configSource) throws IOException { + + Properties config = new Properties(); + + config.load(configSource); + + // Set Emblem + this.setDefaultEmblem(config + .getProperty(Constants.CFG_EMBLEM)); + + // Set Mobile Phone Number + this.setDefaultMobileNumber(config + .getProperty(Constants.CFG_MOBILE_NUMBER)); + + // Set signature note + this.setSignatureNote(config + .getProperty(Constants.CFG_SIGNATURE_NOTE)); + + // Set Proxy Host + this.setProxyHost(config + .getProperty(Constants.CFG_PROXY_HOST)); + + // Set Output Folder + this.setDefaultOutputFolder(config + .getProperty(Constants.CFG_OUTPUT_FOLDER)); + + String localeString = config.getProperty(Constants.CFG_LOCALE); + + Locale targetLocale = LocaleSerializer.parseFromString(localeString); + if (targetLocale != null) { + this.setLocale(targetLocale); + } + + String signlocalString = config.getProperty(Constants.CFG_SIGN_LOCALE); + + Locale signtargetLocale = LocaleSerializer.parseFromString(signlocalString); + if (signtargetLocale != null) { + this.setSignLocale(signtargetLocale); + } + + String bkuUrl = config + .getProperty(Constants.CFG_MOBILE_BKU_URL); + + if (bkuUrl != null && !bkuUrl.isEmpty()) { + this.configuration.setMobileBKUURL(bkuUrl); + } + + String bkuType = config + .getProperty(Constants.CFG_MOBILE_BKU_TYPE); + + if (bkuType != null && !bkuType.isEmpty()) { + try { + this.configuration.setMobileBKUType(MobileBKUs.valueOf( + bkuType.trim().toUpperCase())); + } catch (IllegalArgumentException e) { + log.error("Invalid BKU type: " + bkuType); //$NON-NLS-1$ + this.configuration.setMobileBKUType(Constants.DEFAULT_MOBILE_BKU_TYPE); + } + } + + // Set Proxy Port + String proxyPortString = config + .getProperty(Constants.CFG_PROXY_PORT); + + if (proxyPortString != null && !proxyPortString.trim().isEmpty()) { + int port = Integer.parseInt(proxyPortString); + + if (port > 0 && port <= 0xFFFF) { + this.setProxyPort(port); + } else { + log.warn("Proxy port is out of range!: " + port); //$NON-NLS-1$ + } + } + + // Set Default BKU + String bkuString = config.getProperty(Constants.CFG_BKU); + BKUs defaultBKU = BKUs.NONE; + if (bkuString != null) { + try { + defaultBKU = BKUs.valueOf(bkuString); + } catch (IllegalArgumentException ex) { + log.error("Invalid BKU config value " + bkuString + " using none!"); //$NON-NLS-1$ //$NON-NLS-2$ + defaultBKU = BKUs.NONE; + } catch (NullPointerException ex) { + log.error("Invalid BKU config value " + bkuString + " using none!"); //$NON-NLS-1$ //$NON-NLS-2$ + defaultBKU = BKUs.NONE; + } + } + this.setDefaultBKU(defaultBKU); + + // Set Signature placeholder transparency + int transparency = Constants.DEFAULT_SIGNATURE_PLACEHOLDER_TRANSPARENCY; + String trans = config.getProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY); + if (trans != null) { + try { + transparency = Integer.parseInt(trans); + } catch (NumberFormatException e) { + log.debug("Couldn't parse placeholder transparency", e); //$NON-NLS-1$ + // ignore parsing exception + } + } + this.setPlaceholderTransparency(transparency); + + // Set MainWindow size + int width = Constants.DEFAULT_MAINWINDOW_WIDTH; + int height = Constants.DEFAULT_MAINWINDOW_HEIGHT; + String size = config.getProperty(Constants.CFG_MAINWINDOW_SIZE); + parse: { + if (size == null) + break parse; + int pos = size.indexOf(','); + if (pos <= 0) + break parse; + + try { + width = Integer.parseInt(size.substring(0, pos).trim()); + height = Integer.parseInt(size.substring(pos + 1).trim()); + } catch (NumberFormatException e) { + log.debug("Couldn't parse main window size", e); //$NON-NLS-1$ + // ignore parsing exception + } + } + this.configuration.setMainWindowSize(new Point(width, height)); + + // Set Signature Position + String signaturePosition = config + .getProperty(Constants.CFG_SIGNATURE_POSITION); + + SignaturePosition position = null; + + if (signaturePosition != null && !signaturePosition.trim().isEmpty()) { + + signaturePosition = signaturePosition.trim().toLowerCase(); + + Pattern pattern = Pattern.compile(SIGN_POS_REGEX); + + Matcher matcher = pattern.matcher(signaturePosition); + + if (matcher.matches()) { + if (matcher.groupCount() == 8) { + if (matcher.group(1) != null) { + // we have format: x=..;y=..;p=... + try { + // group 2 = x value + float x = Float.parseFloat(matcher.group(2)); + + // group 3 = y value + float y = Float.parseFloat(matcher.group(3)); + + // group 4 = p value + int p = Integer.parseInt(matcher.group(3)); + + position = new SignaturePosition(x, y, p); + } catch (NumberFormatException ex) { + log.error( + "Signature Position read from config failed: Not a valid number", ex); //$NON-NLS-1$ + } + } else if (matcher.group(5) != null) { + // we have format auto + position = new SignaturePosition(); + } else if (matcher.group(6) != null) { + // we have format x=...;y=...; + // group 7 = x value + float x = Float.parseFloat(matcher.group(7)); + + // group 8 = y value + float y = Float.parseFloat(matcher.group(8)); + + position = new SignaturePosition(x, y); + } + } else { + log.error("Signature Position read from config failed: wrong group Count!"); //$NON-NLS-1$ + } + } else { + log.error("Signature Position read from config failed: not matching string"); //$NON-NLS-1$ + } + + } + + this.setDefaultSignaturePosition(position); + } + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigManipulator#saveCurrentConfiguration() + */ + @Override + public void saveCurrentConfiguration() throws IOException { + String filename = this.getConfigurationFile(); + + File configFile = new File(this.getConfigurationDirectory() + + File.separator + filename); + + Properties props = new Properties(); + props.clear(); + + props.setProperty(Constants.CFG_BKU, this.getDefaultBKUPersistent().toString()); + props.setProperty(Constants.CFG_PROXY_HOST, this.getProxyHostPersistent()); + props.setProperty(Constants.CFG_PROXY_PORT, + Integer.toString(getProxyPortPersistent())); + props.setProperty(Constants.CFG_EMBLEM, this.getDefaultEmblemPersistent()); + props.setProperty(Constants.CFG_SIGNATURE_NOTE, this.getSignatureNote()); + props.setProperty(Constants.CFG_MOBILE_NUMBER, this.getDefaultMobileNumberPersistent()); + props.setProperty(Constants.CFG_OUTPUT_FOLDER, this.getDefaultOutputFolderPersistent()); + props.setProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY, + Integer.toString(getPlaceholderTransparency())); + + Point size = this.configuration.getMainWindowSize(); + props.setProperty(Constants.CFG_MAINWINDOW_SIZE, size.x + "," + size.y); //$NON-NLS-1$ + + Locale configLocale = getLocale(); + if(configLocale != null) { + props.setProperty(Constants.CFG_LOCALE, LocaleSerializer.getParsableString(configLocale)); + } + + Locale signLocale = this.getSignLocale(); + if(signLocale != null) { + props.setProperty(Constants.CFG_SIGN_LOCALE, LocaleSerializer.getParsableString(signLocale)); + } + + SignaturePosition pos = getDefaultSignaturePosition(); + + if (pos == null) { + props.setProperty(Constants.CFG_SIGNATURE_POSITION, ""); //$NON-NLS-1$ + } else if (pos.useAutoPositioning()) { + props.setProperty(Constants.CFG_SIGNATURE_POSITION, "auto"); //$NON-NLS-1$ + } else { + props.setProperty(Constants.CFG_SIGNATURE_POSITION, + String.format((Locale) null, "x=%f;y=%f;p=%d", //$NON-NLS-1$ + pos.getX(), pos.getY(), pos.getPage())); + } + + String mobileBKUURL = getMobileBKUURL(); + if (!mobileBKUURL.equals(Constants.DEFAULT_MOBILE_BKU_URL)) + props.setProperty(Constants.CFG_MOBILE_BKU_URL, mobileBKUURL); + + MobileBKUs mobileBKUType = getMobileBKUType(); + if (mobileBKUType != Constants.DEFAULT_MOBILE_BKU_TYPE) + props.setProperty(Constants.CFG_MOBILE_BKU_TYPE, mobileBKUType.toString()); + + if (Constants.THEME != Constants.Themes.DEFAULT) + props.setProperty(Constants.CFG_THEME, Constants.THEME.name()); + + FileOutputStream outputstream = new FileOutputStream(configFile, false); + + props.store(outputstream, "Configuration file was generated!"); //$NON-NLS-1$ + + log.info("Configuration file saved to " + configFile.getAbsolutePath()); //$NON-NLS-1$ + } + + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationDirectory() + */ + @Override + public String getConfigurationDirectory() { + return Constants.CONFIG_DIRECTORY; + } + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigManipulator#setConfigurationFile(java + * .lang.String) + */ + @Override + public void setConfigurationFile(String configurationFile) { + this.configurationFile = configurationFile; + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getConfigurationFile() + */ + @Override + public String getConfigurationFile() { + return this.configurationFile; + } + + /** + * Sets the default bku type + * + * @param bku + * the bku type + */ + @Override + public void setDefaultBKU(BKUs bku) { + this.configuration.setDefaultBKU(bku); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultBKUOverlay(at.asit.pdfover.signator.BKUs) + */ + @Override + public void setDefaultBKUOverlay(BKUs bku) { + this.configurationOverlay.setDefaultBKU(bku); + + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultBKU() + */ + @Override + public BKUs getDefaultBKU() { + BKUs bku = this.configurationOverlay.getDefaultBKU(); + if (bku == BKUs.NONE) + bku = getDefaultBKUPersistent(); + return bku; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getDefaultBKUPersistent() + */ + @Override + public BKUs getDefaultBKUPersistent() { + return this.configuration.getDefaultBKU(); + } + + /** + * Sets the default signature position + * + * @param signaturePosition + * the default signature position + */ + @Override + public void setDefaultSignaturePosition(SignaturePosition signaturePosition) { + this.configuration.setDefaultSignaturePosition(signaturePosition); + } + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultSignaturePosition() + */ + @Override + public SignaturePosition getDefaultSignaturePosition() { + return this.configuration.getDefaultSignaturePosition(); + } + + /** + * Sets the signature placeholder transparency + * + * @param transparency + * the signature placeholder transparency + */ + @Override + public void setPlaceholderTransparency(int transparency) { + this.configuration.setPlaceholderTransparency(transparency); + } + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigProvider#getPlaceholderTransparency() + */ + @Override + public int getPlaceholderTransparency() { + return this.configuration.getPlaceholderTransparency(); + } + + /** + * Sets the default mobile number + * + * @param number + * the default mobile number + */ + @Override + public void setDefaultMobileNumber(String number) { + try { + if (number == null || number.trim().isEmpty()) { + this.configuration.setMobileNumber(STRING_EMPTY); + } else { + this.configuration.setMobileNumber(number); + } + } catch (InvalidNumberException e) { + log.error("Error setting mobile number", e); //$NON-NLS-1$ + try { + this.configuration.setMobileNumber(STRING_EMPTY); + } catch (InvalidNumberException e1) { + // Ignore + } + } + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultMobileNumberOverlay(java.lang.String) + */ + @Override + public void setDefaultMobileNumberOverlay(String number) { + try { + if (number == null || number.trim().isEmpty()) { + this.configurationOverlay.setMobileNumber(STRING_EMPTY); + } else { + this.configurationOverlay.setMobileNumber(number); + } + } catch (InvalidNumberException e) { + log.error("Error setting mobile number", e); //$NON-NLS-1$ + try { + this.configurationOverlay.setMobileNumber(STRING_EMPTY); + } catch (InvalidNumberException e1) { + // Ignore + } + } + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultMobileNumber() + */ + @Override + public String getDefaultMobileNumber() { + String number = this.configurationOverlay.getMobileNumber(); + if (number == null) + number = getDefaultMobileNumberPersistent(); + return number; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getDefaultMobileNumberPersistent() + */ + @Override + public String getDefaultMobileNumberPersistent() { + String number = this.configuration.getMobileNumber(); + if (number == null) + number = STRING_EMPTY; + return number; + } + + /** + * Sets the default mobile password + * + * @param password + * the default password + */ + @Override + public void setDefaultMobilePassword(String password) { + if (password == null || password.trim().isEmpty()) { + this.configuration.setMobilePassword(STRING_EMPTY); + } else { + this.configuration.setMobilePassword(password); + } + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultMobilePasswordOverlay(java.lang.String) + */ + @Override + public void setDefaultMobilePasswordOverlay(String password) { + if (password == null || password.trim().isEmpty()) { + this.configurationOverlay.setMobilePassword(STRING_EMPTY); + } else { + this.configurationOverlay.setMobilePassword(password); + } + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultPassword() + */ + @Override + public String getDefaultMobilePassword() { + String password = this.configurationOverlay.getMobilePassword(); + if (password == null) + password = getDefaultMobilePasswordPersistent(); + return password; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getDefaultMobilePasswordPersistent() + */ + @Override + public String getDefaultMobilePasswordPersistent() { + String password = this.configuration.getMobilePassword(); + if (password == null) + password = STRING_EMPTY; + return password; + } + + /** + * Sets the default emblem + * + * @param emblem + * the default emblem + */ + @Override + public void setDefaultEmblem(String emblem) { + try { + if (emblem == null || emblem.trim().isEmpty()) { + this.configuration.setEmblem(STRING_EMPTY); + } else { + this.configuration.setEmblem(emblem); + } + } catch (InvalidEmblemFile e) { + log.error("Error setting emblem file", e); //$NON-NLS-1$ + try { + this.configuration.setEmblem(STRING_EMPTY); + } catch (InvalidEmblemFile e1) { + // Ignore + } + } + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultEmblemOverlay(java.lang.String) + */ + @Override + public void setDefaultEmblemOverlay(String emblem) { + try { + if (emblem == null || emblem.trim().isEmpty()) { + this.configurationOverlay.setEmblem(STRING_EMPTY); + } else { + this.configurationOverlay.setEmblem(emblem); + } + } catch (InvalidEmblemFile e) { + log.error("Error setting emblem file", e); //$NON-NLS-1$ + try { + this.configurationOverlay.setEmblem(STRING_EMPTY); + } catch (InvalidEmblemFile e1) { + // Ignore + } + } + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultEmblem() + */ + @Override + public String getDefaultEmblem() { + String emblem = this.configurationOverlay.getEmblem(); + if (emblem == null) + emblem = getDefaultEmblemPersistent(); + return emblem; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getDefaultEmblemPersistent() + */ + @Override + public String getDefaultEmblemPersistent() { + String emblem = this.configuration.getEmblem(); + if (emblem == null) + emblem = STRING_EMPTY; + return emblem; + } + + /** + * Sets the proxy host + * + * @param host + * the proxy host + */ + @Override + public void setProxyHost(String host) { + if (host == null || host.trim().isEmpty()) { + this.configuration.setProxyHost(STRING_EMPTY); + } else { + this.configuration.setProxyHost(host); + } + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setProxyHostOverlay(java.lang.String) + */ + @Override + public void setProxyHostOverlay(String host) { + if (host == null || host.trim().isEmpty()) { + this.configurationOverlay.setProxyHost(STRING_EMPTY); + } else { + this.configurationOverlay.setProxyHost(host); + } + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getProxyHost() + */ + @Override + public String getProxyHost() { + String host = this.configurationOverlay.getProxyHost(); + if (host == null) + host = getProxyHostPersistent(); + return host; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getProxyHostPersistent() + */ + @Override + public String getProxyHostPersistent() { + String host = this.configuration.getProxyHost(); + if (host == null) + host = STRING_EMPTY; + return host; + } + + /** + * Sets the proxy port + * + * @param port + * the proxy port + */ + @Override + public void setProxyPort(int port) { + try { + this.configuration.setProxyPort(port); + } catch (InvalidPortException e) { + log.error("Error setting proxy port" , e); //$NON-NLS-1$ + // ignore + } + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setProxyPortOverlay(int) + */ + @Override + public void setProxyPortOverlay(int port) { + try { + this.configurationOverlay.setProxyPort(port); + } catch (InvalidPortException e) { + log.error("Error setting proxy port" , e); //$NON-NLS-1$ + // ignore + } + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getProxyPort() + */ + @Override + public int getProxyPort() { + int port = this.configurationOverlay.getProxyPort(); + if (port == -1) + port = getProxyPortPersistent(); + return port; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getProxyPortPersistent() + */ + @Override + public int getProxyPortPersistent() { + return this.configuration.getProxyPort(); + } + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigManipulator#setDefaultOutputFolder + * (java.lang.String) + */ + @Override + public void setDefaultOutputFolder(String outputFolder) { + if (outputFolder == null || outputFolder.trim().isEmpty()) { + this.configuration.setOutputFolder(STRING_EMPTY); + } else { + this.configuration.setOutputFolder(outputFolder); + } + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultOutputFolderOverlay(java.lang.String) + */ + @Override + public void setDefaultOutputFolderOverlay(String outputFolder) { + if (outputFolder == null || outputFolder.trim().isEmpty()) { + this.configurationOverlay.setOutputFolder(STRING_EMPTY); + } else { + this.configurationOverlay.setOutputFolder(outputFolder); + } + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultOutputFolder() + */ + @Override + public String getDefaultOutputFolder() { + String outputFolder = this.configurationOverlay.getOutputFolder(); + if (outputFolder == null) + outputFolder = getDefaultOutputFolderPersistent(); + return outputFolder; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.PersistentConfigProvider#getDefaultOutputFolderPersistent() + */ + @Override + public String getDefaultOutputFolderPersistent() { + String outputFolder = this.configuration.getOutputFolder(); + if (outputFolder == null) + outputFolder = STRING_EMPTY; + return outputFolder; + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getMobileBKUURL() + */ + @Override + public String getMobileBKUURL() { + return this.configuration.getMobileBKUURL(); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getMobileBKUType() + */ + @Override + public MobileBKUs getMobileBKUType() { + return this.configuration.getMobileBKUType(); + } + + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.workflow.ConfigManipulator#setSignatureNote(java. + * lang.String) + */ + @Override + public void setSignatureNote(String note) { + if (note == null || note.trim().isEmpty()) { + this.configuration.setSignatureNote(STRING_EMPTY); + } else { + this.configuration.setSignatureNote(note); + } + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getSignatureNote() + */ + @Override + public String getSignatureNote() { + String note = this.configuration.getSignatureNote(); + if (note == null) + note = STRING_EMPTY; + return note; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setLocale(java.util.Locale) + */ + @Override + public void setLocale(Locale locale) { + if(locale == null) { + this.configuration.setLocale(Messages.getDefaultLocale()); + } else { + this.configuration.setLocale(locale); + Locale.setDefault(locale); + Messages.setLocale(locale); + } + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getConfigLocale() + */ + @Override + public Locale getLocale() { + Locale locale = this.configuration.getLocale(); + if (locale == null) + locale = Messages.getDefaultLocale(); + return locale; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setSignLocale(java.util.Locale) + */ + @Override + public void setSignLocale(Locale locale) { + if(locale == null) { + this.configuration.setSignLocale(Messages.getDefaultLocale()); + } else { + this.configuration.setSignLocale(locale); + } + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getSignLocale() + */ + @Override + public Locale getSignLocale() { + Locale locale = this.configuration.getSignLocale(); + if (locale == null) + locale = Messages.getDefaultLocale(); + return locale; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setMainWindowSize(org.eclipse.swt.graphics.Point) + */ + @Override + public void setMainWindowSize(Point size) { + this.configuration.setMainWindowSize(size); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getMainWindowSize() + */ + @Override + public Point getMainWindowSize() { + return this.configuration.getMainWindowSize(); + } +} 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 new file mode 100644 index 00000000..21a635a5 --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java @@ -0,0 +1,233 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.workflow.config; + +import java.util.Locale; + +import org.eclipse.swt.graphics.Point; + +import at.asit.pdfover.gui.exceptions.InvalidEmblemFile; +import at.asit.pdfover.gui.exceptions.InvalidNumberException; +import at.asit.pdfover.gui.exceptions.InvalidPortException; +import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs; +import at.asit.pdfover.signator.BKUs; +import at.asit.pdfover.signator.SignaturePosition; + +/** + * + */ +public interface ConfigurationContainer { + /** + * Gets the configured emblem + * @return the configured emblem + */ + public String getEmblem(); + + /** + * Sets the emblem + * @param emblem the emblem + * @throws InvalidEmblemFile + */ + public void setEmblem(String emblem) throws InvalidEmblemFile; + + /** + * Gets the mobile phone number + * @return the mobile phone number + */ + public String getMobileNumber(); + + /** + * Sets the mobile phone number + * @param number the mobile phone number + * @throws InvalidNumberException + */ + public void setMobileNumber(String number) throws InvalidNumberException; + + /** + * Gets the mobile phone number + * @return the mobile phone number + */ + public String getMobilePassword(); + + /** + * Sets the mobile phone password + * @param password the mobile phone password + */ + public void setMobilePassword(String password); + + /** + * Gets the proxy host + * @return the proxy host + */ + public String getProxyHost(); + + /** + * Sets the proxy host + * @param host the proxy host + */ + public void setProxyHost(String host); + + /** + * Gets the signature note + * @return the signature note + */ + public String getSignatureNote(); + + /** + * Sets the signature note + * @param note the signature note + */ + public void setSignatureNote(String note); + + /** + * Gets the proxy port + * + * if port is -1 no port is selected + * + * @return the proxy port + */ + public int getProxyPort(); + + /** + * Sets the proxy port + * + * set to -1 for no port + * + * @param port the proxy port + * @throws InvalidPortException + */ + public void setProxyPort(int port) throws InvalidPortException; + + /** + * Gets the automatic position + * @return the automatic position + */ + public boolean getAutomaticPosition(); + + /** + * Sets the automatic position + * @param automatic the automatic position + */ + public void setAutomaticPosition(boolean automatic); + + /** + * Gets the transparency of the placeholder + * @return transparency of the placeholder (0-255) + */ + public int getPlaceholderTransparency(); + + /** + * Sets the transparency of the placeholder + * @param transparency transparency of the placeholder (0-255) + */ + public void setPlaceholderTransparency(int transparency); + + /** + * Gets the default BKU + * @return the default BKU + */ + public BKUs getDefaultBKU(); + + /** + * Sets the default BKU + * @param defaultBKU the default BKU + */ + public void setDefaultBKU(BKUs defaultBKU); + + /** + * Gets the default output folder + * @return the default output folder + */ + public String getOutputFolder(); + + /** + * Sets the default output folder + * @param folder the default output folder + */ + public void setOutputFolder(String folder); + + /** + * Gets the locale + * @return the locale + */ + public Locale getLocale(); + + /** + * Sets the locale + * @param locale the locale + */ + public void setLocale(Locale locale); + + /** + * Gets the signature locale + * @return the signature locale + */ + public Locale getSignLocale(); + + /** + * Sets the signature locale + * @param locale the signature locale + */ + public void setSignLocale(Locale locale); + + /** + * Gets the mobile BKU URL + * @return the mobile BKU URL + */ + public String getMobileBKUURL(); + + /** + * Sets the mobile BKU URL + * @param bkuUrl the mobile BKU URL + */ + public void setMobileBKUURL(String bkuUrl); + + /** + * Gets the mobile BKU type + * @return the mobile BKU type + */ + public MobileBKUs getMobileBKUType(); + + /** + * Sets the mobile BKU type + * @param bkuType the mobile BKU type + */ + public void setMobileBKUType(MobileBKUs bkuType); + + /** + * Gets the default signature position + * @return the default signature position + */ + public SignaturePosition getDefaultSignaturePosition(); + + /** + * Gets the default signature position + * @param signaturePosition the default signature position + */ + public void setDefaultSignaturePosition(SignaturePosition signaturePosition); + + /** + * Gets the main window size + * @return the main window size + */ + public Point getMainWindowSize(); + + /** + * Sets the main window size + * @param size the main window size + */ + public void setMainWindowSize(Point size); +} 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 new file mode 100644 index 00000000..0729cb51 --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java @@ -0,0 +1,420 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.workflow.config; + +// Imports +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Locale; + +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Display; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.Constants; +import at.asit.pdfover.gui.exceptions.InvalidEmblemFile; +import at.asit.pdfover.gui.exceptions.InvalidNumberException; +import at.asit.pdfover.gui.exceptions.InvalidPortException; +import at.asit.pdfover.gui.utils.Messages; +import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHelper; +import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs; +import at.asit.pdfover.signator.BKUs; +import at.asit.pdfover.signator.SignaturePosition; + +/** + * + */ +public class ConfigurationContainerImpl implements ConfigurationContainer { + /** + * SLF4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory + .getLogger(ConfigurationContainerImpl.class); + + + /** the emblem File */ + protected String emblemFile = null; + + /** The mobile phone number */ + protected String mobileNumber = null; + + /** The mobile phone password */ + protected String mobilePassword = null; + + /** Holds the proxy Host */ + protected String proxyHost = null; + + /** Holds the signatureNote */ + protected String signatureNote = null; + + /** Holds the proxy port number */ + protected int proxyPort = -1; + + /** Holds the locale */ + protected Locale locale = null; + + /** Holds the signature locale */ + protected Locale signLocale = null; + + /** Holds the output folder */ + protected String folder = null; + + /** Holds the default BKU to use */ + protected BKUs defaultBKU = BKUs.NONE; + + /** Holds the automatic positioning value */ + protected boolean automaticPositioning = false; + + /** Holds the transparency of the signature placeholder */ + protected int placeholderTransparency = Constants.DEFAULT_SIGNATURE_PLACEHOLDER_TRANSPARENCY; + + /** Holds the mobile BKU URL */ + protected String mobileBKUURL = Constants.DEFAULT_MOBILE_BKU_URL; + + /** Holds the mobile BKU type */ + protected MobileBKUs mobileBKUType = Constants.DEFAULT_MOBILE_BKU_TYPE; + + /** Holds the main window size */ + protected Point mainWindowSize = null; + + /** Holds the default signature position */ + protected SignaturePosition defaultSignaturePosition = null; + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getEmblem() + */ + @Override + public String getEmblem() { + return this.emblemFile; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setEmblem(java.lang.String) + */ + @Override + public void setEmblem(String emblemFile) throws InvalidEmblemFile { + if (emblemFile == null || emblemFile.trim().isEmpty()) { + // Ok to set no file ... + } else { + File imageFile = new File(emblemFile); + if (!imageFile.exists()) { + throw new InvalidEmblemFile(imageFile, + new FileNotFoundException(emblemFile)); + } + + try { + Image img = new Image(Display.getDefault(), new ImageData( + emblemFile)); + + img.dispose(); + } catch (Exception ex) { + throw new InvalidEmblemFile(imageFile, ex); + } + } + + this.emblemFile = emblemFile; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getNumber() + */ + @Override + public String getMobileNumber() { + return this.mobileNumber; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setNumber(java.lang.String) + */ + @Override + public void setMobileNumber(String number) throws InvalidNumberException { + if(number == null || number.trim().isEmpty()) { + this.mobileNumber = null; + return; + } + try { + this.mobileNumber = MobileBKUHelper.normalizeMobileNumber(number); + } catch (InvalidNumberException e) { + throw new InvalidNumberException(Messages.getString("error.InvalidPhoneNumber")); //$NON-NLS-1$ + } + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getDefaultMobilePassword() + */ + @Override + public String getMobilePassword() { + return this.mobilePassword; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setDefaultMobilePassword(java.lang.String) + */ + @Override + public void setMobilePassword(String password) { + this.mobilePassword = password; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getProxyHost() + */ + @Override + public String getProxyHost() { + return this.proxyHost; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setProxyHost(java.lang.String) + */ + @Override + public void setProxyHost(String host) { + this.proxyHost = host; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getProxyPort() + */ + @Override + public int getProxyPort() { + return this.proxyPort; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setProxyPort(int) + */ + @Override + public void setProxyPort(int port) throws InvalidPortException { + if(port > 0 && port <= 0xFFFF) { + this.proxyPort = port; + return; + } + if(port == -1) { + this.proxyPort = -1; + return; + } + throw new InvalidPortException(port); + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getAutomaticPosition() + */ + @Override + public boolean getAutomaticPosition() { + return this.automaticPositioning; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setAutomaticPosition(boolean) + */ + @Override + public void setAutomaticPosition(boolean automatic) { + this.automaticPositioning = automatic; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getPlaceholderTransparency() + */ + @Override + public int getPlaceholderTransparency() { + return this.placeholderTransparency; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setPlaceholderTransparency(int) + */ + @Override + public void setPlaceholderTransparency(int transparency) { + this.placeholderTransparency = transparency; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getBKUSelection() + */ + @Override + public BKUs getDefaultBKU() { + return this.defaultBKU; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setBKUSelection(at.asit.pdfover.signator.BKUs) + */ + @Override + public void setDefaultBKU(BKUs bkuSelection) { + this.defaultBKU = bkuSelection; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#getOutputFolder() + */ + @Override + public String getOutputFolder() { + return this.folder; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.ConfigurationContainer#setOutputFolder(java.lang.String) + */ + @Override + public void setOutputFolder(String folder) { + this.folder = folder; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getSignatureNote() + */ + @Override + public String getSignatureNote() { + return this.signatureNote; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignatureNote(java.lang.String) + */ + @Override + public void setSignatureNote(String note) { + this.signatureNote = note; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getLocale() + */ + @Override + public Locale getLocale() { + return this.locale; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setLocale(java.util.Locale) + */ + @Override + public void setLocale(Locale locale) { + this.locale = locale; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getSignLocale() + */ + @Override + public Locale getSignLocale() { + return this.signLocale; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignLocale(java.util.Locale) + */ + @Override + public void setSignLocale(Locale locale) { + this.signLocale = locale; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getMobileBkURL() + */ + @Override + public String getMobileBKUURL() { + return this.mobileBKUURL; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setMobileBkURL(java.lang.String) + */ + @Override + public void setMobileBKUURL(String bkuUrl) { + this.mobileBKUURL = bkuUrl; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getMobileBKUType() + */ + @Override + public MobileBKUs getMobileBKUType() { + return this.mobileBKUType; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setMobileBKUType(at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs) + */ + @Override + public void setMobileBKUType(MobileBKUs bkuType) { + this.mobileBKUType = bkuType; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getSignaturePosition() + */ + @Override + public SignaturePosition getDefaultSignaturePosition() { + return this.defaultSignaturePosition; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignaturePosition(at.asit.pdfover.signator.SignaturePosition) + */ + @Override + public void setDefaultSignaturePosition(SignaturePosition signaturePosition) { + this.defaultSignaturePosition = signaturePosition; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getMainWindowSize() + */ + @Override + public Point getMainWindowSize() { + return this.mainWindowSize; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setMainWindowSize(org.eclipse.swt.graphics.Point) + */ + @Override + public void setMainWindowSize(Point size) { + this.mainWindowSize = size; + } +} 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 new file mode 100644 index 00000000..f79d7d56 --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java @@ -0,0 +1,123 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.workflow.config; + +import java.util.Locale; + +import org.eclipse.swt.graphics.Point; + +import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUs; +import at.asit.pdfover.signator.BKUs; +import at.asit.pdfover.signator.SignaturePosition; + +/** + * An interface for reading the persistent configuration + * + * This reads the configuration that will be saved + */ +public interface PersistentConfigProvider { + /** + * Get the default configured BKU + * @return the default configured BKU + */ + public BKUs getDefaultBKUPersistent(); + + /** + * Gets the default Mobile number + * @return the default mobile number + */ + public String getDefaultMobileNumberPersistent(); + + /** + * Gets the password to use for Mobile BKU + * @return the password + */ + public String getDefaultMobilePasswordPersistent(); + + /** + * Gets the filename of the default emblem + * @return the emblem + */ + public String getDefaultEmblemPersistent(); + + /** + * Gets the proxy host + * @return the proxy hostname or ip address + */ + public String getProxyHostPersistent(); + + /** + * Gets the proxy port + * @return the proxy port + */ + public int getProxyPortPersistent(); + + /** + * Gets the default output folder for signed documents + * @return the default output folder + */ + public String getDefaultOutputFolderPersistent(); + + // Declare the other configuration getters for convenience + + /** + * Get the default configured SignaturePosition + * @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 mobile BKU URL + * @return the mobile BKU URL + */ + public String getMobileBKUURL(); + + /** + * Gets the mobile BKU type + * @return the mobile BKU type + */ + public MobileBKUs getMobileBKUType(); + + /** + * 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 getSignLocale(); + + /** + * Gets the configured MainWindow size + * @return the configured MainWindow size + */ + public Point getMainWindowSize(); +} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java index 797ce925..14d06d47 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java @@ -23,9 +23,9 @@ import org.slf4j.LoggerFactory; import at.asit.pdfover.gui.MainWindow.Buttons; import at.asit.pdfover.gui.MainWindowBehavior; import at.asit.pdfover.gui.composites.BKUSelectionComposite; -import at.asit.pdfover.gui.workflow.ConfigProvider; 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.BKUs; /** 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 bc8a9e83..faea77a0 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 @@ -23,9 +23,9 @@ 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.workflow.ConfigProvider; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; +import at.asit.pdfover.gui.workflow.config.ConfigProvider; /** * Selects the data source for the signature process. diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java index 4d2b75f5..967d255e 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java @@ -26,9 +26,9 @@ import at.asit.pdfover.gui.composites.OutputComposite; import at.asit.pdfover.gui.controls.ErrorDialog; import at.asit.pdfover.gui.controls.Dialog.BUTTONS; import at.asit.pdfover.gui.utils.Messages; -import at.asit.pdfover.gui.workflow.ConfigProvider; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; +import at.asit.pdfover.gui.workflow.config.ConfigProvider; /** * Produces the output of the signature process. (save file, open file) 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 1fdc4228..5f731470 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 @@ -26,9 +26,9 @@ import at.asit.pdfover.gui.composites.WaitingComposite; import at.asit.pdfover.gui.controls.ErrorDialog; import at.asit.pdfover.gui.controls.Dialog.BUTTONS; import at.asit.pdfover.gui.utils.Messages; -import at.asit.pdfover.gui.workflow.ConfigProvider; 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.BKUs; import at.asit.pdfover.signator.FileNameEmblem; import at.asit.pdfover.signator.PDFFileDocumentSource; diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustStatus.java index d5beaf2d..c4705227 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustStatus.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustStatus.java @@ -19,7 +19,7 @@ package at.asit.pdfover.gui.workflow.states.mobilebku; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.asit.pdfover.gui.workflow.ConfigProvider; +import at.asit.pdfover.gui.workflow.config.ConfigProvider; /** * A-Trust MobileBKUStatus implementation diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/IAIKStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/IAIKStatus.java index df399375..52aacf82 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/IAIKStatus.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/IAIKStatus.java @@ -19,7 +19,7 @@ package at.asit.pdfover.gui.workflow.states.mobilebku; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.asit.pdfover.gui.workflow.ConfigProvider; +import at.asit.pdfover.gui.workflow.config.ConfigProvider; /** * IAIK MobileBKUStatus implementation -- cgit v1.2.3