Class CosEncryption
- java.lang.Object
-
- com.adobe.internal.pdftoolkit.core.cos.CosEncryption
-
public class CosEncryption extends java.lang.Object
Performs all encryption-related operations on a Cos Document
-
-
Constructor Summary
Constructors Constructor Description CosEncryption(CosDocument doc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
authenticateDecryption(DecryptedState decryptedState)
InputByteStream
decryptStream(ASName cryptFilter, CosStream strObj, InputByteStream content)
Get the decrypted contents of a stream.byte[]
decryptString(CosString strObj, byte[] content)
Get the decrypted bytes for a stringInputByteStream
encryptStream(ASName cryptFilter, CosStream strObj, InputByteStream content)
Get the encrypted contents of a stream.byte[]
encryptString(CosString strObj, byte[] content)
Get the encrypted bytes for a stringjava.util.Map
getDecryptionMap()
SecurityManager
getDecryptionSecurityManager()
SecurityHandler
getDefaultDecryptionHandler()
Return the default decryption handlerCosDictionary
getEncryption()
EnableEncryption
getEncryptionImpl()
Return the encryption implementationjava.util.Map
getEncryptionMap()
SecurityManager
getEncryptionSecurityManager()
boolean
getEncryptionState()
boolean
needsDecryption()
boolean
needsEncryption()
void
resetDecryptionSecurityManager()
void
resetEncryptionSecurityManager()
void
setDecryptionAsEncryption()
Sets Security Manager for decryption equal to the Security Manager for encryption.void
setDecryptionSecurityManager(SecurityManager securityMgr)
void
setEncryptionSecurityManager(SecurityManager securityMgr, java.util.Map encryptParams)
boolean
setEncryptionState(boolean doIt)
boolean
setNeedsDecryption(boolean decrypt)
void
setupDecryption()
void
setupEncryption()
Setup encryption
-
-
-
Constructor Detail
-
CosEncryption
public CosEncryption(CosDocument doc)
-
-
Method Detail
-
setupDecryption
public void setupDecryption() throws PDFCosParseException, PDFIOException, PDFSecurityException
-
needsDecryption
public boolean needsDecryption()
-
setNeedsDecryption
public boolean setNeedsDecryption(boolean decrypt)
-
needsEncryption
public boolean needsEncryption()
-
getEncryption
public CosDictionary getEncryption()
-
getDecryptionMap
public java.util.Map getDecryptionMap() throws PDFCosParseException, PDFIOException, PDFSecurityException
-
getEncryptionMap
public java.util.Map getEncryptionMap() throws PDFSecurityAuthorizationException
-
getDefaultDecryptionHandler
public SecurityHandler getDefaultDecryptionHandler() throws PDFCosParseException, PDFSecurityException
Return the default decryption handler
-
getEncryptionImpl
public EnableEncryption getEncryptionImpl() throws PDFUnsupportedFeatureException
Return the encryption implementation- Throws:
PDFUnsupportedFeatureException
- if there is no encryption implementation This represents a "can't happen" situation
-
getDecryptionSecurityManager
public SecurityManager getDecryptionSecurityManager()
-
authenticateDecryption
public boolean authenticateDecryption(DecryptedState decryptedState) throws PDFSecurityException
- Throws:
PDFSecurityException
-
setDecryptionSecurityManager
public void setDecryptionSecurityManager(SecurityManager securityMgr) throws PDFSecurityException, PDFCosParseException, PDFIOException
-
getEncryptionSecurityManager
public SecurityManager getEncryptionSecurityManager()
-
setEncryptionSecurityManager
public void setEncryptionSecurityManager(SecurityManager securityMgr, java.util.Map encryptParams)
-
setDecryptionAsEncryption
public void setDecryptionAsEncryption() throws PDFSecurityException, PDFCosParseException, PDFIOException
Sets Security Manager for decryption equal to the Security Manager for encryption. Resets Security Manager for decryption if the Security Manager for encryption is not set.
-
setupEncryption
public void setupEncryption() throws PDFCosParseException, PDFIOException, PDFSecurityException
Setup encryption
-
resetEncryptionSecurityManager
public void resetEncryptionSecurityManager()
-
resetDecryptionSecurityManager
public void resetDecryptionSecurityManager()
-
encryptString
public byte[] encryptString(CosString strObj, byte[] content) throws PDFSecurityException
Get the encrypted bytes for a string- Throws:
PDFUnsupportedFeatureException
- if no encryption implementation is in placePDFSecurityException
-
decryptString
public byte[] decryptString(CosString strObj, byte[] content) throws PDFSecurityException
Get the decrypted bytes for a string- Throws:
PDFUnsupportedFeatureException
PDFSecurityException
PDFSecurityException
PDFUnsupportedFeatureException
- if no encryption implementation is in place
-
decryptStream
public InputByteStream decryptStream(ASName cryptFilter, CosStream strObj, InputByteStream content) throws PDFIOException, PDFSecurityException, PDFCosParseException
Get the decrypted contents of a stream. This stream becomes the property of the caller and must be closed by them.- Throws:
PDFIOException
PDFSecurityException
PDFCosParseException
PDFUnsupportedFeatureException
- if no encryption implementation is in place
-
encryptStream
public InputByteStream encryptStream(ASName cryptFilter, CosStream strObj, InputByteStream content) throws PDFCosParseException, PDFIOException, PDFSecurityException
Get the encrypted contents of a stream. This encrypts the entire contents of theInputByteStream
. If the caller desires to enrypt only a portion of anInputByteStream
they should slice the originalInputByteStream
. The returned encrypted stream becomes the property of the caller and must be closed by them.- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
PDFUnsupportedFeatureException
- if no encryption implementation is in place
-
setEncryptionState
public boolean setEncryptionState(boolean doIt)
-
getEncryptionState
public boolean getEncryptionState()
-
-