to see how to protect document with this security handler.
| Modifier and Type | Field and Description |
|---|---|
| private static final byte[] | ENCRYPT_PADDING
Standard padding for encryption. |
| public static final String | FILTER
Type of security handler. |
| private static final String[] | |
| private static final Log | LOG
Hides org. |
| public static final Class | PROTECTION_POLICY_CLASS
Protection policy class for this handler. |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | StandardSecurityHandler(StandardProtectionPolicy
The protection policy. standardProtectionPolicy)Constructor used for encryption. |
| Modifier and Type | Method and Description |
|---|---|
| private static byte[] | |
| public byte[] | Returns: The encrypted key bytes.The password to compute the encrypted key. password, byte[] The O entry of the encryption dictionary. o, byte[] The U entry of the encryption dictionary. u, byte[] The OE entry of the encryption dictionary. oe, byte[] The UE entry of the encryption dictionary. ue, int The permissions for the document. permissions, byte[] The document id. id, int The revision of the encryption algorithm. encRevision, int The length of the encryption key in bytes. keyLengthInBytes, boolean The encryption metadata encryptMetadata, boolean whether the password given is the owner password (for revision 6) isOwnerPassword)Compute the encryption key. |
| private byte[] | computeEncryptedKeyRev234(byte[] password, byte[] o, int permissions, byte[] id, boolean encryptMetadata, int length, int encRevision)
|
| private byte[] | computeEncryptedKeyRev56(byte[] password, boolean isOwnerPassword, byte[] o, byte[] u, byte[] oe, byte[] ue, int encRevision)
|
| private byte[] | |
| private static byte[] | |
| public byte[] | Returns: The o entry of the encryption dictionary.The plaintext owner password. ownerPassword, byte[] The plaintext user password. userPassword, int The revision number of the encryption algorithm. encRevision, int The length of the encryption key. length)Compute the owner entry in the encryption dictionary. |
| private byte[] | |
| private int | Returns: The computed revision number.The version number. version)Computes the revision version of the StandardSecurityHandler to use regarding the version number and the permissions bits set. |
| private static byte[] | |
| public byte[] | Returns: The user password.The plain text password. password, byte[] The owner password hash. owner, int The document permissions. permissions, byte[] The document id. id, int The revision of the encryption. encRevision, int The length of the encryption key in bytes. keyLengthInBytes, boolean The encryption metadata encryptMetadata)This will compute the user password hash. |
| private static byte[] | |
| private static byte[] | |
| private byte[] | |
| public byte[] | Returns: The u entry of the encryption dictionary.The plaintext owner password. ownerPassword, byte[] The o entry of the encryption dictionary. owner, int The encryption revision number. encRevision, int The key length. length)Get the user password based on the owner password. |
| private byte[] | |
| public boolean | Returns: True If the ownerPassword param is the owner password.The owner password. ownerPassword, byte[] The u entry of the encryption dictionary. user, byte[] The o entry of the encryption dictionary. owner, int The set of permissions on the document. permissions, byte[] The document id. id, int The encryption algorithm revision. encRevision, int The encryption key length in bytes. keyLengthInBytes, boolean The encryption metadata encryptMetadata)Check for owner password. |
| public boolean | Returns: True If the ownerPassword param is the owner password.The owner password. password, byte[] The u entry of the encryption dictionary. user, byte[] The o entry of the encryption dictionary. owner, int The set of permissions on the document. permissions, byte[] The document id. id, int The encryption algorithm revision. encRevision, int The encryption key length in bytes. keyLengthInBytes, boolean The encryption metadata encryptMetadata)Check for owner password. |
| private boolean | isOwnerPassword234(byte[] ownerPassword, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int keyLengthInBytes, boolean encryptMetadata)
|
| private boolean | |
| public boolean | Returns: true If the plaintext password is the user password.The plaintext password. password, byte[] The u entry of the encryption dictionary. user, byte[] The o entry of the encryption dictionary. owner, int The permissions set in the PDF. permissions, byte[] The document id used for encryption. id, int The revision of the encryption algorithm. encRevision, int The length of the encryption key in bytes. keyLengthInBytes, boolean The encryption metadata. encryptMetadata)Check if a plaintext password is the user password. |
| public boolean | Returns: true If the plaintext password is the user password.The plaintext password. password, byte[] The u entry of the encryption dictionary. user, byte[] The o entry of the encryption dictionary. owner, int The permissions set in the PDF. permissions, byte[] The document id used for encryption. id, int The revision of the encryption algorithm. encRevision, int The length of the encryption key in bytes. keyLengthInBytes, boolean The encryption metadata encryptMetadata)Check if a plaintext password is the user password. |
| private boolean | isUserPassword234(byte[] password, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int length, boolean encryptMetadata)
|
| private boolean | |
| private static void | |
| public void | prepareDocumentForEncryption(PDDocument
The document to encrypt. document)Implements abstract org. Prepare document for encryption. |
| private void | |
| private void | prepareEncryptionDictRev234(String ownerPassword, String userPassword, PDEncryption encryptionDictionary, int permissionInt, PDDocument document, int revision, int length)
|
| private void | prepareEncryptionDictRev6(String ownerPassword, String userPassword, PDEncryption encryptionDictionary, int permissionInt)
|
| public void | prepareForDecryption(PDEncryption
encryption dictionary encryption, COSArray document id documentIDArray, DecryptionMaterial Information used to decrypt the document. decryptionMaterial)Implements abstract org. Prepares everything to decrypt the document. |
| private static byte[] | |
| private byte[] | Returns: The padded or truncated password.The password to pad or truncate. password)This will take the password and truncate or pad it as necessary. |
| private void |
| ENCRYPT_PADDING | back to summary |
|---|---|
| private static final byte[] ENCRYPT_PADDING Standard padding for encryption. | |
| FILTER | back to summary |
|---|---|
| public static final String FILTER Type of security handler. | |
| HASHES_2B | back to summary |
|---|---|
| private static final String[] HASHES_2B | |
| LOG | back to summary |
|---|---|
| private static final Log LOG Hides org. Log instance. | |
| PROTECTION_POLICY_CLASS | back to summary |
|---|---|
| public static final Class<?> PROTECTION_POLICY_CLASS Protection policy class for this handler. | |
| REVISION_2 | back to summary |
|---|---|
| private static final int REVISION_2 | |
| REVISION_3 | back to summary |
|---|---|
| private static final int REVISION_3 | |
| REVISION_4 | back to summary |
|---|---|
| private static final int REVISION_4 | |
| REVISION_5 | back to summary |
|---|---|
| private static final int REVISION_5 | |
| REVISION_6 | back to summary |
|---|---|
| private static final int REVISION_6 | |
| StandardSecurityHandler | back to summary |
|---|---|
| public StandardSecurityHandler() Constructor. | |
| StandardSecurityHandler | back to summary |
|---|---|
| public StandardSecurityHandler(StandardProtectionPolicy standardProtectionPolicy) Constructor used for encryption.
| |
| adjustUserKey | back to summary |
|---|---|
| private static byte[] adjustUserKey(byte[] u) throws IOException | |
| computeEncryptedKey | back to summary |
|---|---|
| public byte[] computeEncryptedKey(byte[] password, byte[] o, byte[] u, byte[] oe, byte[] ue, int permissions, byte[] id, int encRevision, int keyLengthInBytes, boolean encryptMetadata, boolean isOwnerPassword) throws IOException Compute the encryption key.
| |
| computeEncryptedKeyRev234 | back to summary |
|---|---|
| private byte[] computeEncryptedKeyRev234(byte[] password, byte[] o, int permissions, byte[] id, boolean encryptMetadata, int length, int encRevision) | |
| computeEncryptedKeyRev56 | back to summary |
|---|---|
| private byte[] computeEncryptedKeyRev56(byte[] password, boolean isOwnerPassword, byte[] o, byte[] u, byte[] oe, byte[] ue, int encRevision) throws IOException | |
| computeHash2A | back to summary |
|---|---|
| private byte[] computeHash2A(byte[] password, byte[] salt, byte[] u) throws IOException | |
| computeHash2B | back to summary |
|---|---|
| private static byte[] computeHash2B(byte[] input, byte[] password, byte[] userKey) throws IOException | |
| computeOwnerPassword | back to summary |
|---|---|
| public byte[] computeOwnerPassword(byte[] ownerPassword, byte[] userPassword, int encRevision, int length) throws IOException Compute the owner entry in the encryption dictionary.
| |
| computeRC4key | back to summary |
|---|---|
| private byte[] computeRC4key(byte[] ownerPassword, int encRevision, int length) | |
| computeRevisionNumber | back to summary |
|---|---|
| private int computeRevisionNumber(int version) Computes the revision version of the StandardSecurityHandler to use regarding the version number and the permissions bits set. See PDF Spec 1.6 p98
| |
| computeSHA256 | back to summary |
|---|---|
| private static byte[] computeSHA256(byte[] input, byte[] password, byte[] userKey) throws IOException | |
| computeUserPassword | back to summary |
|---|---|
| public byte[] computeUserPassword(byte[] password, byte[] owner, int permissions, byte[] id, int encRevision, int keyLengthInBytes, boolean encryptMetadata) throws IOException This will compute the user password hash.
| |
| concat | back to summary |
|---|---|
| private static byte[] concat(byte[] a, byte[] b) | |
| concat | back to summary |
|---|---|
| private static byte[] concat(byte[] a, byte[] b, byte[] c) | |
| getDocumentIDBytes | back to summary |
|---|---|
| private byte[] getDocumentIDBytes(COSArray documentIDArray) | |
| getUserPassword | back to summary |
|---|---|
| public byte[] getUserPassword(byte[] ownerPassword, byte[] owner, int encRevision, int length) throws IOException Get the user password based on the owner password.
| |
| getUserPassword234 | back to summary |
|---|---|
| private byte[] getUserPassword234(byte[] ownerPassword, byte[] owner, int encRevision, int length) throws IOException | |
| isOwnerPassword | back to summary |
|---|---|
| public boolean isOwnerPassword(byte[] ownerPassword, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int keyLengthInBytes, boolean encryptMetadata) throws IOException Check for owner password.
| |
| isOwnerPassword | back to summary |
|---|---|
| public boolean isOwnerPassword(String password, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int keyLengthInBytes, boolean encryptMetadata) throws IOException Check for owner password.
| |
| isOwnerPassword234 | back to summary |
|---|---|
| private boolean isOwnerPassword234(byte[] ownerPassword, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int keyLengthInBytes, boolean encryptMetadata) throws IOException | |
| isOwnerPassword56 | back to summary |
|---|---|
| private boolean isOwnerPassword56(byte[] ownerPassword, byte[] user, byte[] owner, int encRevision) throws IOException | |
| isUserPassword | back to summary |
|---|---|
| public boolean isUserPassword(byte[] password, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int keyLengthInBytes, boolean encryptMetadata) throws IOException Check if a plaintext password is the user password.
| |
| isUserPassword | back to summary |
|---|---|
| public boolean isUserPassword(String password, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int keyLengthInBytes, boolean encryptMetadata) throws IOException Check if a plaintext password is the user password.
| |
| isUserPassword234 | back to summary |
|---|---|
| private boolean isUserPassword234(byte[] password, byte[] user, byte[] owner, int permissions, byte[] id, int encRevision, int length, boolean encryptMetadata) throws IOException | |
| isUserPassword56 | back to summary |
|---|---|
| private boolean isUserPassword56(byte[] password, byte[] user, int encRevision) throws IOException | |
| logIfStrongEncryptionMissing | back to summary |
|---|---|
| private static void logIfStrongEncryptionMissing() | |
| prepareDocumentForEncryption | back to summary |
|---|---|
| public void prepareDocumentForEncryption(PDDocument document) throws IOException Implements abstract org. Prepare document for encryption.
| |
| prepareEncryptionDictAES | back to summary |
|---|---|
| private void prepareEncryptionDictAES(PDEncryption encryptionDictionary, COSName aesVName) | |
| prepareEncryptionDictRev234 | back to summary |
|---|---|
| private void prepareEncryptionDictRev234(String ownerPassword, String userPassword, PDEncryption encryptionDictionary, int permissionInt, PDDocument document, int revision, int length) throws IOException | |
| prepareEncryptionDictRev6 | back to summary |
|---|---|
| private void prepareEncryptionDictRev6(String ownerPassword, String userPassword, PDEncryption encryptionDictionary, int permissionInt) throws IOException | |
| prepareForDecryption | back to summary |
|---|---|
| public void prepareForDecryption(PDEncryption encryption, COSArray documentIDArray, DecryptionMaterial decryptionMaterial) throws IOException Implements abstract org. Prepares everything to decrypt the document. Only if decryption of single objects is needed this should be called.
| |
| truncate127 | back to summary |
|---|---|
| private static byte[] truncate127(byte[] in) | |
| truncateOrPad | back to summary |
|---|---|
| private byte[] truncateOrPad(byte[] password) This will take the password and truncate or pad it as necessary.
| |
| validatePerms | back to summary |
|---|---|
| private void validatePerms(PDEncryption encryption, int dicPermissions, boolean encryptMetadata) throws IOException | |