From c1af1550afe468537f480b399896d477f950c7d1 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 17 Dec 2013 11:08:51 +0100 Subject: Added default value for Signature Profile Entries --- .../settings/DefaultSignatureProfileSettings.java | 75 ++++++++++++++++++++++ .../common/settings/SignatureProfileEntry.java | 6 ++ .../common/settings/SignatureProfileSettings.java | 24 +++++++ .../at/gv/egiz/pdfas/common/utils/DNUtils.java | 3 + .../java/at/gv/egiz/sl/util/BaseSLConnector.java | 2 +- 5 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/DefaultSignatureProfileSettings.java diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/DefaultSignatureProfileSettings.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/DefaultSignatureProfileSettings.java new file mode 100644 index 00000000..9cd8cfea --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/DefaultSignatureProfileSettings.java @@ -0,0 +1,75 @@ +package at.gv.egiz.pdfas.common.settings; + +import java.util.HashMap; +import java.util.Map; + +public class DefaultSignatureProfileSettings { + + private static Map profileSettings = new HashMap(); + + public static final String KEY_SIG_SUBJECT = "SIG_SUBJECT"; + public static final String KEY_SIG_SUBJECT_DEFAULT = "Unterzeichner"; + + public static final String KEY_SIG_ISSUER = "SIG_ISSUER"; + public static final String KEY_SIG_ISSUER_DEFAULT = "Aussteller-Zertifikat"; + + public static final String KEY_SIG_NUMBER = "SIG_NUMBER"; + public static final String KEY_SIG_NUMBER_DEFAULT = "Serien-Nr."; + + public static final String KEY_SIG_KZ = "SIG_KZ"; + public static final String KEY_SIG_KZ_DEFAULT = "Methode"; + + public static final String KEY_SIG_ID = "SIG_ID"; + public static final String KEY_SIG_ID_DEFAULT = "Parameter"; + + public static final String KEY_SIG_META = "SIG_META"; + public static final String KEY_SIG_META_DEFAULT = "Pr\u00fcfinformation"; + + public static final String KEY_SIG_DATE = "SIG_DATE"; + public static final String KEY_SIG_DATE_DEFAULT = "Datum/Zeit-UTC"; + + public static final String VALUE_SIG_SUBJECT_DEFAULT = "${subject.T != null ? (subject.T + \" \") : \"\"}${subject.CN}"; + + public static final String VALUE_SIG_ISSUER_DEFAULT = "${issuer.DN}"; + + public static final String VALUE_SIG_NUMBER_DEFAULT = "${sn}"; + + public static final String VALUE_SIG_KZ_DEFAULT = ""; + + public static final String VALUE_SIG_ID_DEFAULT = ""; + + public static final String VALUE_SIG_META_DEFAULT = "Informationen zur Pr\u00FCfung der elektronischen Signatur finden Sie unter: https://www.signaturpruefung.gv.at\n\nInformationen zur Pr\u00FCfung des Ausdrucks finden Sie unter: https://www.behoerde.gv.at/el_signatur/"; + + public static final String VALUE_SIG_DATE_DEFAULT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; + + static { + profileSettings.put(KEY_SIG_SUBJECT, new SignatureProfileEntry(KEY_SIG_SUBJECT, KEY_SIG_SUBJECT_DEFAULT, VALUE_SIG_SUBJECT_DEFAULT) ); + profileSettings.put(KEY_SIG_ISSUER, new SignatureProfileEntry(KEY_SIG_ISSUER, KEY_SIG_ISSUER_DEFAULT, VALUE_SIG_ISSUER_DEFAULT) ); + profileSettings.put(KEY_SIG_NUMBER, new SignatureProfileEntry(KEY_SIG_NUMBER, KEY_SIG_NUMBER_DEFAULT, VALUE_SIG_NUMBER_DEFAULT) ); + profileSettings.put(KEY_SIG_KZ, new SignatureProfileEntry(KEY_SIG_KZ, KEY_SIG_KZ_DEFAULT, VALUE_SIG_KZ_DEFAULT) ); + profileSettings.put(KEY_SIG_ID, new SignatureProfileEntry(KEY_SIG_ID, KEY_SIG_ID_DEFAULT, VALUE_SIG_ID_DEFAULT) ); + profileSettings.put(KEY_SIG_META, new SignatureProfileEntry(KEY_SIG_META, KEY_SIG_META_DEFAULT, VALUE_SIG_META_DEFAULT) ); + profileSettings.put(KEY_SIG_DATE, new SignatureProfileEntry(KEY_SIG_DATE, KEY_SIG_DATE_DEFAULT, VALUE_SIG_DATE_DEFAULT) ); + } + + public static Map getDefaultValues() { + return profileSettings; + } + + public static String getDefaultKeyValue(String key) { + SignatureProfileEntry entry = profileSettings.get(key); + if(entry != null) { + return entry.getValue(); + } + return null; + } + + public static String getDefaultKeyCaption(String key) { + SignatureProfileEntry entry = profileSettings.get(key); + if(entry != null) { + return entry.getCaption(); + } + return null; + } + +} diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileEntry.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileEntry.java index 3df929b1..d8842014 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileEntry.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileEntry.java @@ -7,6 +7,12 @@ public class SignatureProfileEntry { public SignatureProfileEntry() { } + + public SignatureProfileEntry(String key, String caption, String value) { + this.key = key; + this.caption = caption; + this.value = value; + } public String getKey() { return key; diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileSettings.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileSettings.java index 5c443039..456e58b2 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileSettings.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileSettings.java @@ -46,6 +46,15 @@ public class SignatureProfileSettings implements IProfileConstants { String valueValue = values.get(valuesPrefix + KEY_SEPARATOR + key); + // Lookup default values + if(valueKey == null) { + valueKey = DefaultSignatureProfileSettings.getDefaultKeyCaption(key); + } + + if(valueValue == null) { + valueValue = DefaultSignatureProfileSettings.getDefaultKeyValue(key); + } + SignatureProfileEntry entry = new SignatureProfileEntry(); entry.setKey(key); entry.setCaption(valueKey); @@ -66,6 +75,11 @@ public class SignatureProfileSettings implements IProfileConstants { String valueValue = values.get(valuesPrefix + KEY_SEPARATOR + key); + // Lookup default values + if(valueValue == null) { + valueValue = DefaultSignatureProfileSettings.getDefaultKeyValue(key); + } + SignatureProfileEntry entry = profileInformations.get(key); if (entry == null) { entry = new SignatureProfileEntry(); @@ -100,6 +114,16 @@ public class SignatureProfileSettings implements IProfileConstants { logger.debug(" Settings: " + key + " : " + value); } + + + Iterator dumpIterator = + profileInformations.values().iterator(); + + logger.debug("Settings for profile {}", profileID); + while(dumpIterator.hasNext()) { + SignatureProfileEntry entry = dumpIterator.next(); + logger.debug(" " + entry.toString()); + } } public String getCaption(String key) { diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/DNUtils.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/DNUtils.java index 429151ee..d61a1694 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/DNUtils.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/DNUtils.java @@ -28,6 +28,9 @@ public class DNUtils { logger.debug(rdn.getType() + " = " + rdn.getValue().toString()); map.put(rdn.getType(), rdn.getValue().toString()); } + + map.put("DN", dn); + logger.debug("DN = " + dn); return map; } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java index b02e4f1a..59e5d7cf 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java @@ -58,7 +58,7 @@ public abstract class BaseSLConnector implements ISLConnector { byte[] data = new byte[dataSize]; int currentdataOff = 0; - Arrays.fill(data, (byte)0); + Arrays.fill(data, (byte)0x0); int[] exclude_range = new int[byteRange.length-2]; for(int i = 0; i < byteRange.length; i = i + 2) { int offset = byteRange[i]; -- cgit v1.2.3