Package com.sun.pdfview.decrypt
Class PDFDecrypterFactory
java.lang.Object
com.sun.pdfview.decrypt.PDFDecrypterFactory
Produces a
PDFDecrypter for documents given a (possibly non-existent)
Encrypt dictionary. Supports decryption of versions 1, 2 and 4 of the
password-based encryption mechanisms as described in PDF Reference version
1.7. This means that it supports RC4 and AES encryption with keys of
40-128 bits; esentially, password-protected documents with compatibility
up to Acrobat 8.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the standard Identity CryptFilterprivate static final intDefault key length for versions where key length is optional -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static PDFDecryptercreateCryptFilterDecrypter(PDFObject encryptDict, PDFObject documentId, PDFPassword password, int v) Create a decrypter working from a crypt filter dictionary, as in version 4 encryptionstatic PDFDecryptercreateDecryptor(PDFObject encryptDict, PDFObject documentId, PDFPassword password) Create a decryptor for a given encryption dictionary.private static PDFDecryptercreateStandardDecrypter(PDFObject encryptDict, PDFObject documentId, PDFPassword password, Integer keyLength, boolean encryptMetadata, StandardDecrypter.EncryptionAlgorithm encryptionAlgorithm) Create a standard single-algorithm AES or RC4 decrypter.
-
Field Details
-
CF_IDENTITY
The name of the standard Identity CryptFilter- See Also:
-
DEFAULT_KEY_LENGTH
private static final int DEFAULT_KEY_LENGTHDefault key length for versions where key length is optional- See Also:
-
-
Constructor Details
-
PDFDecrypterFactory
public PDFDecrypterFactory()
-
-
Method Details
-
createDecryptor
public static PDFDecrypter createDecryptor(PDFObject encryptDict, PDFObject documentId, PDFPassword password) throws IOException, EncryptionUnsupportedByPlatformException, EncryptionUnsupportedByProductException, PDFAuthenticationFailureException Create a decryptor for a given encryption dictionary. A check is immediately performed that the supplied password decrypts content described by the encryption specification.- Parameters:
encryptDict- the Encrypt dict as found in the document's trailer. May be null, in which case theIdentityDecrypterwill be returned.documentId- the object with key "ID" in the trailer's dictionary. Should always be present if Encrypt is.password- the password to use; may benull- Returns:
- The decryptor that should be used for all encrypted data in the PDF
- Throws:
IOException- will typically be aPDFParseException, indicating an IO problem, an error in the structure of the document, or a failure to obtain various ciphers from the installed JCE providersEncryptionUnsupportedByPlatformException- if the encryption is not supported by the environment in which the code is executingEncryptionUnsupportedByProductException- if PDFRenderer does not currently support the specified encryptionPDFAuthenticationFailureException- if the supplied password was not able to
-
createCryptFilterDecrypter
private static PDFDecrypter createCryptFilterDecrypter(PDFObject encryptDict, PDFObject documentId, PDFPassword password, int v) throws PDFAuthenticationFailureException, IOException, EncryptionUnsupportedByPlatformException, EncryptionUnsupportedByProductException Create a decrypter working from a crypt filter dictionary, as in version 4 encryption- Parameters:
encryptDict- the Encrypt dictionarydocumentId- the document IDpassword- the provided passwordv- the version of encryption being used; must be at least 4- Returns:
- the decrypter corresponding to the scheme expressed in encryptDict
- Throws:
PDFAuthenticationFailureException- if the provided password does not decrypt this documentIOException- if there is a problem reading the PDF, an invalid document structure, or an inability to obtain the required ciphers from the platform's JCEEncryptionUnsupportedByPlatformException- if the encryption is not supported by the environment in which the code is executingEncryptionUnsupportedByProductException- if PDFRenderer does not currently support the specified encryption
-
createStandardDecrypter
private static PDFDecrypter createStandardDecrypter(PDFObject encryptDict, PDFObject documentId, PDFPassword password, Integer keyLength, boolean encryptMetadata, StandardDecrypter.EncryptionAlgorithm encryptionAlgorithm) throws PDFAuthenticationFailureException, IOException, EncryptionUnsupportedByPlatformException, EncryptionUnsupportedByProductException Create a standard single-algorithm AES or RC4 decrypter. The Encrypt dictionary is used where possible, but where different encryption versions employ different mechanisms of specifying configuration or may be specified via a CF entry (e.g. key length), the value is specified as a parameter.- Parameters:
encryptDict- the Encrypt dictionarydocumentId- the document IDpassword- the passwordkeyLength- the key length, in bits; may benullto use adefaultencryptMetadata- whether metadata is being encryptedencryptionAlgorithm- , the encryption algorithm- Returns:
- the decrypter
- Throws:
PDFAuthenticationFailureException- if the provided password is not the one expressed by the encryption dictionaryIOException- if there is a problem reading the PDF content, if the content does not comply with the PDF specificationEncryptionUnsupportedByPlatformException- if the encryption is not supported by the environment in which the code is executingEncryptionUnsupportedByProductException- if PDFRenderer does not currently support the specified encryption
-