pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1854336 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
Date Mon, 25 Feb 2019 19:20:10 GMT
Author: tilman
Date: Mon Feb 25 19:20:10 2019
New Revision: 1854336

URL: http://svn.apache.org/viewvc?rev=1854336&view=rev
Log:
PDFBOX-3017: move segment to bottom so that output comes together with signature verification

Modified:
    pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java

Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java?rev=1854336&r1=1854335&r2=1854336&view=diff
==============================================================================
--- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
(original)
+++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
Mon Feb 25 19:20:10 2019
@@ -144,30 +144,6 @@ public final class ShowSignature
 
                     System.out.println("Signature found");
 
-                    int[] byteRange = sig.getByteRange();
-                    if (byteRange.length != 4)
-                    {
-                        System.err.println("Signature byteRange must have 4 items");
-                    }
-                    else
-                    {
-                        long fileLen = infile.length();
-                        long rangeMax = byteRange[2] + (long) byteRange[3];
-                        // multiply content length with 2 (because it is in hex in the PDF)
and add 2 for < and >
-                        int contentLen = contents.getString().length() * 2 + 2;
-                        if (fileLen != rangeMax || byteRange[0] != 0 || byteRange[1] + contentLen
!= byteRange[2])
-                        {
-                            // a false result doesn't necessarily mean that the PDF is a
fake
-                            // see this answer why:
-                            // https://stackoverflow.com/a/48185913/535646
-                            System.out.println("Signature does not cover whole document");
-                        }
-                        else
-                        {
-                            System.out.println("Signature covers whole document");
-                        }
-                    }
-
                     if (sig.getName() != null)
                     {
                         System.out.println("Name:     " + sig.getName());
@@ -267,6 +243,30 @@ public final class ShowSignature
                     {
                         throw new IOException("Missing subfilter for cert dictionary");
                     }
+
+                    int[] byteRange = sig.getByteRange();
+                    if (byteRange.length != 4)
+                    {
+                        System.err.println("Signature byteRange must have 4 items");
+                    }
+                    else
+                    {
+                        long fileLen = infile.length();
+                        long rangeMax = byteRange[2] + (long) byteRange[3];
+                        // multiply content length with 2 (because it is in hex in the PDF)
and add 2 for < and >
+                        int contentLen = contents.getString().length() * 2 + 2;
+                        if (fileLen != rangeMax || byteRange[0] != 0 || byteRange[1] + contentLen
!= byteRange[2])
+                        {
+                            // a false result doesn't necessarily mean that the PDF is a
fake
+                            // see this answer why:
+                            // https://stackoverflow.com/a/48185913/535646
+                            System.out.println("Signature does not cover whole document");
+                        }
+                        else
+                        {
+                            System.out.println("Signature covers whole document");
+                        }
+                    }
                 }
                 analyseDSS(document);
             }



Mime
View raw message