pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1659645 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: cos/COSDocument.java pdfwriter/COSWriter.java pdmodel/PDDocument.java
Date Fri, 13 Feb 2015 18:55:29 GMT
Author: lehmi
Date: Fri Feb 13 18:55:28 2015
New Revision: 1659645

URL: http://svn.apache.org/r1659645
Log:
PDFBOX-2683: removed reference to signatureInterface from COSDocument

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=1659645&r1=1659644&r2=1659645&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java Fri Feb 13 18:55:28
2015
@@ -29,7 +29,6 @@ import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.pdfparser.PDFObjectStreamParser;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface;
 
 /**
  * This is the in-memory representation of the PDF document.  You need to call
@@ -66,11 +65,6 @@ public class COSDocument extends COSBase
      */
     private COSDictionary trailer;
     
-    /**
-     * Signature interface.
-     */
-    private SignatureInterface signatureInterface;
-
     private boolean warnMissingClose = true;
     
     /** 
@@ -317,15 +311,6 @@ public class COSDocument extends COSBase
     }
 
     /**
-     * This will return the signature interface.
-     * @return the signature interface 
-     */
-    public SignatureInterface getSignatureInterface() 
-    {
-        return signatureInterface;
-    }
-    
-    /**
      * This will set the encryption dictionary, this should only be called when
      * encrypting the document.
      *
@@ -417,15 +402,6 @@ public class COSDocument extends COSBase
     }
     
     /**
-     * Set the signature interface to the given value.
-     * @param sigInterface the signature interface
-     */
-    public void setSignatureInterface(SignatureInterface sigInterface) 
-    {
-        signatureInterface = sigInterface;
-    }
-
-    /**
      * This will get the document catalog.
      *
      * Maybe this should move to an object at PDFEdit level

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1659645&r1=1659644&r2=1659645&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Fri Feb 13
18:55:28 2015
@@ -210,6 +210,7 @@ public class COSWriter implements ICOSVi
     private long byteRangeOffset, byteRangeLength;
     private InputStream incrementalInput;
     private OutputStream incrementalOutput;
+    private SignatureInterface signatureInterface;
 
     /**
      * COSWriter constructor comment.
@@ -724,7 +725,6 @@ public class COSWriter implements ICOSVi
                 new ByteArrayInputStream(signBuffer));
 
         // sign the bytes
-        SignatureInterface signatureInterface = doc.getSignatureInterface();
         byte[] sign = signatureInterface.sign(signStream);
         String signature = new COSString(sign).toHexString();
         // substract 2 bytes because of the enclosing "<>"
@@ -1209,10 +1209,25 @@ public class COSWriter implements ICOSVi
      */
     public void write(PDDocument doc) throws IOException
     {
+        write(doc, null);
+    }
+
+    /**
+     * This will write the pdf document.
+     *
+     * @param doc The document to write.
+     * @param signInterface class to be used for signing 
+     *
+     * @throws IOException If an error occurs while generating the data.
+     */
+    public void write(PDDocument doc, SignatureInterface signInterface) throws IOException
+    {
         Long idTime = doc.getDocumentId() == null ? System.currentTimeMillis() : 
                                                     doc.getDocumentId();
 
         pdDocument = doc;
+        signatureInterface = signInterface;
+        
         if(incrementalUpdate)
         {
             prepareIncrement(doc);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1659645&r1=1659644&r2=1659645&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Fri Feb 13
18:55:28 2015
@@ -102,6 +102,9 @@ public class PDDocument implements Close
     // fonts to subset before saving
     private final Set<PDFont> fontsToSubset = new HashSet<PDFont>();
     
+    // Signature interface
+    private SignatureInterface signInterface;
+    
     /**
      * Creates an empty PDF document.
      * You need to add at least one page for the document to be valid.
@@ -180,7 +183,7 @@ public class PDDocument implements Close
         // Reserve ByteRange
         sigObject.setByteRange(new int[] { 0, 1000000000, 1000000000, 1000000000 });
 
-        getDocument().setSignatureInterface(signatureInterface);
+        signInterface = signatureInterface;
 
         //
         // Create SignatureForm for signature
@@ -967,7 +970,7 @@ public class PDDocument implements Close
         try
         {
             writer = new COSWriter(output, input);
-            writer.write(this);
+            writer.write(this, signInterface);
             writer.close();
         }
         finally



Mime
View raw message