Hi,

Am 30.12.2014 um 18:29 schrieb Thomas Chojecki:
Am Tue, 30 Dec 2014 10:08:14 +0100
schrieb Tilman Hausherr <[email protected]>:

Hi,
Hi Tilman,

...

And then there's the second one in PDFBOX-2469, that doesn't work
either. The text at the end of PDFBOX-2469 is somewhat unclear, but
it seems we didn't solve them all.

I discussed the problem with Adreas already. See the comment
https://issues.apache.org/jira/browse/PDFBOX-2469#comment-14216197

In some documents the decryption is broken or something else does not
seems working. So while decrypting and finalizing the stream, an
exception will stop the decryption process.

Ignoring the exception will help but let the document maybe in an
incosistent form. Maybe we can use the "force" flag for the parser to
skip this decryption errors. So people who work with the "force" flag
will know what they do and can risk inconsistance.
The "old" parser is behaving wrong, see my comment in PDFBOX-2469 [1]. The exception is just a subsequent issue.

+1 from my side :P because I need it only for signature parsing and
verifying, which aren't encrypted at all.

Best regards
Thomas


BR
Andreas Lehmkühler

[1] https://issues.apache.org/jira/browse/PDFBOX-2469?focusedCommentId=14216027&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14216027


Tilman



Am 30.12.2014 um 03:15 schrieb Barry Zhao [Zhao]:
Hi team,

I see that the PDFBox has staged out new release 1.8.8, so I just
try to use the new version.
When I decrypt a PDF file which is decrypted, I got the exception
bellow:

org.apache.pdfbox.exceptions.WrappedIOException
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:375)
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptString(SecurityHandler.java:577)
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:429)
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptDictionary(SecurityHandler.java:530)
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:437)
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:403)
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:221)
at
org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
at
org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1601)
at Testpdf10.main(Testpdf10.java:44)
Caused by: javax.crypto.BadPaddingException: Given final block not
properly padded
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
at
com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)
at javax.crypto.Cipher.doFinal(Cipher.java:1969) at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:351)
... 9 more

And my code is :
PDDocument doc = PDDocument.load(originFile);
if (doc.isEncrypted())
{
try
{
DecryptionMaterial dm = new StandardDecryptionMaterial("");
doc.openProtection(dm);
doc.setAllSecurityToBeRemoved(true);
}
catch (Exception cre) {
cre.printStackTrace();
}
}

I use the attachment file to do the operation.


I found this
http://stackoverflow.com/questions/26963718/badpaddingexception-when-decrypting-with-pdfbox
in stackoverflow.
I tried by the advices and it still not work.
So I post this email to you. Hope to get your answer.

Best wishes,
Barry



Reply via email to