3#ifndef PDFSDK_CXX_PDF_STANDARD_SECURITY_H_INCLUDED_
4#define PDFSDK_CXX_PDF_STANDARD_SECURITY_H_INCLUDED_
10#include <pdfsdk/core.h>
11#include <pdfsdk/cxx/exception.h>
75 PDStdSecurityModifyFlags modifyFlags = 0;
130 static PDStdPerms GetAllAllowedDefaultPermissions();
243 return keyLen > 5 ? 2 : 1;
256 return keyLen > 5 ? 3 : 2;
260inline PDStdPerms StdSecurityParams::GetAllAllowedDefaultPermissions() {
274 permissions |= kPDStdPermPrint | kPDStdPermHighPrint;
281 permissions |= kPDStdPermFillAndSign | kPDStdPermEditNotes;
283 permissions |= kPDStdPermFillAndSign | kPDStdPermEditNotes | kPDStdPermEdit;
286 permissions |= kPDStdPermAccessible | kPDStdPermCopy;
331 return std::wstring{};
335 if (hasOwnerPassword)
337 return std::wstring{};
342 if (!newUserPassword.empty()) {
343 PDStdPasswordSetChars(&
userPassword, newUserPassword.c_str());
348 modifyFlags |= kPDStdSecurityModifyUserPassword;
353 if (!newOwnerPassword.empty()) {
354 PDStdPasswordSetChars(&
ownerPassword, newOwnerPassword.c_str());
355 hasOwnerPassword =
true;
357 hasOwnerPassword =
false;
359 modifyFlags |= kPDStdSecurityModifyOwnerPassword;
Helper class that represents the data of the Standard Security Handler.
Definition standard_security.h:29
PrintPermissions
Enum representing the print permissions for the Standard Security Handler.
Definition standard_security.h:39
@ 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:291
EditPermissions
Enum representing the edit permissions for the Standard Security Handler.
Definition standard_security.h:53
@ 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:247
void SetPermissions(PrintPermissions printPerms, EditPermissions editPerms, ExtractPermissions extractPerms)
Set the permissions for the Standard Security Handler.
Definition standard_security.h:268
bool HasPasswords() const
Check if the Standard Security Handler has either an owner or a user password set,...
Definition standard_security.h:324
StdSecurityParams()
Default constructor for StdSecurityParams.
Definition standard_security.h:264
std::wstring GetOwnerPassword() const
Get the owner password for the Standard Security Handler.
Definition standard_security.h:334
static int GetDefaultKeyLengthByCryptMethod(PDAtom cryptMethod)
Get the default key length of the file encryption key, based on the cryptographic method.
Definition standard_security.h:218
void ResetToDefault()
Reset the Standard Security Handler parameters to their default values.
Definition standard_security.h:300
void SetUserPassword(const std::wstring &newUserPassword)
Set the user password for the Standard Security Handler.
Definition standard_security.h:340
std::wstring GetUserPassword() const
Get the user password for the Standard Security Handler.
Definition standard_security.h:328
ExtractPermissions
Enum representing the extraction permissions for the Standard Security Handler.
Definition standard_security.h:69
@ 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:351
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:234
Definition security.h:137
int version
Definition security.h:175
bool encryptMetadata
Definition security.h:196
bool encryptAttachmentsOnly
Definition security.h:202
PDStdPerms permissions
Definition security.h:163
PDAtom cryptMethod
Definition security.h:182
bool hasUserPassword
Definition security.h:147
int keyLength
Definition security.h:190
PDStdPassword ownerPassword
Definition security.h:152
PDStdPassword userPassword
Definition security.h:141
int revision
Definition security.h:168