NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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_V1_CERTIFICATE_HPP
27 #define NDN_SECURITY_V1_CERTIFICATE_HPP
28 
29 #include "../../common.hpp"
30 #include "../../data.hpp"
33 #include "public-key.hpp"
34 
35 namespace ndn {
36 namespace security {
37 namespace v1 {
38 
39 class Certificate : public Data
40 {
41 public:
42  class Error : public Data::Error
43  {
44  public:
45  explicit
46  Error(const std::string& what)
47  : Data::Error(what)
48  {
49  }
50  };
51 
52  typedef std::vector<CertificateSubjectDescription> SubjectDescriptionList;
53  typedef std::vector<CertificateExtension> ExtensionList;
54 
58  Certificate();
59 
64  explicit
65  Certificate(const Data& data);
66 
71  explicit
72  Certificate(const Block& block);
73 
74  virtual
75  ~Certificate();
76 
77  void
78  wireDecode(const Block& wire);
79 
83  void
84  encode();
85 
90  void
92  {
93  m_subjectDescriptionList.push_back(description);
94  }
95 
96  const SubjectDescriptionList&
98  {
100  }
101 
102  SubjectDescriptionList&
104  {
106  }
107 
112  void
114  {
115  m_extensionList.push_back(extension);
116  }
117 
118  const ExtensionList&
120  {
121  return m_extensionList;
122  }
123 
124  ExtensionList&
126  {
127  return m_extensionList;
128  }
129 
130  void
132  {
133  m_notBefore = notBefore;
134  }
135 
138  {
139  return m_notBefore;
140  }
141 
143  getNotBefore() const
144  {
145  return m_notBefore;
146  }
147 
148  void
150  {
151  m_notAfter = notAfter;
152  }
153 
156  {
157  return m_notAfter;
158  }
159 
161  getNotAfter() const
162  {
163  return m_notAfter;
164  }
165 
166  void
168  {
169  m_key = key;
170  }
171 
172  PublicKey&
174  {
175  return m_key;
176  }
177 
178  const PublicKey&
180  {
181  return m_key;
182  }
183 
188  bool
189  isTooEarly();
190 
195  bool
196  isTooLate();
197 
198  void
199  printCertificate(std::ostream& os, const std::string& indent = "") const;
200 
201 protected:
202  void
203  decode();
204 
205 protected:
206  SubjectDescriptionList m_subjectDescriptionList;
210  ExtensionList m_extensionList;
211 };
212 
213 std::ostream&
214 operator<<(std::ostream& os, const Certificate& cert);
215 
216 } // namespace v1
217 } // namespace security
218 
219 #ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
222 #endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
223 
224 } // namespace ndn
225 
226 #endif // NDN_SECURITY_V1_CERTIFICATE_HPP
Copyright (c) 2011-2015 Regents of the University of California.
time::system_clock::TimePoint m_notBefore
void addExtension(const CertificateExtension &extension)
Add a certificate extension.
void setNotAfter(const time::system_clock::TimePoint &notAfter)
std::ostream & operator<<(std::ostream &os, const Certificate &cert)
const PublicKey & getPublicKeyInfo() const
Certificate()
The default constructor.
Definition: certificate.cpp:45
const SubjectDescriptionList & getSubjectDescriptionList() const
Definition: certificate.hpp:97
SubjectDescriptionList m_subjectDescriptionList
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
void addSubjectDescription(const CertificateSubjectDescription &description)
Add a subject description.
Definition: certificate.hpp:91
const ExtensionList & getExtensionList() const
bool isTooEarly()
Check if the certificate is valid.
Definition: certificate.cpp:76
void setNotBefore(const time::system_clock::TimePoint &notBefore)
void setPublicKeyInfo(const PublicKey &key)
std::vector< CertificateSubjectDescription > SubjectDescriptionList
Definition: certificate.hpp:52
ExtensionList & getExtensionList()
A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
void encode()
encode certificate info into content
Definition: certificate.cpp:94
SubjectDescriptionList & getSubjectDescriptionList()
time::system_clock::TimePoint & getNotAfter()
time_point TimePoint
Definition: time.hpp:90
void printCertificate(std::ostream &os, const std::string &indent="") const
bool isTooLate()
Check if the certificate is valid.
Definition: certificate.cpp:85
A CertificateExtension represents the Extension entry in a certificate.
Error(const std::string &what)
Definition: certificate.hpp:46
time::system_clock::TimePoint m_notAfter
represents a Data packet
Definition: data.hpp:37
void wireDecode(const Block &wire)
Definition: certificate.cpp:69
std::vector< CertificateExtension > ExtensionList
Definition: certificate.hpp:53
const time::system_clock::TimePoint & getNotAfter() const
const time::system_clock::TimePoint & getNotBefore() const
time::system_clock::TimePoint & getNotBefore()