From c7358ca0e6e14322a380d39b8d0d99bcd9575c09 Mon Sep 17 00:00:00 2001 From: ferbas Date: Thu, 3 Dec 2009 15:20:20 +0000 Subject: improved adobe sig attribute; SubFilter -> Methode git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@487 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../wag/egov/egiz/pdf/BinarySignature.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/pdf') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java index f07d8c6..47bae56 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java @@ -52,6 +52,7 @@ import at.knowcenter.wag.egov.egiz.exceptions.PresentableException; import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException; import at.knowcenter.wag.egov.egiz.exceptions.SettingsException; import at.knowcenter.wag.egov.egiz.sig.SignatureFieldDefinition; +import at.knowcenter.wag.egov.egiz.sig.SignatureObject; import at.knowcenter.wag.egov.egiz.sig.SignatureTypeDefinition; import at.knowcenter.wag.egov.egiz.sig.SignatureTypes; import at.knowcenter.wag.egov.egiz.tools.CodingHelper; @@ -783,7 +784,7 @@ public abstract class BinarySignature * Forwarded exception. */ public static IncrementalUpdateInformation writeIncrementalUpdate(PdfDataSource original_document, DataSink written_pdf, PdfPTable pdf_table, String profile, PositioningInstruction pi, - List variable_field_definitions, List all_field_definitions, List invisible_field_definitions, String invisibleKZString, TimeStamper timeStamper, SignatorInformation si) throws PresentableException + List variable_field_definitions, List all_field_definitions, List invisible_field_definitions, String invisibleKZString, TimeStamper timeStamper, SignatorInformation si, SignatureObject so) throws PresentableException { try { @@ -905,7 +906,7 @@ public abstract class BinarySignature } //stamper.close(); - createAdobeSigAttrib(stamper, si, atp); // here..., stamper is closed + createAdobeSigAttrib(stamper, si, so, atp); // here..., stamper is closed // System.out.println("wprinz: STAMPING FINISHED"); // just to make sure the stream is really closed @@ -927,12 +928,15 @@ public abstract class BinarySignature } /** - * Schreibt Adobe-pdf signatur attribut mittels itext + * Writes Adobe-pdf signature entry with itext * @param stamper * @param si + * @param so * @param atp + * @throws PresentableException */ - public static void createAdobeSigAttrib(PdfStamper stamper, SignatorInformation si, ActualTablePos atp) { + public static void createAdobeSigAttrib(PdfStamper stamper, SignatorInformation si, SignatureObject so, ActualTablePos atp) + throws PresentableException { try { logger.info("create adobe signature field"); @@ -946,8 +950,10 @@ public abstract class BinarySignature // the following line marks the sig block as adobe sig //sap.setVisibleSignature(createRectangleFromTablePos(iui.actualTablePos), iui.actualTablePos.page, "PDF-AS-Signatur"); sap.setVisibleSignature(new Rectangle(0, 0, 0, 0), atp.page, "PDF-AS-Signatur"); - String subfilter = "urn:pdfsigfilter:bka.gv.at:binaer:v1.1.0"; - if (si != null) { + String subfilter = "unknown"; + if (so != null && so.getKZ() != null) { + subfilter = so.getKZ().toString(); + } else if (si != null) { subfilter = si.getSignSignatureObject().kz; } PdfSignature sig = new PdfSignature(new PdfName("Adobe.PDF-AS"), new PdfName(subfilter)); @@ -980,10 +986,9 @@ public abstract class BinarySignature sap.close(dic); } catch (Exception ex) { logger.error("error", ex); - throw new RuntimeException(ex ); + throw new PresentableException(ErrorCode.CANNOT_WRITE_PDF, "Error creating adobe signature attribute", ex); } - //stamper.close(); } private static Rectangle createRectangleFromTablePos(ActualTablePos pos) { -- cgit v1.2.3