Package com.pd4ml.pdf.cos.security
Class StandardSecurityHandler
- java.lang.Object
-
- com.pd4ml.pdf.cos.security.StandardSecurityHandler
-
public final class StandardSecurityHandler extends java.lang.ObjectImplements the PDF Standard security handler (ISO 32000-1 §7.6.3 / ISO 32000-2 §7.6.4): given a document's/Encryptdictionary, its first/IDelement, and a candidate password, derives the file encryption key and can then decrypt any string or stream belonging to an indirect object in that document.Supports
/V1, 2, 4 (RC4 and AESV2/AES-128 crypt filters) and 5 (AESV3/AES-256, both the R5 "Adobe extension level 3" and the R6/ISO 32000-2 hardened-hash schemes). The password is tried first as the user password, then as the owner password, matching how most PDF viewers behave for a document opened without prompting (typically an empty user password).
-
-
Constructor Summary
Constructors Constructor Description StandardSecurityHandler(COSDictionary encryptDict, byte[] firstIdBytes, java.lang.String password)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]decryptStream(byte[] data, long objectNumber, int generation)byte[]decryptString(byte[] data, long objectNumber, int generation)booleanisEmptyKey()booleanisEncryptMetadata()Whether the document's/Metadatastream is included in encryption (/EncryptMetadata, default true).
-
-
-
Constructor Detail
-
StandardSecurityHandler
public StandardSecurityHandler(COSDictionary encryptDict, byte[] firstIdBytes, java.lang.String password) throws COSSecurityException
- Throws:
COSSecurityException
-
-
Method Detail
-
isEmptyKey
public boolean isEmptyKey()
-
isEncryptMetadata
public boolean isEncryptMetadata()
Whether the document's/Metadatastream is included in encryption (/EncryptMetadata, default true).
-
decryptString
public byte[] decryptString(byte[] data, long objectNumber, int generation) throws COSSecurityException- Throws:
COSSecurityException
-
decryptStream
public byte[] decryptStream(byte[] data, long objectNumber, int generation) throws COSSecurityException- Throws:
COSSecurityException
-
-