3#ifndef PDFSDK_CXX_PDF_STANDARD_SECURITY_H_INCLUDED_
4#define PDFSDK_CXX_PDF_STANDARD_SECURITY_H_INCLUDED_
15#include <pdfsdk/core.h>
16#include <pdfsdk/cxx/exception.h>
80 PDStdSecurityModifyFlags modifyFlags = 0;
135 static PDStdPerms GetAllAllowedDefaultPermissions();
248 return keyLen > 5 ? 2 : 1;
261 return keyLen > 5 ? 3 : 2;
265inline PDStdPerms StdSecurityParams::GetAllAllowedDefaultPermissions() {
336 return std::wstring{};
340 if (hasOwnerPassword)
342 return std::wstring{};
347 if (!newUserPassword.empty()) {
348 PDStdPasswordSetChars(&
userPassword, newUserPassword.c_str());
353 modifyFlags |= kPDStdSecurityModifyUserPassword;
358 if (!newOwnerPassword.empty()) {
359 PDStdPasswordSetChars(&
ownerPassword, newOwnerPassword.c_str());
360 hasOwnerPassword =
true;
362 hasOwnerPassword =
false;
364 modifyFlags |= kPDStdSecurityModifyOwnerPassword;
@ kPDStdPermHighPrint
Definition security.h:181
@ kPDStdPermPrint
Definition security.h:158
@ kPDStdPermFillAndSign
Definition security.h:174
@ kPDStdPermEdit
Definition security.h:159
@ kPDStdPermAccessible
Definition security.h:177
@ kPDStdPermEditNotes
Definition security.h:164
@ kPDStdPermDocAssembly
Definition security.h:179
@ kPDStdPermCopy
Definition security.h:162
Helper class that represents the data of the Standard Security Handler.
Definition standard_security.h:34
PrintPermissions
Enum representing the print permissions for the Standard Security Handler.
Definition standard_security.h:44
@ LowResolution
Low resolution print permissions.
@ None
No print permissions.
@ HighResolution
High resolution print permissions.
void SetCryptMethod(PDAtom method, int keyLen=0)
Set the cryptographic method and key length for the Standard Security Handler.
Definition standard_security.h:296
EditPermissions
Enum representing the edit permissions for the Standard Security Handler.
Definition standard_security.h:58
@ FormFillAndSign
Filling-in form fields and signing.
@ DocumentAssembly
Creating, inserting, deleting, and rotating pages.
@ AnyButExtractPages
Any permissions except extract pages.
@ ReviewFormFillAndSign
Commenting, filling-in form fields, and signing existing signature fields.
static int GetDefaultRevisionByCryptMethod(PDAtom cryptMethod, int keyLen)
Get the default standard security handler revision based on the cryptographic method and key length.
Definition standard_security.h:252
void SetPermissions(PrintPermissions printPerms, EditPermissions editPerms, ExtractPermissions extractPerms)
Set the permissions for the Standard Security Handler.
Definition standard_security.h:273
bool HasPasswords() const
Check if the Standard Security Handler has either an owner or a user password set,...
Definition standard_security.h:329
StdSecurityParams()
Default constructor for StdSecurityParams.
Definition standard_security.h:269
std::wstring GetOwnerPassword() const
Get the owner password for the Standard Security Handler.
Definition standard_security.h:339
static int GetDefaultKeyLengthByCryptMethod(PDAtom cryptMethod)
Get the default key length of the file encryption key, based on the cryptographic method.
Definition standard_security.h:223
void ResetToDefault()
Reset the Standard Security Handler parameters to their default values.
Definition standard_security.h:305
void SetUserPassword(const std::wstring &newUserPassword)
Set the user password for the Standard Security Handler.
Definition standard_security.h:345
std::wstring GetUserPassword() const
Get the user password for the Standard Security Handler.
Definition standard_security.h:333
ExtractPermissions
Enum representing the extraction permissions for the Standard Security Handler.
Definition standard_security.h:74
@ Accessibility
Enable copying of text, images, and other content.
@ Any
Enable copying of any content.
void SetOwnerPassword(const std::wstring &newOwnerPassword)
Set the owner password for the Standard Security Handler.
Definition standard_security.h:356
static int GetDefaultVersionByCryptMethod(PDAtom cryptMethod, int keyLen)
Get the default version of the encryption algorithm used, based on the cryptographic method and key l...
Definition standard_security.h:239
Definition security.h:207
int version
Definition security.h:245
bool encryptMetadata
Definition security.h:266
bool encryptAttachmentsOnly
Definition security.h:272
PDStdPerms permissions
Definition security.h:233
PDAtom cryptMethod
Definition security.h:252
bool hasUserPassword
Definition security.h:217
int keyLength
Definition security.h:260
PDStdPassword ownerPassword
Definition security.h:222
PDStdPassword userPassword
Definition security.h:211
int revision
Definition security.h:238