signature: Add ValidityPeriod into SignatureInfo

Change-Id: I02571a4876e2f0ccd8cc088ecc6477d20dd701cb
Refs: #2868
diff --git a/src/signature-info.cpp b/src/signature-info.cpp
index 9c1f0de..e48482e 100644
--- a/src/signature-info.cpp
+++ b/src/signature-info.cpp
@@ -91,6 +91,32 @@
 }
 
 void
+SignatureInfo::setValidityPeriod(const security::ValidityPeriod& validityPeriod)
+{
+  unsetValidityPeriod();
+  m_otherTlvs.push_front(validityPeriod.wireEncode());
+}
+
+void
+SignatureInfo::unsetValidityPeriod()
+{
+  m_wire.reset();
+  if (!m_otherTlvs.empty() && m_otherTlvs.front().type() == tlv::ValidityPeriod) {
+    m_otherTlvs.erase(m_otherTlvs.begin());
+  }
+}
+
+security::ValidityPeriod
+SignatureInfo::getValidityPeriod() const
+{
+  if (m_otherTlvs.empty() || m_otherTlvs.front().type() != tlv::ValidityPeriod) {
+    throw Error("SignatureInfo does not contain the requested ValidityPeriod field");
+  }
+
+  return security::ValidityPeriod(m_otherTlvs.front());
+}
+
+void
 SignatureInfo::appendTypeSpecificTlv(const Block& block)
 {
   m_otherTlvs.push_back(block);
diff --git a/src/signature-info.hpp b/src/signature-info.hpp
index a88b759..4ee8e64 100644
--- a/src/signature-info.hpp
+++ b/src/signature-info.hpp
@@ -24,6 +24,7 @@
 
 #include "encoding/tlv.hpp"
 #include "key-locator.hpp"
+#include "security/validity-period.hpp"
 #include <list>
 
 namespace ndn {
@@ -90,6 +91,18 @@
   const KeyLocator&
   getKeyLocator() const;
 
+  /// @brief Set ValidityPeriod
+  void
+  setValidityPeriod(const security::ValidityPeriod& validityPeriod);
+
+  /// @brief Unset ValidityPeriod
+  void
+  unsetValidityPeriod();
+
+  /// @brief Get ValidityPeriod
+  security::ValidityPeriod
+  getValidityPeriod() const;
+
   /// @brief Append signature type specific tlv block
   void
   appendTypeSpecificTlv(const Block& block);