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 
104  virtual Blob
105  getKey(const Name& keyName) = 0;
106 
111  virtual void
112  activateKey(const Name& keyName) = 0;
113 
118  virtual void
119  deactivateKey(const Name& keyName) = 0;
120 
126  virtual bool
127  doesCertificateExist(const Name& certificateName) = 0;
128 
134  virtual void
135  addCertificate(const IdentityCertificate& certificate) = 0;
136 
144  virtual ptr_lib::shared_ptr<IdentityCertificate>
145  getCertificate(const Name &certificateName, bool allowAny = false) = 0;
146 
147 
148  /*****************************************
149  * Get/Set Default *
150  *****************************************/
151 
157  virtual Name
158  getDefaultIdentity() = 0;
159 
166  virtual Name
167  getDefaultKeyNameForIdentity(const Name& identityName) = 0;
168 
176  Name
177  getDefaultCertificateNameForIdentity(const Name& identityName);
178 
186  virtual Name
187  getDefaultCertificateNameForKey(const Name& keyName) = 0;
188 
196  virtual void
198  (const Name& identityName, std::vector<Name>& nameList, bool isDefault) = 0;
199 
205  virtual void
206  setDefaultIdentity(const Name& identityName) = 0;
207 
215  virtual void
216  setDefaultKeyNameForIdentity(const Name& keyName, const Name& identityNameCheck = Name()) = 0;
217 
223  virtual void
224  setDefaultCertificateNameForKey(const Name& keyName, const Name& certificateName) = 0;
225 
231  virtual ptr_lib::shared_ptr<IdentityCertificate>
233 
234  /*****************************************
235  * Delete Methods *
236  *****************************************/
237 
242  virtual void
243  deleteCertificateInfo(const Name& certificateName) = 0;
244 
249  virtual void
250  deletePublicKeyInfo(const Name& keyName) = 0;
251 
256  virtual void
257  deleteIdentityInfo(const Name& identity) = 0;
258 
259 private:
260  static bool lastTimestampIsInitialized_;
261  static uint64_t lastTimestamp_;
262 };
263 
264 }
265 
266 #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
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 ptr_lib::shared_ptr< IdentityCertificate > getCertificate(const Name &certificateName, bool allowAny=false)=0
Get a certificate from the identity storage.
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 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.