org.pdfbox.pdmodel.encryption
Class PDEncryptionDictionary
java.lang.Object
org.pdfbox.pdmodel.encryption.PDEncryptionDictionary
public class PDEncryptionDictionary
extends java.lang.Object
This class is a specialized view of the encryption dictionary of a PDF document.
It contains a low level dictionary (COSDictionary) and provides the methods to
manage its fields.
The available fields are the ones who are involved by standard security handler
and public key security handler.
COSDictionary | getCOSDictionary() - This will get the dictionary associated with this encryption dictionary.
|
String | getFilter() - Get the name of the filter.
|
int | getLength() - This will return the Length entry of the encryption dictionary.
The length in bits for the encryption algorithm.
|
byte[] | getOwnerKey() - This will get the O entry in the standard encryption dictionary.
|
int | getPermissions() - This will get the permissions bit mask.
|
COSString | getRecipientStringAt(int i) - returns the COSString contained in the Recipients field at position i.
|
int | getRecipientsLength() - Returns the number of recipients contained in the Recipients field of the dictionary.
|
int | getRevision() - This will return the R entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.14.
|
byte[] | getUserKey() - This will get the U entry in the standard encryption dictionary.
|
int | getVersion() - This will return the V entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.13.
|
void | setFilter(String filter) - Sets the filter entry of the encryption dictionary.
|
void | setLength(int length) - This will set the number of bits to use for the encryption algorithm.
|
void | setOwnerKey(byte[] o) - This will set the O entry in the standard encryption dictionary.
|
void | setPermissions(int permissions) - This will set the permissions bit mask.
|
void | setRecipients(byte[][] recipients) - This will set the Recipients field of the dictionary.
|
void | setRevision(int revision) - This will set the R entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.14.
|
void | setSubFilter(String subfilter) - Set the subfilter entry of the encryption dictionary.
|
void | setUserKey(byte[] u) - This will set the U entry in the standard encryption dictionary.
|
void | setVersion(int version) - This will set the V entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.13.
|
DEFAULT_LENGTH
public static final int DEFAULT_LENGTH
The default length for the encryption key.
DEFAULT_NAME
public static final String DEFAULT_NAME
The default security handler.
DEFAULT_VERSION
public static final int DEFAULT_VERSION
The default version, according to the PDF Reference.
VERSION0_UNDOCUMENTED_UNSUPPORTED
public static final int VERSION0_UNDOCUMENTED_UNSUPPORTED
See PDF Reference 1.4 Table 3.13.
VERSION1_40_BIT_ALGORITHM
public static final int VERSION1_40_BIT_ALGORITHM
See PDF Reference 1.4 Table 3.13.
VERSION2_VARIABLE_LENGTH_ALGORITHM
public static final int VERSION2_VARIABLE_LENGTH_ALGORITHM
See PDF Reference 1.4 Table 3.13.
VERSION3_UNPUBLISHED_ALGORITHM
public static final int VERSION3_UNPUBLISHED_ALGORITHM
See PDF Reference 1.4 Table 3.13.
VERSION4_SECURITY_HANDLER
public static final int VERSION4_SECURITY_HANDLER
See PDF Reference 1.4 Table 3.13.
encryptionDictionary
protected COSDictionary encryptionDictionary
COS encryption dictionary.
PDEncryptionDictionary
public PDEncryptionDictionary()
creates a new empty encryption dictionary.
PDEncryptionDictionary
public PDEncryptionDictionary(COSDictionary d)
creates a new encryption dictionary from the low level dictionary provided.
d
- the low level dictionary that will be managed by the newly created object
getCOSDictionary
public COSDictionary getCOSDictionary()
This will get the dictionary associated with this encryption dictionary.
- The COS dictionary that this object wraps.
getFilter
public String getFilter()
Get the name of the filter.
- The filter name contained in this encryption dictionary.
getLength
public int getLength()
This will return the Length entry of the encryption dictionary.
The length in bits for the encryption algorithm. This will return a multiple of 8.
- The length in bits for the encryption algorithm
getOwnerKey
public byte[] getOwnerKey()
throws IOException
This will get the O entry in the standard encryption dictionary.
- A 32 byte array or null if there is no owner key.
getPermissions
public int getPermissions()
This will get the permissions bit mask.
- The permissions bit mask.
getRecipientStringAt
public COSString getRecipientStringAt(int i)
returns the COSString contained in the Recipients field at position i.
i
- the position in the Recipients field array.
- a COSString object containing information about the recipient number i.
getRecipientsLength
public int getRecipientsLength()
Returns the number of recipients contained in the Recipients field of the dictionary.
- the number of recipients contained in the Recipients field.
getRevision
public int getRevision()
This will return the R entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.14.
- The encryption revision to use.
getUserKey
public byte[] getUserKey()
throws IOException
This will get the U entry in the standard encryption dictionary.
- A 32 byte array or null if there is no user key.
getVersion
public int getVersion()
This will return the V entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.13.
- The encryption version to use.
setFilter
public void setFilter(String filter)
Sets the filter entry of the encryption dictionary.
filter
- The filter name.
setLength
public void setLength(int length)
This will set the number of bits to use for the encryption algorithm.
length
- The new key length.
setOwnerKey
public void setOwnerKey(byte[] o)
throws IOException
This will set the O entry in the standard encryption dictionary.
o
- A 32 byte array or null if there is no owner key.
setPermissions
public void setPermissions(int permissions)
This will set the permissions bit mask.
permissions
- The new permissions bit mask
setRecipients
public void setRecipients(byte[][] recipients)
throws IOException
This will set the Recipients field of the dictionary. This field contains an array
of string.
recipients
- the array of bytes arrays to put in the Recipients field.
setRevision
public void setRevision(int revision)
This will set the R entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.14.
Note: This value is used to decrypt the pdf document. If you change this when
the document is encrypted then decryption will fail!.
revision
- The new encryption version.
setSubFilter
public void setSubFilter(String subfilter)
Set the subfilter entry of the encryption dictionary.
subfilter
- The value of the subfilter field.
setUserKey
public void setUserKey(byte[] u)
throws IOException
This will set the U entry in the standard encryption dictionary.
setVersion
public void setVersion(int version)
This will set the V entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.13.
Note: This value is used to decrypt the pdf document. If you change this when
the document is encrypted then decryption will fail!.
version
- The new encryption version.