pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1642764 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
Date Mon, 01 Dec 2014 21:28:11 GMT
Author: tilman
Date: Mon Dec  1 21:28:10 2014
New Revision: 1642764

URL: http://svn.apache.org/r1642764
Log:
PDFBOX-2533: add decryptDictionary method that supports recursion; renamed decrypt to decryptString

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java?rev=1642764&r1=1642763&r2=1642764&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
Mon Dec  1 21:28:10 2014
@@ -1549,26 +1549,11 @@ public class NonSequentialPDFParser exte
                     // decrypt
                     if (pb instanceof COSString)
                     {
-                        decrypt((COSString) pb, objNr, objGenNr);
+                        decryptString((COSString) pb, objNr, objGenNr);
                     }
                     else if (pb instanceof COSDictionary)
                     {
-                        COSDictionary dict = (COSDictionary) pb;
-                        // skip dictionary containing the signature
-                        if (!COSName.SIG.equals(dict.getCOSName(COSName.TYPE)))
-                        {
-                            for (Entry<COSName, COSBase> entry : dict.entrySet())
-                            {
-                                if (entry.getValue() instanceof COSString)
-                                {
-                                    decrypt((COSString) entry.getValue(), objNr, objGenNr);
-                                }
-                                else if (entry.getValue() instanceof COSArray)
-                                {
-                                    securityHandler.decryptArray((COSArray) entry.getValue(),
objNr, objGenNr);
-                                }                            
-                            }
-                        }
+                        decryptDictionary((COSDictionary) pb, objNr, objGenNr);
                     }
                     else if (pb instanceof COSArray)
                     {
@@ -1577,7 +1562,7 @@ public class NonSequentialPDFParser exte
                         {
                             if (array.get(aIdx) instanceof COSString)
                             {
-                                decrypt((COSString) array.get(aIdx), objNr, objGenNr);
+                                decryptString((COSString) array.get(aIdx), objNr, objGenNr);
                             }
                         }
                     }
@@ -1643,6 +1628,36 @@ public class NonSequentialPDFParser exte
 
     // ------------------------------------------------------------------------
     /**
+     * 
+     * @param dict the dictionary to be decrypted
+     * @param the object number
+     * @param objGenNr the object generation number
+     * @throws IOException ff something went wrong
+     */
+    protected final void decryptDictionary(COSDictionary dict, long objNr, long objGenNr)
throws IOException
+    {
+        // skip dictionary containing the signature
+        if (!COSName.SIG.equals(dict.getItem(COSName.TYPE)))
+        {
+            for (Entry<COSName, COSBase> entry : dict.entrySet())
+            {
+                if (entry.getValue() instanceof COSString)
+                {
+                    decryptString((COSString) entry.getValue(), objNr, objGenNr);
+                }
+                else if (entry.getValue() instanceof COSArray)
+                {
+                    securityHandler.decryptArray((COSArray) entry.getValue(), objNr, objGenNr);
+                }
+                else if (entry.getValue() instanceof COSDictionary)
+                {
+                    decryptDictionary((COSDictionary) entry.getValue(), objNr, objGenNr);
+                }
+            }
+        }
+    }
+
+    /**
      * Decrypts given COSString.
      * 
      * @param str the string to be decrypted
@@ -1650,7 +1665,7 @@ public class NonSequentialPDFParser exte
      * @param objGenNr the object generation number
      * @throws IOException ff something went wrong
      */
-    protected final void decrypt(COSString str, long objNr, long objGenNr) throws IOException
+    protected final void decryptString(COSString str, long objNr, long objGenNr) throws IOException
     {
         securityHandler.decryptString(str, objNr, objGenNr);
     }



Mime
View raw message