public class PDFSecurityHandler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ACCESSABILITY_EXTRACTS_ALLOWED |
static int |
ADD_ANNOTATIONS_ALLOWED |
static int |
ASSEMBLE_DOCUMENT_ALLOWED |
static int |
EXTRACT_TEXT_AND_IMAGES_ALLOWED |
static int |
FILL_IN_FORMS_ALLOWED |
static int |
MAXIMUM_RESOLUTION_PRINTING_ALLOWED |
static int |
MODIFICATIONS_ALLOWED |
static int |
PRINTING_ALLOWED |
Constructor and Description |
---|
PDFSecurityHandler() |
Modifier and Type | Method and Description |
---|---|
void |
arcfour_decrypt(byte[] inout)
decrypt using the cached encryption key
|
void |
authenticateUserPassword(byte[] uEntry) |
java.lang.Object |
decryptDeep(java.lang.Object o) |
java.lang.Object |
decryptObject(java.lang.Object o,
int objNum,
int generationNum) |
byte[] |
generateEncryptionKey(byte[] oEntry,
java.lang.String password,
int keyLength)
Uses algorithm 3.2 from pdf spec to generate a key from the file
|
static byte[] |
getBytesForEncryptionEntry(java.util.Map encDict,
java.lang.String key) |
static java.lang.String |
getEncryptionEntryStringForBytes(byte[] buffer)
Inverse of above
|
byte[] |
getEncryptionKey(java.util.Map encrypt,
java.util.List fileID,
java.lang.String pass)
Gets the key length and algorithm from the dictionary and creats the key
|
static java.lang.Class |
getHandler(java.lang.String name)
Convenience method for above
|
static PDFSecurityHandler |
getInstance(java.util.Map encryptionDict,
java.util.List fileID,
java.lang.String pdfversion)
Returns an instance of the appropriate PDFSecurityHandler subclass.
|
java.lang.String |
getOwnerPasswordEntry(java.lang.String ownerP,
java.lang.String userP)
Returns the string corresponding to the /O entry.
|
byte[] |
getOwnerPasswordEntryBytes(java.lang.String ownerP,
java.lang.String userP)
For encryption - generate a /O encryption entry for an encryption dictionary (from Algorithm 3.3 of the spec) This
routine uses Revision 3 of the algorithm and 128 bit keys.
|
java.lang.String |
getUserPasswordEntry()
Returns the string corresponding to the /U entry.
|
byte[] |
getUserPasswordEntryBytes() |
void |
init(java.util.Map encryptionDict,
java.util.List fileID,
java.lang.String pdfversion,
java.lang.String apass)
Main security handler initialization.
|
static void |
main(java.lang.String[] args) |
byte[] |
pad(java.lang.String password)
returns a 32 byte array with the characters of the input string, potentially padded with the password padding.
|
static java.lang.Class |
registerHandler(java.lang.Class hclass,
java.lang.String key)
like a test&set.
|
void |
setEncryptionParameters(byte[] fileID,
java.lang.String ownerP,
java.lang.String userP,
int permissionFlags)
Initialization for encryption.
|
void |
startDecrypt(int objNum,
int generationNum) |
public static final int PRINTING_ALLOWED
public static final int MODIFICATIONS_ALLOWED
public static final int EXTRACT_TEXT_AND_IMAGES_ALLOWED
public static final int ADD_ANNOTATIONS_ALLOWED
public static final int FILL_IN_FORMS_ALLOWED
public static final int ACCESSABILITY_EXTRACTS_ALLOWED
public static final int ASSEMBLE_DOCUMENT_ALLOWED
public static final int MAXIMUM_RESOLUTION_PRINTING_ALLOWED
public static java.lang.Class registerHandler(java.lang.Class hclass, java.lang.String key)
public static java.lang.Class getHandler(java.lang.String name)
public static PDFSecurityHandler getInstance(java.util.Map encryptionDict, java.util.List fileID, java.lang.String pdfversion)
public void init(java.util.Map encryptionDict, java.util.List fileID, java.lang.String pdfversion, java.lang.String apass) throws com.ribs.pdf.PDFBadPasswordException
com.ribs.pdf.PDFBadPasswordException
public void setEncryptionParameters(byte[] fileID, java.lang.String ownerP, java.lang.String userP, int permissionFlags)
public byte[] getEncryptionKey(java.util.Map encrypt, java.util.List fileID, java.lang.String pass)
public byte[] pad(java.lang.String password)
public byte[] generateEncryptionKey(byte[] oEntry, java.lang.String password, int keyLength)
public void authenticateUserPassword(byte[] uEntry) throws com.ribs.pdf.PDFBadPasswordException
com.ribs.pdf.PDFBadPasswordException
public byte[] getUserPasswordEntryBytes()
public static byte[] getBytesForEncryptionEntry(java.util.Map encDict, java.lang.String key)
public static java.lang.String getEncryptionEntryStringForBytes(byte[] buffer)
public void startDecrypt(int objNum, int generationNum)
public java.lang.Object decryptObject(java.lang.Object o, int objNum, int generationNum)
public java.lang.Object decryptDeep(java.lang.Object o)
public byte[] getOwnerPasswordEntryBytes(java.lang.String ownerP, java.lang.String userP)
public java.lang.String getOwnerPasswordEntry(java.lang.String ownerP, java.lang.String userP)
public java.lang.String getUserPasswordEntry()
public static void main(java.lang.String[] args)
public void arcfour_decrypt(byte[] inout)