Loading...
Searching...
No Matches
SecurityHandler.h
Go to the documentation of this file.
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2025 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
12namespace pdftron {
13 namespace SDF {
14
15class Obj;
16class SDFDoc;
17
18
23{
24public:
25
39
52
57 int GetKeyLength() const;
58
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
107
114
131 SecurityHandler (const char* name, int key_len, int enc_code);
133
137
144 void ChangeUserPasswordASCII(const char* password);
145
152 void ChangeUserPassword(const char* password, size_t pwd_length );
153
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
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
265
270
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
413
422 void SetDerived(UInt32 overloaded_funct);
423
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
@ e_RC4_128
128-bit RC4 algorithm.
@ e_AES
Use Crypt filters with 128-bit AES (Advanced Encryption Standard) algorithm.
@ e_AES_256
Use Crypt filters with 256-bit AES (Advanced Encryption Standard) algorithm.
@ e_RC4_40
40-bit RC4 algorithm.
void ChangeUserPassword(const pdftron::UString &password)
@ e_doc_modify
edit the document more than adding or modifying text notes.
@ e_access_support
content access for the visually impaired.
@ e_owner
the user has 'owner' rights (e.g. rights to change the document's security settings).
@ e_print_high
high resolution print.
@ e_extract_content
enable content extraction
@ e_mod_annot
allow modifications to annotations
@ e_assemble_doc
allow document assembly
@ e_fill_forms
allow changes to fill in forms
@ e_doc_open
open and decrypt the document.
@ e_print
print the document.
void ChangeUserPasswordASCII(const char *password)
SecurityHandler(const SecurityHandler &s)
SecurityHandler(const char *name, int key_len, int enc_code)
SecurityHandler * GetDerived() const
void ChangeRevisionNumber(int rev_num)
bool GetPermission(Permission p)
void SetEncryptMetadata(bool encrypt_metadata)
size_t GetMasterPasswordSize() const
void ChangeUserPassword(const char *password, size_t pwd_length)
void InitPasswordASCII(const char *password)
virtual bool EditSecurityData(SDFDoc &doc)
void ChangeUserPassword(const std::vector< pdftron::UInt8 > &password_buf)
virtual SecurityHandler * Clone(TRN_SecurityHandler base) const
void ChangeMasterPassword(const pdftron::UString &password)
virtual bool Authorize(Permission p)
virtual Obj FillEncryptDict(class SDFDoc &doc)
size_t GetUserPasswordSize() const
void ChangeMasterPasswordASCII(const char *password)
void SetPermission(Permission perm, bool value)
const char * GetMasterPassword()
void ChangeMasterPassword(const char *password, size_t pwd_length)
SecurityHandler(AlgorithmType crypt_type)
virtual bool GetAuthorizationData(Permission req_opr)
bool IsAES(Obj stream) const
void InitPassword(const std::vector< pdftron::UInt8 > &password_buf)
void ChangeMasterPassword(const std::vector< pdftron::UInt8 > &password_buf)
const char * GetHandlerDocName() const
SecurityHandler & operator=(const SecurityHandler &)
void InitPassword(const pdftron::UString &password)
void SetModified(bool is_modified=true)
void InitPassword(const char *password, size_t pwd_length)
void SetDerived(UInt32 overloaded_funct)
TRN_UInt32 UInt32
Definition BasicTypes.h:13