diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-06 17:27:03 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-06 17:27:03 +0200 |
commit | bd8c480935a4b5ce8747f2a9405c4dc97d9d01a8 (patch) | |
tree | 3f426e8fa800a298c1f1566dda4e18bb6913417a /pdf-over-gui/src/main/java/at/asit | |
parent | da37de85afc55f67b4ceefe35350ac9a0af32c6e (diff) | |
download | pdf-over-bd8c480935a4b5ce8747f2a9405c4dc97d9d01a8.tar.gz pdf-over-bd8c480935a4b5ce8747f2a9405c4dc97d9d01a8.tar.bz2 pdf-over-bd8c480935a4b5ce8747f2a9405c4dc97d9d01a8.zip |
YAGNI: ConfigurationContainer interface
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit')
7 files changed, 373 insertions, 1371 deletions
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 3691a519..33f19845 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 @@ -44,7 +44,6 @@ import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.workflow.PDFSigner; import at.asit.pdfover.gui.workflow.config.ConfigManipulator; import at.asit.pdfover.gui.workflow.config.ConfigurationContainer; -import at.asit.pdfover.gui.workflow.config.ConfigurationContainerImpl; import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider; import at.asit.pdfover.gui.workflow.states.State; @@ -97,7 +96,7 @@ public class ConfigurationComposite extends StateComposite { /** * configuration container Keeps state for current configuration changes */ - ConfigurationContainer configurationContainer = new ConfigurationContainerImpl(); + ConfigurationContainer configurationContainer = new ConfigurationContainer(); /** * The stack layout 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 6212c5ca..0a405d3a 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 @@ -247,7 +247,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { @Override public void widgetSelected(SelectionEvent e) { int selectionIndex = getBKUElementIndex( - AdvancedConfigurationComposite.this.configurationContainer.getDefaultBKU()); + AdvancedConfigurationComposite.this.configurationContainer.defaultBKU); if (AdvancedConfigurationComposite.this.cmbBKUAuswahl.getSelectionIndex() != selectionIndex) { selectionIndex = AdvancedConfigurationComposite.this.cmbBKUAuswahl.getSelectionIndex(); performBKUSelectionChanged( @@ -348,7 +348,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { this.cmbLocaleAuswahl.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - Locale currentLocale = AdvancedConfigurationComposite.this.configurationContainer.getLocale(); + Locale currentLocale = AdvancedConfigurationComposite.this.configurationContainer.locale; Locale selectedLocale = Constants.SUPPORTED_LOCALES[AdvancedConfigurationComposite.this.cmbLocaleAuswahl .getSelectionIndex()]; if (!currentLocale.equals(selectedLocale)) { @@ -450,7 +450,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { private void performPostFixChanged(String postfix) { log.debug("Save file postfix changed to : {}", postfix); - this.configurationContainer.setSaveFilePostFix(postfix); + this.configurationContainer.saveFilePostFix = postfix; AdvancedConfigurationComposite.this.txtSaveFilePostFix.setText(postfix); } @@ -467,7 +467,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { void performOutputFolderChanged(String foldername) { log.debug("Selected Output folder: {}", foldername); - this.configurationContainer.setOutputFolder(foldername); + this.configurationContainer.outputFolder = foldername; AdvancedConfigurationComposite.this.txtOutputFolder.setText(foldername); } @@ -485,7 +485,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { void performBKUSelectionChanged(BKUs selected) { log.debug("Selected BKU: {}", selected); - this.configurationContainer.setDefaultBKU(selected); + this.configurationContainer.defaultBKU = selected; this.cmbBKUAuswahl.select(this.getBKUElementIndex(selected)); } @@ -527,14 +527,14 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { void performLocaleSelectionChanged(Locale selected) { log.debug("Selected Locale: {}", selected); - this.configurationContainer.setLocale(selected); + this.configurationContainer.locale = selected; this.cmbLocaleAuswahl.select(this.getLocaleElementIndex(selected)); } void performPositionSelection(boolean automatic) { log.debug("Selected Position: {}", automatic); SignaturePosition pos = automatic ? new SignaturePosition() : null; - this.configurationContainer.setDefaultSignaturePosition(pos); + this.configurationContainer.defaultSignaturePosition = pos; this.btnAutomatischePositionierung.setSelection(automatic); } @@ -551,17 +551,17 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { void performEnableUsePlaceholder(boolean enable) { this.btnPlatzhalterVerwenden.setEnabled(enable); this.btnSignatureFieldsUsage.setEnabled(enable); - this.configurationContainer.setEnablePlaceholderUsage(enable); + this.configurationContainer.enabledPlaceholderUsage = enable; this.btnEnablePlaceholderUsage.setSelection(enable); } void performPdfACompatSelection(boolean compat) { - this.configurationContainer.setSignaturePdfACompat(compat); + this.configurationContainer.signaturePDFACompat = compat; this.btnPdfACompat.setSelection(compat); } void performKeystoreEnabledSelection(boolean enabled) { - this.configurationContainer.setKeyStoreEnabled(enabled); + this.configurationContainer.keystoreEnabled = enabled; this.btnKeystoreEnabled.setSelection(enabled); this.configurationComposite.keystoreEnabled(enabled); @@ -581,11 +581,11 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { } void performPlaceholderTransparency(int transparency) { - this.configurationContainer.setPlaceholderTransparency(transparency); + this.configurationContainer.placeholderTransparency = transparency; } void performUpdateCheckSelection(boolean checkUpdate) { - this.configurationContainer.setUpdateCheck(checkUpdate); + this.configurationContainer.updateCheck = checkUpdate; this.btnUpdateCheck.setSelection(checkUpdate); } @@ -605,7 +605,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { */ private void plainProxyHostSetter() { String host = this.txtProxyHost.getText(); - this.configurationContainer.setProxyHost(host); + this.configurationContainer.proxyHost = host; } void processProxyPortChanged() { @@ -656,31 +656,31 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { */ @Override public void initConfiguration(PersistentConfigProvider provider) { - this.configurationContainer.setDefaultSignaturePosition(provider.getDefaultSignaturePositionPersistent()); + this.configurationContainer.defaultSignaturePosition = provider.getDefaultSignaturePositionPersistent(); this.configurationContainer.setUseMarker(provider.getUseMarker()); this.configurationContainer.setUseSignatureFields(provider.getUseSignatureFields()); - this.configurationContainer.setEnablePlaceholderUsage(provider.getEnablePlaceholderUsage()); - this.configurationContainer.setSignaturePdfACompat(provider.getSignaturePdfACompat()); - this.configurationContainer.setPlaceholderTransparency(provider.getPlaceholderTransparency()); + this.configurationContainer.enabledPlaceholderUsage = provider.getEnablePlaceholderUsage(); + this.configurationContainer.signaturePDFACompat = provider.getSignaturePdfACompat(); + this.configurationContainer.placeholderTransparency = provider.getPlaceholderTransparency(); - this.configurationContainer.setDefaultBKU(provider.getDefaultBKUPersistent()); - this.configurationContainer.setKeyStoreEnabled(provider.getKeyStoreEnabledPersistent()); + this.configurationContainer.defaultBKU = provider.getDefaultBKUPersistent(); + this.configurationContainer.keystoreEnabled = provider.getKeyStoreEnabledPersistent(); - this.configurationContainer.setOutputFolder(provider.getDefaultOutputFolderPersistent()); - this.configurationContainer.setSaveFilePostFix(provider.getSaveFilePostFix()); + this.configurationContainer.outputFolder = provider.getDefaultOutputFolderPersistent(); + this.configurationContainer.saveFilePostFix = provider.getSaveFilePostFix(); - this.configurationContainer.setLocale(provider.getLocale()); + this.configurationContainer.locale = provider.getLocale(); - this.configurationContainer.setUpdateCheck(provider.getUpdateCheck()); + this.configurationContainer.updateCheck = provider.getUpdateCheck(); - this.configurationContainer.setProxyHost(provider.getProxyHostPersistent()); + this.configurationContainer.proxyHost = provider.getProxyHostPersistent(); try { this.configurationContainer.setProxyPort(provider.getProxyPortPersistent()); } catch (InvalidPortException e) { log.error("Failed to set proxy port!", e); } - this.configurationContainer.setProxyUser(provider.getProxyUserPersistent()); - this.configurationContainer.setProxyPass(provider.getProxyPassPersistent()); + this.configurationContainer.proxyUser = provider.getProxyUserPersistent(); + this.configurationContainer.proxyPass = provider.getProxyPassPersistent(); this.configurationContainer.setSignatureProfile(Profile.getProfile(provider.getSignatureProfile())); } @@ -693,27 +693,27 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { @Override public void loadConfiguration() { // load advanced settings - performBKUSelectionChanged(this.configurationContainer.getDefaultBKU()); - String outputFolder = this.configurationContainer.getOutputFolder(); + performBKUSelectionChanged(this.configurationContainer.defaultBKU); + String outputFolder = this.configurationContainer.outputFolder; if (outputFolder != null) { performOutputFolderChanged(outputFolder); } - String postFix = this.configurationContainer.getSaveFilePostFix(); + String postFix = this.configurationContainer.saveFilePostFix; if (postFix != null) { performPostFixChanged(postFix); } else { performPostFixChanged(Constants.DEFAULT_POSTFIX); } - SignaturePosition pos = this.configurationContainer.getDefaultSignaturePosition(); + SignaturePosition pos = this.configurationContainer.defaultSignaturePosition; performPositionSelection(pos != null && pos.useAutoPositioning()); performUseMarkerSelection(this.configurationContainer.getUseMarker()); performUseSignatureFieldsSelection(this.configurationContainer.getUseSignatureFields()); - performEnableUsePlaceholder(this.configurationContainer.getEnablePlaceholderUsage()); - this.sclTransparenz.setSelection(this.configurationContainer.getPlaceholderTransparency()); - performLocaleSelectionChanged(this.configurationContainer.getLocale()); - performPdfACompatSelection(this.configurationContainer.getSignaturePdfACompat()); - performKeystoreEnabledSelection(this.configurationContainer.getKeyStoreEnabled()); - performUpdateCheckSelection(this.configurationContainer.getUpdateCheck()); + performEnableUsePlaceholder(this.configurationContainer.enabledPlaceholderUsage); + this.sclTransparenz.setSelection(this.configurationContainer.placeholderTransparency); + performLocaleSelectionChanged(this.configurationContainer.locale); + performPdfACompatSelection(this.configurationContainer.signaturePDFACompat); + performKeystoreEnabledSelection(this.configurationContainer.keystoreEnabled); + performUpdateCheckSelection(this.configurationContainer.updateCheck); performSetSignatureProfile(this.configurationContainer.getSignatureProfile()); int port = this.configurationContainer.getProxyPort(); @@ -721,7 +721,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { this.txtProxyPort.setText(Integer.toString(port)); } - String host = this.configurationContainer.getProxyHost(); + String host = this.configurationContainer.proxyHost; if (host != null) { this.txtProxyHost.setText(host); } @@ -756,26 +756,26 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { */ @Override public void storeConfiguration(ConfigManipulator store, PersistentConfigProvider provider) { - store.setDefaultSignaturePosition(this.configurationContainer.getDefaultSignaturePosition()); + store.setDefaultSignaturePosition(this.configurationContainer.defaultSignaturePosition); store.setUseMarker(this.configurationContainer.getUseMarker()); store.setUseSignatureFields(this.configurationContainer.getUseSignatureFields()); - store.setEnablePlaceholderUsage(this.configurationContainer.getEnablePlaceholderUsage()); - store.setSignaturePdfACompat(this.configurationContainer.getSignaturePdfACompat()); - store.setPlaceholderTransparency(this.configurationContainer.getPlaceholderTransparency()); + store.setEnablePlaceholderUsage(this.configurationContainer.enabledPlaceholderUsage); + store.setSignaturePdfACompat(this.configurationContainer.signaturePDFACompat); + store.setPlaceholderTransparency(this.configurationContainer.placeholderTransparency); - store.setDefaultBKU(this.configurationContainer.getDefaultBKU()); - store.setKeyStoreEnabled(this.configurationContainer.getKeyStoreEnabled()); + store.setDefaultBKU(this.configurationContainer.defaultBKU); + store.setKeyStoreEnabled(this.configurationContainer.keystoreEnabled); - store.setDefaultOutputFolder(this.configurationContainer.getOutputFolder()); - store.setSaveFilePostFix(this.configurationContainer.getSaveFilePostFix()); - store.setLocale(this.configurationContainer.getLocale()); + store.setDefaultOutputFolder(this.configurationContainer.outputFolder); + store.setSaveFilePostFix(this.configurationContainer.saveFilePostFix); + store.setLocale(this.configurationContainer.locale); - store.setUpdateCheck(this.configurationContainer.getUpdateCheck()); + store.setUpdateCheck(this.configurationContainer.updateCheck); store.setSignatureProfile(this.configurationContainer.getSignatureProfile().name()); String hostOld = provider.getProxyHostPersistent(); - String hostNew = this.configurationContainer.getProxyHost(); + String hostNew = this.configurationContainer.proxyHost; if (hostOld != null && !hostOld.isEmpty() && (hostNew == null || hostNew.isEmpty())) { // Proxy has been removed, let's clear the system properties // Otherwise, the proxy settings wouldn't get removed @@ -794,7 +794,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { store.setProxyPort(portNew); String userOld = provider.getProxyUserPersistent(); - String userNew = this.configurationContainer.getProxyUser(); + String userNew = this.configurationContainer.proxyUser; if (userOld != null && !userOld.isEmpty() && (userNew == null || userNew.isEmpty())) { // cf. above System.clearProperty("http.proxyUser"); @@ -803,7 +803,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { store.setProxyUser(userNew); String passOld = provider.getProxyPassPersistent(); - String passNew = this.configurationContainer.getProxyPass(); + String passNew = this.configurationContainer.proxyPass; if (passOld != null && passNew == null) { // cf. above System.clearProperty("http.proxyPassword"); @@ -821,7 +821,7 @@ public class AdvancedConfigurationComposite extends ConfigurationCompositeBase { @Override public void validateSettings(int resumeIndex) throws Exception { - String foldername = this.configurationContainer.getOutputFolder(); + String foldername = this.configurationContainer.outputFolder; switch (resumeIndex) { case 0: 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 a2284ee3..4e4694da 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 @@ -213,7 +213,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { @Override public void widgetSelected(SelectionEvent e) { File f = new File(KeystoreConfigurationComposite.this - .configurationContainer.getKeyStoreFile()); + .configurationContainer.keystoreFile); try { loadKeystore(); } catch (KeyStoreException ex) { @@ -280,10 +280,10 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { void loadKeystore() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { ConfigurationContainer config = KeystoreConfigurationComposite.this.configurationContainer; - File f = new File(config.getKeyStoreFile()); - this.ks = KeyStore.getInstance(config.getKeyStoreType()); + File f = new File(config.keystoreFile); + this.ks = KeyStore.getInstance(config.keystoreType); FileInputStream fis = new FileInputStream(f); - this.ks.load(fis, config.getKeyStoreStorePass().toCharArray()); + this.ks.load(fis, config.keystoreStorePass.toCharArray()); this.cmbKeystoreAlias.remove(0, this.cmbKeystoreAlias.getItemCount()-1); Enumeration<String> aliases = this.ks.aliases(); while (aliases.hasMoreElements()) @@ -301,7 +301,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { */ protected void performKeystoreFileChanged(String fileName) { log.debug("Selected keystore file: " + fileName); - this.configurationContainer.setKeyStoreFile(fileName); + this.configurationContainer.keystoreFile = fileName; KeystoreConfigurationComposite.this.txtKeystoreFile.setText(fileName); int i = fileName.lastIndexOf('.'); if (i > 0) { @@ -323,7 +323,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { */ protected void performKeystoreTypeChanged(String type) { log.debug("Selected keystore type: " + type); - this.configurationContainer.setKeyStoreType(type); + this.configurationContainer.keystoreType = type; for (int i = 0; i < this.cmbKeystoreType.getItemCount(); ++i) { if (this.keystoreTypes.get(this.cmbKeystoreType.getItem(i)).equals(type)) { this.cmbKeystoreType.select(i); @@ -337,7 +337,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { */ protected void performKeystoreStorePassChanged(String storepass) { log.debug("Changed keystore store password"); - this.configurationContainer.setKeyStoreStorePass(storepass); + this.configurationContainer.keystoreStorePass = storepass; this.txtKeystoreStorePass.setText(storepass); } @@ -346,7 +346,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { */ protected void performKeystoreAliasChanged(String alias) { log.debug("Selected keystore alias: " + alias); - this.configurationContainer.setKeyStoreAlias(alias); + this.configurationContainer.keystoreAlias = alias; this.cmbKeystoreAlias.setText(alias); } @@ -355,7 +355,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { */ protected void performKeystoreKeyPassChanged(String keypass) { log.debug("Changed keystore key password"); - this.configurationContainer.setKeyStoreKeyPass(keypass); + this.configurationContainer.keystoreKeyPass = keypass; this.txtKeystoreKeyPass.setText(keypass); } @@ -387,11 +387,11 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { @Override public void initConfiguration(PersistentConfigProvider provider) { ConfigurationContainer config = this.configurationContainer; - config.setKeyStoreFile(provider.getKeyStoreFilePersistent()); - config.setKeyStoreType(provider.getKeyStoreTypePersistent()); - config.setKeyStoreAlias(provider.getKeyStoreAliasPersistent()); - config.setKeyStoreStorePass(provider.getKeyStoreStorePassPersistent()); - config.setKeyStoreKeyPass(provider.getKeyStoreKeyPassPersistent()); + config.keystoreFile = provider.getKeyStoreFilePersistent(); + config.keystoreType = provider.getKeyStoreTypePersistent(); + config.keystoreAlias = provider.getKeyStoreAliasPersistent(); + config.keystoreStorePass = provider.getKeyStoreStorePassPersistent(); + config.keystoreKeyPass = provider.getKeyStoreKeyPassPersistent(); } /* @@ -403,10 +403,10 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { public void loadConfiguration() { // Initialize form fields from configuration Container ConfigurationContainer config = this.configurationContainer; - String ks = config.getKeyStoreFile(); + String ks = config.keystoreFile; performKeystoreFileChanged(ks); - performKeystoreTypeChanged(config.getKeyStoreType()); - performKeystoreStorePassChanged(config.getKeyStoreStorePass()); + performKeystoreTypeChanged(config.keystoreType); + performKeystoreStorePassChanged(config.keystoreStorePass); try { File ksf = new File(ks); if (ksf.exists()) @@ -414,8 +414,8 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { } catch (Exception e) { log.error("Error loading keystore", e); } - performKeystoreAliasChanged(config.getKeyStoreAlias()); - performKeystoreKeyPassChanged(config.getKeyStoreKeyPass()); + performKeystoreAliasChanged(config.keystoreAlias); + performKeystoreKeyPassChanged(config.keystoreKeyPass); } /* (non-Javadoc) @@ -425,11 +425,11 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { public void storeConfiguration(ConfigManipulator store, PersistentConfigProvider provider) { ConfigurationContainer config = this.configurationContainer; - store.setKeyStoreFile(config.getKeyStoreFile()); - store.setKeyStoreType(config.getKeyStoreType()); - store.setKeyStoreAlias(config.getKeyStoreAlias()); - store.setKeyStoreStorePass(config.getKeyStoreStorePass()); - store.setKeyStoreKeyPass(config.getKeyStoreKeyPass()); + store.setKeyStoreFile(config.keystoreFile); + store.setKeyStoreType(config.keystoreType); + store.setKeyStoreAlias(config.keystoreAlias); + store.setKeyStoreStorePass(config.keystoreStorePass); + store.setKeyStoreKeyPass(config.keystoreKeyPass); } /* @@ -444,7 +444,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { ConfigurationContainer config = this.configurationContainer; switch (resumeFrom) { case 0: - String fname = config.getKeyStoreFile(); + String fname = config.keystoreFile; if (fname.isEmpty()) break; //no checks required File f = new File(fname); @@ -459,7 +459,7 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { } // Fall through case 2: - String alias = config.getKeyStoreAlias(); + String alias = config.keystoreAlias; if (!this.ks.containsAlias(alias)) throw new KeystoreAliasDoesntExistException(alias, 4); //skip next check if (!this.ks.isKeyEntry(alias)) @@ -467,8 +467,8 @@ public class KeystoreConfigurationComposite extends ConfigurationCompositeBase { // Fall through case 3: try { - alias = config.getKeyStoreAlias(); - String keypass = config.getKeyStoreKeyPass(); + alias = config.keystoreAlias; + String keypass = config.keystoreKeyPass; this.ks.getKey(alias, keypass.toCharArray()); } catch (Exception e) { throw new KeystoreKeyPasswordException(4); 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 bf74eaa8..b6a9edf0 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 @@ -303,11 +303,8 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { this.cmbSignatureLang.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - Locale currentLocale = SimpleConfigurationComposite.this.configurationContainer - .getSignatureLocale(); - Locale selectedLocale = Constants. - SUPPORTED_LOCALES[SimpleConfigurationComposite.this.cmbSignatureLang - .getSelectionIndex()]; + Locale currentLocale = SimpleConfigurationComposite.this.configurationContainer.signatureLocale; + Locale selectedLocale = Constants.SUPPORTED_LOCALES[SimpleConfigurationComposite.this.cmbSignatureLang.getSelectionIndex()]; if (!currentLocale.equals(selectedLocale)) { performSignatureLangSelectionChanged(selectedLocale, currentLocale); } @@ -446,12 +443,12 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { try { if (this.signer != null) { SignatureParameter param = this.signer.getPDFSigner().newParameter(); - if(this.configurationContainer.getSignatureNote() != null && !this.configurationContainer.getSignatureNote().isEmpty()) { - param.setProperty("SIG_NOTE", this.configurationContainer.getSignatureNote()); + if(this.configurationContainer.signatureNote != null && !this.configurationContainer.signatureNote.isEmpty()) { + param.setProperty("SIG_NOTE", this.configurationContainer.signatureNote); } - param.setSignatureLanguage(this.configurationContainer.getSignatureLocale().getLanguage()); - param.setSignaturePdfACompat(this.configurationContainer.getSignaturePdfACompat()); + param.setSignatureLanguage(this.configurationContainer.signatureLocale.getLanguage()); + param.setSignaturePdfACompat(this.configurationContainer.signaturePDFACompat); if (image != null && !image.trim().isEmpty()) { logo = new ImageData(image); param.setEmblem(new CachedFileNameEmblem(image)); @@ -527,7 +524,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { void performSignatureLangSelectionChanged(Locale selected, Locale previous) { log.debug("Selected Sign Locale: {}", selected); - this.configurationContainer.setSignatureLocale(selected); + this.configurationContainer.signatureLocale = selected; this.cmbSignatureLang.select(this.getLocaleElementIndex(selected)); if ((previous != null) && (txtSignatureNote.getText().equals(getDefaultSignatureBlockNoteTextFor(null, previous)))) @@ -543,7 +540,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { this.cmbSignatureProfiles.select(newProfile.ordinal()); if (newProfile.equals(Profile.AMTSSIGNATURBLOCK) || newProfile.equals(Profile.INVISIBLE)){ - this.configurationContainer.setDefaultSignaturePosition(new SignaturePosition()); + this.configurationContainer.defaultSignaturePosition = new SignaturePosition(); } setSignatureProfileSetting(); if (txtSignatureNote.getText().equals(getDefaultSignatureBlockNoteTextFor(oldProfile, null))) @@ -554,7 +551,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { if (profile == null) profile = configurationContainer.getSignatureProfile(); if (locale == null) - locale = configurationContainer.getSignatureLocale(); + locale = configurationContainer.signatureLocale; return profile.getDefaultSignatureBlockNote(locale); } @@ -597,7 +594,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { void processSignatureNoteChanged() { String note = this.txtSignatureNote.getText(); - this.configurationContainer.setSignatureNote(note); + this.configurationContainer.signatureNote = note; } /* @@ -626,11 +623,8 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { log.error("Failed to set emblem!", e); } - this.configurationContainer.setSignatureLocale( - provider.getSignatureLocale()); - - this.configurationContainer.setSignatureNote( - provider.getSignatureNote()); + this.configurationContainer.signatureLocale = provider.getSignatureLocale(); + this.configurationContainer.signatureNote = provider.getSignatureNote(); } /* @@ -661,7 +655,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { } } - String note = this.configurationContainer.getSignatureNote(); + String note = this.configurationContainer.signatureNote; if (note != null) { this.txtSignatureNote.setText(note); @@ -669,7 +663,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { this.setVisibleImage(); - this.performSignatureLangSelectionChanged(this.configurationContainer.getSignatureLocale(), null); + this.performSignatureLangSelectionChanged(this.configurationContainer.signatureLocale, null); this.preformProfileSelectionChanged(this.configurationContainer.getSignatureProfile()); @@ -679,16 +673,11 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#storeConfiguration(at.asit.pdfover.gui.workflow.config.ConfigManipulator, at.asit.pdfover.gui.workflow.config.PersistentConfigProvider) */ @Override - public void storeConfiguration(ConfigManipulator store, - PersistentConfigProvider provider) { + public void storeConfiguration(ConfigManipulator store, PersistentConfigProvider provider) { store.setDefaultMobileNumber(this.configurationContainer.getMobileNumber()); - store.setDefaultEmblem(this.configurationContainer.getEmblem()); - - store.setSignatureLocale(this.configurationContainer.getSignatureLocale()); - - store.setSignatureNote(this.configurationContainer.getSignatureNote()); - + store.setSignatureLocale(this.configurationContainer.signatureLocale); + store.setSignatureNote(this.configurationContainer.signatureNote); store.setSignatureProfile(this.configurationContainer.getSignatureProfile().name()); @@ -704,14 +693,14 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { @Override public void validateSettings(int resumeFrom) throws Exception { switch (resumeFrom) { - case 0: - this.plainMobileNumberSetter(); - // Fall through - case 1: - this.processSignatureNoteChanged(); - break; - default: - //Fall through + case 0: + this.plainMobileNumberSetter(); + // Fall through + case 1: + this.processSignatureNoteChanged(); + break; + default: + break; } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java index 1377f4ac..69978e27 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java @@ -73,8 +73,8 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, * Constructor */ public ConfigProviderImpl() { - this.configuration = new ConfigurationContainerImpl(); - this.configurationOverlay = new ConfigurationContainerImpl(); + this.configuration = new ConfigurationContainer(); + this.configurationOverlay = new ConfigurationContainer(); } /* @@ -150,7 +150,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, String bkuUrl = config.getProperty(Constants.CFG_MOBILE_BKU_URL); if (bkuUrl != null && !bkuUrl.isEmpty()) - this.configuration.setMobileBKUURL(bkuUrl); + this.configuration.mobileBKUURL = bkuUrl; String bkuType = config .getProperty(Constants.CFG_MOBILE_BKU_TYPE); @@ -159,17 +159,16 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, { try { - this.configuration.setMobileBKUType(MobileBKUs.valueOf( - bkuType.trim().toUpperCase())); + this.configuration.mobileBKUType = MobileBKUs.valueOf(bkuType.trim().toUpperCase()); } catch (IllegalArgumentException e) { log.error("Invalid BKU type: " + bkuType); - this.configuration.setMobileBKUType(DEFAULT_MOBILE_BKU_TYPE); + this.configuration.mobileBKUType = DEFAULT_MOBILE_BKU_TYPE; } } String useBase64 = config.getProperty(Constants.CFG_MOBILE_BKU_BASE64); if (useBase64 != null) - this.configuration.setMobileBKUBase64(useBase64.equalsIgnoreCase(Constants.TRUE)); + this.configuration.mobileBKUBase64 = useBase64.equalsIgnoreCase(Constants.TRUE); String proxyPortString = config.getProperty(Constants.CFG_PROXY_PORT); if (proxyPortString != null && !proxyPortString.trim().isEmpty()) @@ -230,7 +229,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, // ignore parsing exception } } - this.configuration.setMainWindowSize(new Point(width, height)); + this.configuration.mainWindowSize = new Point(width, height); // Set Signature Position String signaturePosition = config.getProperty(Constants.CFG_SIGNATURE_POSITION); @@ -337,7 +336,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, props.setProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY, Integer.toString(getPlaceholderTransparency())); - Point size = this.configuration.getMainWindowSize(); + Point size = this.configuration.mainWindowSize; props.setProperty(Constants.CFG_MAINWINDOW_SIZE, size.x + "," + size.y); Locale configLocale = getLocale(); @@ -462,7 +461,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setDefaultBKU(BKUs bku) { - this.configuration.setDefaultBKU(bku); + this.configuration.defaultBKU = bku; } /* (non-Javadoc) @@ -470,7 +469,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setDefaultBKUOverlay(BKUs bku) { - this.configurationOverlay.setDefaultBKU(bku); + this.configurationOverlay.defaultBKU = bku; } @@ -481,7 +480,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public BKUs getDefaultBKU() { - BKUs bku = this.configurationOverlay.getDefaultBKU(); + BKUs bku = this.configurationOverlay.defaultBKU; if (bku == BKUs.NONE) bku = getDefaultBKUPersistent(); return bku; @@ -492,7 +491,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public BKUs getDefaultBKUPersistent() { - return this.configuration.getDefaultBKU(); + return this.configuration.defaultBKU; } /** @@ -503,7 +502,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setDefaultSignaturePosition(SignaturePosition signaturePosition) { - this.configuration.setDefaultSignaturePosition(signaturePosition); + this.configuration.defaultSignaturePosition = signaturePosition; } @@ -512,7 +511,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setDefaultSignaturePositionOverlay(SignaturePosition signaturePosition) { - this.configurationOverlay.setDefaultSignaturePosition(signaturePosition); + this.configurationOverlay.defaultSignaturePosition = signaturePosition; } /* @@ -523,7 +522,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public SignaturePosition getDefaultSignaturePosition() { - SignaturePosition position = this.configurationOverlay.getDefaultSignaturePosition(); + SignaturePosition position = this.configurationOverlay.defaultSignaturePosition; if (position == null) position = getDefaultSignaturePositionPersistent(); return position; @@ -534,7 +533,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public SignaturePosition getDefaultSignaturePositionPersistent() { - return this.configuration.getDefaultSignaturePosition(); + return this.configuration.defaultSignaturePosition; } /** @@ -545,7 +544,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setPlaceholderTransparency(int transparency) { - this.configuration.setPlaceholderTransparency(transparency); + this.configuration.placeholderTransparency = transparency; } /* @@ -556,7 +555,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public int getPlaceholderTransparency() { - return this.configuration.getPlaceholderTransparency(); + return this.configuration.placeholderTransparency; } /** @@ -619,9 +618,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setDefaultMobilePassword(String password) { if (password == null || password.trim().isEmpty()) { - this.configuration.setMobilePassword(STRING_EMPTY); + this.configuration.mobilePassword = STRING_EMPTY; } else { - this.configuration.setMobilePassword(password); + this.configuration.mobilePassword = password; } } @@ -631,9 +630,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setDefaultMobilePasswordOverlay(String password) { if (password == null || password.trim().isEmpty()) { - this.configurationOverlay.setMobilePassword(STRING_EMPTY); + this.configurationOverlay.mobilePassword = STRING_EMPTY; } else { - this.configurationOverlay.setMobilePassword(password); + this.configurationOverlay.mobilePassword = password; } } @@ -644,7 +643,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getDefaultMobilePassword() { - String password = this.configurationOverlay.getMobilePassword(); + String password = this.configurationOverlay.mobilePassword; if (password == null) password = getDefaultMobilePasswordPersistent(); return password; @@ -655,7 +654,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getDefaultMobilePasswordPersistent() { - String password = this.configuration.getMobilePassword(); + String password = this.configuration.mobilePassword; if (password == null) password = STRING_EMPTY; return password; @@ -744,9 +743,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setProxyHost(String host) { if (host == null || host.trim().isEmpty()) { - this.configuration.setProxyHost(STRING_EMPTY); + this.configuration.proxyHost = STRING_EMPTY; } else { - this.configuration.setProxyHost(host); + this.configuration.proxyHost = host; } } @@ -756,9 +755,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setProxyHostOverlay(String host) { if (host == null || host.trim().isEmpty()) { - this.configurationOverlay.setProxyHost(STRING_EMPTY); + this.configurationOverlay.proxyHost = STRING_EMPTY; } else { - this.configurationOverlay.setProxyHost(host); + this.configurationOverlay.proxyHost = host; } } @@ -769,7 +768,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getProxyHost() { - String host = this.configurationOverlay.getProxyHost(); + String host = this.configurationOverlay.proxyHost; if (host == null) host = getProxyHostPersistent(); return host; @@ -780,7 +779,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getProxyHostPersistent() { - String host = this.configuration.getProxyHost(); + String host = this.configuration.proxyHost; if (host == null) host = STRING_EMPTY; return host; @@ -845,9 +844,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setProxyUser(String user) { if (user == null || user.trim().isEmpty()) { - this.configuration.setProxyUser(STRING_EMPTY); + this.configuration.proxyUser = STRING_EMPTY; } else { - this.configuration.setProxyUser(user); + this.configuration.proxyUser = user; } } @@ -857,9 +856,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setProxyUserOverlay(String user) { if (user == null || user.trim().isEmpty()) { - this.configurationOverlay.setProxyUser(STRING_EMPTY); + this.configurationOverlay.proxyUser = STRING_EMPTY; } else { - this.configurationOverlay.setProxyUser(user); + this.configurationOverlay.proxyUser = user; } } @@ -868,7 +867,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getProxyUser() { - String user = this.configurationOverlay.getProxyUser(); + String user = this.configurationOverlay.proxyUser; if (user == null) user = getProxyUserPersistent(); return user; @@ -879,7 +878,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getProxyUserPersistent() { - String user = this.configuration.getProxyUser(); + String user = this.configuration.proxyUser; if (user == null) user = STRING_EMPTY; return user; @@ -894,9 +893,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setProxyPass(String pass) { if (pass == null || pass.trim().isEmpty()) { - this.configuration.setProxyPass(STRING_EMPTY); + this.configuration.proxyPass = STRING_EMPTY; } else { - this.configuration.setProxyPass(pass); + this.configuration.proxyPass = pass; } } @@ -906,9 +905,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setProxyPassOverlay(String pass) { if (pass == null || pass.trim().isEmpty()) { - this.configurationOverlay.setProxyPass(STRING_EMPTY); + this.configurationOverlay.proxyPass = STRING_EMPTY; } else { - this.configurationOverlay.setProxyPass(pass); + this.configurationOverlay.proxyPass = pass; } } @@ -917,7 +916,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getProxyPass() { - String pass = this.configurationOverlay.getProxyPass(); + String pass = this.configurationOverlay.proxyPass; if (pass == null) pass = getProxyPassPersistent(); return pass; @@ -928,7 +927,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getProxyPassPersistent() { - String pass = this.configuration.getProxyPass(); + String pass = this.configuration.proxyPass; if (pass == null) pass = STRING_EMPTY; return pass; @@ -944,9 +943,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setDefaultOutputFolder(String outputFolder) { if (outputFolder == null || outputFolder.trim().isEmpty()) { - this.configuration.setOutputFolder(STRING_EMPTY); + this.configuration.outputFolder = STRING_EMPTY; } else { - this.configuration.setOutputFolder(outputFolder); + this.configuration.outputFolder = outputFolder; } } @@ -956,9 +955,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setDefaultOutputFolderOverlay(String outputFolder) { if (outputFolder == null || outputFolder.trim().isEmpty()) { - this.configurationOverlay.setOutputFolder(STRING_EMPTY); + this.configurationOverlay.outputFolder = STRING_EMPTY; } else { - this.configurationOverlay.setOutputFolder(outputFolder); + this.configurationOverlay.outputFolder = outputFolder; } } @@ -969,7 +968,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getDefaultOutputFolder() { - String outputFolder = this.configurationOverlay.getOutputFolder(); + String outputFolder = this.configurationOverlay.outputFolder; if (outputFolder == null) outputFolder = getDefaultOutputFolderPersistent(); return outputFolder; @@ -980,7 +979,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getDefaultOutputFolderPersistent() { - String outputFolder = this.configuration.getOutputFolder(); + String outputFolder = this.configuration.outputFolder; if (outputFolder == null) outputFolder = STRING_EMPTY; return outputFolder; @@ -993,7 +992,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getMobileBKUURL() { - return this.configuration.getMobileBKUURL(); + return this.configuration.mobileBKUURL; } /* (non-Javadoc) @@ -1001,7 +1000,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public MobileBKUs getMobileBKUType() { - return this.configuration.getMobileBKUType(); + return this.configuration.mobileBKUType; } @@ -1010,7 +1009,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public boolean getMobileBKUBase64() { - return this.configuration.getMobileBKUBase64(); + return this.configuration.mobileBKUBase64; } /* @@ -1023,9 +1022,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setSignatureNote(String note) { if (note == null || note.trim().isEmpty()) { - this.configuration.setSignatureNote(STRING_EMPTY); + this.configuration.signatureNote = STRING_EMPTY; } else { - this.configuration.setSignatureNote(note); + this.configuration.signatureNote = note; } } @@ -1036,7 +1035,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getSignatureNote() { - String note = this.configuration.getSignatureNote(); + String note = this.configuration.signatureNote; if (note == null) note = STRING_EMPTY; return note; @@ -1048,9 +1047,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setLocale(Locale locale) { if(locale == null) { - this.configuration.setLocale(Messages.getDefaultLocale()); + this.configuration.locale = Messages.getDefaultLocale(); } else { - this.configuration.setLocale(locale); + this.configuration.locale = locale; Locale.setDefault(locale); Messages.setLocale(locale); } @@ -1061,7 +1060,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public Locale getLocale() { - Locale locale = this.configuration.getLocale(); + Locale locale = this.configuration.locale; if (locale == null) locale = Messages.getDefaultLocale(); return locale; @@ -1073,9 +1072,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setSignatureLocale(Locale locale) { if(locale == null) { - this.configuration.setSignatureLocale(Messages.getDefaultLocale()); + this.configuration.signatureLocale = Messages.getDefaultLocale(); } else { - this.configuration.setSignatureLocale(locale); + this.configuration.signatureLocale = locale; } } @@ -1084,7 +1083,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public Locale getSignatureLocale() { - Locale locale = this.configuration.getSignatureLocale(); + Locale locale = this.configuration.signatureLocale; if (locale == null) locale = Messages.getDefaultLocale(); return locale; @@ -1095,7 +1094,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setSignaturePdfACompat(boolean compat) { - this.configuration.setSignaturePdfACompat(compat); + this.configuration.signaturePDFACompat = compat; } /* (non-Javadoc) @@ -1103,7 +1102,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public boolean getSignaturePdfACompat() { - return this.configuration.getSignaturePdfACompat(); + return this.configuration.signaturePDFACompat; } /* (non-Javadoc) @@ -1111,7 +1110,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setKeyStoreEnabled(Boolean enabled) { - this.configuration.setKeyStoreEnabled(enabled); + this.configuration.keystoreEnabled = enabled; } /* (non-Javadoc) @@ -1119,7 +1118,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setKeyStoreEnabledOverlay(Boolean enabled) { - this.configurationOverlay.setKeyStoreEnabled(enabled); + this.configurationOverlay.keystoreEnabled = enabled; } /* (non-Javadoc) @@ -1127,7 +1126,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public Boolean getKeyStoreEnabled() { - Boolean enabled = this.configurationOverlay.getKeyStoreEnabled(); + Boolean enabled = this.configurationOverlay.keystoreEnabled; if (enabled == null) enabled = getKeyStoreEnabledPersistent(); return enabled; @@ -1138,7 +1137,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public Boolean getKeyStoreEnabledPersistent() { - Boolean enabled = this.configuration.getKeyStoreEnabled(); + Boolean enabled = this.configuration.keystoreEnabled; if (enabled == null) enabled = false; return enabled; @@ -1150,9 +1149,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setKeyStoreFile(String file) { if (file == null || file.trim().isEmpty()) { - this.configuration.setKeyStoreFile(STRING_EMPTY); + this.configuration.keystoreFile = STRING_EMPTY; } else { - this.configuration.setKeyStoreFile(file); + this.configuration.keystoreFile = file; } } @@ -1162,9 +1161,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setKeyStoreFileOverlay(String file) { if (file == null || file.trim().isEmpty()) { - this.configurationOverlay.setKeyStoreFile(STRING_EMPTY); + this.configurationOverlay.keystoreFile = STRING_EMPTY; } else { - this.configurationOverlay.setKeyStoreFile(file); + this.configurationOverlay.keystoreFile = file; } } @@ -1173,7 +1172,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getKeyStoreFile() { - String file = this.configurationOverlay.getKeyStoreFile(); + String file = this.configurationOverlay.keystoreFile; if (file == null) file = getKeyStoreFilePersistent(); return file; @@ -1184,7 +1183,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getKeyStoreFilePersistent() { - String file = this.configuration.getKeyStoreFile(); + String file = this.configuration.keystoreFile; if (file == null) file = STRING_EMPTY; return file; @@ -1196,9 +1195,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setKeyStoreType(String type) { if (type == null || type.trim().isEmpty()) { - this.configuration.setKeyStoreType(STRING_EMPTY); + this.configuration.keystoreType = STRING_EMPTY; } else { - this.configuration.setKeyStoreType(type); + this.configuration.keystoreType = type; } } @@ -1208,9 +1207,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setKeyStoreTypeOverlay(String type) { if (type == null || type.trim().isEmpty()) { - this.configurationOverlay.setKeyStoreType(STRING_EMPTY); + this.configurationOverlay.keystoreType = STRING_EMPTY; } else { - this.configurationOverlay.setKeyStoreType(type); + this.configurationOverlay.keystoreType = type; } } @@ -1219,7 +1218,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getKeyStoreType() { - String type = this.configurationOverlay.getKeyStoreType(); + String type = this.configurationOverlay.keystoreType; if (type == null) type = getKeyStoreTypePersistent(); return type; @@ -1230,7 +1229,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getKeyStoreTypePersistent() { - String type = this.configuration.getKeyStoreType(); + String type = this.configuration.keystoreType; if (type == null) type = STRING_EMPTY; return type; @@ -1242,9 +1241,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setKeyStoreAlias(String alias) { if (alias == null || alias.trim().isEmpty()) { - this.configuration.setKeyStoreAlias(STRING_EMPTY); + this.configuration.keystoreAlias = STRING_EMPTY; } else { - this.configuration.setKeyStoreAlias(alias); + this.configuration.keystoreAlias = alias; } } @@ -1254,9 +1253,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setKeyStoreAliasOverlay(String alias) { if (alias == null || alias.trim().isEmpty()) { - this.configurationOverlay.setKeyStoreAlias(STRING_EMPTY); + this.configurationOverlay.keystoreAlias = STRING_EMPTY; } else { - this.configurationOverlay.setKeyStoreAlias(alias); + this.configurationOverlay.keystoreAlias = alias; } } @@ -1265,7 +1264,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getKeyStoreAlias() { - String alias = this.configurationOverlay.getKeyStoreAlias(); + String alias = this.configurationOverlay.keystoreAlias; if (alias == null) alias = getKeyStoreAliasPersistent(); return alias; @@ -1276,7 +1275,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getKeyStoreAliasPersistent() { - String alias = this.configuration.getKeyStoreAlias(); + String alias = this.configuration.keystoreAlias; if (alias == null) alias = STRING_EMPTY; return alias; @@ -1288,9 +1287,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setKeyStoreStorePass(String storePass) { if (storePass == null || storePass.trim().isEmpty()) { - this.configuration.setKeyStoreStorePass(STRING_EMPTY); + this.configuration.keystoreStorePass = STRING_EMPTY; } else { - this.configuration.setKeyStoreStorePass(storePass); + this.configuration.keystoreStorePass = storePass; } } @@ -1300,9 +1299,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setKeyStoreStorePassOverlay(String storePass) { if (storePass == null || storePass.trim().isEmpty()) { - this.configurationOverlay.setKeyStoreStorePass(STRING_EMPTY); + this.configurationOverlay.keystoreStorePass = STRING_EMPTY; } else { - this.configurationOverlay.setKeyStoreStorePass(storePass); + this.configurationOverlay.keystoreStorePass = storePass; } } @@ -1311,7 +1310,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getKeyStoreStorePass() { - String storePass = this.configurationOverlay.getKeyStoreStorePass(); + String storePass = this.configurationOverlay.keystoreStorePass; if (storePass != null) return storePass; return getKeyStoreStorePassPersistent(); @@ -1322,7 +1321,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getKeyStoreStorePassPersistent() { - String storePass = this.configuration.getKeyStoreStorePass(); + String storePass = this.configuration.keystoreStorePass; if (storePass == null) storePass = STRING_EMPTY; return storePass; @@ -1334,9 +1333,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setKeyStoreKeyPass(String keyPass) { if (keyPass == null || keyPass.trim().isEmpty()) { - this.configuration.setKeyStoreKeyPass(STRING_EMPTY); + this.configuration.keystoreKeyPass = STRING_EMPTY; } else { - this.configuration.setKeyStoreKeyPass(keyPass); + this.configuration.keystoreKeyPass = keyPass; } } @@ -1346,9 +1345,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setKeyStoreKeyPassOverlay(String keyPass) { if (keyPass == null || keyPass.trim().isEmpty()) { - this.configurationOverlay.setKeyStoreKeyPass(STRING_EMPTY); + this.configurationOverlay.keystoreKeyPass = STRING_EMPTY; } else { - this.configurationOverlay.setKeyStoreKeyPass(keyPass); + this.configurationOverlay.keystoreKeyPass = keyPass; } } @@ -1357,7 +1356,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getKeyStoreKeyPass() { - String keyPass = this.configurationOverlay.getKeyStoreKeyPass(); + String keyPass = this.configurationOverlay.keystoreKeyPass; if (keyPass != null) return keyPass; return getKeyStoreKeyPassPersistent(); @@ -1368,7 +1367,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public String getKeyStoreKeyPassPersistent() { - String keyPass = this.configuration.getKeyStoreKeyPass(); + String keyPass = this.configuration.keystoreKeyPass; if (keyPass == null) keyPass = STRING_EMPTY; return keyPass; @@ -1379,7 +1378,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setUpdateCheck(boolean checkUpdate) { - this.configuration.setUpdateCheck(checkUpdate); + this.configuration.updateCheck = checkUpdate; } /* (non-Javadoc) @@ -1387,7 +1386,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public boolean getUpdateCheck() { - return this.configuration.getUpdateCheck(); + return this.configuration.updateCheck; } /* (non-Javadoc) @@ -1395,7 +1394,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setMainWindowSize(Point size) { - this.configuration.setMainWindowSize(size); + this.configuration.mainWindowSize = size; } /* (non-Javadoc) @@ -1403,7 +1402,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public Point getMainWindowSize() { - return this.configuration.getMainWindowSize(); + return this.configuration.mainWindowSize; } /* (non-Javadoc) @@ -1411,7 +1410,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public boolean getSkipFinish() { - return this.configurationOverlay.getSkipFinish(); + return this.configurationOverlay.skipFinish; } /* (non-Javadoc) @@ -1419,7 +1418,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, */ @Override public void setSkipFinishOverlay(boolean skipFinish) { - this.configurationOverlay.setSkipFinish(skipFinish); + this.configurationOverlay.skipFinish = skipFinish; } /* @@ -1468,12 +1467,12 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setSaveFilePostFix(String postFix) { - this.configurationOverlay.setSaveFilePostFix(postFix); + this.configurationOverlay.saveFilePostFix = postFix; } @Override public String getSaveFilePostFix(){ - return this.configurationOverlay.getSaveFilePostFix(); + return this.configurationOverlay.saveFilePostFix; } @Override @@ -1484,12 +1483,12 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, @Override public void setEnablePlaceholderUsage(boolean bool) { - this.configurationOverlay.setEnablePlaceholderUsage(bool); + this.configurationOverlay.enabledPlaceholderUsage = bool; } @Override public boolean getEnablePlaceholderUsage() { - return this.configurationOverlay.getEnablePlaceholderUsage(); + return this.configurationOverlay.enabledPlaceholderUsage; } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java index 70661f3d..b238da01 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java @@ -15,11 +15,21 @@ */ package at.asit.pdfover.gui.workflow.config; +// Imports +import java.io.File; +import java.io.FileNotFoundException; import java.util.Locale; import at.asit.pdfover.commons.Profile; +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.commons.Constants; +import at.asit.pdfover.gui.bku.mobile.MobileBKUHelper; import at.asit.pdfover.gui.bku.mobile.MobileBKUs; import at.asit.pdfover.gui.exceptions.InvalidEmblemFile; import at.asit.pdfover.gui.exceptions.InvalidPortException; @@ -27,402 +37,158 @@ import at.asit.pdfover.signator.BKUs; import at.asit.pdfover.signator.SignaturePosition; /** - * Configuration container + * Implementation of the configuration container */ -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 - */ - public void setMobileNumber(String number); - - /** - * 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 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 proxy username - * @return the proxy username - */ - public String getProxyUser(); - - /** - * Sets the proxy username - * @param user the proxy username - */ - public void setProxyUser(String user); - - /** - * Gets the proxy password - * @return the proxy password - */ - public String getProxyPass(); - - /** - * Sets the proxy password - * @param pass the proxy password - */ - public void setProxyPass(String pass); - - /** - * 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 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 getSignatureLocale(); - - /** - * Sets the signature locale - * @param locale the signature locale - */ - public void setSignatureLocale(Locale locale); - - /** - * Gets the signature PDF/A compatibility setting - * @return the signature PDF/A compatibility setting - */ - public boolean getSignaturePdfACompat(); - - /** - * Sets the signature PDF/A compatibility setting - * @param compat the signature PDF/A compatibility setting - */ - public void setSignaturePdfACompat(boolean compat); - - /** - * 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 mobile BKU BASE64 setting - * @return the mobile BKU BASE64 setting - */ - public boolean getMobileBKUBase64(); - - /** - * Sets the mobile BKU BASE64 setting - * @param useBase64 the mobile BKU BASE64 setting - */ - public void setMobileBKUBase64(boolean useBase64); - - /** - * Gets the default signature position - * @return the default signature position - */ - public SignaturePosition getDefaultSignaturePosition(); - - /** - * Sets the default signature position - * @param signaturePosition the default signature position - */ - public void setDefaultSignaturePosition(SignaturePosition signaturePosition); - - /** - * Gets whether keystore signing is enabled - * @return whether keystore signing is enabled - */ - public Boolean getKeyStoreEnabled(); - - /** - * Sets whether keystore signing is enabled - * @param enabled whether keystore signing is enabled - */ - public void setKeyStoreEnabled(Boolean enabled); - - /** - * Gets the keystore file - * @return the keystore file - */ - public String getKeyStoreFile(); - - /** - * Sets the keystore file - * @param file the keystore file - */ - public void setKeyStoreFile(String file); - - /** - * Gets the keystore type - * @return the keystore type - */ - public String getKeyStoreType(); - - /** - * Sets the keystore type - * @param type the keystore type - */ - public void setKeyStoreType(String type); - - /** - * Gets the keystore alias - * @return the keystore alias - */ - public String getKeyStoreAlias(); - - /** - * Sets the keystore alias - * @param alias the keystore alias - */ - public void setKeyStoreAlias(String alias); - - /** - * Gets the keystore store password - * @return the keystore store password - */ - public String getKeyStoreStorePass(); - - /** - * Sets the keystore store password - * @param storePass the keystore store password - */ - public void setKeyStoreStorePass(String storePass); - - /** - * Gets the keystore key password - * @return the keystore key password - */ - public String getKeyStoreKeyPass(); - - /** - * Sets the keystore key password - * @param keyPass the keystore key password - */ - public void setKeyStoreKeyPass(String keyPass); - - /** - * Gets whether to automatically check for application updates - * @return whether to automatically check for application updates - */ - public boolean getUpdateCheck(); - - /** - * Sets whether to automatically check for application updates - * @param checkUpdate whether to automatically check for application updates - */ - public void setUpdateCheck(boolean checkUpdate); - - /** - * 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); - - /** - * Gets whether to skip the finish screen - * @return whether to skip the finish screen - */ - public boolean getSkipFinish(); - - /** - * Sets whether to skip the finish screen - * @param skipFinish whether to skip the finish screen - */ - public void setSkipFinish(boolean skipFinish); - - - /** - * Gets theCertificate-Download URL - * @return the Certificate-Download URL - */ - public String getDownloadURL(); - - - - /** - * Gets whether to use an existing signature marker. - * - * @return whether to use an existing signature marker - */ - public boolean getUseMarker(); - - /** - * Sets whether to use an existing signature marker. - * - * @param useMarker - * whether to use an existing signature marker - */ - public void setUseMarker(boolean useMarker); - - - /*** - * Extension to the standard use marker implementation - * @param useFields - */ - public void setUseSignatureFields(boolean useFields); - - - /** - * @return if the usage of signatureFields is enabled - */ - public boolean getUseSignatureFields(); - - /** - * @param bool - */ - public void setEnablePlaceholderUsage(boolean bool); - - /** - * @return boolean - */ - public boolean getEnablePlaceholderUsage(); - - - /** - * @param profile set the selected profile - */ - public void setSignatureProfile(Profile profile); - - - /** - * @return selected signature profile as string - */ - public Profile getSignatureProfile(); - - - public void setSaveFilePostFix(String postFix); +public class ConfigurationContainer { + /** + * SLF4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory.getLogger(ConfigurationContainer.class); + + /** the emblem File */ + protected String emblemFile = null; + public String getEmblem() { return this.emblemFile; } + 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; + } + + /** The mobile phone number */ + protected String mobileNumber = null; + public String getMobileNumber() { return this.mobileNumber; } + public void setMobileNumber(String number) { + if(number == null || number.trim().isEmpty()) { + this.mobileNumber = null; + return; + } + this.mobileNumber = MobileBKUHelper.normalizeMobileNumber(number); + } + + /** The mobile phone password */ + public String mobilePassword = null; + + /** Holds the proxy host */ + public String proxyHost = null; + + /** Holds the proxy port number */ + protected int proxyPort = -1; + public int getProxyPort() { return this.proxyPort; } + 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); + } + + /** Holds the proxy username */ + public String proxyUser = null; + + /** Holds the proxy password */ + public String proxyPass = null; + + /** Holds the transparency of the signature placeholder */ + public int placeholderTransparency = Constants.DEFAULT_SIGNATURE_PLACEHOLDER_TRANSPARENCY; + + /** Holds the default BKU to use */ + public BKUs defaultBKU = BKUs.NONE; + + /** Holds the output folder */ + public String outputFolder = null; + + /** Holds the signatureNote */ + public String signatureNote = null; + + /** Holds the locale */ + public Locale locale = null; + + /** Holds the signature locale */ + public Locale signatureLocale = null; + + /** Holds the PDF/A compatibility setting */ + public boolean signaturePDFACompat = false; + + /** Holds the mobile BKU URL */ + public String mobileBKUURL = Constants.DEFAULT_MOBILE_BKU_URL; + + /** Holds the mobile BKU type */ + public MobileBKUs mobileBKUType = ConfigProviderImpl.DEFAULT_MOBILE_BKU_TYPE; + + /** Holds the mobile BKU BASE64 setting */ + protected boolean mobileBKUBase64 = false; + + /** Holds the default signature position */ + public SignaturePosition defaultSignaturePosition = null; + + /** Keystore signing options */ + public Boolean keystoreEnabled = null; + public String keystoreFile = null; + public String keystoreType = null; + public String keystoreAlias = null; + public String keystoreStorePass = null; + public String keystoreKeyPass = null; + + /** Whether to automatically check for updates */ + public boolean updateCheck = true; + + /** Holds the main window size */ + public Point mainWindowSize = null; + + /** Whether to skip the output state */ + public boolean skipFinish = false; + + /** Whether to use an existing signature marker. */ + protected boolean useMarker = false; + public boolean getUseMarker() { return this.useMarker; } + public void setUseMarker(boolean useMarker) { + this.useMarker = useMarker; + if (useMarker) setUseSignatureFields(false); + } + + /** Either QR-Code or signature fields as marker */ + protected boolean useSignatureFields = false; + public boolean getUseSignatureFields() { return this.useSignatureFields; } + public void setUseSignatureFields(boolean useFields) { + this.useSignatureFields = useFields; + if (useFields) setUseMarker(false); + } + + /** describes if the placeholder search is enabled */ + public boolean enabledPlaceholderUsage = false; + + /** The Signature Profile */ + protected Profile signatureProfile = null; + public Profile getSignatureProfile() { + if (this.signatureProfile == null) { + this.signatureProfile = Profile.SIGNATURBLOCK_SMALL; + } + return this.signatureProfile; + } + public void setSignatureProfile(Profile profile) { this.signatureProfile = profile; } + + public String saveFilePostFix = "_signed"; - public String getSaveFilePostFix(); } 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 deleted file mode 100644 index c0c84054..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java +++ /dev/null @@ -1,751 +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.config; - -// Imports -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Locale; - -import at.asit.pdfover.commons.Profile; -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.commons.Constants; -import at.asit.pdfover.gui.bku.mobile.MobileBKUHelper; -import at.asit.pdfover.gui.bku.mobile.MobileBKUs; -import at.asit.pdfover.gui.exceptions.InvalidEmblemFile; -import at.asit.pdfover.gui.exceptions.InvalidPortException; -import at.asit.pdfover.signator.BKUs; -import at.asit.pdfover.signator.SignaturePosition; - -/** - * Implementation of the configuration container - */ -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 proxy port number */ - protected int proxyPort = -1; - - /** Holds the proxy username */ - protected String proxyUser = null; - - /** Holds the proxy password */ - protected String proxyPass = null; - - /** Holds the signatureNote */ - protected String signatureNote = null; - - /** Holds the locale */ - protected Locale locale = null; - - /** Holds the signature locale */ - protected Locale signatureLocale = null; - - /** Holds the PDF/A compatibility setting */ - protected boolean pdfACompat = false; - - /** 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 = ConfigProviderImpl.DEFAULT_MOBILE_BKU_TYPE; - - /** Holds the mobile BKU BASE64 setting */ - protected boolean mobileBKUBase64 = false; - - /** Holds the main window size */ - protected Point mainWindowSize = null; - - /** Holds the default signature position */ - protected SignaturePosition defaultSignaturePosition = null; - - /** Whether keystore signing is enabled */ - protected Boolean keystoreEnabled = null; - - /** Keystore file */ - protected String keystoreFile = null; - - /** Keystore type */ - protected String keystoreType = null; - - /** Keystore alias */ - protected String keystoreAlias = null; - - /** Keystore store password */ - protected String keystoreStorePass = null; - - /** Keystore key password */ - protected String keystoreKeyPass = null; - - /** Whether to automatically check for updates */ - protected boolean updateCheck = true; - - /** Whether to skip the output state */ - protected boolean skipFinish = false; - - /** Default Download URL for certificates*/ - protected String downloadURL = null; - - /** describes if the placeholder search is enabled */ - protected boolean enabledPlaceholderUsage = false; - - /** Whether to use an existing signature marker. */ - protected boolean useMarker = false; - - /** Either QR-Code or signature fields as marker */ - protected boolean useSignatureFields = false; - - /** The Signature Profile */ - protected Profile signatureProfile = null; - - protected String saveFilePostFix = "_signed"; - - /* (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) { - if(number == null || number.trim().isEmpty()) { - this.mobileNumber = null; - return; - } - this.mobileNumber = MobileBKUHelper.normalizeMobileNumber(number); - } - - - /* (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.workflow.config.ConfigurationContainer#getProxyUser() - */ - @Override - public String getProxyUser() { - return this.proxyUser; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setProxyUser(java.lang.String) - */ - @Override - public void setProxyUser(String user) { - this.proxyUser = user; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getProxyPass() - */ - @Override - public String getProxyPass() { - return this.proxyPass; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setProxyPass(java.lang.String) - */ - @Override - public void setProxyPass(String pass) { - this.proxyPass = pass; - } - - - /* (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#getSignatureLocale() - */ - @Override - public Locale getSignatureLocale() { - return this.signatureLocale; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignatureLocale(java.util.Locale) - */ - @Override - public void setSignatureLocale(Locale locale) { - this.signatureLocale = locale; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getSignaturePdfACompat() - */ - @Override - public boolean getSignaturePdfACompat() { - return this.pdfACompat; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setSignaturePdfACompat(boolean) - */ - @Override - public void setSignaturePdfACompat(boolean compat) { - this.pdfACompat = compat; - } - - - /* (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.config.ConfigurationContainer#getMobileBKUBase64() - */ - @Override - public boolean getMobileBKUBase64() { - return this.mobileBKUBase64; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getMobileBKUBase64(boolean) - */ - @Override - public void setMobileBKUBase64(boolean useBase64) { - this.mobileBKUBase64 = useBase64; - } - - - /* (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.config.ConfigurationContainer#getKeyStoreEnabled() - */ - @Override - public Boolean getKeyStoreEnabled() { - return this.keystoreEnabled; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setKeyStoreEnabled(boolean) - */ - @Override - public void setKeyStoreEnabled(Boolean enabled) { - this.keystoreEnabled = enabled; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getKeyStoreFile() - */ - @Override - public String getKeyStoreFile() { - return this.keystoreFile; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setKeyStoreFile(java.lang.String) - */ - @Override - public void setKeyStoreFile(String file) { - this.keystoreFile = file; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getKeyStoreType() - */ - @Override - public String getKeyStoreType() { - return this.keystoreType; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setKeyStoreType(java.lang.String) - */ - @Override - public void setKeyStoreType(String type) { - this.keystoreType = type; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getKeyStoreAlias() - */ - @Override - public String getKeyStoreAlias() { - return this.keystoreAlias; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setKeyStoreAlias(java.lang.String) - */ - @Override - public void setKeyStoreAlias(String alias) { - this.keystoreAlias = alias; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getKeyStoreStorePass() - */ - @Override - public String getKeyStoreStorePass() { - return this.keystoreStorePass; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setKeyStoreStorePass(java.lang.String) - */ - @Override - public void setKeyStoreStorePass(String storePass) { - this.keystoreStorePass = storePass; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getKeyStoreKeyPass() - */ - @Override - public String getKeyStoreKeyPass() { - return this.keystoreKeyPass; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setKeyStoreKeyPass(java.lang.String) - */ - @Override - public void setKeyStoreKeyPass(String keyPass) { - this.keystoreKeyPass = keyPass; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getUpdateCheck() - */ - @Override - public boolean getUpdateCheck() { - return this.updateCheck; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setUpdateCheck(boolean) - */ - @Override - public void setUpdateCheck(boolean checkUpdate) { - this.updateCheck = checkUpdate; - } - - - /* (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; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getSkipFinish() - */ - @Override - public boolean getSkipFinish() { - return this.skipFinish; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setSkipFinish(boolean) - */ - @Override - public void setSkipFinish(boolean skipFinish) { - this.skipFinish = skipFinish; - } - - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setDownloadURL(java.lang.String) - - @Override - public void setDownloadURL(String downloadURL) { - this.downloadURL = downloadURL; - - - }*/ - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getDownloadURL() - */ - @Override - public String getDownloadURL() { - return this.downloadURL; - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getUseMarker() - */ - @Override - public boolean getUseMarker() { - return this.useMarker; - } - - /* - * (non-Javadoc) - * - * @see - * at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setUseMarker( - * boolean) - */ - @Override - public void setUseMarker(boolean useMarker) { - this.useMarker = useMarker; - if (useMarker) setUseSignatureFields(false); - } - - - @Override - public void setUseSignatureFields(boolean useFields) { - this.useSignatureFields = useFields; - if (useFields) setUseMarker(false); - } - - - - @Override - public boolean getUseSignatureFields() { - return this.useSignatureFields; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setEnablePlaceholderUsage(boolean) - */ - @Override - public void setEnablePlaceholderUsage(boolean bool) { - this.enabledPlaceholderUsage = bool; - - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getEnablePlaceholderUsage() - */ - @Override - public boolean getEnablePlaceholderUsage() { - return this.enabledPlaceholderUsage; - } - - - @Override - public Profile getSignatureProfile() { - if (this.signatureProfile == null) { - this.signatureProfile = Profile.SIGNATURBLOCK_SMALL; - } - return this.signatureProfile; - } - - @Override - public String getSaveFilePostFix() { - return this.saveFilePostFix; - } - - @Override - public void setSaveFilePostFix(String postfix){ - this.saveFilePostFix = postfix; - } - - - @Override - public void setSignatureProfile(Profile profile) { - this.signatureProfile = profile; - } - -} |