public class PDFEncryption extends Object
 Notice that encryption is not only about pure encryption, it is also about setting the available features on the pdf:
 can print, copy, modify, ... (see PDFBox AccessPermission).
 
To use this class and its encrypt()/removeEncryption() methods you must always use the appropriate setters first, to set the misc info (original owner password so an encrypted PDF can be handled, encryption key length, ...).
| Constructor and Description | 
|---|
| PDFEncryption(Blob inBlob)Basic constructor. | 
| Modifier and Type | Method and Description | 
|---|---|
| Blob | encrypt(org.apache.pdfbox.pdmodel.encryption.AccessPermission inPerm)Encrypts the PDF with the new permissions (see  AccessPermission). | 
| Blob | encryptReadOnly()Encrypts the PDF with readonly permission. | 
| Blob | removeEncryption()Removes all protection from the PDF, returns a copy of it. | 
| void | setKeyLength(int keyLength)Set the lentgh of the key to be used for encryption. | 
| void | setOriginalOwnerPwd(String originalOwnerPwd)Set the password to use when opening a protected PDF. | 
| void | setOwnerPwd(String ownerPwd)Set the owner password to use when encrypting PDF. | 
| void | setUserPwd(String userPwd)Set the user password to use when encrypting PDF. | 
public PDFEncryption(Blob inBlob)
inBlob - Input blob.public Blob encryptReadOnly()
 WARNING: If you are familiar with PDFBox AccessPermission, notice our encryptReadOnly() method is not the
 same as AccessPermission#AccessPermission#setReadOnly. The latter just makes sure the code cannot call
 other setter later on.
 
 encryptReadOnly sets the following permissions on the document:
 
IMPORTANT
It is required that the following setters are called before:setOriginalOwnerPwd(java.lang.String): Only if the original PDF already is encrypted. This password
 allows to open it for modification.setKeyLength(int): To set the length of the key.setOwnerPwd(java.lang.String): The password for the owner. If not called, originalOwnerPwd
 is used instead.setUserPwd(java.lang.String): The password for the user.public Blob encrypt(org.apache.pdfbox.pdmodel.encryption.AccessPermission inPerm)
AccessPermission).
 IMPORTANT
It is required that the following setters are called before:setOriginalOwnerPwd(java.lang.String): Only if the original PDF already is encrypted. This password
 allows to open it for modification.setKeyLength(int): To set the length of the key.setOwnerPwd(java.lang.String): The password for the owner. If not called, originalOwnerPwd
 is used instead.setUserPwd(java.lang.String): The password for the user.inPerm - Input permissions.public Blob removeEncryption()
IMPORTANT
If the PDF is encrypted, it is required forsetOriginalOwnerPwd(java.lang.String) to be called before to
 removeEncryption.
 setOriginalOwnerPwd(java.lang.String): Only if the original PDF already is encrypted. This password
 allows to open it for modification.setKeyLength(int): To set the length of the key.setOwnerPwd(java.lang.String): The password for the owner. If not called, originalOwnerPwd
 is used instead.setUserPwd(java.lang.String): The password for the user.public void setKeyLength(int keyLength) throws NuxeoException
 Possible values are 40 and 128. Default value is 128 if keyLength is <= 0.
keyLength - Lenght of the encryption key.NuxeoExceptionpublic void setOriginalOwnerPwd(String originalOwnerPwd)
originalOwnerPwd - Original owner password.public void setOwnerPwd(String ownerPwd)
Owners can do whatever they want to the PDF (modify, change protection, ...).
ownerPwd - Owner password.public void setUserPwd(String userPwd)
Users can have less rights than owners (for example, not being able to remove protection).
userPwd - User password.Copyright © 2019 Nuxeo. All rights reserved.