All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SecurityHandler.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPSDFSecurityHandler
6 #define PDFTRON_H_CPPSDFSecurityHandler
7 
8 #include <vector>
9 #include <Common/UString.h>
10 #include <Filters/Filter.h>
11 
12 namespace pdftron {
13  namespace SDF {
14 
15 class Obj;
16 class SDFDoc;
17 
18 
23 {
24 public:
25 
27  {
28  e_owner = 1,
38  };
39 
51  bool GetPermission(Permission p);
52 
57  int GetKeyLength() const;
58 
65  int GetEncryptionAlgorithmID() const;
66 
71  const char* GetHandlerDocName() const;
72 
80  bool IsModified () const;
81 
86  bool IsValid () const;
87 
88 
95  void SetModified (bool is_modified = true);
96 
97 
102  e_RC4_40 = 1,
106  };
107 
113  SecurityHandler (AlgorithmType crypt_type);
114 
131  SecurityHandler (const char* name, int key_len, int enc_code);
132  SecurityHandler ();
133 
134  SecurityHandler (const SecurityHandler& s);
136  virtual ~SecurityHandler ();
137 
144  void ChangeUserPasswordASCII(const char* password);
145 
152  void ChangeUserPassword(const char* password, size_t pwd_length );
153 
158  void ChangeUserPassword(const pdftron::UString& password);
159 
164  void ChangeUserPassword(const std::vector<pdftron::UInt8>& password_buf);
165 
169  const char* GetUserPassword();
170 
175  size_t GetUserPasswordSize() const;
176 
183  void ChangeMasterPasswordASCII(const char* password);
184 
191  void ChangeMasterPassword(const char* password, size_t pwd_length);
192 
197  void ChangeMasterPassword(const pdftron::UString& password);
198 
203  void ChangeMasterPassword(const std::vector<pdftron::UInt8>& password_buf);
204 
208  const char* GetMasterPassword();
209 
214  size_t GetMasterPasswordSize() const;
215 
232  void SetPermission (Permission perm, bool value);
233 
246  void ChangeRevisionNumber (int rev_num);
247 
259  void SetEncryptMetadata(bool encrypt_metadata);
260 
264  int GetRevisionNumber ();
265 
269  bool IsUserPasswordRequired ();
270 
274  bool IsMasterPasswordRequired ();
275 
280  bool IsAES() const;
281 
289  bool IsAES(Obj stream) const;
290 
294  bool IsRC4() const;
295 
299  operator bool () { return mp_handler!=0;}
300 
306  virtual void AuthorizeFailed();
307 
323  virtual bool Authorize (Permission p);
324 
336  virtual bool GetAuthorizationData (Permission req_opr);
337 
344  virtual bool EditSecurityData(SDFDoc& doc);
345 
368  virtual Obj FillEncryptDict(class SDFDoc& doc);
369 
374  virtual SecurityHandler* Clone(TRN_SecurityHandler base) const;
375 
382  void InitPasswordASCII(const char* password);
383 
390  void InitPassword(const char* password, size_t pwd_length);
391 
396  void InitPassword(const pdftron::UString& password);
397 
402  void InitPassword(const std::vector<pdftron::UInt8>& password_buf);
403 
404 
407  has_AuthProc = 0x02,
412  };
413 
422  void SetDerived(UInt32 overloaded_funct);
423 
427  SecurityHandler* GetDerived() const;
428 
429 // @cond PRIVATE_DOC
430 #ifndef SWIGHIDDEN
431  SecurityHandler(TRN_SecurityHandler impl, bool owner, UInt32 derived_procs);
432  TRN_SecurityHandler mp_handler;
433  bool m_owner;
434  UInt32 m_derived_procs;
435 #endif
436 // @endcond
437 };
438 
439 
440  }; // namespace SDF
441 }; // namespace pdftron
442 
443 #include <Impl/SDFDoc.inl>
444 
445 #endif // PDFTRON_H_CPPSDFSecurityHandler
edit the document more than adding or modifying text notes.
void ChangeUserPassword(const char *password, size_t pwd_length)
void SetDerived(UInt32 overloaded_funct)
void ChangeMasterPasswordASCII(const char *password)
SecurityHandler & operator=(const SecurityHandler &)
SecurityHandler * GetDerived() const
size_t GetUserPasswordSize() const
virtual bool EditSecurityData(SDFDoc &doc)
bool GetPermission(Permission p)
void InitPassword(const char *password, size_t pwd_length)
open and decrypt the document.
const char * GetHandlerDocName() const
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
Use Crypt filters with 256-bit AES (Advanced Encryption Standard) algorithm.
allow changes to fill in forms
Use Crypt filters with 128-bit AES (Advanced Encryption Standard) algorithm.
virtual bool Authorize(Permission p)
the user has &#39;owner&#39; rights (e.g. rights to change the document&#39;s security settings).
size_t GetMasterPasswordSize() const
void ChangeMasterPassword(const char *password, size_t pwd_length)
void ChangeRevisionNumber(int rev_num)
virtual Obj FillEncryptDict(class SDFDoc &doc)
virtual SecurityHandler * Clone(TRN_SecurityHandler base) const
virtual bool GetAuthorizationData(Permission req_opr)
void InitPasswordASCII(const char *password)
content access for the visually impaired.
void ChangeUserPasswordASCII(const char *password)
int GetEncryptionAlgorithmID() const
void SetModified(bool is_modified=true)
allow modifications to annotations
void SetEncryptMetadata(bool encrypt_metadata)
const char * GetMasterPassword()
void SetPermission(Permission perm, bool value)