public class SecurityHandler
extends java.lang.Object
implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
static int |
e_access_support
The Constant e_access_support.
|
static int |
e_AES
The Constant e_AES.
|
static int |
e_assemble_doc
The Constant e_assemble_doc.
|
static int |
e_doc_modify
The Constant e_doc_modify.
|
static int |
e_doc_open
The Constant e_doc_open.
|
static int |
e_extract_content
The Constant e_extract_content.
|
static int |
e_fill_forms
The Constant e_fill_forms.
|
static int |
e_mod_annot
The Constant e_mod_annot.
|
static int |
e_owner
The Constant e_owner.
|
static int |
e_print
The Constant e_print.
|
static int |
e_print_high
The Constant e_print_high.
|
static int |
e_RC4_128
The Constant e_RC4_128.
|
static int |
e_RC4_40
The algorithm to be used in encrypting and decrypting the document.
|
Constructor and Description |
---|
SecurityHandler()
Instantiates a new security handler.
|
SecurityHandler(int crypt_type)
Create a Standard Security Handler.
|
SecurityHandler(int key_len,
int enc_code)
Create a Standard Security Handler.
|
Modifier and Type | Method and Description |
---|---|
static SecurityHandler |
__Create(long impl,
java.lang.Object ref) |
long |
__GetHandle() |
void |
__SetRefHandle(java.lang.Object ref) |
void |
changeMasterPassword(byte[] passwordBuffer)
Modify the master/owner password.
|
void |
changeMasterPassword(java.lang.String password)
Modify the master password.
|
void |
changeRevisionNumber(int rev_num)
Change the revision number and the encryption algorithm of the
standard security handler.
|
void |
changeUserPassword(byte[] passwordBuffer)
Modify the user password.
|
void |
changeUserPassword(java.lang.String password)
Modify the user password.
|
java.lang.Object |
clone() |
void |
destroy()
Frees the native memory of the object.
|
int |
getEncryptionAlgorithmID()
Get the encryption algorithm ID.
|
java.lang.String |
getHandlerDocName()
Get the name of SecurityHandler.
|
int |
getKeyLength()
Get the encryption key length.
|
java.lang.String |
getMasterPassword()
Get the master password.
|
boolean |
getPermission(int type)
Get the security permission.
|
int |
getRevisionNumber()
Get the revision number.
|
java.lang.String |
getUserPassword()
Get the user password.
|
boolean |
isAES()
Checks if encryption is AES.
|
boolean |
isAES(Obj stream)
The following function can be used to verify whether a given stream is
encrypted using AES.
|
boolean |
isMasterPasswordRequired()
Checks if is master password required.
|
boolean |
isModified()
Checks if SecurityHandler is modified.
|
boolean |
isRC4()
Checks if encryption is RC4.
|
boolean |
isUserPasswordRequired()
Checks if is user password required.
|
void |
setEncryptMetadata(boolean encrypt_metadata)
Indicates whether the document-level metadata stream is to
be encrypted.
|
void |
setModified()
The method allows derived classes to set SecurityHandler is modified flag.
|
void |
setModified(boolean is_modified)
The method allows derived classes to set SecurityHandler is modified flag.
|
void |
setPermission(int perm,
boolean value)
Set the permission setting of the StdSecurityHandler.
|
public static final int e_owner
public static final int e_doc_open
public static final int e_doc_modify
public static final int e_print
public static final int e_print_high
public static final int e_extract_content
public static final int e_mod_annot
public static final int e_fill_forms
public static final int e_access_support
public static final int e_assemble_doc
public static final int e_RC4_40
public static final int e_RC4_128
public static final int e_AES
public SecurityHandler(int crypt_type)
crypt_type
- The encryption algorithm identifier.public SecurityHandler(int key_len, int enc_code)
key_len
- The bit length of the encryption key (40 or 128 bit).
Default value is 128.enc_code
- The encryption algorithm identifier. The number corresponds
to the V entry in encryption dictionary. Currently allowed values are (see
Table 3.18 in PDF Reference Manual v1.6 for more details):
public SecurityHandler()
public boolean getPermission(int type)
type
- security permission typespublic java.lang.Object clone()
clone
in class java.lang.Object
public int getKeyLength()
Note: The returned key length is given in bytes.
public int getEncryptionAlgorithmID()
public java.lang.String getHandlerDocName()
public boolean isModified()
public void setModified()
public void setModified(boolean is_modified)
is_modified
- boolean value of SecurityHandler modification statepublic void destroy()
public void changeUserPassword(java.lang.String password)
password
- the new user passwordpublic void changeUserPassword(byte[] passwordBuffer)
passwordBuffer
- The new user password represented in bytes.public java.lang.String getUserPassword()
public void changeMasterPassword(java.lang.String password)
password
- the new master/owner passwordpublic void changeMasterPassword(byte[] passwordBuffer)
passwordBuffer
- The new master/owner password represented in bytes.public java.lang.String getMasterPassword()
public void setPermission(int perm, boolean value)
perm
- indicates a permission to set or clear. It can be any of the
following values:
e_print // print the document.
e_doc_modify // edit the document more than adding or modifying text notes.
e_extract_content // enable content extraction
e_mod_annot // allow modifications to annotations
e_fill_forms // allow changes to fill in forms
e_access_support // content access for the visually impaired.
e_assemble_doc // allow document assembly
e_print_high // high resolution print.value
- true if the permission/s should be granted, false otherwise.public void changeRevisionNumber(int rev_num)
rev_num
- the new revision number of the standard security
algorithm. Currently allowed values for the revision number are
(see Table 3.18 in PDF Reference Manual v1.6 for more details):
- 2 : Encryption using 40-bit RC4 algorithm.
- 3 : Encryption using 128-bit RC4 algorithm. Available in PDF 1.4 and above.
- 4 : Encryption using Crypt filters and 128-bit AES (Advanced Encryption
Standard) algorithm. Available in PDF 1.6 and above.public void setEncryptMetadata(boolean encrypt_metadata)
Note: EncryptMetadata flag affects only Crypt filters available in PDF 1.5 (Acrobat 6) and later. By default, metadata stream will be encrypted.
encrypt_metadata
- true if metadata stream should be
encrypted, false otherwise.public int getRevisionNumber()
public boolean isUserPasswordRequired()
public boolean isMasterPasswordRequired()
public boolean isAES()
public boolean isAES(Obj stream)
stream
- A pointer to an SDF::Stream objectpublic boolean isRC4()
public static SecurityHandler __Create(long impl, java.lang.Object ref)
public long __GetHandle()
public void __SetRefHandle(java.lang.Object ref)