pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1858697 - in /pdfbox/trunk: ./ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
Date Sun, 05 May 2019 17:12:31 GMT
Author: lehmi
Date: Sun May  5 17:12:31 2019
New Revision: 1858697

URL: http://svn.apache.org/viewvc?rev=1858697&view=rev
Log:
PDFBOX-4517: add the missing pieces to support identity filter as proposed by Jerome Joslet

Modified:
    pdfbox/trunk/   (props changed)
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java

Propchange: pdfbox/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May  5 17:12:31 2019
@@ -1,3 +1,3 @@
-/pdfbox/branches/2.0:1760418,1761484,1762133,1763609,1779822,1780783,1780789,1782684,1784450,1792784,1795704,1795712,1799081-1799082,1814046,1814285,1814459,1824914,1825811,1825820,1825912,1844477,1844516,1844519,1844567,1850577,1857953
+/pdfbox/branches/2.0:1760418,1761484,1762133,1763609,1779822,1780783,1780789,1782684,1784450,1792784,1795704,1795712,1799081-1799082,1814046,1814285,1814459,1824914,1825811,1825820,1825912,1844477,1844516,1844519,1844567,1850577,1857953,1858696
 /pdfbox/branches/no-awt:1618517-1621410
 /pdfbox/no-awt:1618514-1618516

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=1858697&r1=1858696&r2=1858697&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
Sun May  5 17:12:31 2019
@@ -101,6 +101,16 @@ public abstract class SecurityHandler
     private AccessPermission currentAccessPermission = null;
 
     /**
+     * The stream filter name.
+     */
+	private COSName streamFilterName;
+
+	/**
+	 * The string filter name.
+	 */
+	private COSName stringFilterName;
+
+    /**
      * Set wether to decrypt meta data.
      *
      * @param decryptMetadata true if meta data has to be decrypted.
@@ -109,6 +119,26 @@ public abstract class SecurityHandler
     {
         this.decryptMetadata = decryptMetadata;
     }
+    
+    /**
+     * Set the string filter name.
+     * 
+     * @param stringFilterName the string filter name.
+     */
+    protected void setStringFilterName(COSName stringFilterName)
+    {
+		this.stringFilterName = stringFilterName;
+	}
+
+    /**
+     * Set the stream filter name.
+     * 
+     * @param streamFilterName the stream filter name.
+     */
+    protected void setStreamFilterName(COSName streamFilterName)
+	{
+    	this.streamFilterName = streamFilterName;
+	}
 
     /**
      * Prepare the document for encryption.
@@ -418,6 +448,12 @@ public abstract class SecurityHandler
      */
     public void decryptStream(COSStream stream, long objNum, long genNum) throws IOException
     {
+    	// Stream encrypted with identity filter
+    	if (COSName.IDENTITY.equals(streamFilterName))
+    	{
+            return;
+    	}
+    	
         COSBase type = stream.getCOSName(COSName.TYPE);
         if (!decryptMetadata && COSName.METADATA.equals(type))
         {
@@ -528,6 +564,12 @@ public abstract class SecurityHandler
      */
     private void decryptString(COSString string, long objNum, long genNum) throws IOException
     {
+    	// String encrypted with identity filter
+    	if (COSName.IDENTITY.equals(stringFilterName))
+    	{
+            return;
+    	}
+    	
         ByteArrayInputStream data = new ByteArrayInputStream(string.getBytes());
         ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         try

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java?rev=1858697&r1=1858696&r2=1858697&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
Sun May  5 17:12:31 2019
@@ -176,6 +176,12 @@ public final class StandardSecurityHandl
         {
             throw new IOException("Decryption material is not compatible with the document");
         }
+        
+        // This is only used with security version 4 and 5.
+        if (encryption.getVersion() >= 4) {
+	        setStreamFilterName(encryption.getStreamFilterName());
+	        setStringFilterName(encryption.getStreamFilterName());
+        }
         setDecryptMetadata(encryption.isEncryptMetaData());
         StandardDecryptionMaterial material = (StandardDecryptionMaterial)decryptionMaterial;
 



Mime
View raw message