aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java52
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/signator/textual/TextualSignator_1_0_0.java44
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java28
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureEntry.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java16
5 files changed, 93 insertions, 49 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java b/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java
index 4b6f483..3d4be31 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java
@@ -43,6 +43,7 @@ import at.gv.egiz.pdfas.impl.signator.IncrementalUpdateHelper;
import at.gv.egiz.pdfas.utils.OgnlUtil;
import at.knowcenter.wag.egov.egiz.PdfAS;
import at.knowcenter.wag.egov.egiz.PdfASID;
+import at.knowcenter.wag.egov.egiz.cfg.OverridePropertyHolder;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.NormalizeException;
import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
@@ -322,28 +323,35 @@ public class BinarySignator_1_0_0 implements Signator
*/
protected void fillReplacesWithValues(final IncrementalUpdateInformation iui)
{
- Iterator it = iui.replaces.iterator();
- HashMap ognlCtx = new HashMap();
- ognlCtx.put("iui", iui);
- ognlCtx.put("sso", iui.signed_signature_object);
- ognlCtx.put("issuer", iui.signed_signature_object.getIssuerDNMap());
- ognlCtx.put("subject", iui.signed_signature_object.getSubjectDNMap());
- OgnlUtil ognl = new OgnlUtil(ognlCtx);
-
- while (it.hasNext())
- {
- ReplaceInfo ri = (ReplaceInfo) it.next();
-
- // dferbas
- if (ognl.containsExpression(ri.sfd.value)) {
- // evaluate expression
- String res = ognl.compileMessage(ri.sfd.value);
-
- ri.value = this.normalizer.normalize(res, true);
-
- } else {
- ri.value = iui.signed_signature_object.retrieveStringValue(ri.sfd.field_name);
- }
+ try {
+ Iterator it = iui.replaces.iterator();
+ HashMap ognlCtx = new HashMap();
+ ognlCtx.put("iui", iui);
+ ognlCtx.put("sso", iui.signed_signature_object);
+ ognlCtx.put("issuer", iui.signed_signature_object.getIssuerDNMap());
+ ognlCtx.put("subject", iui.signed_signature_object.getSubjectDNMap());
+ OgnlUtil ognl = new OgnlUtil(ognlCtx);
+
+ OverridePropertyHolder.setOgnlUtil(ognl);
+
+ while (it.hasNext()) {
+ ReplaceInfo ri = (ReplaceInfo) it.next();
+ String overrideVal = OverridePropertyHolder.getProperty(ri.sfd.field_name);
+ if (overrideVal != null) {
+ ri.sfd.value = overrideVal;
+ ri.value = overrideVal;
+ } else if (ognl.containsExpression(ri.sfd.value)) { // dferbas
+ // evaluate expression
+ String res = ognl.compileMessage(ri.sfd.value);
+
+ ri.value = this.normalizer.normalize(res, true);
+
+ } else if (overrideVal == null) {
+ ri.value = iui.signed_signature_object.retrieveStringValue(ri.sfd.field_name);
+ }
+ }
+ } finally {
+ OverridePropertyHolder.removeOgnlUtil();
}
}
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/signator/textual/TextualSignator_1_0_0.java b/src/main/java/at/gv/egiz/pdfas/impl/signator/textual/TextualSignator_1_0_0.java
index 942814a..b29f0e6 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/signator/textual/TextualSignator_1_0_0.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/signator/textual/TextualSignator_1_0_0.java
@@ -33,6 +33,7 @@ import at.gv.egiz.pdfas.impl.signator.IncrementalUpdateHelper;
import at.gv.egiz.pdfas.utils.OgnlUtil;
import at.knowcenter.wag.egov.egiz.PdfAS;
import at.knowcenter.wag.egov.egiz.PdfASID;
+import at.knowcenter.wag.egov.egiz.cfg.OverridePropertyHolder;
import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
import at.knowcenter.wag.egov.egiz.pdf.IncrementalUpdateInformation;
@@ -162,6 +163,9 @@ public class TextualSignator_1_0_0 implements Signator
{
throw new SignatorException(pe);
}
+ finally {
+ OverridePropertyHolder.removeOgnlUtil();
+ }
// catch (IOException e)
// {
// throw new SignatorException(ErrorCode.DOCUMENT_CANNOT_BE_READ, e);
@@ -170,27 +174,27 @@ public class TextualSignator_1_0_0 implements Signator
private void evaluteOgnl(SignatureObject so, TextualSignatorInformation tsi) {
HashMap ognlCtx = new HashMap();
- //ognlCtx.put("iui", tsi.);
- ognlCtx.put("sso", tsi.signSignatureObject);
- ognlCtx.put("issuer", tsi.signSignatureObject.getIssuerDNMap());
- ognlCtx.put("subject", tsi.signSignatureObject.getSubjectDNMap());
- OgnlUtil ognl = new OgnlUtil(ognlCtx);
-
- Iterator it = so.getSigEntries().values().iterator();
- while (it.hasNext())
- {
- SignatureEntry se = (SignatureEntry) it.next();
+ //ognlCtx.put("iui", tsi.);
+ ognlCtx.put("sso", tsi.signSignatureObject);
+ ognlCtx.put("issuer", tsi.signSignatureObject.getIssuerDNMap());
+ ognlCtx.put("subject", tsi.signSignatureObject.getSubjectDNMap());
+ OgnlUtil ognl = new OgnlUtil(ognlCtx);
+ OverridePropertyHolder.setOgnlUtil(ognl);
+
+ Iterator it = so.getSigEntries().values().iterator();
+ while (it.hasNext())
+ {
+ SignatureEntry se = (SignatureEntry) it.next();
+
+ if (ognl.containsExpression(se.getValue())) {
+ // evaluate expression
+ String res = ognl.compileMessage(se.getValue());
+ se.setValue(res);
+ //ri.value = this.normalizer.normalize(res, true);
- if (ognl.containsExpression(se.getValue())) {
- // evaluate expression
- String res = ognl.compileMessage(se.getValue());
- se.setValue(res);
- //ri.value = this.normalizer.normalize(res, true);
-
- }
- }
-
-}
+ }
+ }
+ }
public String getEncoding() {
// old signatures used this encoding implicit most of the time (windows default)
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java
index 33a0e4a..049ce06 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/OverridePropertyHolder.java
@@ -3,6 +3,7 @@ package at.knowcenter.wag.egov.egiz.cfg;
import java.util.Properties;
import at.gv.egiz.pdfas.api.sign.SignParameters;
+import at.gv.egiz.pdfas.utils.OgnlUtil;
/**
* Thread local holder for profile override values.
@@ -16,6 +17,7 @@ public class OverridePropertyHolder {
private static ThreadLocal propHolder = new ThreadLocal() {
protected Object initialValue() { return new Properties();};
};
+ private static ThreadLocal ognlHolder = new ThreadLocal();
public static Properties getOverrideProps() {
return (Properties) propHolder.get();
@@ -30,12 +32,32 @@ public class OverridePropertyHolder {
}
public static String getProperty(String key) {
- return getOverrideProps().getProperty(key);
+
+ String res = getOverrideProps().getProperty(key);
+ if (res != null) {
+ OgnlUtil ognl = getOgnl();
+ if (ognl != null && ognl.containsExpression(res)) {
+ // evaluate expression
+ res = ognl.compileMessage(res);
+ }
+ }
+ return res;
}
- public static void removeProperties() {
- propHolder.remove();
+ public static void removeProperties() {
propHolder.set(new Properties());
}
+
+ public static void setOgnlUtil(OgnlUtil ognl) {
+ ognlHolder.set(ognl);
+ }
+
+ private static OgnlUtil getOgnl() {
+ return (OgnlUtil) ognlHolder.get();
+ }
+
+ public static void removeOgnlUtil() {
+ ognlHolder.set(null);
+ }
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureEntry.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureEntry.java
index 2782f2b..b62e504 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureEntry.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureEntry.java
@@ -53,6 +53,8 @@ public class SignatureEntry implements Serializable {
* The starting index position of the key if it is found in the signature text.
*/
private int startIndex_ = -1;
+
+ public boolean isPlaceholder = false;
/**
* The empty constructor.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
index 44363d7..25e996e 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureObject.java
@@ -357,7 +357,11 @@ public class SignatureObject implements Serializable
* @return <code>true</code> if a new signature value is created,
* <code>false</code> otherwise
*/
- public boolean setSigValue(String key, String value)
+ public boolean setSigValue(String key, String value) {
+ return setSigValue(key, value, false);
+ }
+
+ public boolean setSigValue(String key, String value, boolean placeholder)
{
SignatureEntry sig_entry = null;
boolean is_new = false;
@@ -377,6 +381,7 @@ public class SignatureObject implements Serializable
value = removeAllWhiteSpaces(value);
}
sig_entry.setValue(value);
+ sig_entry.isPlaceholder = placeholder;
return is_new;
}
@@ -428,16 +433,19 @@ public class SignatureObject implements Serializable
{
String value = null;
+ SignatureEntry sigEntry = null;
if (sigEntries_.containsKey(key))
{
- value = ((SignatureEntry) sigEntries_.get(key)).getValue();
+ sigEntry = (SignatureEntry) sigEntries_.get(key);
+ value = sigEntry.getValue();
}
if (value == null && SignatureTypes.SIG_NORM.equals(key))
{
value = normalizer_.getVersion();
}
+
String overrideVal = OverridePropertyHolder.getProperty(key);
- if (overrideVal != null) {
+ if (value != null && sigEntry != null && !sigEntry.isPlaceholder && overrideVal != null) { // TODO this!! SignatureEntry.isPlaceholder
value = overrideVal;
if (logger_.isDebugEnabled()) {
logger_.debug("Using override property for key '" + key + "' = " + value);
@@ -1742,7 +1750,7 @@ public class SignatureObject implements Serializable
variable_fields.add(sfd);
- setSigValue(sfd.field_name, value_string);
+ setSigValue(sfd.field_name, value_string, true);
}
}