Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BB0F4200B97 for ; Sun, 9 Oct 2016 22:38:58 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B9BC9160ADA; Sun, 9 Oct 2016 20:38:58 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0453E160AD6 for ; Sun, 9 Oct 2016 22:38:57 +0200 (CEST) Received: (qmail 96514 invoked by uid 500); 9 Oct 2016 20:38:57 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 96504 invoked by uid 99); 9 Oct 2016 20:38:57 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Oct 2016 20:38:57 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 9E6D1180532 for ; Sun, 9 Oct 2016 20:38:56 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.999 X-Spam-Level: X-Spam-Status: No, score=-1.999 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id cFozJCnjI59E for ; Sun, 9 Oct 2016 20:38:55 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 3AE865F471 for ; Sun, 9 Oct 2016 20:38:55 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 60F03E0057 for ; Sun, 9 Oct 2016 20:38:54 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 5D63C3A0218 for ; Sun, 9 Oct 2016 20:38:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1764010 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Date: Sun, 09 Oct 2016 20:38:54 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20161009203854.5D63C3A0218@svn01-us-west.apache.org> archived-at: Sun, 09 Oct 2016 20:38:58 -0000 Author: tilman Date: Sun Oct 9 20:38:54 2016 New Revision: 1764010 URL: http://svn.apache.org/viewvc?rev=1764010&view=rev Log: PDFBOX-3525: move the signature check to visitFromDictionary(), because it didn't work when the signaturefield is a direct object Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1764010&r1=1764009&r2=1764010&view=diff ============================================================================== --- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original) +++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Sun Oct 9 20:38:54 2016 @@ -507,15 +507,6 @@ public class COSWriter implements ICOSVi public void doWriteObject( COSBase obj ) throws IOException { writtenObjects.add( obj ); - if(obj instanceof COSDictionary) - { - COSBase itemType = ((COSDictionary) obj).getItem(COSName.TYPE); - if (COSName.SIG.equals(itemType) || COSName.DOC_TIME_STAMP.equals(itemType)) - { - reachedSignature = true; - } - } - // find the physical reference currentObjectKey = getObjectKey( obj ); // add a x ref entry @@ -743,7 +734,7 @@ public class COSWriter implements ICOSVi * signatures externally. {@link #write(PDDocument)} method should have been called prior. * The created signature should be set using {@link #writeExternalSignature(byte[])}. *

- * When {@link SignatureInterface} instance is used, COSWriter obtains and writes the signature itsef. + * When {@link SignatureInterface} instance is used, COSWriter obtains and writes the signature itself. *

* * @return data stream to be signed @@ -978,6 +969,14 @@ public class COSWriter implements ICOSVi @Override public Object visitFromDictionary(COSDictionary obj) throws IOException { + if (!reachedSignature) + { + COSBase itemType = obj.getItem(COSName.TYPE); + if (COSName.SIG.equals(itemType) || COSName.DOC_TIME_STAMP.equals(itemType)) + { + reachedSignature = true; + } + } getStandardOutput().write(DICT_OPEN); getStandardOutput().writeEOL(); for (Map.Entry entry : obj.entrySet())