pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1652616 - in /pdfbox/trunk: examples/src/main/java/org/apache/pdfbox/examples/fdf/ examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ examples/src/main/java/org/apache/pdfbox/examples/util/ pdfbox/src/main/java/org/apache/pdfbox/pd...
Date Sat, 17 Jan 2015 14:50:40 GMT
Author: lehmi
Date: Sat Jan 17 14:50:40 2015
New Revision: 1652616

URL: http://svn.apache.org/r1652616
Log:
PDFOX-2600: removed all PDDocument#openProtection references

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeyDecryptionMaterial.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java?rev=1652616&r1=1652615&r2=1652616&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java Sat
Jan 17 14:50:40 2015
@@ -24,8 +24,6 @@ import java.util.List;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
-import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
-import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
 import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
 import org.apache.pdfbox.pdmodel.interactive.form.PDFieldTreeNode;
 import org.apache.pdfbox.pdmodel.interactive.form.PDNonTerminalField;
@@ -145,19 +143,6 @@ public class PrintFields
             {
                 pdf = PDDocument.load(new File(args[0]));
                 PrintFields exporter = new PrintFields();
-                if (pdf.isEncrypted())
-                {
-                    try
-                    {
-                        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial("");
-                        pdf.openProtection(sdm);
-                    }
-                    catch (InvalidPasswordException e)
-                    {
-                        System.err.println("Error: The document is encrypted.");
-                        usage();
-                    }
-                }
                 exporter.printFields(pdf);
             }
         }

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java?rev=1652616&r1=1652615&r2=1652616&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java
Sat Jan 17 14:50:40 2015
@@ -26,7 +26,6 @@ import org.apache.pdfbox.pdmodel.PDDocum
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.common.PDStream;
-import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
 import org.apache.pdfbox.pdmodel.font.PDCIDFont;
 import org.apache.pdfbox.pdmodel.font.PDCIDFontType2;
 import org.apache.pdfbox.pdmodel.font.PDFont;
@@ -122,13 +121,7 @@ public class ExtractTTFFonts
                 PDDocument document = null;
                 try
                 {
-                    document = PDDocument.load(new File(pdfFile));
-
-                    if (document.isEncrypted())
-                    {
-                        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password);
-                        document.openProtection(sdm);
-                    }
+                    document = PDDocument.load(new File(pdfFile), password);
                     for (PDPage page : document.getPages())
                     {
                         PDResources resources = page.getResources();

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java?rev=1652616&r1=1652615&r2=1652616&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
Sat Jan 17 14:50:40 2015
@@ -19,15 +19,12 @@ package org.apache.pdfbox.examples.util;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.common.PDStream;
-import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
 import org.apache.pdfbox.util.PDFTextStripper;
 import org.apache.pdfbox.text.TextPosition;
 
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
-
 /**
  * This is an example on how to get some x/y coordinates of text.
  *
@@ -66,19 +63,6 @@ public class PrintTextLocations extends
             try
             {
                 document = PDDocument.load( new File(args[0]) );
-                if( document.isEncrypted() )
-                {
-                    try
-                    {
-                        StandardDecryptionMaterial sdm = new StandardDecryptionMaterial("");
-                        document.openProtection(sdm);
-                    }
-                    catch( InvalidPasswordException e )
-                    {
-                        System.err.println( "Error: Document is encrypted with a password."
);
-                        System.exit( 1 );
-                    }
-                }
                 PrintTextLocations printer = new PrintTextLocations();
                 int pageNum = 0;
                 for( PDPage page : document.getPages() )

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeyDecryptionMaterial.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeyDecryptionMaterial.java?rev=1652616&r1=1652615&r2=1652616&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeyDecryptionMaterial.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeyDecryptionMaterial.java
Sat Jan 17 14:50:40 2015
@@ -51,10 +51,8 @@ import java.util.Enumeration;
  *
  * In this code sample certificate_path contains the path to the PKCS#12 certificate.
  *
- * @see org.apache.pdfbox.pdmodel.PDDocument#openProtection(DecryptionMaterial)
- *
- * @author Benoit Guillon (benoit.guillon@snv.jussieu.fr)
- * @version $Revision: 1.2 $
+ * @author Benoit Guillon
+ * 
  */
 
 public class PublicKeyDecryptionMaterial extends DecryptionMaterial
@@ -92,8 +90,8 @@ public class PublicKeyDecryptionMaterial
     {
         if(keyStore.size() == 1)
         {
-            Enumeration aliases = keyStore.aliases();
-            String keyStoreAlias = (String)aliases.nextElement();
+            Enumeration<String> aliases = keyStore.aliases();
+            String keyStoreAlias = aliases.nextElement();
             return (X509Certificate)keyStore.getCertificate(keyStoreAlias);
         }
         else
@@ -128,8 +126,8 @@ public class PublicKeyDecryptionMaterial
         {
             if(keyStore.size() == 1)
             {
-                Enumeration aliases = keyStore.aliases();
-                String keyStoreAlias = (String)aliases.nextElement();
+                Enumeration<String> aliases = keyStore.aliases();
+                String keyStoreAlias = aliases.nextElement();
                 return keyStore.getKey(keyStoreAlias, password.toCharArray());
             }
             else



Mime
View raw message