aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/pdfas
diff options
context:
space:
mode:
authorrpiazzi <rpiazzi@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2011-08-22 09:20:07 +0000
committerrpiazzi <rpiazzi@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2011-08-22 09:20:07 +0000
commit0c1b6cf880ef8801ca884689c6172027b8910240 (patch)
tree5f1cac1a59196df97677373263eae13d458da59c /src/main/java/at/gv/egiz/pdfas
parent1f1ac1f59eaba62eb899ecd8f7ec62c6c79f0e56 (diff)
downloadpdf-as-3-0c1b6cf880ef8801ca884689c6172027b8910240.tar.gz
pdf-as-3-0c1b6cf880ef8801ca884689c6172027b8910240.tar.bz2
pdf-as-3-0c1b6cf880ef8801ca884689c6172027b8910240.zip
Changed to allow a static SIG_SUBJECT to be taken from config file (within method: protected void fillReplacesWithValues(final IncrementalUpdateInformation iui)) when no override value is given through (SignParameters:setProfileOverrideValue(String key, String value))
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@795 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/signator/binary/BinarySignator_1_0_0.java43
1 files changed, 35 insertions, 8 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 c8ac073..8757110 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
@@ -184,6 +184,7 @@ public class BinarySignator_1_0_0 implements Signator
List invisible_field_definitions = new ArrayList();
boolean isKZInvisible = false;
String invKZString = null;
+
for (int i = 0; i < all_invisible_field_definitions.size(); i++)
{
SignatureFieldDefinition sfd = (SignatureFieldDefinition) all_invisible_field_definitions.get(i);
@@ -204,11 +205,23 @@ public class BinarySignator_1_0_0 implements Signator
invisible_field_definitions.add(sfd);
}
+ //check if signature block is invisible, and if so and if also signature block is positioned
+ //on a new page, prevent pdf-as to do that, because why should make a new page just for an invisible block
+ //added by rpiazzi
+ /*if (signature_object.getSignatureTypeDefinition().getInvisibleFieldDefinitions().size()==SignatureTypes.REQUIRED_SIG_KEYS.length) {
+ if (pi.isMakeNewPage()) {
+ int pageNumber = pi.getPage();
+ pi = new PositioningInstruction(false, pageNumber-1, 0, 0);
+ }
+ }*/
+ //end added
+
IncrementalUpdateInformation iui = IncrementalUpdateHelper.writeIncrementalUpdate(pdfDataSource, pdf_table, profile, pi, variable_field_definitions, all_field_definitions, invisible_field_definitions, invKZString, timeStamper, null, signature_object);
iui.invisible_field_definitions = invisible_field_definitions;
+
iui.invisibleKZString = invKZString;
-
+
String temp_string = iui.temp_ir_number + " " + iui.temp_ir_generation + " obj"; //$NON-NLS-1$//$NON-NLS-2$
byte[] temp_bytes = ArrayUtils.add(temp_string.getBytes("US-ASCII"), 0, (byte) 0x0A);
int temp_start = ByteArrayUtils.lastIndexOf(iui.signed_pdf, temp_bytes);
@@ -341,22 +354,36 @@ public class BinarySignator_1_0_0 implements Signator
OgnlUtil ognl = new OgnlUtil(ognlCtx);
OverridePropertyHolder.setOgnlUtil(ognl);
-
- while (it.hasNext()) {
- ReplaceInfo ri = (ReplaceInfo) it.next();
+ 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
+ } 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);
- }
+ } else if (overrideVal == null) {
+ //If SUBJECT is not overridden and and also isn't an expression
+ //check whether a set value for subject exists.
+ //In this case take the value from the config file.
+ //Added by rpiazzi to make a static signator possible without having
+ //to override it any time
+ if (ri.sfd.field_name.equals(SignatureTypes.SIG_SUBJECT)) {
+ if (ri.sfd.value.length()!=0) {
+ ri.value = ri.sfd.value;
+ }
+ else {
+ ri.value = iui.signed_signature_object.retrieveStringValue(ri.sfd.field_name);
+ }
+ }
+ else {
+ ri.value = iui.signed_signature_object.retrieveStringValue(ri.sfd.field_name);
+ }
+ }
}
} finally {
OverridePropertyHolder.removeOgnlUtil();