NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
certificate.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NDN_SECURITY_CERTIFICATE_HPP
27 #define NDN_SECURITY_CERTIFICATE_HPP
28 
29 #include "../common.hpp"
30 #include "../data.hpp"
33 #include "public-key.hpp"
34 
35 namespace ndn {
36 
37 class Certificate : public Data
38 {
39 public:
40  class Error : public Data::Error
41  {
42  public:
43  explicit
44  Error(const std::string& what)
45  : Data::Error(what)
46  {
47  }
48  };
49 
50  typedef std::vector<CertificateSubjectDescription> SubjectDescriptionList;
51  typedef std::vector<CertificateExtension> ExtensionList;
52 
56  Certificate();
57 
62  explicit
63  Certificate(const Data& data);
64 
69  explicit
70  Certificate(const Block& block);
71 
72  virtual
73  ~Certificate();
74 
75  void
76  wireDecode(const Block& wire);
77 
81  void
82  encode();
83 
88  void
90  {
91  m_subjectDescriptionList.push_back(description);
92  }
93 
94  const SubjectDescriptionList&
96  {
98  }
99 
100  SubjectDescriptionList&
102  {
104  }
105 
110  void
112  {
113  m_extensionList.push_back(extension);
114  }
115 
116  const ExtensionList&
118  {
119  return m_extensionList;
120  }
121 
122  ExtensionList&
124  {
125  return m_extensionList;
126  }
127 
128  void
130  {
131  m_notBefore = notBefore;
132  }
133 
136  {
137  return m_notBefore;
138  }
139 
141  getNotBefore() const
142  {
143  return m_notBefore;
144  }
145 
146  void
148  {
149  m_notAfter = notAfter;
150  }
151 
154  {
155  return m_notAfter;
156  }
157 
159  getNotAfter() const
160  {
161  return m_notAfter;
162  }
163 
164  void
166  {
167  m_key = key;
168  }
169 
170  PublicKey&
172  {
173  return m_key;
174  }
175 
176  const PublicKey&
178  {
179  return m_key;
180  }
181 
186  bool
187  isTooEarly();
188 
193  bool
194  isTooLate();
195 
196  void
197  printCertificate(std::ostream& os, const std::string& indent = "") const;
198 
199 protected:
200  void
201  decode();
202 
203 protected:
204  SubjectDescriptionList m_subjectDescriptionList;
208  ExtensionList m_extensionList;
209 };
210 
211 std::ostream&
212 operator<<(std::ostream& os, const Certificate& cert);
213 } // namespace ndn
214 
215 #endif // NDN_SECURITY_CERTIFICATE_HPP
time::system_clock::TimePoint & getNotBefore()
Copyright (c) 2011-2015 Regents of the University of California.
Error(const std::string &what)
Definition: certificate.hpp:44
ExtensionList m_extensionList
time::system_clock::TimePoint & getNotAfter()
void addSubjectDescription(const CertificateSubjectDescription &description)
Add a subject description.
Definition: certificate.hpp:89
void addExtension(const CertificateExtension &extension)
Add a certificate extension.
std::vector< CertificateExtension > ExtensionList
Definition: certificate.hpp:51
A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
const SubjectDescriptionList & getSubjectDescriptionList() const
Definition: certificate.hpp:95
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition: data.cpp:340
void wireDecode(const Block &wire)
Definition: certificate.cpp:69
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
Certificate()
The default constructor.
Definition: certificate.cpp:45
const time::system_clock::TimePoint & getNotAfter() const
PublicKey & getPublicKeyInfo()
const ExtensionList & getExtensionList() const
time::system_clock::TimePoint m_notAfter
void setNotBefore(const time::system_clock::TimePoint &notBefore)
bool isTooLate()
Check if the certificate is valid.
Definition: certificate.cpp:85
void encode()
encode certificate info into content
Definition: certificate.cpp:94
const PublicKey & getPublicKeyInfo() const
time::system_clock::TimePoint m_notBefore
bool isTooEarly()
Check if the certificate is valid.
Definition: certificate.cpp:76
time_point TimePoint
Definition: time.hpp:78
SubjectDescriptionList m_subjectDescriptionList
SubjectDescriptionList & getSubjectDescriptionList()
std::vector< CertificateSubjectDescription > SubjectDescriptionList
Definition: certificate.hpp:50
virtual ~Certificate()
Definition: certificate.cpp:64
void printCertificate(std::ostream &os, const std::string &indent="") const
ExtensionList & getExtensionList()
const time::system_clock::TimePoint & getNotBefore() const
A CertificateExtension represents the Extension entry in a certificate.
represents a Data packet
Definition: data.hpp:39
void setNotAfter(const time::system_clock::TimePoint &notAfter)
void setPublicKeyInfo(const PublicKey &key)