From c6cc43d237021fe27a9c264c807d00c9a711464b Mon Sep 17 00:00:00 2001 From: ferbas Date: Wed, 2 Dec 2009 16:14:07 +0000 Subject: added adobe sig attribute git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@469 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../impl/signator/binary/BinarySignator_1_0_0.java | 63 ++++++---------------- 1 file changed, 17 insertions(+), 46 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 79a7658..f62b298 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 @@ -180,7 +180,7 @@ public class BinarySignator_1_0_0 implements Signator invisible_field_definitions.add(sfd); } - IncrementalUpdateInformation iui = IncrementalUpdateHelper.writeIncrementalUpdate(pdfDataSource, pdf_table, profile, pi, variable_field_definitions, all_field_definitions, invisible_field_definitions, invKZString, timeStamper); + IncrementalUpdateInformation iui = IncrementalUpdateHelper.writeIncrementalUpdate(pdfDataSource, pdf_table, profile, pi, variable_field_definitions, all_field_definitions, invisible_field_definitions, invKZString, timeStamper, null); iui.invisible_field_definitions = invisible_field_definitions; iui.invisibleKZString = invKZString; @@ -268,54 +268,25 @@ public class BinarySignator_1_0_0 implements Signator BinarySignature.replaceCertificate(iui); BinarySignature.replaceTimestamp(iui); BinarySignature.replacePlaceholders(iui); - + +// dferbas: alternative sign attrib creation +// PdfReader reader = new PdfReader(iui.signed_pdf); +// +// OutputStream os = dataSink.createOutputStream(PdfAS.PDF_MIME_TYPE); +// +// try { +// PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0', null, true); +// +// BinarySignature.createAdobeSigAttrib(stamper, signatorInformation, signatorInformation.getActualTablePos()); +// +// } catch (DocumentException e) { +// log.error("pdf error", e); +// throw new SignatorException(ErrorCode.CANNOT_WRITE_PDF, e); +// } OutputStream os = dataSink.createOutputStream(PdfAS.PDF_MIME_TYPE); os.write(iui.signed_pdf); - os.close(); - - -// // dferbas write itext marker -// PdfReader rd = new PdfReader(iui.signed_pdf); -// FileOutputStream fout = new FileOutputStream("itextsigned.pdf"); -// try { -// log.info("sign itext external"); -// PdfStamper stamper = PdfStamper.createSignature(rd, fout, '\0'); -// PdfSignatureAppearance sap = stamper.getSignatureAppearance(); -// Certificate[] certs = new Certificate[] { iui.signed_signature_object.x509Certificate }; -// sap.setCrypto(null, certs, null, PdfSignatureAppearance.SELF_SIGNED); -// sap.setReason("pdf-as signature"); -// sap.setLocation("dahoam"); -// //sap.setExternalDigest(digest, RSAdata, digestEncryptionAlgorithm); -// byte[] sigVal = Base64.decodeBase64(iui.signed_signature_object.signatureValue.getBytes()); -// //byte[] sigVal = iui.signed_signature_object.signatureValue.getBytes(); -// sap.setExternalDigest(sigVal, null, "RSA"); -//// int csize = 40000; -//// HashMap exc = new HashMap(); -//// exc.put(PdfName.CONTENTS, new Integer(csize * 2 + 2)); -// sap.preClose(); // *2+2 -// -//// sap.preClose(new HashMap() {{ put(PdfName.CONTENTS, new Integer(4000)); }}); -// -// PdfPKCS7 sig = sap.getSigStandard().getSigner(); -// sig.setExternalDigest(sigVal, null, "RSA"); -// -// log.info(new PdfString(sigVal).setHexWriting(true)+ "END"); -// -// PdfDictionary dic = new PdfDictionary(); -// dic.put(PdfName.CONTENTS, new PdfString(sigVal).setHexWriting(true)); -// sap.close(dic); -// -// //stamper.close(); -// -// -// } catch (DocumentException e) { -// log.error(e, e); -// throw new RuntimeException(e); -// } - - //SignResult sign_result = new SignResult(PdfAS.PDF_MIME_TYPE, iui.signed_pdf); - //return sign_result; + os.close(); } catch (PDFDocumentException e) { -- cgit v1.2.3