From 6ead42a9814b83f744d29c8c021fb6e685d301f2 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 1 Jul 2014 10:07:44 +0200 Subject: added generation of dynamic child signature profile #25 --- .../at/gv/egiz/pdfas/lib/api/Configuration.java | 26 ++++++++++++++ .../pdfas/lib/api/PdfAsConfigurationConstants.java | 40 ++++++++++++++++++++++ .../lib/impl/configuration/ConfigurationImpl.java | 23 +++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsConfigurationConstants.java (limited to 'pdf-as-lib/src/main/java') diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/Configuration.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/Configuration.java index 54046e39..b56bf8c7 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/Configuration.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/Configuration.java @@ -51,4 +51,30 @@ public interface Configuration { * @param value The configuration value */ public void setValue(String key, String value); + + /** + * Clone configuration values at runtime only + * All configuration values with originalPrefix are copied and + * inserted as clonedPrefix + * + * Example usage might be the generation of dynamic signature profiles: + * cloneProfile(PdfAsConfigurationConstants.SIG_OBJECT_PREFIX + "SIGNATURBLOCK_DE", + * PdfAsConfigurationConstants.SIG_OBJECT_PREFIX + "MY_DYNAMIC_PROFILE"); + * + * @param originalPrefix The original configuration key prefix + * @param clonedPrefix The cloned configuration key prefix + */ + public void cloneProfile(String originalPrefix, String clonedPrefix); + + /** + * Removes all dynamically configured values with a given prefix. + * + * It can be used to remove a profile during runtime. + * + * Example usage might be the generation of dynamic signature profiles: + * removeProfile(PdfAsConfigurationConstants.SIG_OBJECT_PREFIX + "MY_DYNAMIC_PROFILE"); + * + * @param configurationPrefix The configuration key prefix + */ + public void removeProfile(String configurationPrefix); } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsConfigurationConstants.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsConfigurationConstants.java new file mode 100644 index 00000000..da0b3487 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsConfigurationConstants.java @@ -0,0 +1,40 @@ +package at.gv.egiz.pdfas.lib.api; + +/** + * Collection of useful configuration key + */ +public interface PdfAsConfigurationConstants { + /** + * Signature object Prefix + */ + public static final String SIG_OBJECT_PREFIX = "sig_obj."; + + /** + * MOA SS Signing Key Identifier + */ + public static final String MOA_SS_KEY_IDENTIFIER = "moa.sign.KeyIdentifier"; + + /** + * MOA SS Signing Certificate + */ + public static final String MOA_SS_KEY_CERTIFICATE = "moa.sign.Certificate"; + + + /** + * MOA Trustprofile configuration Key + */ + public static final String MOA_TRUSTPROFILE_ID = "moa.verify.TrustProfileID"; + + + /** + * MOA Verify URL configuration Key + */ + public static final String MOA_VERIFY_URL = "moa.verify.url"; + + + /** + * MOA Sign URL configuration Key + */ + public static final String MOA_SIGN_URL = "moa.sign.url"; + +} diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java index c767b990..a553fcd3 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java @@ -139,5 +139,28 @@ public class ConfigurationImpl implements ISettings, Configuration { return this.settings.getWorkingDirectory(); } + public void cloneProfile(String originalPrefix, String clonedPrefix) { + Map source = getValuesPrefix(originalPrefix); + + Iterator keyIt = source.keySet().iterator(); + + while(keyIt.hasNext()) { + String origKey = keyIt.next(); + String cloneKey = origKey.replace(originalPrefix, clonedPrefix); + this.overwrittenProperties.setProperty(cloneKey, source.get(origKey)); + } + } + + public void removeProfile(String configurationPrefix) { + Iterator keyIterator = overwrittenProperties.keySet().iterator(); + while(keyIterator.hasNext()) { + String key = keyIterator.next().toString(); + + if(key.startsWith(configurationPrefix)) { + overwrittenProperties.remove(key); + } + } + } + } -- cgit v1.2.3