aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-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();