public class PasswordEncryptionParams extends EncryptionParams
PasswordEncryptionParams
is used for standard password encryption.
It inherits from class EncryptionParams
and also contains methods to access to parameters specified for standard password encryption.
A PasswordEncryptionParams
object should be created and set,
if users want to use PDFDocument.startEncryption(EncryptionParams, com.foxit.gsdk.utils.FileHandler, int)
to do standard password encryption.CIPHER_AES, CIPHER_NONE, CIPHER_RC4
Constructor and Description |
---|
PasswordEncryptionParams()
Default constructor of PasswordEncryptionParams.
|
Modifier and Type | Method and Description |
---|---|
int |
checkPassword(byte[] password)
Detect type of password.
|
void |
setCipher(int cipherType,
int keyLength)
Set the type of encryption algorithm and the key length of it.
|
void |
setOwnerPassword(byte[] password)
Set the owner password.
|
void |
setUserPassword(byte[] password)
Set the user password.
|
void |
setUserPermissions(long permissions)
Set the permission flags.
|
getFilter, getParam, getSubFilter, getType, setEncryptMetadata
public PasswordEncryptionParams()
public int checkPassword(byte[] password) throws PDFException
PasswordEncryptionParams
object is returned by PDFDocument.getEncryptionParams()
.
If current PasswordEncryptionParams
object is newly created, this function will return PDFDocument.PASSWORDTYPE_INVALID
.password
- A byte array that specifies the byte string password. It should be valid and not be empty.PDFDocument.PASSWORDTYPE_XXX
, and it will be one of them.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setUserPermissions(long permissions)
PasswordEncryptionParams
object is newly created.permissions
- Permission flags.
Please refer to constant definitions PERMISSION_XXX
and this should be one or a combination of these constants.public void setUserPassword(byte[] password)
PasswordEncryptionParams
object is newly created.password
- A byte array that specifies the user password,
which could be set to null
.public void setOwnerPassword(byte[] password)
PasswordEncryptionParams
object is newly created.password
- A byte array that specifies the owner password,
which could be set to null
.public void setCipher(int cipherType, int keyLength) throws PDFException
PasswordEncryptionParams
object is newly created.cipherType
- The type of encryption algorithm. It should be one of the followings:
keyLength
- Key length of the type of encryption algorithm, in byte.
For CIPHER_AES
, this can only be 16 or 32.
For CIPHER_RC4
, this should be between 5 and 16.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException