v1/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_V1_SEC_PUBLIC_INFO_HPP
23 #define NDN_SECURITY_V1_SEC_PUBLIC_INFO_HPP
24 
25 #include "../../name.hpp"
26 #include "../security-common.hpp"
27 #include "public-key.hpp"
28 #include "identity-certificate.hpp"
29 
30 namespace ndn {
31 namespace security {
32 namespace v1 {
33 
40 class SecPublicInfo : noncopyable
41 {
42 public:
43  class Error : public std::runtime_error
44  {
45  public:
46  explicit
47  Error(const std::string& what)
48  : std::runtime_error(what)
49  {
50  }
51  };
52 
53  explicit
54  SecPublicInfo(const std::string& location);
55 
59  virtual
61 
73  virtual void
74  setTpmLocator(const std::string& tpmLocator) = 0;
75 
81  virtual std::string
82  getTpmLocator() = 0;
83 
87  std::string
88  getPibLocator();
89 
96  virtual bool
97  doesIdentityExist(const Name& identityName) = 0;
98 
106  virtual void
107  addIdentity(const Name& identityName) = 0;
108 
114  virtual bool
115  revokeIdentity() = 0;
116 
123  virtual bool
124  doesPublicKeyExist(const Name& keyName) = 0;
125 
134  DEPRECATED(
135  void
136  addPublicKey(const Name& keyName, KeyType keyType, const PublicKey& publicKey));
137 
144  virtual void
145  addKey(const Name& keyName, const PublicKey& publicKey) = 0;
146 
153  virtual shared_ptr<PublicKey>
154  getPublicKey(const Name& keyName) = 0;
155 
165  virtual KeyType
166  getPublicKeyType(const Name& keyName) = 0;
167 
173  virtual bool
174  doesCertificateExist(const Name& certificateName) = 0;
175 
183  virtual void
184  addCertificate(const IdentityCertificate& certificate) = 0;
185 
192  virtual shared_ptr<IdentityCertificate>
193  getCertificate(const Name& certificateName) = 0;
194 
195 
196  /*****************************************
197  * Default Getter *
198  *****************************************/
199 
205  virtual Name
206  getDefaultIdentity() = 0;
207 
214  virtual Name
215  getDefaultKeyNameForIdentity(const Name& identityName) = 0;
216 
223  virtual Name
224  getDefaultCertificateNameForKey(const Name& keyName) = 0;
225 
232  virtual void
233  getAllIdentities(std::vector<Name>& nameList, bool isDefault) = 0;
234 
241  virtual void
242  getAllKeyNames(std::vector<Name>& nameList, bool isDefault) = 0;
243 
251  virtual void
252  getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault) = 0;
253 
260  virtual void
261  getAllCertificateNames(std::vector<Name>& nameList, bool isDefault) = 0;
262 
270  virtual void
271  getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name>& nameList, bool isDefault) = 0;
272 
273  /*****************************************
274  * Delete Methods *
275  *****************************************/
276 
282  virtual void
283  deleteCertificateInfo(const Name& certificateName) = 0;
284 
290  virtual void
291  deletePublicKeyInfo(const Name& keyName) = 0;
292 
298  virtual void
299  deleteIdentityInfo(const Name& identity) = 0;
300 
301 protected:
302 
303  /*****************************************
304  * Default Setter *
305  *****************************************/
306 
312  virtual void
313  setDefaultIdentityInternal(const Name& identityName) = 0;
314 
321  virtual void
322  setDefaultKeyNameForIdentityInternal(const Name& keyName) = 0;
323 
330  virtual void
331  setDefaultCertificateNameForKeyInternal(const Name& certificateName) = 0;
332 
336  virtual std::string
337  getScheme() = 0;
338 
339 public:
340 
341  /*****************************************
342  * Helper Methods *
343  *****************************************/
344 
351  void
352  setDefaultIdentity(const Name& identityName);
353 
360  void
361  setDefaultKeyNameForIdentity(const Name& keyName);
362 
369  void
370  setDefaultCertificateNameForKey(const Name& certificateName);
371 
379  Name
380  getNewKeyName(const Name& identityName, bool useKsk);
381 
389  Name
390  getDefaultCertificateNameForIdentity(const Name& identityName);
391 
398  Name
400 
407  void
409 
417  void
419 
427  void
429 
436  DEPRECATED(
437  shared_ptr<IdentityCertificate>
439 
445  shared_ptr<IdentityCertificate>
447 
451  void
453 
454 protected:
455  shared_ptr<IdentityCertificate> m_defaultCertificate;
456  std::string m_location;
457 };
458 
459 } // namespace v1
460 
461 #ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
462 using v1::SecPublicInfo;
463 #endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
464 
465 } // namespace security
466 
467 #ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
469 #endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
470 
471 } // namespace ndn
472 
473 #endif // NDN_SECURITY_V1_SEC_PUBLIC_INFO_HPP
virtual void deleteIdentityInfo(const Name &identity)=0
Delete an identity and related public keys and certificates.
shared_ptr< IdentityCertificate > defaultCertificate()
Get cached default certificate of the default identity.
shared_ptr< IdentityCertificate > m_defaultCertificate
virtual Name getDefaultKeyNameForIdentity(const Name &identityName)=0
Get name of the default key name for the specified identity.
virtual Name getDefaultCertificateNameForKey(const Name &keyName)=0
Get name of the default certificate name for the specified key.
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:75
virtual void setDefaultIdentityInternal(const Name &identityName)=0
Set the default identity.
Name getDefaultCertificateName()
Get the default certificate name of the default identity.
virtual ~SecPublicInfo()
The virtual Destructor.
virtual void getAllCertificateNames(std::vector< Name > &nameList, bool isDefault)=0
Get all the certificate name in public info.
std::string getPibLocator()
Get PIB Locator.
virtual void getAllKeyNamesOfIdentity(const Name &identity, std::vector< Name > &nameList, bool isDefault)=0
Get all the key names of a particular identity.
STL namespace.
virtual void deleteCertificateInfo(const Name &certificateName)=0
Delete a certificate.
virtual void addCertificate(const IdentityCertificate &certificate)=0
Add a certificate to the identity storage.
virtual void addIdentity(const Name &identityName)=0
Add a new identity.
virtual bool doesIdentityExist(const Name &identityName)=0
Check if the specified identity already exists.
virtual Name getDefaultIdentity()=0
Get name of the default identity.
void addCertificateAsSystemDefault(const IdentityCertificate &certificate)
Add a certificate into the public key identity storage and set the certificate as the default one of ...
void setDefaultCertificateNameForKey(const Name &certificateName)
Set the default certificate name for the corresponding key.
virtual bool doesPublicKeyExist(const Name &keyName)=0
Check if the specified key already exists.
void setDefaultIdentity(const Name &identityName)
Set the default identity.
virtual shared_ptr< IdentityCertificate > getCertificate(const Name &certificateName)=0
Get a shared pointer to identity certificate object from the identity storage.
void refreshDefaultCertificate()
try to get the default certificate of the default identity from the public info
Name getDefaultCertificateNameForIdentity(const Name &identityName)
Get the default certificate name for the specified identity.
SecPublicInfo(const std::string &location)
virtual std::string getScheme()=0
return the scheme of the PibLocator
void addPublicKey(const Name &keyName, KeyType keyType, const PublicKey &publicKey)
Add a public key to the identity storage.
SecPublicInfo is a base class for the storage of public information.
virtual void addKey(const Name &keyName, const PublicKey &publicKey)=0
Add a public key to the identity storage.
virtual bool revokeIdentity()=0
Revoke the identity.
virtual void deletePublicKeyInfo(const Name &keyName)=0
Delete a public key and related certificates.
Represents an absolute name.
Definition: name.hpp:42
virtual void setDefaultKeyNameForIdentityInternal(const Name &keyName)=0
Set the default key name for the corresponding identity.
virtual bool doesCertificateExist(const Name &certificateName)=0
Check if the specified certificate already exists.
virtual std::string getTpmLocator()=0
Get TPM Locator.
void addCertificateAsKeyDefault(const IdentityCertificate &certificate)
Add a certificate and set the certificate as the default one of its corresponding key...
void addCertificateAsIdentityDefault(const IdentityCertificate &certificate)
Add a certificate into the public key identity storage and set the certificate as the default one of ...
virtual void setDefaultCertificateNameForKeyInternal(const Name &certificateName)=0
Set the default certificate name for the corresponding key.
shared_ptr< IdentityCertificate > getDefaultCertificate()
Get cached default certificate of the default identity.
#define DEPRECATED(func)
Definition: common.hpp:72
virtual void getAllIdentities(std::vector< Name > &nameList, bool isDefault)=0
Get all the identities from public info.
virtual void getAllKeyNames(std::vector< Name > &nameList, bool isDefault)=0
Get all the key names from public info.
virtual void setTpmLocator(const std::string &tpmLocator)=0
Set the corresponding TPM information to tpmLocator.
Name getNewKeyName(const Name &identityName, bool useKsk)
Generate a key name for the identity.
virtual KeyType getPublicKeyType(const Name &keyName)=0
Get the type of the queried public key.
virtual void getAllCertificateNamesOfKey(const Name &keyName, std::vector< Name > &nameList, bool isDefault)=0
Get all the certificate name of a particular key name.
void setDefaultKeyNameForIdentity(const Name &keyName)
Set the default key name for the corresponding identity.
virtual shared_ptr< PublicKey > getPublicKey(const Name &keyName)=0
Get shared pointer to PublicKey object from the identity storage.