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 
153  virtual std::string
154  getTpmLocator() = 0;
155 
156  /*****************************************
157  * Get/Set Default *
158  *****************************************/
159 
165  virtual Name
166  getDefaultIdentity() = 0;
167 
174  virtual Name
175  getDefaultKeyNameForIdentity(const Name& identityName) = 0;
176 
184  Name
185  getDefaultCertificateNameForIdentity(const Name& identityName);
186 
194  virtual Name
195  getDefaultCertificateNameForKey(const Name& keyName) = 0;
196 
203  virtual void
204  getAllIdentities(std::vector<Name>& nameList, bool isDefault) = 0;
205 
213  virtual void
215  (const Name& identityName, std::vector<Name>& nameList, bool isDefault) = 0;
216 
224  virtual void
226  (const Name& keyName, std::vector<Name>& nameList, bool isDefault) = 0;
227 
233  virtual void
234  setDefaultIdentity(const Name& identityName) = 0;
235 
243  virtual void
244  setDefaultKeyNameForIdentity(const Name& keyName, const Name& identityNameCheck = Name()) = 0;
245 
251  virtual void
252  setDefaultCertificateNameForKey(const Name& keyName, const Name& certificateName) = 0;
253 
259  virtual ptr_lib::shared_ptr<IdentityCertificate>
261 
262  /*****************************************
263  * Delete Methods *
264  *****************************************/
265 
270  virtual void
271  deleteCertificateInfo(const Name& certificateName) = 0;
272 
277  virtual void
278  deletePublicKeyInfo(const Name& keyName) = 0;
279 
284  virtual void
285  deleteIdentityInfo(const Name& identity) = 0;
286 
287 private:
288  static bool lastTimestampIsInitialized_;
289  static uint64_t lastTimestamp_;
290 };
291 
292 }
293 
294 #endif
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:36
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:78
virtual std::string getTpmLocator()=0
Get the TPM locator associated with this storage.
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:71
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:43
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 ~IdentityStorage()
The virtual Destructor.
Definition: identity-storage.cpp:40
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 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.