7#ifndef PDF_SIGNING_CONTEXT_H
8#define PDF_SIGNING_CONTEXT_H
14 class PODOFO_API PdfSignerId final
18 PdfSignerId(
const PdfReference& ref,
unsigned signerIndex);
20 const PdfReference& GetSignatureRef()
const {
return m_SignatureRef; }
21 unsigned GetSignerIndex()
const {
return m_SignerIndex; }
23 bool operator==(
const PdfSignerId& rhs)
const
25 return m_SignatureRef == rhs.m_SignatureRef && m_SignerIndex == rhs.m_SignerIndex;
28 bool operator!=(
const PdfSignerId& rhs)
const
30 return m_SignatureRef != rhs.m_SignatureRef || m_SignerIndex != rhs.m_SignerIndex;
34 PdfReference m_SignatureRef;
35 unsigned m_SignerIndex;
44 struct hash<
PoDoFo::PdfSignerId>
46 std::size_t operator()(
const PoDoFo::PdfSignerId&
id)
const noexcept
48 return id.GetSignatureRef().ObjectNumber() ^ (
id.GetSignatureRef().GenerationNumber() << 16)
49 ^ ((
size_t)
id.GetSignerIndex() << 24);
61 std::unordered_map<PdfSignerId, charbuff> Intermediate;
80 std::unique_ptr<PdfMemDocument> Restore(std::shared_ptr<StreamDevice>
device);
84 PdfSignerId AddSigner(
const PdfSignature&
signature, std::shared_ptr<PdfSigner>
signer);
116 bool IsEmpty()
const;
119 struct SignerDescriptors
121 std::string SignatureFullName;
122 unsigned SignaturePageIndex = 0
u - 1u;
123 unsigned ContextIndex = 0
u - 1u;
125 std::shared_ptr<PdfSigner> SignerStorage;
133 size_t BeaconSize = 0;
134 PdfSignatureBeacons Beacons;
149 void AddSignerUnsafe(
const PdfSignature& signature, PdfSigner& signer);
152 PdfSignerId addSigner(
const PdfSignature& signature, PdfSigner* signer,
153 std::shared_ptr<PdfSigner>&& storage);
154 void ensureNotStarted()
const;
155 std::vector<SignerContext> prepareSignatureContexts(PdfMemDocument& doc,
bool deferredSigning);
156 void saveDocForSigning(PdfMemDocument& doc, StreamDevice& device, PdfSaveOptions saveOptions);
157 void appendDataForSigning(PdfMemDocument& doc, StreamDevice& device, std::vector<SignerContext>& contexts,
158 std::unordered_map<PdfSignerId, charbuff>* intermediateResults, charbuff& tmpbuff);
159 void computeSignatures(std::vector<SignerContext>& contexts, PdfMemDocument& doc, StreamDevice& device,
160 const PdfSigningResults* processedResults, charbuff& tmpbuff);
163 PdfSigningContext(
const PdfSigningContext&) =
delete;
164 PdfSigningContext& operator==(
const PdfSigningContext&) =
delete;
167 std::unordered_map<PdfReference, SignerDescriptors> m_signers;
169 PdfMemDocument* m_doc;
170 std::shared_ptr<StreamDevice> m_device;
172 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:81
PdfMemDocument is the core class for reading and manipulating PDF files and writing them back to disk...
Definition PdfMemDocument.h:38
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:24
A context that can be used to customize the signing process.
Definition PdfSigningContext.h:72
std::shared_ptr< PdfSigner > GetSignerEntry(const std::string_view &fullName, PdfReference &signatureRef)
Get the fist signer entry 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:31
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:38
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition basetypes.h:16
PdfSaveOptions
Definition PdfDeclarations.h:469
Interchange signing procedure results.
Definition PdfSigningContext.h:60