public abstract class SecurityHandler
extends java.lang.Object
SecurityHandler
represents an abstract class.
This class holds a number of interfaces for customizing security handling.
It should be set to Foxit PDF SDK by calling
before doing customized encryption or decryption.
PDFDocument.registerSecurityHandler(String, SecurityHandler)
is used to unregistered it from Foxit PDF SDK.PDFDocument.unregisterSecurityHandler(String)
Modifier and Type | Class and Description |
---|---|
class |
SecurityHandler.CipherInfo
Class
CipherInfo represents the cipher information. |
Modifier and Type | Field and Description |
---|---|
java.lang.Object |
clientData
User-defined data.
|
Constructor and Description |
---|
SecurityHandler() |
Modifier and Type | Method and Description |
---|---|
abstract java.lang.Object |
createContext(java.lang.Object clientData,
FileHandler file,
java.lang.String filter,
java.lang.String subFilter,
java.lang.String encryptInfo)
Callback function to initialize context handle.
|
abstract byte[] |
decryptData(java.lang.Object clientData,
java.lang.Object decryptor,
byte[] encDataBuf)
Callback function to decrypted data to the decryptor.
|
abstract byte[] |
encryptData(java.lang.Object clientData,
java.lang.Object context,
int objNum,
int genNum,
byte[] srcBuf)
Callback function to encrypt data.
|
abstract byte[] |
finishDecryptor(java.lang.Object clientData,
java.lang.Object decryptor)
Callback function to release internal structure of the started decryptor context.
|
abstract SecurityHandler.CipherInfo |
getCipherInfo(java.lang.Object clientData,
java.lang.Object context)
Callback function to get cipher information including encryption algorithm and key.
|
abstract long |
getDecryptedSize(java.lang.Object clientData,
java.lang.Object context,
long dataSize)
Callback function to get the estimation size of decrypted data for a source data block.
|
abstract long |
getEncryptedSize(java.lang.Object clientData,
java.lang.Object context,
int objNum,
int genNum,
byte[] srcBuf)
Callback function to get encrypted data size for a source data block.
|
abstract long |
getUserPermissions(java.lang.Object clientData,
java.lang.Object context,
long userPermission)
Callback function to get permissions of user for context.
|
abstract boolean |
isOwner(java.lang.Object clientData,
java.lang.Object context)
Callback function to get identity type: owner or user.
|
abstract void |
releaseContext(java.lang.Object clientData,
java.lang.Object context)
Callback function to release context handle of a custom handler.
|
abstract java.lang.Object |
startDecryptor(java.lang.Object clientData,
java.lang.Object context,
int objNum,
int genNum)
Callback function to start a decryptor context, for decrypting a data stream.
|
public java.lang.Object clientData
public abstract java.lang.Object createContext(java.lang.Object clientData, FileHandler file, java.lang.String filter, java.lang.String subFilter, java.lang.String encryptInfo) throws PDFException
clientData
- The user-defined data.file
- A FileHandler
object.filter
- A String
object to specify filter value.subFilter
- A String
object to specify sub filter value.encryptInfo
- A String
object to specify encryption info data.Object
object that receives a context handle. Return null
if fails.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FileHandler
public abstract void releaseContext(java.lang.Object clientData, java.lang.Object context) throws PDFException
clientData
- The user-defined data.context
- A context
object which is created by callback function createContext(Object, FileHandler, String, String, String)
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public abstract long getUserPermissions(java.lang.Object clientData, java.lang.Object context, long userPermission) throws PDFException
clientData
- The user-defined data.context
- A context
object which is created by callback function createContext(Object, FileHandler, String, String, String)
.userPermission
- Original permission settings of the document.
Please refer to macro definitions PDFDocument.PERMISSION_XXX
and this should be one or a combination of these constants.PDFDocument.PERMISSION_XXX
and this should be one or a combination of these constants.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument
public abstract boolean isOwner(java.lang.Object clientData, java.lang.Object context) throws PDFException
clientData
- The user-defined data.context
- A context
object which is created by callback function createContext(Object, FileHandler, String, String, String)
.true
if decryption of the current PDF document is done by the owner,
or false
if decryption is done by the user.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public abstract SecurityHandler.CipherInfo getCipherInfo(java.lang.Object clientData, java.lang.Object context) throws PDFException
If standard encryption and decryption is used,
callback function
must be set.
Foxit PDF SDK will call this function twice in order to allocate buffer with required and get the cipher info.
So implementation of this interface should be prepared to this situation.getCipherInfo(Object, Object)
clientData
- The user-defined data.context
- A context
object which is created by callback function createContext(Object, FileHandler, String, String, String)
.CipherInfo
object that receives the cipher information.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
SecurityHandler.CipherInfo
public abstract long getDecryptedSize(java.lang.Object clientData, java.lang.Object context, long dataSize) throws PDFException
If application doesn't want to do the estimation, just return 0.
clientData
- The user-defined data.context
- A context
object which is created by callback function createContext(Object, FileHandler, String, String, String)
.dataSize
- Size of source data which is an encrypted data block.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public abstract java.lang.Object startDecryptor(java.lang.Object clientData, java.lang.Object context, int objNum, int genNum) throws PDFException
clientData
- The user-defined data.context
- A context object which is created by callback function createContext(Object, FileHandler, String, String, String)
.objNum
- PDF object number for the object being decrypted.genNum
- PDF version number for the object being decrypted.null
for failurePDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public abstract byte[] decryptData(java.lang.Object clientData, java.lang.Object decryptor, byte[] encDataBuf) throws PDFException
For each encrypted data buffer, Foxit PDF SDK will call this function twice in order to allocate buffer with required size and get the decrypted data. So implementation of this interface should be prepared to this situation.
clientData
- The user-defined data.decryptor
- An internal structure of the created filter.encDataBuf
- A source (encrypted) data.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public abstract byte[] finishDecryptor(java.lang.Object clientData, java.lang.Object decryptor) throws PDFException
clientData
- The user-defined data.decryptor
- An internal object of the created filter.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public abstract long getEncryptedSize(java.lang.Object clientData, java.lang.Object context, int objNum, int genNum, byte[] srcBuf) throws PDFException
This interface is always called before callback function
is used.
Foxit PDF SDK will call this function to prepare enough space to receive the final encrypted data block.encryptData(java.lang.Object, java.lang.Object, int, int, byte[])
clientData
- The user-defined data.context
- A context
object which is created by callback function createContext(Object, FileHandler, String, String, String)
.objNum
- PDF object number for the object being encrypted.genNum
- PDF generation number for the object being encrypted.srcBuf
- A byte array that contains source data block.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public abstract byte[] encryptData(java.lang.Object clientData, java.lang.Object context, int objNum, int genNum, byte[] srcBuf) throws PDFException
clientData
- The user-defined data.context
- A context
object which is created by callback function createContext(Object, FileHandler, String, String, String)
.objNum
- PDF object number for the object being encrypted.genNum
- PDF generation number for the object being encrypted.srcBuf
- A byte array that contains source data block.null
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException