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 --- .../framework/signators/BinarySignator_1_0_0.java | 2 +- .../framework/signators/TextualSignator_1_0_0.java | 2 +- .../wag/egov/egiz/pdf/BinarySignature.java | 21 +++++++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_0_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_0_0.java index 7a28805..8f9ffed 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_0_0.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_0_0.java @@ -123,7 +123,7 @@ public class BinarySignator_1_0_0 implements Signator variable_field_definitions.add(sfd); } } - IncrementalUpdateInformation iui = IncrementalUpdateHelper.writeIncrementalUpdate(pdf, pdf_table, signature_type, pi, variable_field_definitions, all_field_definitions, null, null); + IncrementalUpdateInformation iui = IncrementalUpdateHelper.writeIncrementalUpdate(pdf, pdf_table, signature_type, pi, variable_field_definitions, all_field_definitions, null, null, null); String temp_string = iui.temp_ir_number + " " + iui.temp_ir_generation + " obj"; //$NON-NLS-1$//$NON-NLS-2$ byte[] temp_bytes = temp_string.getBytes("US-ASCII"); //$NON-NLS-1$ diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_0_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_0_0.java index 8bdd935..f34fcdd 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_0_0.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_0_0.java @@ -119,7 +119,7 @@ public class TextualSignator_1_0_0 implements Signator PositioningInstruction pi = PdfAS.determineTablePositioning(iui.pos, iui.signature_type, iui.original_document, pdf_table); - IncrementalUpdateInformation signed_iui = IncrementalUpdateHelper.writeIncrementalUpdate(iui.original_document, pdf_table, iui.signature_type, pi, null, null, null, null); + IncrementalUpdateInformation signed_iui = IncrementalUpdateHelper.writeIncrementalUpdate(iui.original_document, pdf_table, iui.signature_type, pi, null, null, null, null, null); SignResult sign_result = new SignResult(PdfAS.PDF_MIME_TYPE, signed_iui.signed_pdf); return sign_result; 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