NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
sec-public-info.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_SEC_PUBLIC_INFO_HPP
23 #define NDN_SECURITY_SEC_PUBLIC_INFO_HPP
24 
25 #include "../name.hpp"
26 #include "security-common.hpp"
27 #include "v1/public-key.hpp"
29 
30 namespace ndn {
31 namespace security {
32 
39 class SecPublicInfo : noncopyable
40 {
41 public:
42  class Error : public std::runtime_error
43  {
44  public:
45  explicit
46  Error(const std::string& what)
47  : std::runtime_error(what)
48  {
49  }
50  };
51 
52  explicit
53  SecPublicInfo(const std::string& location);
54 
58  virtual
60 
72  virtual void
73  setTpmLocator(const std::string& tpmLocator) = 0;
74 
80  virtual std::string
81  getTpmLocator() = 0;
82 
86  std::string
87  getPibLocator();
88 
95  virtual bool
96  doesIdentityExist(const Name& identityName) = 0;
97 
105  virtual void
106  addIdentity(const Name& identityName) = 0;
107 
113  virtual bool
114  revokeIdentity() = 0;
115 
122  virtual bool
123  doesPublicKeyExist(const Name& keyName) = 0;
124 
133  DEPRECATED(
134  void
135  addPublicKey(const Name& keyName, KeyType keyType, const v1::PublicKey& publicKey));
136 
143  virtual void
144  addKey(const Name& keyName, const v1::PublicKey& publicKey) = 0;
145 
152  virtual shared_ptr<v1::PublicKey>
153  getPublicKey(const Name& keyName) = 0;
154 
164  virtual KeyType
165  getPublicKeyType(const Name& keyName) = 0;
166 
172  virtual bool
173  doesCertificateExist(const Name& certificateName) = 0;
174 
182  virtual void
183  addCertificate(const v1::IdentityCertificate& certificate) = 0;
184 
191  virtual shared_ptr<v1::IdentityCertificate>
192  getCertificate(const Name& certificateName) = 0;
193 
194 
195  /*****************************************
196  * Default Getter *
197  *****************************************/
198 
204  virtual Name
205  getDefaultIdentity() = 0;
206 
213  virtual Name
214  getDefaultKeyNameForIdentity(const Name& identityName) = 0;
215 
222  virtual Name
223  getDefaultCertificateNameForKey(const Name& keyName) = 0;
224 
231  virtual void
232  getAllIdentities(std::vector<Name>& nameList, bool isDefault) = 0;
233 
240  virtual void
241  getAllKeyNames(std::vector<Name>& nameList, bool isDefault) = 0;
242 
250  virtual void
251  getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault) = 0;
252 
259  virtual void
260  getAllCertificateNames(std::vector<Name>& nameList, bool isDefault) = 0;
261 
269  virtual void
270  getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name>& nameList, bool isDefault) = 0;
271 
272  /*****************************************
273  * Delete Methods *
274  *****************************************/
275 
281  virtual void
282  deleteCertificateInfo(const Name& certificateName) = 0;
283 
289  virtual void
290  deletePublicKeyInfo(const Name& keyName) = 0;
291 
297  virtual void
298  deleteIdentityInfo(const Name& identity) = 0;
299 
300 protected:
301 
302  /*****************************************
303  * Default Setter *
304  *****************************************/
305 
311  virtual void
312  setDefaultIdentityInternal(const Name& identityName) = 0;
313 
320  virtual void
321  setDefaultKeyNameForIdentityInternal(const Name& keyName) = 0;
322 
329  virtual void
330  setDefaultCertificateNameForKeyInternal(const Name& certificateName) = 0;
331 
335  virtual std::string
336  getScheme() = 0;
337 
338 public:
339 
340  /*****************************************
341  * Helper Methods *
342  *****************************************/
343 
350  void
351  setDefaultIdentity(const Name& identityName);
352 
359  void
360  setDefaultKeyNameForIdentity(const Name& keyName);
361 
368  void
369  setDefaultCertificateNameForKey(const Name& certificateName);
370 
378  Name
379  getNewKeyName(const Name& identityName, bool useKsk);
380 
388  Name
389  getDefaultCertificateNameForIdentity(const Name& identityName);
390 
397  Name
399 
406  void
408 
416  void
418 
426  void
428 
435  DEPRECATED(
436  shared_ptr<v1::IdentityCertificate>
437  defaultCertificate());
438 
444  shared_ptr<v1::IdentityCertificate>
446 
450  void
452 
453 protected:
454  shared_ptr<v1::IdentityCertificate> m_defaultCertificate;
455  std::string m_location;
456 };
457 
458 } // namespace security
459 
461 
462 } // namespace ndn
463 
464 #endif // NDN_SECURITY_SEC_PUBLIC_INFO_HPP
SecPublicInfo(const std::string &location)
virtual bool revokeIdentity()=0
Revoke the identity.
Copyright (c) 2011-2015 Regents of the University of California.
virtual void addIdentity(const Name &identityName)=0
Add a new identity.
virtual Name getDefaultCertificateNameForKey(const Name &keyName)=0
Get name of the default certificate name for the specified key.
virtual shared_ptr< v1::IdentityCertificate > getCertificate(const Name &certificateName)=0
Get a shared pointer to identity certificate object from the identity storage.
void addCertificateAsSystemDefault(const v1::IdentityCertificate &certificate)
Add a certificate into the public key identity storage and set the certificate as the default one of ...
void addCertificateAsKeyDefault(const v1::IdentityCertificate &certificate)
Add a certificate and set the certificate as the default one of its corresponding key...
virtual void setDefaultIdentityInternal(const Name &identityName)=0
Set the default identity.
virtual std::string getScheme()=0
return the scheme of the PibLocator
virtual ~SecPublicInfo()
The virtual Destructor.
Name getNewKeyName(const Name &identityName, bool useKsk)
Generate a key name for the identity.
STL namespace.
virtual void deleteCertificateInfo(const Name &certificateName)=0
Delete a certificate.
virtual void getAllCertificateNamesOfKey(const Name &keyName, std::vector< Name > &nameList, bool isDefault)=0
Get all the certificate name of a particular key name.
void addCertificateAsIdentityDefault(const v1::IdentityCertificate &certificate)
Add a certificate into the public key identity storage and set the certificate as the default one of ...
shared_ptr< v1::IdentityCertificate > getDefaultCertificate()
Get cached default certificate of the default identity.
virtual shared_ptr< v1::PublicKey > getPublicKey(const Name &keyName)=0
Get shared pointer to PublicKey object from the identity storage.
virtual void addKey(const Name &keyName, const v1::PublicKey &publicKey)=0
Add a public key to the identity storage.
virtual void getAllIdentities(std::vector< Name > &nameList, bool isDefault)=0
Get all the identities from public info.
virtual void setTpmLocator(const std::string &tpmLocator)=0
Set the corresponding TPM information to tpmLocator.
virtual bool doesIdentityExist(const Name &identityName)=0
Check if the specified identity already exists.
std::string getPibLocator()
Get PIB Locator.
virtual bool doesCertificateExist(const Name &certificateName)=0
Check if the specified certificate already exists.
shared_ptr< v1::IdentityCertificate > m_defaultCertificate
void setDefaultIdentity(const Name &identityName)
Set the default identity.
DEPRECATED(void addPublicKey(const Name &keyName, KeyType keyType, const v1::PublicKey &publicKey))
Add a public key to the identity storage.
virtual void getAllKeyNames(std::vector< Name > &nameList, bool isDefault)=0
Get all the key names from public info.
virtual void addCertificate(const v1::IdentityCertificate &certificate)=0
Add a certificate to the identity storage.
virtual void deleteIdentityInfo(const Name &identity)=0
Delete an identity and related public keys and certificates.
Name getDefaultCertificateName()
Get the default certificate name of the default identity.
virtual std::string getTpmLocator()=0
Get TPM Locator.
virtual KeyType getPublicKeyType(const Name &keyName)=0
Get the type of the queried public key.
Name abstraction to represent an absolute name.
Definition: name.hpp:46
virtual bool doesPublicKeyExist(const Name &keyName)=0
Check if the specified key already exists.
Name getDefaultCertificateNameForIdentity(const Name &identityName)
Get the default certificate name for the specified identity.
virtual void getAllKeyNamesOfIdentity(const Name &identity, std::vector< Name > &nameList, bool isDefault)=0
Get all the key names of a particular identity.
virtual Name getDefaultIdentity()=0
Get name of the default identity.
SecPublicInfo is a base class for the storage of public information.
void refreshDefaultCertificate()
try to get the default certificate of the default identity from the public info
virtual void getAllCertificateNames(std::vector< Name > &nameList, bool isDefault)=0
Get all the certificate name in public info.
virtual void setDefaultKeyNameForIdentityInternal(const Name &keyName)=0
Set the default key name for the corresponding identity.
virtual void deletePublicKeyInfo(const Name &keyName)=0
Delete a public key and related certificates.
virtual Name getDefaultKeyNameForIdentity(const Name &identityName)=0
Get name of the default key name for the specified identity.
virtual void setDefaultCertificateNameForKeyInternal(const Name &certificateName)=0
Set the default certificate name for the corresponding key.
void setDefaultCertificateNameForKey(const Name &certificateName)
Set the default certificate name for the corresponding key.
void setDefaultKeyNameForIdentity(const Name &keyName)
Set the default key name for the corresponding identity.