PoDoFo 1.2.0
Loading...
Searching...
No Matches
PdfSignature.h
1// SPDX-FileCopyrightText: 2011 Dominik Seichter <domseichter@web.de>
2// SPDX-FileCopyrightText: 2011 Petr Pytelka
3// SPDX-FileCopyrightText: 2020 Francesco Pretto <ceztko@gmail.com>
4// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
5
6#ifndef PDF_SIGNATURE_H
7#define PDF_SIGNATURE_H
8
9#include "PdfDeclarations.h"
10
11#include "PdfAnnotation.h"
12#include "PdfField.h"
13#include "PdfDate.h"
14#include "PdfData.h"
15#include <podofo/auxiliary/InputDevice.h>
16#include <podofo/auxiliary/OutputDevice.h>
17
18namespace PoDoFo {
19
20class PdfAcroForm;
21
22enum class PdfCertPermission : uint8_t
23{
24 NoPerms = 1,
25 FormFill = 2,
26 Annotations = 3,
27};
28
29struct PdfSignatureBeacons final
30{
31 PdfSignatureBeacons();
32 charbuff ContentsBeacon;
33 charbuff ByteRangeBeacon;
34 std::shared_ptr<size_t> ContentsOffset;
35 std::shared_ptr<size_t> ByteRangeOffset;
36};
37
38class PODOFO_API PdfSignature final : public PdfField
39{
40 friend class PdfField;
41 friend class PdfSigningContext;
42
43private:
44 PdfSignature(PdfAcroForm& acroform, std::shared_ptr<PdfField>&& parent);
45
46 PdfSignature(PdfAnnotationWidget& widget, std::shared_ptr<PdfField>&& parent);
47
48 PdfSignature(PdfObject& obj, PdfAcroForm* acroform);
49
50public:
54 void SetSignerName(nullable<const PdfString&> text);
55
59 void SetSignatureReason(nullable<const PdfString&> text);
60
64 void SetSignatureLocation(nullable<const PdfString&> text);
65
66 [[deprecated("Use the SetCreatingApplication method instead")]]
67 void SetSignatureCreator(nullable<const PdfString&> creator);
68
72 void SetCreatingApplication(nullable<const PdfName&> application);
73
75 void SetSignatureDate(nullable<const PdfDate&> sigDate);
76
80 void AddCertificationReference(PdfCertPermission perm = PdfCertPermission::NoPerms);
81
85 nullable<const PdfString&> GetSignerName() const;
86
90 nullable<const PdfString&> GetSignatureReason() const;
91
95 nullable<const PdfString&> GetSignatureLocation() const;
96
100 nullable<PdfDate> GetSignatureDate() const;
101
106 void EnsureValueObject();
107
108 PdfSignature* GetParent();
109 const PdfSignature* GetParent() const;
110
114 bool TryGetPreviousRevision(InputStreamDevice& input, OutputStreamDevice& output) const;
115
116protected:
117 PdfObject* getValueObject() const override;
118
119private:
132 void PrepareForSigning(const std::string_view& filter,
133 const std::string_view& subFilter,
134 const std::string_view& type,
135 const PdfSignatureBeacons& beacons);
136
137 // To be called by SignDocument()
138 void SetContentsByteRangeNoDirtySet(const bufferview& contents, PdfArray&& byteRange);
139
140 void ensureValueObject();
141private:
142 void init(PdfAcroForm& acroForm);
143
144private:
145 PdfObject* m_ValueObj;
146};
147
148}
149
150#endif // PDF_SIGNATURE_H
This file should be included as the FIRST file in every header of PoDoFo lib.
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13