Author: tilman
Date: Mon Feb 16 12:04:49 2026
New Revision: 1931887

Log:
PDFBOX-5660: optimize, as suggested by Valery Bokov; closes #420

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

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
 Mon Feb 16 12:02:15 2026        (r1931886)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
 Mon Feb 16 12:04:49 2026        (r1931887)
@@ -152,8 +152,10 @@ public final class StandardSecurityHandl
             throw new IOException("Decryption material is not compatible with 
the document");
         }
         
+        int encryptionVersion = encryption.getVersion();
         // This is only used with security version 4 and 5.
-        if (encryption.getVersion() >= REVISION_4) {
+        if (encryptionVersion >= REVISION_4)
+        {
             setStreamFilterName(encryption.getStreamFilterName());
             setStringFilterName(encryption.getStringFilterName());
         }
@@ -168,9 +170,9 @@ public final class StandardSecurityHandl
 
         int dicPermissions = encryption.getPermissions();
         int dicRevision = encryption.getRevision();
-        int dicLength = encryption.getVersion() == 1 ? 5 : 
encryption.getLength() / 8;
+        int dicLength = encryptionVersion == 1 ? 5 : encryption.getLength() / 
8;
         
-        if (encryption.getVersion() == REVISION_4 || encryption.getVersion() 
== REVISION_5)
+        if (encryptionVersion == REVISION_4 || encryptionVersion == REVISION_5)
         {
             // detect whether AES encryption is used. This assumes that the 
encryption algo is 
             // stored in the PDCryptFilterDictionary

Reply via email to