Skip to content

Commit bc1d31a

Browse files
committed
PDFBOX-5660: optimize, as suggested by Valery Bokov; closes #420
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1931887 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8a4a700 commit bc1d31a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,10 @@ public void prepareForDecryption(PDEncryption encryption, COSArray documentIDArr
152152
throw new IOException("Decryption material is not compatible with the document");
153153
}
154154

155+
int encryptionVersion = encryption.getVersion();
155156
// This is only used with security version 4 and 5.
156-
if (encryption.getVersion() >= REVISION_4) {
157+
if (encryptionVersion >= REVISION_4)
158+
{
157159
setStreamFilterName(encryption.getStreamFilterName());
158160
setStringFilterName(encryption.getStringFilterName());
159161
}
@@ -168,9 +170,9 @@ public void prepareForDecryption(PDEncryption encryption, COSArray documentIDArr
168170

169171
int dicPermissions = encryption.getPermissions();
170172
int dicRevision = encryption.getRevision();
171-
int dicLength = encryption.getVersion() == 1 ? 5 : encryption.getLength() / 8;
173+
int dicLength = encryptionVersion == 1 ? 5 : encryption.getLength() / 8;
172174

173-
if (encryption.getVersion() == REVISION_4 || encryption.getVersion() == REVISION_5)
175+
if (encryptionVersion == REVISION_4 || encryptionVersion == REVISION_5)
174176
{
175177
// detect whether AES encryption is used. This assumes that the encryption algo is
176178
// stored in the PDCryptFilterDictionary

0 commit comments

Comments
 (0)