diff options
author | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-12-15 11:54:14 +0000 |
---|---|---|
committer | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2009-12-15 11:54:14 +0000 |
commit | c699751c11265ec9f00d093cbc3346b8a8ea1b0d (patch) | |
tree | c02f1a2e5f71cb9c8c96ea598c2d2af3a0bed7ec /src/main/java/at/knowcenter/wag | |
parent | a68a8a4122e62f22a44c79f904aef68a500bf9ca (diff) | |
download | pdf-as-3-c699751c11265ec9f00d093cbc3346b8a8ea1b0d.tar.gz pdf-as-3-c699751c11265ec9f00d093cbc3346b8a8ea1b0d.tar.bz2 pdf-as-3-c699751c11265ec9f00d093cbc3346b8a8ea1b0d.zip |
Index for Adobe.PDF-AS Signatures adjusted
Configuration updates
Minor bug (Configuration key for adobe sign field was adobeSignFieldName which did not match the key in the configuration)
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@519 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag')
-rw-r--r-- | src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java index 6a7c545..9a52a84 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/AdobeSignatureHelper.java @@ -1,12 +1,14 @@ package at.knowcenter.wag.egov.egiz.pdf;
import java.util.HashMap;
+import java.util.Iterator;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import org.apache.log4j.Logger;
+import at.gv.egiz.pdfas.api.commons.Constants;
import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.gv.egiz.pdfas.framework.signator.SignatorInformation;
import at.gv.egiz.pdfas.utils.OgnlUtil;
@@ -16,9 +18,11 @@ import at.knowcenter.wag.egov.egiz.exceptions.SettingsException; import at.knowcenter.wag.egov.egiz.sig.SignatureObject;
import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.AcroFields;
import com.lowagie.text.pdf.PdfDate;
import com.lowagie.text.pdf.PdfDictionary;
import com.lowagie.text.pdf.PdfName;
+import com.lowagie.text.pdf.PdfObject;
import com.lowagie.text.pdf.PdfSignature;
import com.lowagie.text.pdf.PdfSignatureAppearance;
import com.lowagie.text.pdf.PdfStamper;
@@ -31,7 +35,7 @@ import com.lowagie.text.pdf.PdfString; *
*/
public class AdobeSignatureHelper {
- private static final String ADOBE_SIGN_FIELDNAME_KEY = "adobeSignFieldName";
+ private static final String ADOBE_SIGN_FIELDNAME_KEY = "adobeSignFieldValue";
private static final String ADOBE_SIG_ENABLED_KEY = "adobeSignEnabled";
@@ -54,17 +58,36 @@ public class AdobeSignatureHelper { SignatureObject so, ActualTablePos atp) throws PresentableException {
try {
- logger.info("create adobe signature field");
+ logger.debug("Creating adobe signature field.");
PdfSignatureAppearance sap = stamper.getSignatureAppearance();
String fieldName = getAdobeFieldName(so.getSignatureTypeDefinition().getType());
// find field num
+ /*
int nexSigNum = 1;
String finalFieldName = fieldName + " #" + nexSigNum;
+
while (stamper.getAcroFields().getField(finalFieldName) != null) {
nexSigNum++;
finalFieldName = fieldName + " #" + nexSigNum;
}
+ */
+
+ AcroFields af = stamper.getAcroFields();
+ Iterator signatureNamesIt = af.getSignatureNames().iterator();
+ PdfName referenceFilterName = new PdfName(ADOBE_SIG_FILTER);
+ int nextSigNum = 1;
+ while (signatureNamesIt.hasNext()) {
+ PdfDictionary dictionary = (PdfDictionary) af.getSignatureDictionary((String) signatureNamesIt.next());
+ PdfObject filterName = dictionary.get(PdfName.FILTER);
+ if (filterName != null && filterName.isName()) {
+ PdfName name = (PdfName) filterName;
+ if (referenceFilterName.equals(name)) {
+ nextSigNum++;
+ }
+ }
+ }
+ String finalFieldName = fieldName + " #" + nextSigNum;
sap.setCrypto(null, null, null, null);
// supress overlay text for visible signatures
@@ -88,11 +111,15 @@ public class AdobeSignatureHelper { // sig.setReason("reason is not visible");
// sig.setContact("contact is not visible");
// sig.setDate(new PdfDate());
+
+ /* disabled in order to align adobe signature appearance for textual signatures with binary signatures
if (si != null) {
XMLGregorianCalendar c = DatatypeFactory.newInstance().newXMLGregorianCalendar(
si.getSignSignatureObject().date);
sig.setDate(new PdfDate(c.toGregorianCalendar()));
}
+ */
+
sig.setName(getAdobeSignText(so.getSignatureTypeDefinition().getType(), si));
sap.setCryptoDictionary(sig);
|