00001
00002
00003
00004
00005
00006 #ifndef H_CPPSDFSecurityHandler
00007 #define H_CPPSDFSecurityHandler
00008
00009
00010 #include <vector>
00011 #include <Filters/Filter.h>
00012
00013
00014 namespace pdftron {
00015 namespace SDF {
00016
00017 class Obj;
00018 class SDFDoc;
00019
00020
00024 class SecurityHandler
00025 {
00026 public:
00027
00028 enum Permission
00029 {
00030 e_all = 1,
00031 e_doc_open,
00032 e_doc_secure,
00033 e_doc_modify,
00034 e_print,
00035 e_print_high,
00036 e_extract_content,
00037 e_mod_annot,
00038 e_fill_forms,
00039 e_access_support,
00040 e_assemble_doc
00041 };
00042
00043 SecurityHandler(TRN_SecurityHandler impl, bool owner);
00044
00051 bool GetPermission(Permission p);
00052
00056 SecurityHandler Clone();
00057
00062 int GetKeyLength() const;
00063
00070 int GetEncryptionAlgorithmID() const;
00071
00076 const char* GetHandlerDocName() const;
00077
00085 bool IsModified () const;
00086
00092 void SetModified (bool is_modified = true);
00093
00094
00098 enum AlgorithmType {
00099 e_RC4_40 = 1,
00100 e_RC4_128,
00101 e_AES
00102 };
00103
00109 SecurityHandler (AlgorithmType crypt_type);
00110
00126 SecurityHandler (int key_len, int enc_code);
00127 SecurityHandler ();
00128
00129 SecurityHandler (const SecurityHandler& s);
00130 ~SecurityHandler ();
00131
00136 void ChangeUserPassword(const char* password);
00137
00141 const char* GetUserPassword();
00142
00147 void ChangeMasterPassword(const char* password);
00148
00152 const char* GetMasterPassword();
00153
00171 void SetPermission (Permission perm, bool value);
00172
00185 void ChangeRevisionNumber (int rev_num);
00186
00198 void SetEncryptMetadata(bool encrypt_metadata);
00199
00203 int GetRevisionNumber ();
00204
00208 bool IsUserPasswordRequired ();
00209
00213 bool IsMasterPasswordRequired ();
00214
00219 bool IsAES() const;
00220
00228 bool IsAES(Obj stream) const;
00229
00233 bool IsRC4() const;
00234
00238 operator bool () { return mp_handler!=0;}
00239
00241 TRN_SecurityHandler mp_handler;
00242 bool m_owner;
00244 };
00245
00246
00247
00248
00249 };
00250 };
00251
00252 #include <Impl/SDFDoc.inl>
00253 #endif
00254