public class StandardDecrypter extends java.lang.Object implements PDFDecrypter
Modifier and Type | Class and Description |
---|---|
static class |
StandardDecrypter.EncryptionAlgorithm
Describes an encryption algorithm to be used, declaring not only the
cipher type, but also key generation techniques
|
Constructor and Description |
---|
StandardDecrypter(StandardDecrypter.EncryptionAlgorithm encryptionAlgorithm,
PDFObject documentId,
int keyBitLength,
int revision,
byte[] oValue,
byte[] uValue,
int pValue,
boolean encryptMetadata,
PDFPassword password)
Class constructor
|
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
decryptBuffer(java.lang.String cryptFilterName,
PDFObject streamObj,
java.nio.ByteBuffer streamBuf)
Decrypt a buffer of data
|
java.lang.String |
decryptString(int objNum,
int objGen,
java.lang.String inputBasicString)
Decrypt a
basic string . |
boolean |
isEncryptionPresent()
Determine whether this actually applies a decryption other than
identity decryption.
|
boolean |
isEncryptionPresent(java.lang.String cryptFilterName)
Determines whether decryption applies for a given crypt filter name
|
boolean |
isOwnerAuthorised()
Determine whether the password known by the decrypter indicates that
the user is the owner of the document.
|
public StandardDecrypter(StandardDecrypter.EncryptionAlgorithm encryptionAlgorithm, PDFObject documentId, int keyBitLength, int revision, byte[] oValue, byte[] uValue, int pValue, boolean encryptMetadata, PDFPassword password) throws java.io.IOException, EncryptionUnsupportedByProductException, EncryptionUnsupportedByPlatformException
encryptionAlgorithm
- the algorithm used for encryptiondocumentId
- the contents of the ID entry of the document's trailer
dictionary; can be null, but according to the spec, shouldn't be. Is
expected to be an array of two byte sequences.keyBitLength
- the length of the key in bits; should be a multiple
of 8 between 40 and 128revision
- the revision of the Standard encryption security handler
being employed. Should be 2, 3 or 4.oValue
- the value of the O entry from the Encrypt dictionaryuValue
- the value of the U entry from the Encrypt dictionarypValue
- the value of the P entry from the Encrypt dictionaryencryptMetadata
- whether metadata is being encrypted, as identified
by the Encrypt dict (with default true if not explicitly identified)password
- the password; not nulljava.io.IOException
- if there's a problem reading the fileEncryptionUnsupportedByPlatformException
- if the encryption is not
supported by the environment in which the code is executingEncryptionUnsupportedByProductException
- if PDFRenderer does not
currently support the specified encryptionpublic java.nio.ByteBuffer decryptBuffer(java.lang.String cryptFilterName, PDFObject streamObj, java.nio.ByteBuffer streamBuf) throws PDFParseException
PDFDecrypter
decryptBuffer
in interface PDFDecrypter
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 decryptPDFParseException
- 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.public java.lang.String decryptString(int objNum, int objGen, java.lang.String inputBasicString) throws PDFParseException
PDFDecrypter
basic string
.decryptString
in interface PDFDecrypter
objNum
- the object number of the containing objectobjGen
- the generation number of the containing objectinputBasicString
- the string to be decryptedPDFParseException
- 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.public boolean isOwnerAuthorised()
PDFDecrypter
PDFDecrypter.isEncryptionPresent()
to determine whether any
permissions apply.isOwnerAuthorised
in interface PDFDecrypter
public boolean isEncryptionPresent()
PDFDecrypter
isEncryptionPresent
in interface PDFDecrypter
public boolean isEncryptionPresent(java.lang.String cryptFilterName)
PDFDecrypter
isEncryptionPresent
in interface PDFDecrypter
cryptFilterName
- the crypt filter name