identity-storage.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_IDENTITY_STORAGE_HPP
24 #define NDN_IDENTITY_STORAGE_HPP
25 
26 #include "../../name.hpp"
27 #include "../security-common.hpp"
28 
29 namespace ndn {
30 
31 class IdentityCertificate;
32 class Data;
33 
40 public:
42 
46  virtual
48 
54  virtual bool
55  doesIdentityExist(const Name& identityName) = 0;
56 
61  virtual void
62  addIdentity(const Name& identityName) = 0;
63 
68  virtual bool
69  revokeIdentity() = 0;
70 
77  Name
78  getNewKeyName(const Name& identityName, bool useKsk);
79 
85  virtual bool
86  doesKeyExist(const Name& keyName) = 0;
87 
96  virtual void
97  addKey(const Name& keyName, KeyType keyType, const Blob& publicKeyDer) = 0;
98 
105  virtual Blob
106  getKey(const Name& keyName) = 0;
107 
112  virtual void
113  activateKey(const Name& keyName) = 0;
114 
119  virtual void
120  deactivateKey(const Name& keyName) = 0;
121 
127  virtual bool
128  doesCertificateExist(const Name& certificateName) = 0;
129 
136  virtual void
137  addCertificate(const IdentityCertificate& certificate) = 0;
138 
145  virtual ptr_lib::shared_ptr<IdentityCertificate>
146  getCertificate(const Name &certificateName) = 0;
147 
148 
149  /*****************************************
150  * Get/Set Default *
151  *****************************************/
152 
158  virtual Name
159  getDefaultIdentity() = 0;
160 
167  virtual Name
168  getDefaultKeyNameForIdentity(const Name& identityName) = 0;
169 
177  Name
178  getDefaultCertificateNameForIdentity(const Name& identityName);
179 
187  virtual Name
188  getDefaultCertificateNameForKey(const Name& keyName) = 0;
189 
196  virtual void
197  getAllIdentities(std::vector<Name>& nameList, bool isDefault) = 0;
198 
206  virtual void
208  (const Name& identityName, std::vector<Name>& nameList, bool isDefault) = 0;
209 
217  virtual void
219  (const Name& keyName, std::vector<Name>& nameList, bool isDefault) = 0;
220 
226  virtual void
227  setDefaultIdentity(const Name& identityName) = 0;
228 
236  virtual void
237  setDefaultKeyNameForIdentity(const Name& keyName, const Name& identityNameCheck = Name()) = 0;
238 
244  virtual void
245  setDefaultCertificateNameForKey(const Name& keyName, const Name& certificateName) = 0;
246 
252  virtual ptr_lib::shared_ptr<IdentityCertificate>
254 
255  /*****************************************
256  * Delete Methods *
257  *****************************************/
258 
263  virtual void
264  deleteCertificateInfo(const Name& certificateName) = 0;
265 
270  virtual void
271  deletePublicKeyInfo(const Name& keyName) = 0;
272 
277  virtual void
278  deleteIdentityInfo(const Name& identity) = 0;
279 
280 private:
281  static bool lastTimestampIsInitialized_;
282  static uint64_t lastTimestamp_;
283 };
284 
285 }
286 
287 #endif
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
virtual bool doesIdentityExist(const Name &identityName)=0
Check if the specified identity already exists.
virtual void setDefaultIdentity(const Name &identityName)=0
Set the default identity.
virtual void addIdentity(const Name &identityName)=0
Add a new identity.
Definition: identity-certificate.hpp:30
virtual ptr_lib::shared_ptr< IdentityCertificate > getDefaultCertificate()
Get the certificate of the default identity.
Definition: identity-storage.cpp:76
virtual ptr_lib::shared_ptr< IdentityCertificate > getCertificate(const Name &certificateName)=0
Get a certificate from the identity storage.
virtual void getAllCertificateNamesOfKey(const Name &keyName, std::vector< Name > &nameList, bool isDefault)=0
Append all the certificate names of a particular key name to the nameList.
Name getDefaultCertificateNameForIdentity(const Name &identityName)
Get the default certificate name for the specified identity.
Definition: identity-storage.cpp:69
virtual Name getDefaultCertificateNameForKey(const Name &keyName)=0
Get the default certificate name for the specified key.
Name getNewKeyName(const Name &identityName, bool useKsk)
Generate a name for a new key belonging to the identity.
Definition: identity-storage.cpp:41
virtual void deletePublicKeyInfo(const Name &keyName)=0
Delete a public key and related certificates.
virtual void setDefaultCertificateNameForKey(const Name &keyName, const Name &certificateName)=0
Set the default key name for the specified identity.
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
virtual void deleteCertificateInfo(const Name &certificateName)=0
Delete a certificate.
IdentityStorage is a base class for the storage of identity, public keys and certificates.
Definition: identity-storage.hpp:39
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
virtual bool doesKeyExist(const Name &keyName)=0
Check if the specified key already exists.
virtual void addKey(const Name &keyName, KeyType keyType, const Blob &publicKeyDer)=0
Add a public key to the identity storage.
virtual void addCertificate(const IdentityCertificate &certificate)=0
Add a certificate to the identity storage.
virtual void setDefaultKeyNameForIdentity(const Name &keyName, const Name &identityNameCheck=Name())=0
Set a key as the default key of an identity.
virtual void activateKey(const Name &keyName)=0
Activate a key.
virtual Name getDefaultIdentity()=0
Get the default identity.
virtual void deleteIdentityInfo(const Name &identity)=0
Delete an identity and related public keys and certificates.
virtual ~IdentityStorage()
The virtual Destructor.
Definition: identity-storage.hpp:47
virtual bool doesCertificateExist(const Name &certificateName)=0
Check if the specified certificate already exists.
virtual Name getDefaultKeyNameForIdentity(const Name &identityName)=0
Get the default key name for the specified identity.
virtual bool revokeIdentity()=0
Revoke the identity.
virtual void getAllKeyNamesOfIdentity(const Name &identityName, std::vector< Name > &nameList, bool isDefault)=0
Append all the key names of a particular identity to the nameList.
virtual void getAllIdentities(std::vector< Name > &nameList, bool isDefault)=0
Append all the identity names to the nameList.
virtual void deactivateKey(const Name &keyName)=0
Deactivate a key.
virtual Blob getKey(const Name &keyName)=0
Get the public key DER blob from the identity storage.