certificate.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_CERTIFICATE_HPP
24 #define NDN_CERTIFICATE_HPP
25 
26 #include "../../data.hpp"
27 #include "../../common.hpp"
28 
29 #include "certificate-subject-description.hpp"
30 #include "certificate-extension.hpp"
31 #include "public-key.hpp"
32 
33 namespace ndn {
34 
35 typedef std::vector<CertificateSubjectDescription> SubjectDescriptionList;
36 typedef std::vector<CertificateExtension> ExtensionList;
37 
38 class Certificate : public Data {
39 public:
43  Certificate();
44 
49  Certificate(const Data& data);
50 
54  virtual
55  ~Certificate();
56 
61  void
62  encode();
63 
71  virtual void
73  (const Blob& input,
75 
80  void
81  addSubjectDescription(const CertificateSubjectDescription& description) { subjectDescriptionList_.push_back(description); }
82 
83  const SubjectDescriptionList&
84  getSubjectDescriptionList() const { return subjectDescriptionList_; }
85 
86  SubjectDescriptionList&
87  getSubjectDescriptionList() { return subjectDescriptionList_; }
88 
93  void
94  addExtension(const CertificateExtension& extension) { extensionList_.push_back(extension); }
95 
96  const ExtensionList&
97  getExtensionList() const { return extensionList_; }
98 
99  ExtensionList&
100  getExtensionList() { return extensionList_; }
101 
102  void
103  setNotBefore(const MillisecondsSince1970& notBefore) { notBefore_ = notBefore; }
104 
106  getNotBefore() { return notBefore_; }
107 
108  const MillisecondsSince1970&
109  getNotBefore() const { return notBefore_; }
110 
111  void
112  setNotAfter(const MillisecondsSince1970& notAfter) { notAfter_ = notAfter; }
113 
115  getNotAfter() { return notAfter_; }
116 
117  const MillisecondsSince1970&
118  getNotAfter() const { return notAfter_; }
119 
120  void
121  setPublicKeyInfo(const PublicKey& key) { key_ = key; }
122 
123  PublicKey&
124  getPublicKeyInfo() { return key_; }
125 
126  const PublicKey&
127  getPublicKeyInfo() const { return key_; }
128 
133  bool
134  isTooEarly() const;
135 
140  bool
141  isTooLate() const;
142 
143  void
144  printCertificate(std::ostream& os) const;
145 
146  void
147  printCertificate() const;
148 
149 protected:
150  void
151  decode();
152 
153  SubjectDescriptionList subjectDescriptionList_;
154  MillisecondsSince1970 notBefore_;
155  MillisecondsSince1970 notAfter_;
156  PublicKey key_;
157  ExtensionList extensionList_;
158 
159 private:
160  ptr_lib::shared_ptr<DerNode>
161  toDer();
162 };
163 
164 }
165 
166 #endif
Certificate()
The default constructor.
Definition: certificate.cpp:37
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
bool isTooEarly() const
Check if the certificate is valid.
Definition: certificate.cpp:55
void addSubjectDescription(const CertificateSubjectDescription &description)
Add a subject description.
Definition: certificate.hpp:81
A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
Definition: certificate-subject-description.hpp:36
Definition: data.hpp:37
bool isTooLate() const
Check if the certificate is valid.
Definition: certificate.cpp:65
void encode()
Encode the contents of the certificate in DER format and set the Content and MetaInfo fields...
Definition: certificate.cpp:75
A CertificateExtension represents the Extension entry in a certificate.
Definition: certificate-extension.hpp:37
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
double MillisecondsSince1970
The calendar time represented as the number of milliseconds since 1/1/1970.
Definition: common.hpp:116
void addExtension(const CertificateExtension &extension)
Add a certificate extension.
Definition: certificate.hpp:94
virtual void wireDecode(const Blob &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Override to call the base class wireDecode then populate the certificate fields.
Definition: certificate.cpp:83
static WireFormat * getDefaultWireFormat()
Return the default WireFormat used by default encoding and decoding methods which was set with setDef...
Definition: wire-format.cpp:34
virtual ~Certificate()
The virtual destructor.
Definition: certificate.cpp:49
Definition: wire-format.hpp:39
Definition: certificate.hpp:38