public final class StandardSecurityHandler extends SecurityHandler
to see how to protect document with this security handler.
Modifier and Type | Field and Description |
---|---|
static String |
FILTER
Type of security handler.
|
static Class<?> |
PROTECTION_POLICY_CLASS
Protection policy class for this handler.
|
encryptionKey, keyLength
Constructor and Description |
---|
StandardSecurityHandler()
Constructor.
|
StandardSecurityHandler(StandardProtectionPolicy p)
Constructor used for encryption.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
computeEncryptedKey(byte[] password,
byte[] o,
byte[] u,
byte[] oe,
byte[] ue,
int permissions,
byte[] id,
int encRevision,
int length,
boolean encryptMetadata,
boolean isOwnerPassword)
Compute the encryption key.
|
byte[] |
computeOwnerPassword(byte[] ownerPassword,
byte[] userPassword,
int encRevision,
int length)
Compute the owner entry in the encryption dictionary.
|
byte[] |
computeUserPassword(byte[] password,
byte[] owner,
int permissions,
byte[] id,
int encRevision,
int length,
boolean encryptMetadata)
This will compute the user password hash.
|
byte[] |
getUserPassword(byte[] ownerPassword,
byte[] owner,
int encRevision,
int length)
Get the user password based on the owner password.
|
boolean |
hasProtectionPolicy()
Returns whether a protection policy has been set.
|
boolean |
isOwnerPassword(byte[] ownerPassword,
byte[] user,
byte[] owner,
int permissions,
byte[] id,
int encRevision,
int length,
boolean encryptMetadata)
Check for owner password.
|
boolean |
isOwnerPassword(String password,
byte[] user,
byte[] owner,
int permissions,
byte[] id,
int encRevision,
int length,
boolean encryptMetadata)
Check for owner password.
|
boolean |
isUserPassword(byte[] password,
byte[] user,
byte[] owner,
int permissions,
byte[] id,
int encRevision,
int length,
boolean encryptMetadata)
Check if a plaintext password is the user password.
|
boolean |
isUserPassword(String password,
byte[] user,
byte[] owner,
int permissions,
byte[] id,
int encRevision,
int length,
boolean encryptMetadata)
Check if a plaintext password is the user password.
|
void |
prepareDocumentForEncryption(PDDocument document)
Prepare document for encryption.
|
void |
prepareForDecryption(PDEncryption encryption,
COSArray documentIDArray,
DecryptionMaterial decryptionMaterial)
Prepares everything to decrypt the document.
|
decrypt, decryptStream, encryptDataRC4, encryptDataRC4, encryptStream, encryptString, getCurrentAccessPermission, getKeyLength, isAES, setAES, setCurrentAccessPermission, setDecryptMetadata, setKeyLength
public static final String FILTER
public static final Class<?> PROTECTION_POLICY_CLASS
public StandardSecurityHandler()
public StandardSecurityHandler(StandardProtectionPolicy p)
p
- The protection policy.public void prepareForDecryption(PDEncryption encryption, COSArray documentIDArray, DecryptionMaterial decryptionMaterial) throws InvalidPasswordException, IOException
prepareForDecryption
in class SecurityHandler
encryption
- encryption dictionarydocumentIDArray
- document iddecryptionMaterial
- Information used to decrypt the document.InvalidPasswordException
- If the password is incorrect.IOException
- If there is an error accessing data.public void prepareDocumentForEncryption(PDDocument document) throws IOException
prepareDocumentForEncryption
in class SecurityHandler
document
- The documeent to encrypt.IOException
- If there is an error accessing data.public boolean isOwnerPassword(byte[] ownerPassword, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int length, boolean encryptMetadata) throws IOException
ownerPassword
- The owner password.user
- The u entry of the encryption dictionary.owner
- 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.encryptMetadata
- The encryption metadataIOException
- If there is an error accessing data.public byte[] getUserPassword(byte[] ownerPassword, byte[] owner, int encRevision, int length) throws IOException
ownerPassword
- The plaintext owner password.owner
- The o entry of the encryption dictionary.encRevision
- The encryption revision number.length
- The key length.IOException
- If there is an error accessing data while generating the user password.public byte[] computeEncryptedKey(byte[] password, byte[] o, byte[] u, byte[] oe, byte[] ue, int permissions, byte[] id, int encRevision, int length, boolean encryptMetadata, boolean isOwnerPassword) throws IOException
password
- The password to compute the encrypted key.o
- The O entry of the encryption dictionary.u
- The U entry of the encryption dictionary.oe
- The OE entry of the encryption dictionary.ue
- The UE 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.encryptMetadata
- The encryption metadataisOwnerPassword
- whether the password given is the owner password (for revision 6)IOException
- If there is an error with encryption.public byte[] computeUserPassword(byte[] password, byte[] owner, int permissions, byte[] id, int encRevision, int length, boolean encryptMetadata) throws IOException
password
- The plain text password.owner
- 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.encryptMetadata
- The encryption metadataIOException
- if the password could not be computedpublic byte[] computeOwnerPassword(byte[] ownerPassword, byte[] userPassword, int encRevision, int length) throws IOException
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.IOException
- if the owner password could not be computedpublic boolean isUserPassword(byte[] password, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int length, boolean encryptMetadata) throws IOException
password
- The plaintext password.user
- The u entry of the encryption dictionary.owner
- The o entry of the encryption dictionary.permissions
- The permissions set in the PDF.id
- The document id used for encryption.encRevision
- The revision of the encryption algorithm.length
- The length of the encryption key.encryptMetadata
- The encryption metadataIOException
- If there is an error accessing data.public boolean isUserPassword(String password, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int length, boolean encryptMetadata) throws IOException
password
- The plaintext password.user
- The u entry of the encryption dictionary.owner
- The o entry of the encryption dictionary.permissions
- The permissions set in the PDF.id
- The document id used for encryption.encRevision
- The revision of the encryption algorithm.length
- The length of the encryption key.encryptMetadata
- The encryption metadataIOException
- If there is an error accessing data.public boolean isOwnerPassword(String password, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int length, boolean encryptMetadata) throws IOException
password
- The owner password.user
- The u entry of the encryption dictionary.owner
- 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.encryptMetadata
- The encryption metadataIOException
- If there is an error accessing data.public boolean hasProtectionPolicy()
hasProtectionPolicy
in class SecurityHandler
Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.