Package com.ribs.pdf
Class PDFSecurityHandler
java.lang.Object
com.ribs.pdf.PDFSecurityHandler
- Direct Known Subclasses:
- PDFEncryptor
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidarcfour_decrypt(byte[] inout) decrypt using the cached encryption keyvoidauthenticateUserPassword(byte[] uEntry) decryptObject(Object o, int objNum, int generationNum) byte[]generateEncryptionKey(byte[] oEntry, String password, int keyLength) Uses algorithm 3.2 from pdf spec to generate a key from the filestatic byte[]getBytesForEncryptionEntry(Map encDict, String key) static StringgetEncryptionEntryStringForBytes(byte[] buffer) Inverse of abovebyte[]getEncryptionKey(Map encrypt, List fileID, String pass) Gets the key length and algorithm from the dictionary and creats the keystatic ClassgetHandler(String name) Convenience method for abovestatic PDFSecurityHandlergetInstance(Map encryptionDict, List fileID, String pdfversion) Returns an instance of the appropriate PDFSecurityHandler subclass.getOwnerPasswordEntry(String ownerP, String userP) Returns the string corresponding to the /O entry.byte[]getOwnerPasswordEntryBytes(String ownerP, 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.Returns the string corresponding to the /U entry.byte[]voidMain security handler initialization.static voidbyte[]returns a 32 byte array with the characters of the input string, potentially padded with the password padding.static ClassregisterHandler(Class hclass, String key) like a test&set.voidsetEncryptionParameters(byte[] fileID, String ownerP, String userP, int permissionFlags) Initialization for encryption.voidstartDecrypt(int objNum, int generationNum) 
- 
Field Details- 
PRINTING_ALLOWEDpublic static final int PRINTING_ALLOWED- See Also:
 
- 
MODIFICATIONS_ALLOWEDpublic static final int MODIFICATIONS_ALLOWED- See Also:
 
- 
EXTRACT_TEXT_AND_IMAGES_ALLOWEDpublic static final int EXTRACT_TEXT_AND_IMAGES_ALLOWED- See Also:
 
- 
ADD_ANNOTATIONS_ALLOWEDpublic static final int ADD_ANNOTATIONS_ALLOWED- See Also:
 
- 
FILL_IN_FORMS_ALLOWEDpublic static final int FILL_IN_FORMS_ALLOWED- See Also:
 
- 
ACCESSABILITY_EXTRACTS_ALLOWEDpublic static final int ACCESSABILITY_EXTRACTS_ALLOWED- See Also:
 
- 
ASSEMBLE_DOCUMENT_ALLOWEDpublic static final int ASSEMBLE_DOCUMENT_ALLOWED- See Also:
 
- 
MAXIMUM_RESOLUTION_PRINTING_ALLOWEDpublic static final int MAXIMUM_RESOLUTION_PRINTING_ALLOWED- See Also:
 
 
- 
- 
Constructor Details- 
PDFSecurityHandlerpublic PDFSecurityHandler()
 
- 
- 
Method Details- 
registerHandlerlike a test&set. pass null for class to look up, otherwise it sets
- 
getHandlerConvenience method for above
- 
getInstanceReturns an instance of the appropriate PDFSecurityHandler subclass. Since any number of different security handlers can be used in pdf, callers should use this method rather than instantiating a handler directly. This also does authentication with the handler, possibly raising a panel to ask for passwords, keys, etc.
- 
initpublic void init(Map encryptionDict, List fileID, String pdfversion, String apass) throws com.ribs.pdf.PDFBadPasswordException Main security handler initialization. Calculates everything necessary to decrypt the pdf objects and performs authorization if necessary.- Throws:
- com.ribs.pdf.PDFBadPasswordException
 
- 
setEncryptionParameterspublic void setEncryptionParameters(byte[] fileID, String ownerP, String userP, int permissionFlags) Initialization for encryption. Sets parameters to revision=3, 128 bit keys
- 
getEncryptionKeyGets the key length and algorithm from the dictionary and creats the key
- 
padreturns a 32 byte array with the characters of the input string, potentially padded with the password padding.
- 
generateEncryptionKeyUses algorithm 3.2 from pdf spec to generate a key from the file
- 
authenticateUserPasswordpublic void authenticateUserPassword(byte[] uEntry) throws com.ribs.pdf.PDFBadPasswordException - Throws:
- com.ribs.pdf.PDFBadPasswordException
 
- 
getUserPasswordEntryBytespublic byte[] getUserPasswordEntryBytes()
- 
getBytesForEncryptionEntry
- 
getEncryptionEntryStringForBytesInverse of above
- 
startDecryptpublic void startDecrypt(int objNum, int generationNum) 
- 
decryptObject
- 
decryptDeep
- 
getOwnerPasswordEntryBytesFor 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.
- 
getOwnerPasswordEntryReturns the string corresponding to the /O entry.
- 
getUserPasswordEntryReturns the string corresponding to the /U entry. The encryption key is assumed to be calculated already.
- 
main
- 
arcfour_decryptpublic void arcfour_decrypt(byte[] inout) decrypt using the cached encryption key
 
-