security: Implement the header for IdentityCertificate.
diff --git a/include/ndn-cpp/security/certificate/certificate.hpp b/include/ndn-cpp/security/certificate/certificate.hpp
index 0fdd213..6d83673 100644
--- a/include/ndn-cpp/security/certificate/certificate.hpp
+++ b/include/ndn-cpp/security/certificate/certificate.hpp
@@ -7,12 +7,20 @@
*/
#ifndef NDN_CERTIFICATE_HPP
-#define NDN_CERTIFICATE_HPP
+#define NDN_CERTIFICATE_HPP
#include "../../data.hpp"
+#include "../../common.hpp"
+
+#include "certificate-subject-description.hpp"
+#include "certificate-extension.hpp"
+#include "public-key.hpp"
namespace ndn {
+typedef std::vector<CertificateSubjectDescription> SubjectDescriptionList;
+typedef std::vector<CertificateExtension> ExtensionList;
+
class Certificate : public Data {
public:
/**
@@ -25,6 +33,90 @@
* @param data The data packet with the content to decode.
*/
Certificate(const Data& data);
+
+ /**
+ * The virtual destructor.
+ */
+ virtual
+ ~Certificate() {}
+
+ /**
+ * encode certificate info into content
+ */
+ void
+ encode();
+
+ /**
+ * Add a subject description.
+ * @param description The description to be added.
+ */
+ void
+ addSubjectDescription(const CertificateSubjectDescription& description) { subjectDescriptionList_.push_back(description); }
+
+ /**
+ * Add a certificate extension.
+ * @param extension the extension to be added
+ */
+ void
+ addExtension(const CertificateExtension& extension) { extensionList_.push_back(extension); }
+
+ void
+ setNotBefore(const Time& notBefore) { notBefore_ = notBefore; }
+
+ Time&
+ getNotBefore() { return notBefore_; }
+
+ const Time&
+ getNotBefore() const { return notBefore_; }
+
+ void
+ setNotAfter(const Time& notAfter) { notAfter_ = notAfter; }
+
+ Time&
+ getNotAfter() { return notAfter_; }
+
+ const Time&
+ getNotAfter() const { return notAfter_; }
+
+ void
+ setPublicKeyInfo(const PublicKey& key) { key_ = key; }
+
+ PublicKey&
+ getPublicKeyInfo() { return key_; }
+
+ const PublicKey&
+ getPublicKeyInfo() const { return key_; }
+
+ virtual Name
+ getPublicKeyName() const = 0;
+
+ /**
+ * Check if the certificate is valid.
+ * @return True if the current time is earlier than notBefore.
+ */
+ bool
+ isTooEarly();
+
+ /**
+ * Check if the certificate is valid.
+ * @return True if the current time is later than notAfter.
+ */
+ bool
+ isTooLate();
+
+ void
+ printCertificate();
+
+protected:
+ void
+ decode();
+
+protected:
+ SubjectDescriptionList subjectDescriptionList_;
+ Time notBefore_;
+ Time notAfter_;
+ PublicKey key_;
+ ExtensionList extensionList_;
};
}
diff --git a/include/ndn-cpp/security/certificate/identity-certificate.hpp b/include/ndn-cpp/security/certificate/identity-certificate.hpp
index e9e90f5..1dff7e9 100644
--- a/include/ndn-cpp/security/certificate/identity-certificate.hpp
+++ b/include/ndn-cpp/security/certificate/identity-certificate.hpp
@@ -26,6 +26,24 @@
* @param data The data packet with the content to decode.
*/
IdentityCertificate(const Data& data);
+
+ /**
+ * The virtual destructor.
+ */
+ virtual
+ ~IdentityCertificate();
+ Data &
+ setName (const Name& name);
+
+ virtual Name
+ getPublicKeyName () const;
+
+ static bool
+ isIdentityCertificate(const Certificate& certificate);
+
+private:
+ static bool
+ isCorrectName(const Name& name);
};
}