Package com.sun.pdfview.decrypt
Class CryptFilterDecrypter
java.lang.Object
com.sun.pdfview.decrypt.CryptFilterDecrypter
- All Implemented Interfaces:
PDFDecrypter
Implements Version 4 standard decryption, whereby the Encrypt dictionary
contains a list of named 'crypt filters', each of which is the equivalent
of a
PDFDecrypter
. In addition to this list of crypt filters,
the name of the filter to use for streams and the default filter to use
for strings is specified. Requests to decode a stream with a named
decrypter (typically Identity) instead of the default decrypter
are honoured.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map
<String, PDFDecrypter> Maps from crypt filter names to their corresponding decryptersprivate PDFDecrypter
The default decrypter for stream contentprivate PDFDecrypter
The default decrypter for string content -
Constructor Summary
ConstructorsConstructorDescriptionCryptFilterDecrypter
(Map<String, PDFDecrypter> decrypters, String defaultStreamCryptName, String defaultStringCryptName) Class constructor -
Method Summary
Modifier and TypeMethodDescriptiondecryptBuffer
(String cryptFilterName, PDFObject streamObj, ByteBuffer streamBuf) Decrypt a buffer of datadecryptString
(int objNum, int objGen, String inputBasicString) Decrypt abasic string
.boolean
Determine whether this actually applies a decryption other than identity decryption.boolean
Determine whether the password known by the decrypter indicates that the user is the owner of the document.
-
Field Details
-
decrypters
Maps from crypt filter names to their corresponding decrypters -
defaultStreamDecrypter
The default decrypter for stream content -
defaultStringDecrypter
The default decrypter for string content
-
-
Constructor Details
-
CryptFilterDecrypter
public CryptFilterDecrypter(Map<String, PDFDecrypter> decrypters, String defaultStreamCryptName, String defaultStringCryptName) throws PDFParseExceptionClass constructor- Parameters:
decrypters
- a map of crypt filter names to their corresponding decrypters. Must already contain the Identity filter.defaultStreamCryptName
- the crypt filter name of the default stream decrypterdefaultStringCryptName
- the crypt filter name of the default string decrypter- Throws:
PDFParseException
- if one of the named defaults is not present in decrypters
-
-
Method Details
-
decryptBuffer
public ByteBuffer decryptBuffer(String cryptFilterName, PDFObject streamObj, ByteBuffer streamBuf) throws PDFParseException Description copied from interface:PDFDecrypter
Decrypt a buffer of data- Specified by:
decryptBuffer
in interfacePDFDecrypter
- Parameters:
cryptFilterName
- the name of the crypt filter, if V4 encryption is being used, where individual crypt filters may be specified for individual streams. If encryption is not using V4 encryption (indicated by V=4 in the Encrypt dictionary) then this must be null. Null may also be specified with V4 encryption to indicate that the default filter should be used.streamObj
- the object whose stream is being decrypted. The containing object's number and generation contribute to the key used for stream encrypted with the document's default encryption, so this is typically required. Should be null only if a cryptFilterName is specified, as objects with specific stream filters use the general document key, rather than a stream-specific key.streamBuf
- the buffer to decrypt- Returns:
- a buffer containing the decrypted stream, positioned at its beginning; will only be the same buffer as streamBuf if the identity decrypter is being used
- Throws:
PDFParseException
- if the named crypt filter does not exist, or if a crypt filter is named when named crypt filters are not supported. Problems due to incorrect passwords are revealed prior to this point.
-
decryptString
public String decryptString(int objNum, int objGen, String inputBasicString) throws PDFParseException Description copied from interface:PDFDecrypter
Decrypt abasic string
.- Specified by:
decryptString
in interfacePDFDecrypter
- Parameters:
objNum
- the object number of the containing objectobjGen
- the generation number of the containing objectinputBasicString
- the string to be decrypted- Returns:
- the decrypted string
- Throws:
PDFParseException
- if the named crypt filter does not exist, or if a crypt filter is named when named crypt filters are not supported. Problems due to incorrect passwords are revealed prior to this point.
-
isEncryptionPresent
public boolean isEncryptionPresent()Description copied from interface:PDFDecrypter
Determine whether this actually applies a decryption other than identity decryption.- Specified by:
isEncryptionPresent
in interfacePDFDecrypter
- Returns:
- whether encryption is present
-
isOwnerAuthorised
public boolean isOwnerAuthorised()Description copied from interface:PDFDecrypter
Determine whether the password known by the decrypter indicates that the user is the owner of the document. Can be used, in conjunction withPDFDecrypter.isEncryptionPresent()
to determine whether any permissions apply.- Specified by:
isOwnerAuthorised
in interfacePDFDecrypter
- Returns:
- whether owner authentication is being used to decrypt the document
-