aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-07-01 10:07:44 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-07-01 10:07:44 +0200
commit6ead42a9814b83f744d29c8c021fb6e685d301f2 (patch)
tree07eddbdcaecc34a840f3671355fffcb0062d4ab5 /pdf-as-lib
parenta1eef5a7fe14d8ba5298ad4b50d0846375796bf5 (diff)
downloadpdf-as-4-6ead42a9814b83f744d29c8c021fb6e685d301f2.tar.gz
pdf-as-4-6ead42a9814b83f744d29c8c021fb6e685d301f2.tar.bz2
pdf-as-4-6ead42a9814b83f744d29c8c021fb6e685d301f2.zip
added generation of dynamic child signature profile #25
Diffstat (limited to 'pdf-as-lib')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/Configuration.java26
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsConfigurationConstants.java40
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java23
3 files changed, 89 insertions, 0 deletions
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<String, String> source = getValuesPrefix(originalPrefix);
+
+ Iterator<String> 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<Object> keyIterator = overwrittenProperties.keySet().iterator();
+ while(keyIterator.hasNext()) {
+ String key = keyIterator.next().toString();
+
+ if(key.startsWith(configurationPrefix)) {
+ overwrittenProperties.remove(key);
+ }
+ }
+ }
+
}