4#ifndef PDF_SIGNING_CONTEXT_H
5#define PDF_SIGNING_CONTEXT_H
11 class PODOFO_API PdfSignerId final
15 PdfSignerId(
const PdfReference& ref,
unsigned signerIndex);
17 const PdfReference& GetSignatureRef()
const {
return m_SignatureRef; }
18 unsigned GetSignerIndex()
const {
return m_SignerIndex; }
20 bool operator==(
const PdfSignerId& rhs)
const
22 return m_SignatureRef == rhs.m_SignatureRef && m_SignerIndex == rhs.m_SignerIndex;
25 bool operator!=(
const PdfSignerId& rhs)
const
27 return m_SignatureRef != rhs.m_SignatureRef || m_SignerIndex != rhs.m_SignerIndex;
31 PdfReference m_SignatureRef;
32 unsigned m_SignerIndex;
40 struct hash<
PoDoFo::PdfSignerId>
42 std::size_t operator()(
const PoDoFo::PdfSignerId&
id)
const noexcept
44 return id.GetSignatureRef().ObjectNumber() ^ (
id.GetSignatureRef().GenerationNumber() << 16)
45 ^ ((
size_t)
id.GetSignerIndex() << 24);
55 std::unordered_map<PdfSignerId, charbuff> Intermediate;
71 std::unique_ptr<PdfMemDocument> Restore(std::shared_ptr<StreamDevice>
device);
74 PdfSignerId AddSigner(
const PdfSignature&
signature, std::shared_ptr<PdfSigner>
signer);
104 void GetSignerReferences(std::vector<PdfReference>&
signatureRefs)
const;
106 unsigned GetSignerCount()
const;
108 bool IsEmpty()
const;
111 struct SignerDescriptors
113 std::string SignatureFullName;
114 unsigned SignaturePageIndex = 0
u - 1u;
115 unsigned ContextIndex = 0
u - 1u;
117 std::shared_ptr<PdfSigner> SignerStorage;
125 size_t BeaconSize = 0;
126 PdfSignatureBeacons Beacons;
141 void AddSignerUnsafe(
const PdfSignature& signature, PdfSigner& signer);
144 PdfSignerId addSigner(
const PdfSignature& signature, PdfSigner* signer,
145 std::shared_ptr<PdfSigner>&& storage);
146 void ensureNotStarted()
const;
147 void checkDocument(PdfMemDocument& doc, PdfSaveOptions saveOptions)
const;
148 std::vector<SignerContext> prepareSignatureContexts(PdfMemDocument& doc,
bool deferredSigning);
149 void saveDocForSigning(PdfMemDocument& doc, StreamDevice& device, PdfSaveOptions saveOptions);
150 void appendDataForSigning(PdfMemDocument& doc, StreamDevice& device, std::vector<SignerContext>& contexts,
151 std::unordered_map<PdfSignerId, charbuff>* intermediateResults, charbuff& tmpbuff);
152 void computeSignatures(std::vector<SignerContext>& contexts, PdfMemDocument& doc, StreamDevice& device,
153 const PdfSigningResults* processedResults, charbuff& tmpbuff);
156 PdfSigningContext(
const PdfSigningContext&) =
delete;
157 PdfSigningContext& operator==(
const PdfSigningContext&) =
delete;
160 std::unordered_map<PdfReference, SignerDescriptors> m_signers;
162 PdfMemDocument* m_doc;
163 std::shared_ptr<StreamDevice> m_device;
165 std::vector<SignerContext> m_contexts;
This class represents a PdfArray Use it for all arrays that are written to a PDF file.
Definition PdfArray.h:76
PdfMemDocument is the core class for reading and manipulating PDF files and writing them back to disk...
Definition PdfMemDocument.h:35
A reference is a pointer to a object in the PDF file of the form "4 0 R", where 4 is the object numbe...
Definition PdfReference.h:20
A context that can be used to customize the signing process.
Definition PdfSigningContext.h:64
std::shared_ptr< PdfSigner > GetSigner(const std::string_view &fullName, PdfReference &signatureRef)
Get the fist signer from the context for the given input signature.
friend PODOFO_API void SignDocument(PdfMemDocument &doc, StreamDevice &device, PdfSigner &signer, PdfSignature &signature, PdfSaveOptions saveOptions)
Sign the document on the given signature field.
This class provides an output device which operates either on a file or on a buffer in memory.
Definition StreamDevice.h:28
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:30
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13
PdfSaveOptions
Definition PdfDeclarations.h:429
Interchange signing procedure results. Used when starting and finishing a deferred (aka "async") sign...
Definition PdfSigningContext.h:54