aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2013-12-12 11:51:36 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2013-12-12 11:51:36 +0100
commit22c56e9d4b8c8ba6bea4993d7bd3cc0a83a23d8b (patch)
tree331b855082e9e7ff25297836f97234792ec617c6
parent49229a4f8480b497265eeb2372cb73d2a5ec010e (diff)
downloadpdf-as-4-22c56e9d4b8c8ba6bea4993d7bd3cc0a83a23d8b.tar.gz
pdf-as-4-22c56e9d4b8c8ba6bea4993d7bd3cc0a83a23d8b.tar.bz2
pdf-as-4-22c56e9d4b8c8ba6bea4993d7bd3cc0a83a23d8b.zip
added certificate serial number for OGNL resolver
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/SignatureProfileSettings.java263
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java2
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/SignatureProfileConfiguration.java2
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateResolver.java2
4 files changed, 140 insertions, 129 deletions
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<String, SignatureProfileEntry> profileInformations = new HashMap<String, SignatureProfileEntry>();
+ private Map<String, SignatureProfileEntry> profileInformations = new HashMap<String, SignatureProfileEntry>();
+
+ private Map<String, String> profileSettings = new HashMap<String, String>();
+
+ 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<String, String> keys = configuration.getValuesPrefix(keysPrefix);
+ Map<String, String> values = configuration
+ .getValuesPrefix(valuesPrefix);
+
+ if (keys != null) {
+ Iterator<String> 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<String> 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<String, String> others = configuration
+ .getValuesPrefix(profilePrefix);
+
+ Iterator<String> 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<String, String> profileSettings = new HashMap<String, String>();
-
- 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<String, String> keys = configuration.getValuesPrefix(keysPrefix);
- Map<String, String> values = configuration.getValuesPrefix(valuesPrefix);
-
- Iterator<String> 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<String> 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<String, String> others = configuration.getValuesPrefix(profilePrefix);
-
- Iterator<String> 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);
+ }
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java
index fc245592..89408bc8 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java
@@ -524,6 +524,8 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants {
.getDefaultPositioning();
}
+ logger.debug("using Positioning: " + posString);
+
boolean legacy32Position = signatureProfileConfiguration.getLegacy32Positioning();
TablePos tablePos = null;
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/SignatureProfileConfiguration.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/SignatureProfileConfiguration.java
index b8a0139a..b2d5207d 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/SignatureProfileConfiguration.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/SignatureProfileConfiguration.java
@@ -20,7 +20,7 @@ public class SignatureProfileConfiguration extends SpecificBaseConfiguration
}
public String getDefaultPositioning() {
- String key = SIG_OBJECT + SEPERATOR + profileID + SEPERATOR + TABLE + SEPERATOR + POS;
+ String key = SIG_OBJECT + SEPERATOR + profileID + SEPERATOR + POS;
return this.configuration.getValue(key);
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateResolver.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateResolver.java
index 78dcbe23..7f8b0a0b 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateResolver.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/CertificateResolver.java
@@ -26,6 +26,8 @@ public class CertificateResolver implements IResolver {
this.certificate = certificate;
this.ctx = new OgnlContext();
+ this.ctx.put("sn", this.certificate.getSerialNumber().toString());
+
try {
Map<String, String> issuerDNMap = DNUtils.dnToMap(certificate.getIssuerDN().getName());
this.ctx.put("issuer", issuerDNMap);