All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DigitalSignatureField.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2020 by PDFTron Systems Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 
6 #ifndef PDFTRON_H_CPPPDFDigitalSignatureField
7 #define PDFTRON_H_CPPPDFDigitalSignatureField
8 #include <C/PDF/TRN_DigitalSignatureField.h>
9 #include <C/PDF/TRN_VerificationResult.h>
10 
12 #include <PDF/VerificationResult.h>
14 #include <Common/BasicTypes.h>
15 #include <Common/UString.h>
16 #include <PDF/PDFDoc.h>
17 #include <PDF/X509Certificate.h>
18 #include <Common/ByteRange.h>
19 #include <vector>
20 
21 namespace pdftron { namespace PDF {
22 
23 
28 {
29 public:
30  //enums:
31 
38  e_unknown = 5,
40  };
42  // No changes to the document shall be permitted; any change to the document shall invalidate the signature.
44  // Permitted changes shall be filling in forms, instantiating page templates, and signing; other changes shall invalidate the signature.
46  // Permitted changes shall be the same as for 2, as well as annotation creation, deletion, and modification; other changes shall invalidate the signature.
48  // Represents the absence of any document permissions during retrieval; not to be used during setting
50  };
52  // Locks all form fields.
54  // Locks only those form fields specified.
55  e_include = 1,
56  // Locks only those form fields not specified.
58  };
59 
62 
68  DigitalSignatureField(const PDF::Field& in_field);
69 
75  bool HasCryptographicSignature() const;
76 
83 
89  UString GetSignatureName() const;
90 
99  Date GetSigningTime() const;
100 
106  UString GetLocation() const;
107 
113  UString GetReason() const;
114 
120  UString GetContactInfo() const;
121 
128  std::vector<UChar> GetCert(UInt32 in_index) const;
129 
135  UInt32 GetCertCount() const;
136 
142  bool HasVisibleAppearance() const;
143 
149  void SetContactInfo(const UString& in_contact_info);
150 
156  void SetLocation(const UString& in_location);
157 
163  void SetReason(const UString& in_reason);
164 
171 #ifdef SWIG
172 // We use an std::vector of UTF-8 std::strings for SWIG, because SWIG has trouble with mapping UString to string when it's in a vector<UString>.
173  void SetFieldPermissions(const FieldPermissions in_action, const std::vector<std::string>& in_field_names = std::vector<std::string>());
174 #else
175 
181  void SetFieldPermissions(const FieldPermissions in_action, const std::vector<UString>& in_field_names_list = std::vector<UString>());
182  void SetFieldPermissions(const FieldPermissions in_action, const UString* in_field_names_list, const size_t in_field_names_list_size);
183 #endif
184 
191 
198  void SignOnNextSave(const UString& in_pkcs12_keyfile_path, const UString& in_password);
199 
207  void SignOnNextSave(const UChar* in_pkcs12_buffer, size_t in_buf_size, const UString& in_password);
208 
214  void SignOnNextSaveWithCustomHandler(const SDF::SignatureHandlerId in_signature_handler_id);
215 
222  void CertifyOnNextSave(const UString& in_pkcs12_keyfile_path, const UString& in_password);
223 
231  void CertifyOnNextSave(const UChar* in_pkcs12_buffer, size_t in_buf_size, const UString& in_password);
232 
238  void CertifyOnNextSaveWithCustomHandler(const SDF::SignatureHandlerId in_signature_handler_id);
239 
245  SDF::Obj GetSDFObj() const;
246 
252  bool IsLockedByDigitalSignature() const;
253 
259 #ifdef SWIG
260 // We use an std::vector of UTF-8 std::strings for SWIG, because SWIG has trouble with mapping UString to string when it's in a vector<UString>.
261  std::vector<std::string> GetLockedFields() const;
262 #else
263  std::vector<UString> GetLockedFields() const;
264 #endif
265 
272 
277  void ClearSignature();
278 
285  VerificationResult Verify(const VerificationOptions& in_opts) const;
286 
292  bool IsCertification() const;
293 
303 
321  std::vector<Common::ByteRange> GetByteRanges() const;
322 
334  std::vector<std::vector<X509Certificate> > GetCertPathsFromCMS() const;
335 
365  bool EnableLTVOfflineVerification(const VerificationResult & in_verification_result) const;
366 
405  void TimestampOnNextSave(const TimestampingConfiguration& in_timestamping_config,
406  const VerificationOptions& in_timestamp_response_verification_options);
407 
408 // @cond PRIVATE_DOC
409 #ifndef SWIGHIDDEN
410  DigitalSignatureField(TRN_DigitalSignatureField impl);
411  TRN_DigitalSignatureField m_impl;
412 #endif
413 // @endcond
414 };
415 
416 #include <Impl/DigitalSignatureField.inl>
417 } //end pdftron
418 } //end PDF
419 
420 
421 #endif //PDFTRON_H_CPPPDFDigitalSignatureField
DigitalSignatureField & operator=(const DigitalSignatureField &other)
DocumentPermissions GetDocumentPermissions() const
void CertifyOnNextSave(const UString &in_pkcs12_keyfile_path, const UString &in_password)
size_t SignatureHandlerId
void SetFieldPermissions(const FieldPermissions in_action, const std::vector< UString > &in_field_names_list=std::vector< UString >())
void TimestampOnNextSave(const TimestampingConfiguration &in_timestamping_config, const VerificationOptions &in_timestamp_response_verification_options)
void SetLocation(const UString &in_location)
std::vector< UString > GetLockedFields() const
bool EnableLTVOfflineVerification(const VerificationResult &in_verification_result) const
std::vector< std::vector< X509Certificate > > GetCertPathsFromCMS() const
void SignOnNextSave(const UString &in_pkcs12_keyfile_path, const UString &in_password)
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
void CertifyOnNextSaveWithCustomHandler(const SDF::SignatureHandlerId in_signature_handler_id)
TRN_UChar UChar
Definition: BasicTypes.h:12
VerificationResult Verify(const VerificationOptions &in_opts) const
void SetReason(const UString &in_reason)
void SetDocumentPermissions(DocumentPermissions in_perms)
std::vector< Common::ByteRange > GetByteRanges() const
void SetContactInfo(const UString &in_contact_info)
void SignOnNextSaveWithCustomHandler(const SDF::SignatureHandlerId in_signature_handler_id)
DigitalSignatureField(const DigitalSignatureField &other)
std::vector< UChar > GetCert(UInt32 in_index) const
X509Certificate GetSignerCertFromCMS() const
SubFilterType GetSubFilter() const