pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Dhabolt <myco...@yahoo.com>
Subject Re: AES Encryption Example? (PDFBox)
Date Tue, 23 Oct 2012 18:53:11 GMT
No thoughts?

Thanks in advance!



________________________________
 From: John Dhabolt <mycolab@yahoo.com>
To: "users@pdfbox.apache.org" <users@pdfbox.apache.org> 
Sent: Monday, October 15, 2012 4:53 PM
Subject: AES Encryption Example?
 
Hi,


I've pretty much exhausted my Google search skills in trying to find any posts covering AES
encryption with PDFBox. I'm looking for the simplest implementation.

It appears I need a StandardSecurityHandler or PublicKeySecurityHandler and apparently the
StandardProtectionPolicy (which is well documented in the Encrypt class), but I keep trying
to bang them together and nothing useful happens.

In one of my clearly naive attempts I do something like this (the only thing that isn't based
on the Encrypt example is the attempt to use the StandardSecurityHandler...obviously incorrectly):

StandardSecurityHandler ssh = new StandardSecurityHandler(spp);
ssh.setKeyLength(KEY_LENGTH);
ssh.setAES(true);

AccessPermission ap = new AccessPermission();
// set various permissions

StandardProtectionPolicy spp = new StandardProtectionPolicy(OWNER_PASSWORD, null, ap);
spp.setEncryptionKeyLength(KEY_LENGTH); 

document.setSecurityHandler(ssh); // Seems to be the way to set a security handler
document.protect(spp); // Completely ignores AES (I get the default 128-bit RC4 encryption)

As noted in the comments above, this correctly locks the PDF but sets 128-bit RC4 encryption
as opposed to AES. 

Thanks in advance for any suggestions.

John
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message