diff options
Diffstat (limited to 'pdf-over-gui')
19 files changed, 131 insertions, 128 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java index 7a51a961..5bc0c745 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java @@ -19,7 +19,7 @@ package at.asit.pdfover.gui.bku.mobile; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl;
+import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
/**
* A-Trust MobileBKUStatus implementation
@@ -52,7 +52,7 @@ public class ATrustStatus extends MobileBKUStatus { * Constructor
* @param provider the ConfigProvider
*/
- public ATrustStatus(ConfigProviderImpl provider) {
+ public ATrustStatus(ConfigurationManager provider) {
this.phoneNumber = provider.getDefaultMobileNumber();
this.mobilePassword = provider.getDefaultMobilePassword();
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKStatus.java index cb150327..c855c99a 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKStatus.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKStatus.java @@ -15,7 +15,7 @@ */ package at.asit.pdfover.gui.bku.mobile; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; /** * IAIK MobileBKUStatus implementation @@ -31,7 +31,7 @@ public class IAIKStatus extends MobileBKUStatus { * Constructor * @param provider the ConfigProvider */ - public IAIKStatus(ConfigProviderImpl provider) { + public IAIKStatus(ConfigurationManager provider) { this.phoneNumber = provider.getDefaultMobileNumber(); this.mobilePassword = provider.getDefaultMobilePassword(); } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java index bf82177e..16a47a42 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java @@ -19,7 +19,7 @@ import at.asit.pdfover.gui.exceptions.InitializationException; import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; /** * CLI Argument base class @@ -52,7 +52,7 @@ public abstract class Argument { this.stateMachine = stateMachine; } - protected ConfigProviderImpl getConfiguration() { + protected ConfigurationManager getConfiguration() { return this.stateMachine.configProvider; } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java index d977e665..013d084f 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java @@ -42,8 +42,8 @@ import at.asit.pdfover.gui.controls.ErrorDialog; import at.asit.pdfover.gui.exceptions.ResumableException; import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.workflow.PDFSigner; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; -import at.asit.pdfover.gui.workflow.config.ConfigurationContainer; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; +import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory; import at.asit.pdfover.gui.workflow.states.State; /** @@ -64,7 +64,7 @@ public class ConfigurationComposite extends StateComposite { /** * configuration provider */ - ConfigProviderImpl configProvider = null; + ConfigurationManager configProvider = null; /** * simple configuration composite @@ -89,7 +89,7 @@ public class ConfigurationComposite extends StateComposite { /** * configuration container Keeps state for current configuration changes */ - ConfigurationContainer configurationContainer = new ConfigurationContainer(); + ConfigurationDataInMemory configurationContainer = new ConfigurationDataInMemory(); /** * The stack layout @@ -308,7 +308,7 @@ public class ConfigurationComposite extends StateComposite { * * @param provider */ - public void setConfigProvider(ConfigProviderImpl provider) { + public void setConfigProvider(ConfigurationManager provider) { this.configProvider = provider; if (this.configProvider != null) { // Initialize Configuration Container diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java index 7eac256a..fe3442a0 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java @@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory; import at.asit.pdfover.commons.Constants; import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.composites.StateComposite; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; public class AboutComposite extends ConfigurationCompositeBase { static final Logger log = LoggerFactory.getLogger(AboutComposite.class); @@ -137,13 +137,13 @@ public class AboutComposite extends ConfigurationCompositeBase { protected void signerChanged() {} @Override - public void initConfiguration(ConfigProviderImpl provider) {} + public void initConfiguration(ConfigurationManager provider) {} @Override public void loadConfiguration() {} @Override - public void storeConfiguration(ConfigProviderImpl store) {} + public void storeConfiguration(ConfigurationManager store) {} @Override public void validateSettings(int resumeFrom) throws Exception {} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java index baba386a..be872c1e 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java @@ -53,8 +53,8 @@ import at.asit.pdfover.gui.controls.ErrorMarker; import at.asit.pdfover.gui.exceptions.InvalidPortException; import at.asit.pdfover.gui.exceptions.OutputfolderDoesntExistException; import at.asit.pdfover.gui.exceptions.OutputfolderNotADirectoryException; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; -import at.asit.pdfover.gui.workflow.config.ConfigurationContainer; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; +import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory; import at.asit.pdfover.gui.workflow.states.State; import at.asit.pdfover.signator.BKUs; import at.asit.pdfover.signator.SignaturePosition; @@ -120,7 +120,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { * @param container * @param config */ - public AdvancedConfigurationComposite(Composite parent, int style, State state, ConfigurationContainer container, + public AdvancedConfigurationComposite(Composite parent, int style, State state, ConfigurationDataInMemory container, ConfigurationComposite config) { super(parent, style, state, container); this.configurationComposite = config; @@ -647,7 +647,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { } @Override - public void initConfiguration(ConfigProviderImpl provider) { + public void initConfiguration(ConfigurationManager provider) { this.configurationContainer.defaultSignaturePosition = provider.getDefaultSignaturePositionPersistent(); this.configurationContainer.setUseMarker(provider.getUseMarker()); this.configurationContainer.setUseSignatureFields(provider.getUseSignatureFields()); @@ -739,7 +739,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { } @Override - public void storeConfiguration(ConfigProviderImpl store) { + public void storeConfiguration(ConfigurationManager store) { store.setDefaultSignaturePosition(this.configurationContainer.defaultSignaturePosition); store.setUseMarker(this.configurationContainer.getUseMarker()); store.setUseSignatureFields(this.configurationContainer.getUseSignatureFields()); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java index d3e458db..16dcd366 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java @@ -20,8 +20,8 @@ import org.eclipse.swt.widgets.Composite; import at.asit.pdfover.gui.composites.StateComposite; import at.asit.pdfover.gui.workflow.PDFSigner; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; -import at.asit.pdfover.gui.workflow.config.ConfigurationContainer; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; +import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory; import at.asit.pdfover.gui.workflow.states.State; /** @@ -32,7 +32,7 @@ public abstract class ConfigurationCompositeBase extends StateComposite { /** * the configuration container */ - protected ConfigurationContainer configurationContainer; + protected ConfigurationDataInMemory configurationContainer; /** * The PDF Signer used to produce signature block preview @@ -65,7 +65,7 @@ public abstract class ConfigurationCompositeBase extends StateComposite { * @param state * @param configuration */ - public ConfigurationCompositeBase(Composite parent, int style, State state, ConfigurationContainer configuration) { + public ConfigurationCompositeBase(Composite parent, int style, State state, ConfigurationDataInMemory configuration) { super(parent, style, state); this.configurationContainer = configuration; } @@ -74,7 +74,7 @@ public abstract class ConfigurationCompositeBase extends StateComposite { * Initialize ConfigurationContainer from ConfigProviderImpl * @param provider the ConfigProviderImpl to load config from */ - public abstract void initConfiguration(ConfigProviderImpl provider); + public abstract void initConfiguration(ConfigurationManager provider); /** * Load configuration from ConfigurationContainer @@ -85,7 +85,7 @@ public abstract class ConfigurationCompositeBase extends StateComposite { * Store configuration from ConfigurationContainer to ConfigProvider * @param store the ConfigProviderImpl to store config to */ - public abstract void storeConfiguration(ConfigProviderImpl store); + public abstract void storeConfiguration(ConfigurationManager store); /** * Called before exit. diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java index 597112df..7ea2a642 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java @@ -55,8 +55,8 @@ import at.asit.pdfover.gui.exceptions.KeystoreAliasNoKeyException; import at.asit.pdfover.gui.exceptions.KeystoreDoesntExistException; import at.asit.pdfover.gui.exceptions.KeystoreKeyPasswordException; import at.asit.pdfover.commons.Messages; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; -import at.asit.pdfover.gui.workflow.config.ConfigurationContainer; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; +import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory; import at.asit.pdfover.gui.workflow.states.State; import iaik.security.provider.IAIK; @@ -97,7 +97,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { */ public KeystoreConfigurationComposite( org.eclipse.swt.widgets.Composite parent, int style, State state, - ConfigurationContainer container) { + ConfigurationDataInMemory container) { super(parent, style, state, container); setLayout(new FormLayout()); @@ -277,7 +277,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { } void loadKeystore() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { - ConfigurationContainer config = + ConfigurationDataInMemory config = KeystoreConfigurationComposite.this.configurationContainer; File f = new File(config.keystoreFile); this.ks = KeyStore.getInstance(config.keystoreType); @@ -380,8 +380,8 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { } @Override - public void initConfiguration(ConfigProviderImpl provider) { - ConfigurationContainer config = this.configurationContainer; + public void initConfiguration(ConfigurationManager provider) { + ConfigurationDataInMemory config = this.configurationContainer; config.keystoreFile = provider.getKeyStoreFilePersistent(); config.keystoreType = provider.getKeyStoreTypePersistent(); config.keystoreAlias = provider.getKeyStoreAliasPersistent(); @@ -397,7 +397,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { @Override public void loadConfiguration() { // Initialize form fields from configuration Container - ConfigurationContainer config = this.configurationContainer; + ConfigurationDataInMemory config = this.configurationContainer; String ks = config.keystoreFile; performKeystoreFileChanged(ks); performKeystoreTypeChanged(config.keystoreType); @@ -414,8 +414,8 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { } @Override - public void storeConfiguration(ConfigProviderImpl store) { - ConfigurationContainer config = this.configurationContainer; + public void storeConfiguration(ConfigurationManager store) { + ConfigurationDataInMemory config = this.configurationContainer; store.setKeyStoreFile(config.keystoreFile); store.setKeyStoreType(config.keystoreType); store.setKeyStoreAlias(config.keystoreAlias); @@ -432,7 +432,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { */ @Override public void validateSettings(int resumeFrom) throws Exception { - ConfigurationContainer config = this.configurationContainer; + ConfigurationDataInMemory config = this.configurationContainer; switch (resumeFrom) { case 0: String fname = config.keystoreFile; diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java index 257f9cc6..c8d9c208 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java @@ -63,8 +63,8 @@ import at.asit.pdfover.gui.controls.ErrorDialog; import at.asit.pdfover.gui.controls.ErrorMarker; import at.asit.pdfover.gui.exceptions.InvalidEmblemFile; import at.asit.pdfover.gui.utils.ImageConverter; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; -import at.asit.pdfover.gui.workflow.config.ConfigurationContainer; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; +import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory; import at.asit.pdfover.gui.workflow.states.State; import at.asit.pdfover.signator.CachedFileNameEmblem; import at.asit.pdfover.signator.SignatureParameter; @@ -119,7 +119,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { */ public SimpleConfigurationComposite( org.eclipse.swt.widgets.Composite parent, int style, State state, - ConfigurationContainer container) { + ConfigurationDataInMemory container) { super(parent, style, state, container); setLayout(new FormLayout()); @@ -607,7 +607,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { } @Override - public void initConfiguration(ConfigProviderImpl provider) { + public void initConfiguration(ConfigurationManager provider) { this.configurationContainer.setMobileNumber(provider.getDefaultMobileNumberPersistent()); try { @@ -663,7 +663,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { } @Override - public void storeConfiguration(ConfigProviderImpl store) { + public void storeConfiguration(ConfigurationManager store) { store.setDefaultMobileNumber(this.configurationContainer.getMobileNumber()); store.setDefaultEmblem(this.configurationContainer.getEmblem()); store.setSignatureLocale(this.configurationContainer.signatureLocale); 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 cbb30b51..17a8d56f 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 @@ -28,7 +28,7 @@ import at.asit.pdfover.gui.MainWindow; import at.asit.pdfover.gui.controls.Dialog.BUTTONS; import at.asit.pdfover.gui.controls.ErrorDialog; import at.asit.pdfover.commons.Messages; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; import at.asit.pdfover.gui.workflow.states.PrepareConfigurationState; import at.asit.pdfover.gui.workflow.states.State; @@ -42,7 +42,7 @@ public class StateMachine implements GUIProvider { public final Status status; public final PDFSigner pdfSigner; - public final ConfigProviderImpl configProvider; + public final ConfigurationManager configProvider; public final String[] cmdLineArgs; /** @@ -54,7 +54,7 @@ public class StateMachine implements GUIProvider { this.status = new Status(); this.status.setCurrentState(new PrepareConfigurationState(this)); this.pdfSigner = new PDFSigner(); - this.configProvider = new ConfigProviderImpl(); + this.configProvider = new ConfigurationManager(); this.cmdLineArgs = cmdLineArgs; } 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/ConfigurationDataInMemory.java index b238da01..c59da748 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java @@ -39,12 +39,12 @@ import at.asit.pdfover.signator.SignaturePosition; /** * Implementation of the configuration container */ -public class ConfigurationContainer { +public class ConfigurationDataInMemory { /** * SLF4J Logger instance **/ @SuppressWarnings("unused") - private static final Logger log = LoggerFactory.getLogger(ConfigurationContainer.class); + private static final Logger log = LoggerFactory.getLogger(ConfigurationDataInMemory.class); /** the emblem File */ protected String emblemFile = null; @@ -135,7 +135,7 @@ public class ConfigurationContainer { public String mobileBKUURL = Constants.DEFAULT_MOBILE_BKU_URL; /** Holds the mobile BKU type */ - public MobileBKUs mobileBKUType = ConfigProviderImpl.DEFAULT_MOBILE_BKU_TYPE; + public MobileBKUs mobileBKUType = ConfigurationManager.DEFAULT_MOBILE_BKU_TYPE; /** Holds the mobile BKU BASE64 setting */ protected boolean mobileBKUBase64 = false; 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/ConfigurationManager.java index 7fc3c832..7823ca41 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java @@ -44,7 +44,7 @@ import at.asit.pdfover.signator.SignaturePosition; /** * Implementation of the configuration provider and manipulator */ -public class ConfigProviderImpl { +public class ConfigurationManager { /** Default Mobile BKU type */ @@ -54,8 +54,7 @@ public class ConfigProviderImpl { /** * SLF4J Logger instance **/ - private static final Logger log = LoggerFactory - .getLogger(ConfigProviderImpl.class); + private static final Logger log = LoggerFactory.getLogger(ConfigurationManager.class); /** * An empty property entry @@ -64,93 +63,89 @@ public class ConfigProviderImpl { private String configurationFile = Constants.DEFAULT_CONFIG_FILENAME; + private boolean loaded = false; + // The persistent configuration read from the config file - private ConfigurationContainer configuration; + private ConfigurationDataInMemory configuration; // The configuration overlay built from the cmd line args - private ConfigurationContainer configurationOverlay; + private ConfigurationDataInMemory configurationOverlay; /** * Constructor */ - public ConfigProviderImpl() { - this.configuration = new ConfigurationContainer(); - this.configurationOverlay = new ConfigurationContainer(); + public ConfigurationManager() { + this.configuration = new ConfigurationDataInMemory(); + this.configurationOverlay = new ConfigurationDataInMemory(); } /* load from disk */ public void loadFromDisk() throws IOException { + if (loaded) + throw new RuntimeException("ConfigProvider double load?"); - Properties config = new Properties(); + Properties diskConfig = new Properties(); - config.load(new FileInputStream(Constants.CONFIG_DIRECTORY + File.separator + getConfigurationFileName())); + diskConfig.load(new FileInputStream(Constants.CONFIG_DIRECTORY + File.separator + getConfigurationFileName())); - setDefaultEmblem(config.getProperty(Constants.CFG_EMBLEM)); + setDefaultEmblem(diskConfig.getProperty(Constants.CFG_EMBLEM)); - setDefaultMobileNumber(config.getProperty(Constants.CFG_MOBILE_NUMBER)); + setDefaultMobileNumber(diskConfig.getProperty(Constants.CFG_MOBILE_NUMBER)); - setProxyHost(config.getProperty(Constants.CFG_PROXY_HOST)); - setProxyUser(config.getProperty(Constants.CFG_PROXY_USER)); - setProxyPass(config.getProperty(Constants.CFG_PROXY_PASS)); + setProxyHost(diskConfig.getProperty(Constants.CFG_PROXY_HOST)); + setProxyUser(diskConfig.getProperty(Constants.CFG_PROXY_USER)); + setProxyPass(diskConfig.getProperty(Constants.CFG_PROXY_PASS)); - setDefaultOutputFolder(config.getProperty(Constants.CFG_OUTPUT_FOLDER)); + setDefaultOutputFolder(diskConfig.getProperty(Constants.CFG_OUTPUT_FOLDER)); - String postFix = config.getProperty(Constants.CFG_POSTFIX); + String postFix = diskConfig.getProperty(Constants.CFG_POSTFIX); if (postFix == null) setSaveFilePostFix(Constants.DEFAULT_POSTFIX); else setSaveFilePostFix(postFix); - String localeString = config.getProperty(Constants.CFG_LOCALE); + String localeString = diskConfig.getProperty(Constants.CFG_LOCALE); Locale targetLocale = LocaleSerializer.parseFromString(localeString); if (targetLocale != null) setLocale(targetLocale); - String signatureLocaleString = config.getProperty(Constants.CFG_SIGNATURE_LOCALE); + String signatureLocaleString = diskConfig.getProperty(Constants.CFG_SIGNATURE_LOCALE); Locale signatureTargetLocale = LocaleSerializer.parseFromString(signatureLocaleString); if (signatureTargetLocale != null) setSignatureLocale(signatureTargetLocale); - String useMarker = config.getProperty(Constants.CFG_USE_MARKER); + String useMarker = diskConfig.getProperty(Constants.CFG_USE_MARKER); if (useMarker != null) setUseMarker(useMarker.equalsIgnoreCase(Constants.TRUE)); - String useSignatureFields = config.getProperty(Constants.CFG_USE_SIGNATURE_FIELDS); + String useSignatureFields = diskConfig.getProperty(Constants.CFG_USE_SIGNATURE_FIELDS); if (useSignatureFields != null) setUseSignatureFields(useSignatureFields.equalsIgnoreCase(Constants.TRUE)); - String enablePlaceholder = config.getProperty(Constants.CFG_ENABLE_PLACEHOLDER); + String enablePlaceholder = diskConfig.getProperty(Constants.CFG_ENABLE_PLACEHOLDER); if (enablePlaceholder != null) setEnablePlaceholderUsage(enablePlaceholder.equalsIgnoreCase(Constants.TRUE)); - String signatureProfile = config.getProperty(Constants.SIGNATURE_PROFILE); - if (signatureProfile != null) - { - Profile profile = Profile.getProfile(signatureProfile); - if (profile != null) - { - this.configuration.setSignatureProfile(profile); - this.configurationOverlay.setSignatureProfile(profile); - } - } + String signatureProfileName = diskConfig.getProperty(Constants.SIGNATURE_PROFILE); + if (signatureProfileName != null) + setSignatureProfile(signatureProfileName); - if (config.containsKey(Constants.CFG_SIGNATURE_NOTE)) - setSignatureNote(config.getProperty(Constants.CFG_SIGNATURE_NOTE)); + if (diskConfig.containsKey(Constants.CFG_SIGNATURE_NOTE)) + setSignatureNote(diskConfig.getProperty(Constants.CFG_SIGNATURE_NOTE)); else setSignatureNote(Profile.getProfile(getSignatureProfile()).getDefaultSignatureBlockNote(getSignatureLocale())); - String compat = config.getProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT); + String compat = diskConfig.getProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT); if (compat != null) setSignaturePdfACompat(compat.equalsIgnoreCase(Constants.TRUE)); - String bkuUrl = config.getProperty(Constants.CFG_MOBILE_BKU_URL); + String bkuUrl = diskConfig.getProperty(Constants.CFG_MOBILE_BKU_URL); if (bkuUrl != null && !bkuUrl.isEmpty()) this.configuration.mobileBKUURL = bkuUrl; - String bkuType = config - .getProperty(Constants.CFG_MOBILE_BKU_TYPE); + String bkuType = diskConfig.getProperty(Constants.CFG_MOBILE_BKU_TYPE); if (bkuType != null && !bkuType.isEmpty()) { @@ -163,11 +158,11 @@ public class ConfigProviderImpl { } } - String useBase64 = config.getProperty(Constants.CFG_MOBILE_BKU_BASE64); + String useBase64 = diskConfig.getProperty(Constants.CFG_MOBILE_BKU_BASE64); if (useBase64 != null) this.configuration.mobileBKUBase64 = useBase64.equalsIgnoreCase(Constants.TRUE); - String proxyPortString = config.getProperty(Constants.CFG_PROXY_PORT); + String proxyPortString = diskConfig.getProperty(Constants.CFG_PROXY_PORT); if (proxyPortString != null && !proxyPortString.trim().isEmpty()) { int port = Integer.parseInt(proxyPortString); @@ -179,7 +174,7 @@ public class ConfigProviderImpl { } // Set Default BKU - String bkuString = config.getProperty(Constants.CFG_BKU); + String bkuString = diskConfig.getProperty(Constants.CFG_BKU); BKUs defaultBKU = BKUs.NONE; if (bkuString != null) { try { @@ -196,7 +191,7 @@ public class ConfigProviderImpl { // Set Signature placeholder transparency int transparency = Constants.DEFAULT_SIGNATURE_PLACEHOLDER_TRANSPARENCY; - String trans = config.getProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY); + String trans = diskConfig.getProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY); if (trans != null) { try { transparency = Integer.parseInt(trans); @@ -210,7 +205,7 @@ public class ConfigProviderImpl { // Set MainWindow size int width = Constants.DEFAULT_MAINWINDOW_WIDTH; int height = Constants.DEFAULT_MAINWINDOW_HEIGHT; - String size = config.getProperty(Constants.CFG_MAINWINDOW_SIZE); + String size = diskConfig.getProperty(Constants.CFG_MAINWINDOW_SIZE); parse: { if (size == null) break parse; @@ -229,7 +224,7 @@ public class ConfigProviderImpl { this.configuration.mainWindowSize = new Point(width, height); // Set Signature Position - String signaturePosition = config.getProperty(Constants.CFG_SIGNATURE_POSITION); + String signaturePosition = diskConfig.getProperty(Constants.CFG_SIGNATURE_POSITION); SignaturePosition position = null; if (signaturePosition != null && !signaturePosition.trim().isEmpty()) { signaturePosition = signaturePosition.trim().toLowerCase(); @@ -278,22 +273,23 @@ public class ConfigProviderImpl { setDefaultSignaturePosition(position); //Set keystore stuff - String keystoreEnabled = config.getProperty(Constants.CFG_KEYSTORE_ENABLED); + String keystoreEnabled = diskConfig.getProperty(Constants.CFG_KEYSTORE_ENABLED); if (keystoreEnabled != null) setKeyStoreEnabled(keystoreEnabled.equalsIgnoreCase(Constants.TRUE)); - setKeyStoreFile(config.getProperty(Constants.CFG_KEYSTORE_FILE)); - setKeyStoreType(config.getProperty(Constants.CFG_KEYSTORE_TYPE)); - setKeyStoreAlias(config.getProperty(Constants.CFG_KEYSTORE_ALIAS)); - setKeyStoreStorePass(config.getProperty(Constants.CFG_KEYSTORE_STOREPASS)); - String keystoreKeyPass = config.getProperty(Constants.CFG_KEYSTORE_KEYPASS); + setKeyStoreFile(diskConfig.getProperty(Constants.CFG_KEYSTORE_FILE)); + setKeyStoreType(diskConfig.getProperty(Constants.CFG_KEYSTORE_TYPE)); + setKeyStoreAlias(diskConfig.getProperty(Constants.CFG_KEYSTORE_ALIAS)); + setKeyStoreStorePass(diskConfig.getProperty(Constants.CFG_KEYSTORE_STOREPASS)); + String keystoreKeyPass = diskConfig.getProperty(Constants.CFG_KEYSTORE_KEYPASS); setKeyStoreKeyPass(keystoreKeyPass); // Set update check - String updateCheck = config.getProperty(Constants.CFG_UPDATE_CHECK); + String updateCheck = diskConfig.getProperty(Constants.CFG_UPDATE_CHECK); if (updateCheck != null) setUpdateCheck(!updateCheck.equalsIgnoreCase(Constants.FALSE)); log.info("Successfully loaded config from: " + getConfigurationFileName()); + loaded = true; } /* save to file */ @@ -411,7 +407,14 @@ public class ConfigProviderImpl { } // TODO review this - public void setConfigurationFileName(String configurationFile) { this.configurationFile = configurationFile; } + public void setConfigurationFileName(String configurationFile) + { + if (this.configurationFile.equals(configurationFile)) + return; + if (this.loaded) + throw new RuntimeException("Cannot change configuration file path after it has been loaded"); + this.configurationFile = configurationFile; + } public String getConfigurationFileName() { return this.configurationFile; } public void setDefaultBKU(BKUs bku) { @@ -980,46 +983,46 @@ public class ConfigProviderImpl { this.configurationOverlay.skipFinish = skipFinish; } - public boolean getUseMarker() { - return this.configurationOverlay.getUseMarker(); + public boolean getUseSignatureFields() { + return this.configuration.getUseSignatureFields(); } - public boolean getUseSignatureFields() { - return this.configurationOverlay.getUseSignatureFields(); + public void setUseSignatureFields(boolean useFields) { + this.configuration.setUseSignatureFields(useFields); + if (useFields) setUseMarker(false); } - public void setUseMarker(boolean useMarker) { - this.configurationOverlay.setUseMarker(useMarker); - if (useMarker) setUseSignatureFields(false); + public boolean getUseMarker() { + return this.configuration.getUseMarker(); } - public void setUseSignatureFields(boolean useFields) { - this.configurationOverlay.setUseSignatureFields(useFields); - if (useFields) setUseMarker(false); + public void setUseMarker(boolean useMarker) { + this.configuration.setUseMarker(useMarker); + if (useMarker) setUseSignatureFields(false); } public void setSignatureProfile(String profile) { - this.configurationOverlay.setSignatureProfile(Profile.getProfile(profile)); + this.configuration.setSignatureProfile(Profile.getProfile(profile)); } public void setSaveFilePostFix(String postFix) { - this.configurationOverlay.saveFilePostFix = postFix; + this.configuration.saveFilePostFix = postFix; } public String getSaveFilePostFix(){ - return this.configurationOverlay.saveFilePostFix; + return this.configuration.saveFilePostFix; } public String getSignatureProfile() { - return this.configurationOverlay.getSignatureProfile().name(); + return this.configuration.getSignatureProfile().name(); } public void setEnablePlaceholderUsage(boolean bool) { - this.configurationOverlay.enabledPlaceholderUsage = bool; + this.configuration.enabledPlaceholderUsage = bool; } public boolean getEnablePlaceholderUsage() { - return this.configurationOverlay.enabledPlaceholderUsage; + return this.configuration.enabledPlaceholderUsage; } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java index 3e74f9ec..2d64d160 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java @@ -30,7 +30,7 @@ import at.asit.pdfover.gui.controls.PasswordInputDialog; import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; import at.asit.pdfover.signator.SignatureException; import at.asit.pdfover.signator.SigningState; @@ -64,7 +64,7 @@ public class KSState extends State { Status status = getStateMachine().status; SigningState signingState = status.signingState; - ConfigProviderImpl config = getStateMachine().configProvider; + ConfigurationManager config = getStateMachine().configProvider; try { String file = config.getKeyStoreFile(); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java index 3595e003..0d0018dd 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java @@ -46,7 +46,7 @@ import at.asit.pdfover.gui.controls.Dialog.BUTTONS; import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl;
+import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
import at.asit.pdfover.signator.SigningState;
/**
@@ -64,7 +64,7 @@ public class MobileBKUState extends State { public MobileBKUState(StateMachine stateMachine) {
super(stateMachine);
- ConfigProviderImpl provider = stateMachine.configProvider;
+ ConfigurationManager provider = stateMachine.configProvider;
switch(provider.getMobileBKUType()) {
case A_TRUST:
this.status = new ATrustStatus(provider);
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 77e1edf4..e7fcb98d 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 @@ -40,7 +40,7 @@ import at.asit.pdfover.gui.composites.DataSourceSelectComposite; import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; import at.asit.pdfover.signator.SignaturePosition; import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData; @@ -81,7 +81,7 @@ public class OpenState extends State { @Override public void run() { - ConfigProviderImpl config = getStateMachine().configProvider; + ConfigurationManager config = getStateMachine().configProvider; Status status = getStateMachine().status; if (!(status.getPreviousState() instanceof PrepareConfigurationState) && !(status.getPreviousState() instanceof OpenState)) { 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 d47b0f84..308b7d5a 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 @@ -29,7 +29,7 @@ import at.asit.pdfover.commons.Constants; import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; /** * Produces the output of the signature process. (save file, open file) @@ -50,7 +50,7 @@ public class OutputState extends State { this.outputComposite = getStateMachine() .createComposite(OutputComposite.class, SWT.RESIZE, this); - ConfigProviderImpl config = getStateMachine().configProvider; + ConfigurationManager config = getStateMachine().configProvider; Status status = getStateMachine().status; File tmpDir = new File(Constants.CONFIG_DIRECTORY + File.separator + "tmp"); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java index 84d61cb0..b09728c9 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java @@ -35,7 +35,7 @@ import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.utils.SignaturePlaceholderCache; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; import at.asit.pdfover.signator.CachedFileNameEmblem; import at.asit.pdfover.signator.Emblem; import at.asit.pdfover.signator.SignatureParameter; @@ -119,7 +119,7 @@ public class PositioningState extends State { this.positionComposite.displayDocument(document); } // Update possibly changed values - ConfigProviderImpl config = stateMachine.configProvider; + ConfigurationManager config = stateMachine.configProvider; SignatureParameter param = stateMachine.pdfSigner.getPDFSigner().newParameter(); Emblem emblem = new CachedFileNameEmblem(config.getDefaultEmblem()); param.setEmblem(emblem); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java index 8480554e..01f7a19c 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java @@ -52,7 +52,7 @@ import at.asit.pdfover.gui.utils.Zipper; import at.asit.pdfover.gui.workflow.GUIProvider; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; import at.asit.pdfover.signator.Signator; /** @@ -246,7 +246,7 @@ public class PrepareConfigurationState extends State { // Read config file try { StateMachine stateMachine = getStateMachine(); - ConfigProviderImpl config = stateMachine.configProvider; + ConfigurationManager config = stateMachine.configProvider; final GUIProvider gui = stateMachine; File configDir = new File(Constants.CONFIG_DIRECTORY); File configFile = new File(configDir, Constants.DEFAULT_CONFIG_FILENAME); 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 364da8c7..c07f7282 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 @@ -31,7 +31,7 @@ import at.asit.pdfover.gui.controls.ErrorDialog; import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; -import at.asit.pdfover.gui.workflow.config.ConfigProviderImpl; +import at.asit.pdfover.gui.workflow.config.ConfigurationManager; import at.asit.pdfover.signator.CachedFileNameEmblem; import at.asit.pdfover.signator.PDFFileDocumentSource; import at.asit.pdfover.signator.SignatureParameter; @@ -69,7 +69,7 @@ public class PrepareSigningState extends State { Status status = this.state.getStateMachine().status; - ConfigProviderImpl configuration = this.state.getStateMachine().configProvider; + ConfigurationManager configuration = this.state.getStateMachine().configProvider; // SET PROXY HOST and PORT settings final String proxyHost = configuration.getProxyHost(); |