DigitalSignature
Contents
[
Hide
]DigitalSignature class
Digital signature in signed file.
class DigitalSignature : public Aspose::Slides::IDigitalSignature
Methods
Method | Description |
---|---|
DigitalSignature(System::SharedPtr<System::Security::Cryptography::X509Certificates::X509Certificate2>) | Creates a new DigitalSignature object with the specified certificate. |
DigitalSignature(System::String, System::String) | Creates a new DigitalSignature object with the specified certificate file path and password. |
virtual bool Equals(ptr) | Compares objects using C# Object.Equals semantics. |
static std::enable_if<IsSmartPtr<T1>::value&&IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&) | Compares reference type objects in C# style. |
static std::enable_if<!IsSmartPtr<T1>::value&&!IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&) | Compares value type objects in C# style. |
static bool Equals(float const&, float const&) | Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN. |
static bool Equals(double const&, double const&) | Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN. |
virtual bool FastCast(const Details::FastRttiBase&, void **) const | For internal purposes only. |
System::SharedPtr<System::Security::Cryptography::X509Certificates::X509Certificate2> get_Certificate() override | Certificate object that was used to sign the document. Read-only X509Certificate2. |
System::String get_Comments() override | The purpose of signature. Read System::String. |
bool get_IsValid() override | If this digital signature is valid and the document has not been tampered with, this value will be true. Read-only bool. |
System::DateTime get_SignTime() override | The time when the document was signed. Read-only System::DateTime. |
Detail::SmartPtrCounter * GetCounter() | Gets reference counter data structure associated with the object. |
virtual int32_t GetHashCode() const | Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. |
virtual const TypeInfo& GetType() const | Gets actual type of object. Analog of C# System.Object.GetType() call. |
virtual bool Is(const TypeInfo&) const | Check if object represents an instance of type described by targetType. Analog of C# ‘is’ operator. |
void Lock() | Implements C# lock() statement locking. Call directly or use LockContext sentry object. |
virtual ptr MemberwiseClone() const | Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. |
Object() | Creates object. Initializes all internal data structures. |
Object(Object const&) | Copy constructor. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses. |
Object& operator=(Object const&) | Assignment operator. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses. |
static bool ReferenceEquals(ptr const&, ptr const&) | Compares objects by reference. |
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, T const&) | Compares objects by reference. |
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, std::nullptr_t) | Reference-compares value type object with nullptr. |
bool ReferenceEquals(String const&, std::nullptr_t) | Specialization of Object::ReferenceEquals for case of string and nullptr. |
bool ReferenceEquals(String const&, String const&) | Specialization of Object::ReferenceEquals for case of strings. |
int RemovedSharedRefs(int) | Decreases shared reference count by specified value. |
void set_Comments(System::String) override | The purpose of signature. Write System::String. |
virtual void SetTemplateWeakPtr(uint32_t) | Set n’th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. |
int SharedCount() const | Gets current value of shared reference counter. |
Object * SharedRefAdded() | Increments shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
int SharedRefRemovedSafe() | Decrements and returns shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
virtual String ToString() const | Analog of C# Object.ToString() method. Enables converting custom objects to string. |
static const TypeInfo& Type() | Implements C# typeof(System.Object) construct. |
void Unlock() | Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. |
Detail::SmartPtrCounter * WeakRefAdded() | Increments weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
void WeakRefRemoved() | Decrements weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector. |
virtual ~Object() | Destroys object. Frees all internal data structures. |
Remarks
The following example demonstrates how to add digital signature from a PFX certificate in PowerPoint Presentation.
// Initialize Presentation instance
auto pres = System::MakeObject<Presentation>();
// Create DigitalSignature object with PFX file and PFX password
System::SharedPtr<DigitalSignature> signature = System::MakeObject<DigitalSignature>(u"testsignature1.pfx", u"testpass1");
// Comment new digital signature
signature->set_Comments(u"Aspose.Slides digital signing test.");
// Add digital signature to presentation
pres->get_DigitalSignatures()->Add(signature);
// Save presentation
pres->Save(u"SomePresentationSigned.pptx", SaveFormat::Pptx);
The following sample code demonstrates how to validate digital signature of PowerPoint Presentation.
// Initialize Presentation instance
auto pres = System::MakeObject<Presentation>(u"SomePresentationSigned.pptx");
if (pres->get_DigitalSignatures()->get_Count() > 0)
{
bool allSignaturesAreValid = true;
System::Console::WriteLine(u"Signatures used to sign the presentation: ");
// Check if all digital signatures are valid
for (auto&& signature : System::IterateOver(pres->get_DigitalSignatures()))
{
System::Console::WriteLine(signature->get_Certificate()->get_SubjectName()->get_Name() + u", " +
signature->get_SignTime().ToString(u"yyyy-MM-dd HH:mm") + u" -- " +
(signature->get_IsValid() ? System::String(u"VALID") : System::String(u"INVALID")));
allSignaturesAreValid &= signature->get_IsValid();
}
if (allSignaturesAreValid)
{
System::Console::WriteLine(u"Presentation is genuine, all signatures are valid.");
}
else
{
System::Console::WriteLine(u"Presentation has been modified since signing.");
}
}
See Also
- Class IDigitalSignature
- Namespace Aspose::Slides
- Library Aspose.Slides