NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
key.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_KEY_HPP
23 #define NDN_SECURITY_KEY_HPP
24 
25 #include "identity-certificate.hpp"
27 
28 namespace ndn {
29 namespace security {
30 
31 class PibImpl;
32 class Identity;
33 class KeyContainer;
34 
45 class Key
46 {
47 public:
48  friend class Identity;
49  friend class KeyContainer;
50  friend class KeyChain;
51 
52 public:
71  Key();
72 
74  const Name&
75  getName() const;
76 
78  const Name&
79  getIdentity() const;
80 
82  const name::Component&
83  getKeyId() const;
84 
86  const PublicKey&
87  getPublicKey() const;
88 
96  getCertificate(const Name& certName) const;
97 
100  getCertificates() const;
101 
107  const IdentityCertificate&
108  getDefaultCertificate() const;
109 
111  operator bool() const;
112 
114  bool
115  operator!() const;
116 
117 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
118 
124  void
125  addCertificate(const IdentityCertificate& certificate);
126 
132  void
133  removeCertificate(const Name& certName);
134 
142  const IdentityCertificate&
143  setDefaultCertificate(const Name& certName);
144 
154  const IdentityCertificate&
155  setDefaultCertificate(const IdentityCertificate& certificate);
156 
168  Key(const Name& identityName, const name::Component& keyId,
169  const PublicKey& publicKey, shared_ptr<PibImpl> impl);
170 
179  Key(const Name& identityName, const name::Component& keyId, shared_ptr<PibImpl> impl);
180 
186  void
187  validityCheck() const;
188 
189 private:
190  Name m_id;
191  name::Component m_keyId;
192  Name m_keyName;
193  PublicKey m_key;
194 
195  mutable bool m_hasDefaultCertificate;
196  mutable IdentityCertificate m_defaultCertificate;
197 
198  mutable bool m_needRefreshCerts;
199  mutable CertificateContainer m_certificates;
200 
201  shared_ptr<PibImpl> m_impl;
202 };
203 
204 } // namespace security
205 } // namespace ndn
206 
207 #endif // NDN_SECURITY_PIB_HPP
Copyright (c) 2011-2015 Regents of the University of California.
void validityCheck() const
Check the validity of this instance.
Definition: key.cpp:193
const name::Component & getKeyId() const
Get the key id of the key.
Definition: key.cpp:87
represents an identity
Definition: identity.hpp:44
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
IdentityCertificate getCertificate(const Name &certName) const
Get a certificate.
Definition: key.cpp:130
The packet signing interface.
Definition: key-chain.hpp:48
represents a key
Definition: key.hpp:45
bool operator!() const
Check if the Key instance is invalid.
Definition: key.cpp:187
A handler to search or enumerate certificates of a key.
Key()
Default Constructor.
Definition: key.cpp:29
const Name & getIdentity() const
Get the name of the belonging identity.
Definition: key.cpp:79
const CertificateContainer & getCertificates() const
Get all the certificates for this key.
Definition: key.cpp:138
A handler to search or enumerate keys of an identity.
const IdentityCertificate & getDefaultCertificate() const
Get the default certificate for this Key.
Definition: key.cpp:169
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const PublicKey shared_ptr< PibImpl > impl
Definition: key.hpp:168
const Name & getName() const
Get the name of the key.
Definition: key.cpp:71
Name abstraction to represent an absolute name.
Definition: name.hpp:46
const IdentityCertificate & setDefaultCertificate(const Name &certName)
Set the default certificate.
Definition: key.cpp:151
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const PublicKey & publicKey
Definition: key.hpp:168
Component holds a read-only name component value.
const PublicKey & getPublicKey() const
Get public key.
Definition: key.cpp:95
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component & keyId
Definition: key.hpp:168
void removeCertificate(const Name &certName)
Remove a certificate.
Definition: key.cpp:118