From 22c56e9d4b8c8ba6bea4993d7bd3cc0a83a23d8b Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Thu, 12 Dec 2013 11:51:36 +0100 Subject: added certificate serial number for OGNL resolver --- .../common/settings/SignatureProfileSettings.java | 263 +++++++++++---------- 1 file changed, 135 insertions(+), 128 deletions(-) (limited to 'pdf-as-common/src/main/java/at/gv/egiz/pdfas') 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 ff5e5d29..4e797ce6 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 @@ -7,135 +7,142 @@ import java.util.*; public class SignatureProfileSettings implements IProfileConstants { - private static final Logger logger = LoggerFactory.getLogger(SignatureProfileSettings.class); + private static final Logger logger = LoggerFactory + .getLogger(SignatureProfileSettings.class); - private Map profileInformations = new HashMap(); + private Map profileInformations = new HashMap(); + + private Map profileSettings = new HashMap(); + + private String profileID; + + private ISettings configuration; + + public SignatureProfileSettings(String profileID, ISettings configuration) { + this.profileID = profileID; + String profilePrefix = SIG_OBJ + profileID + KEY_SEPARATOR; + String keysPrefix = profilePrefix + PROFILE_KEY; + String valuesPrefix = profilePrefix + PROFILE_VALUE; + String tablePrefix = profilePrefix + TABLE; + this.configuration = configuration; + + logger.debug("Reading Profile: " + profileID); + logger.debug("Keys Prefix: " + keysPrefix); + logger.debug("Values Prefix: " + valuesPrefix); + logger.debug("Table Prefix: " + tablePrefix); + + Map keys = configuration.getValuesPrefix(keysPrefix); + Map values = configuration + .getValuesPrefix(valuesPrefix); + + if (keys != null) { + Iterator keyIterator = keys.keySet().iterator(); + + while (keyIterator.hasNext()) { + String key = keyIterator.next(); + key = key.substring(key.lastIndexOf('.') + 1); + String valueKey = keys.get(keysPrefix + KEY_SEPARATOR + key); + + String valueValue = values.get(valuesPrefix + KEY_SEPARATOR + + key); + + SignatureProfileEntry entry = new SignatureProfileEntry(); + entry.setKey(key); + entry.setCaption(valueKey); + entry.setValue(valueValue); + profileInformations.put(key, entry); + logger.debug(" " + entry.toString()); + } + } + + if (values != null) { + // Find entries where only values exists + Iterator valuesIterator = values.keySet().iterator(); + + while (valuesIterator.hasNext()) { + String key = valuesIterator.next(); + key = key.substring(key.lastIndexOf('.') + 1); + + String valueValue = values.get(valuesPrefix + KEY_SEPARATOR + + key); + + SignatureProfileEntry entry = profileInformations.get(key); + if (entry == null) { + entry = new SignatureProfileEntry(); + entry.setKey(key); + entry.setCaption(null); + entry.setValue(valueValue); + profileInformations.put(key, entry); + } + + logger.debug(" " + entry.toString()); + } + } + + Map others = configuration + .getValuesPrefix(profilePrefix); + + Iterator otherIterator = others.keySet().iterator(); + + while (otherIterator.hasNext()) { + String key = otherIterator.next(); + + logger.trace("Checking key " + key); + if (key.startsWith(keysPrefix) || key.startsWith(valuesPrefix) + || key.startsWith(tablePrefix)) { + continue; + } + + String value = others.get(key); + key = key.substring(key.lastIndexOf('.') + 1); + + profileSettings.put(key, others.get(value)); + + logger.debug(" Settings: " + key + " : " + value); + } + } + + public String getCaption(String key) { + SignatureProfileEntry entry = profileInformations.get(key); + if (entry != null) { + return entry.getCaption(); + } + return null; + } - private Map profileSettings = new HashMap(); - - private String profileID; - - private ISettings configuration; - - public SignatureProfileSettings(String profileID, ISettings configuration) { - this.profileID = profileID; - String profilePrefix = SIG_OBJ + profileID + KEY_SEPARATOR; - String keysPrefix = profilePrefix + PROFILE_KEY; - String valuesPrefix = profilePrefix + PROFILE_VALUE; - String tablePrefix = profilePrefix + TABLE; - this.configuration = configuration; - - logger.debug("Reading Profile: " + profileID); - logger.debug("Keys Prefix: " + keysPrefix); - logger.debug("Values Prefix: " + valuesPrefix); - logger.debug("Table Prefix: " + tablePrefix); - - Map keys = configuration.getValuesPrefix(keysPrefix); - Map values = configuration.getValuesPrefix(valuesPrefix); - - Iterator keyIterator = keys.keySet().iterator(); - - while(keyIterator.hasNext()) { - String key = keyIterator.next(); - key = key.substring(key.lastIndexOf('.') + 1); - String valueKey = keys.get(keysPrefix + KEY_SEPARATOR + key); - - String valueValue = values.get(valuesPrefix + KEY_SEPARATOR + key); - - - SignatureProfileEntry entry = new SignatureProfileEntry(); - entry.setKey(key); - entry.setCaption(valueKey); - entry.setValue(valueValue); - profileInformations.put(key, entry); - logger.debug(" " + entry.toString()); - } - - // Find entries where only values exists - Iterator valuesIterator = values.keySet().iterator(); - - while(valuesIterator.hasNext()) { - String key = valuesIterator.next(); - key = key.substring(key.lastIndexOf('.') + 1); - - String valueValue = values.get(valuesPrefix + KEY_SEPARATOR + key); - - SignatureProfileEntry entry = profileInformations.get(key); - if(entry == null) { - entry = new SignatureProfileEntry(); - entry.setKey(key); - entry.setCaption(null); - entry.setValue(valueValue); - profileInformations.put(key, entry); - } - - logger.debug(" " + entry.toString()); - } - - Map others = configuration.getValuesPrefix(profilePrefix); - - Iterator otherIterator = others.keySet().iterator(); - - while(otherIterator.hasNext()) { - String key = otherIterator.next(); - - logger.trace("Checking key " + key); - if( key.startsWith(keysPrefix) || - key.startsWith(valuesPrefix) || - key.startsWith(tablePrefix)) { - continue; - } - - String value = others.get(key); - key = key.substring(key.lastIndexOf('.') + 1); - - profileSettings.put(key, others.get(value)); - - logger.debug(" Settings: " + key + " : " + value); - } - } - - public String getCaption(String key) { - SignatureProfileEntry entry = profileInformations.get(key); - if(entry != null) { - return entry.getCaption(); - } - return null; - } - - protected String getDefaultValue(String key) { - String profilePrefix = SIG_OBJ + profileID + KEY_SEPARATOR; - logger.debug("Searching default value for: " + key); - if(key.startsWith(profilePrefix)) { - key = key.substring(profilePrefix.length()); - } - key = "default." + key; + protected String getDefaultValue(String key) { + String profilePrefix = SIG_OBJ + profileID + KEY_SEPARATOR; + logger.debug("Searching default value for: " + key); + if (key.startsWith(profilePrefix)) { + key = key.substring(profilePrefix.length()); + } + key = "default." + key; logger.debug("Searching default value for: " + key); - return this.configuration.getValue(key); - } - - public String getValue(String key) { - logger.debug("Searching: " + key); - SignatureProfileEntry entry = profileInformations.get(key); - if(entry != null) { - String value = entry.getValue(); - - if(value == null) { - // TODO: try to find default value for key! - return getDefaultValue(key); - } - - return value; - } - // TODO: try to find default value for key! - return getDefaultValue(key); - } - - public String getProfileID() { - return profileID; - } - - public String getSigningReason() { - return this.getValue(SIGNING_REASON); - } + return this.configuration.getValue(key); + } + + public String getValue(String key) { + logger.debug("Searching: " + key); + SignatureProfileEntry entry = profileInformations.get(key); + if (entry != null) { + String value = entry.getValue(); + + if (value == null) { + // TODO: try to find default value for key! + return getDefaultValue(key); + } + + return value; + } + // TODO: try to find default value for key! + return getDefaultValue(key); + } + + public String getProfileID() { + return profileID; + } + + public String getSigningReason() { + return this.getValue(SIGNING_REASON); + } } -- cgit v1.2.3