| Prev Class | Next Class | Frames | No Frames |
| Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Objectorg.pdfbox.pdmodel.encryption.SecurityHandlerorg.pdfbox.pdmodel.encryption.StandardSecurityHandlerpublic class StandardSecurityHandlerextends SecurityHandlerField Summary | |
static byte[] |
|
static String |
|
static Class |
|
Fields inherited from class org.pdfbox.pdmodel.encryption.SecurityHandler | |
currentAccessPermission, document, encryptionKey, keyLength, rc4, version | |
Constructor Summary | |
| |
| |
Method Summary | |
byte[] |
|
byte[] |
|
byte[] |
|
void |
|
byte[] |
|
boolean |
|
boolean |
|
void |
|
Methods inherited from class org.pdfbox.pdmodel.encryption.SecurityHandler | |
decryptDocument, decryptStream, decryptString, encryptData, getCurrentAccessPermission, getKeyLength, prepareDocumentForEncryption, proceedDecryption, setKeyLength | |
public static final byte[] ENCRYPT_PADDING
Standard padding for encryption.
public static final String FILTER
Type of security handler.
public static final Class PROTECTION_POLICY_CLASS
Protection policy class for this handler.
public StandardSecurityHandler()
Constructor.
public StandardSecurityHandler(StandardProtectionPolicy p)
Constructor used for encryption.
- Parameters:
p- The protection policy.
public final byte[] computeEncryptedKey(byte[] password,
byte[] o,
int permissions,
byte[] id,
int encRevision,
int length)
throws CryptographyExceptionCompute the encryption key.
- Parameters:
password- The password to compute the encrypted key.o- The o entry of the encryption dictionary.permissions- The permissions for the document.id- The document id.encRevision- The revision of the encryption algorithm.length- The length of the encryption key.
- Returns:
- The encrypted key bytes.
- Throws:
CryptographyException- If there is an error with encryption.
public final byte[] computeOwnerPassword(byte[] ownerPassword,
byte[] userPassword,
int encRevision,
int length)
throws CryptographyException,
IOExceptionCompute the owner entry in the encryption dictionary.
- Parameters:
ownerPassword- The plaintext owner password.userPassword- The plaintext user password.encRevision- The revision number of the encryption algorithm.length- The length of the encryption key.
- Returns:
- The o entry of the encryption dictionary.
- Throws:
CryptographyException- If there is an error with encryption.
public final byte[] computeUserPassword(byte[] password,
byte[] o,
int permissions,
byte[] id,
int encRevision,
int length)
throws CryptographyException,
IOExceptionThis will compute the user password hash.
- Parameters:
password- The plain text password.o- The owner password hash.permissions- The document permissions.id- The document id.encRevision- The revision of the encryption.length- The length of the encryption key.
- Returns:
- The user password.
- Throws:
CryptographyException- If there is an error computing the user password.
public void decryptDocument(PDDocument doc, DecryptionMaterial decryptionMaterial) throws CryptographyException, IOException
Decrypt the document.
- Overrides:
- decryptDocument in interface SecurityHandler
- Parameters:
doc- The document to be decrypted.decryptionMaterial- Information used to decrypt the document.
- Throws:
CryptographyException- If there is an error with decryption.
public final byte[] getUserPassword(byte[] ownerPassword,
byte[] o,
int encRevision,
long length)
throws CryptographyException,
IOExceptionGet the user password based on the owner password.
- Parameters:
ownerPassword- The plaintext owner password.o- The o entry of the encryption dictionary.encRevision- The encryption revision number.length- The key length.
- Returns:
- The u entry of the encryption dictionary.
- Throws:
CryptographyException- If there is an error generating the user password.
public final boolean isOwnerPassword(byte[] ownerPassword,
byte[] u,
byte[] o,
int permissions,
byte[] id,
int encRevision,
int length)
throws CryptographyException,
IOExceptionCheck for owner password.
- Parameters:
ownerPassword- The owner password.u- The u entry of the encryption dictionary.o- The o entry of the encryption dictionary.permissions- The set of permissions on the document.id- The document id.encRevision- The encryption algorithm revision.length- The encryption key length.
- Returns:
- True If the ownerPassword param is the owner password.
- Throws:
CryptographyException- If there is an error during encryption.
public final boolean isUserPassword(byte[] password,
byte[] u,
byte[] o,
int permissions,
byte[] id,
int encRevision,
int length)
throws CryptographyException,
IOExceptionCheck if a plaintext password is the user password.
- Parameters:
password- The plaintext password.u- The u entry of the encryption dictionary.o- The o entry of the encryption dictionary.permissions- The permissions set in the the PDF.id- The document id used for encryption.encRevision- The revision of the encryption algorithm.length- The length of the encryption key.
- Returns:
- true If the plaintext password is the user password.
- Throws:
CryptographyException- If there is an error during encryption.
public void prepareDocumentForEncryption(PDDocument doc) throws CryptographyException, IOException
Prepare document for encryption.
- Overrides:
- prepareDocumentForEncryption in interface SecurityHandler
- Parameters:
doc- The documeent to encrypt.
- Throws:
CryptographyException- If there is an error with decryption.