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);
118 void GetSignerReferences(std::vector<PdfReference>&
signatureRefs)
const;
120 unsigned GetSignerCount()
const;
122 bool IsEmpty()
const;
125 struct SignerDescriptors
127 std::string SignatureFullName;
128 unsigned SignaturePageIndex = 0
u - 1u;
129 unsigned ContextIndex = 0
u - 1u;
131 std::shared_ptr<PdfSigner> SignerStorage;
139 size_t BeaconSize = 0;
140 PdfSignatureBeacons Beacons;
155 void AddSignerUnsafe(
const PdfSignature& signature, PdfSigner& signer);
158 PdfSignerId addSigner(
const PdfSignature& signature, PdfSigner* signer,
159 std::shared_ptr<PdfSigner>&& storage);
160 void ensureNotStarted()
const;
161 std::vector<SignerContext> prepareSignatureContexts(PdfMemDocument& doc,
bool deferredSigning);
162 void saveDocForSigning(PdfMemDocument& doc, StreamDevice& device, PdfSaveOptions saveOptions);
163 void appendDataForSigning(PdfMemDocument& doc, StreamDevice& device, std::vector<SignerContext>& contexts,
164 std::unordered_map<PdfSignerId, charbuff>* intermediateResults, charbuff& tmpbuff);
165 void computeSignatures(std::vector<SignerContext>& contexts, PdfMemDocument& doc, StreamDevice& device,
166 const PdfSigningResults* processedResults, charbuff& tmpbuff);
169 PdfSigningContext(
const PdfSigningContext&) =
delete;
170 PdfSigningContext& operator==(
const PdfSigningContext&) =
delete;
173 std::unordered_map<PdfReference, SignerDescriptors> m_signers;
175 PdfMemDocument* m_doc;
176 std::shared_ptr<StreamDevice> m_device;
178 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 > 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: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