pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1674940 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
Date Mon, 20 Apr 2015 16:26:41 GMT
Author: lehmi
Date: Mon Apr 20 16:26:41 2015
New Revision: 1674940

URL: http://svn.apache.org/r1674940
Log:
PDFBOX-2301: copy filtered stream data as createFilteredStream resets all data

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java?rev=1674940&r1=1674939&r2=1674940&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
Mon Apr 20 16:26:41 2015
@@ -379,7 +379,8 @@ public abstract class SecurityHandler
             return;
         }
         decryptDictionary(stream, objNum, genNum);
-        InputStream encryptedStream = stream.getFilteredStream();
+        byte[] encrypted = IOUtils.toByteArray(stream.getFilteredStream());
+        ByteArrayInputStream encryptedStream = new ByteArrayInputStream(encrypted);
         encryptData(objNum, genNum, encryptedStream, stream.createFilteredStream(), true
/* decrypt */);
     }
 
@@ -396,7 +397,8 @@ public abstract class SecurityHandler
      */
     public void encryptStream(COSStream stream, long objNum, int genNum) throws IOException
     {
-        InputStream encryptedStream = stream.getFilteredStream();
+        byte[] rawData = IOUtils.toByteArray(stream.getFilteredStream());
+        ByteArrayInputStream encryptedStream = new ByteArrayInputStream(rawData);
         encryptData(objNum, genNum, encryptedStream, stream.createFilteredStream(), false
/* encrypt */);
     }
 



Mime
View raw message