security: Adding delete methods in KeyChain
Change-Id: I8e3bbbf6e911b43189c510c56118d291f8932df4
diff --git a/src/security/sec-public-info.hpp b/src/security/sec-public-info.hpp
index 7cd7230..37afd5d 100644
--- a/src/security/sec-public-info.hpp
+++ b/src/security/sec-public-info.hpp
@@ -145,20 +145,20 @@
virtual Name
getDefaultCertificateNameForKey(const Name& keyName) = 0;
- virtual std::vector<Name>
- getAllIdentities(bool isDefault) = 0;
+ virtual void
+ getAllIdentities(std::vector<Name> &nameList, bool isDefault) = 0;
- virtual std::vector<Name>
- getAllKeyNames(bool isDefault) = 0;
+ virtual void
+ getAllKeyNames(std::vector<Name> &nameList, bool isDefault) = 0;
- virtual std::vector<Name>
- getAllKeyNamesOfIdentity(const Name& identity, bool isDefault) = 0;
+ virtual void
+ getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name> &nameList, bool isDefault) = 0;
- virtual std::vector<Name>
- getAllCertificateNames(bool isDefault) = 0;
+ virtual void
+ getAllCertificateNames(std::vector<Name> &nameList, bool isDefault) = 0;
- virtual std::vector<Name>
- getAllCertificateNamesOfKey(const Name& keyName, bool isDefault) = 0;
+ virtual void
+ getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name> &nameList, bool isDefault) = 0;
protected:
@@ -188,6 +188,31 @@
virtual void
setDefaultCertificateNameForKeyInternal(const Name& certificateName) = 0;
+ /*****************************************
+ * Delete Methods *
+ *****************************************/
+
+ /**
+ * Delete a certificate.
+ * @param certificateName The certificate name.
+ */
+ virtual void
+ deleteCertificateInfo(const Name &certificateName) = 0;
+
+ /**
+ * Delete a public key and related certificates.
+ * @param keyName The key name.
+ */
+ virtual void
+ deletePublicKeyInfo(const Name &keyName) = 0;
+
+ /**
+ * Delete an identity and related public keys and certificates.
+ * @param identity The identity name.
+ */
+ virtual void
+ deleteIdentityInfo(const Name &identity) = 0;
+
public:
/*****************************************
@@ -306,12 +331,12 @@
else
oss << "dsk-";
- oss << static_cast<int>(getNow()/1000);
+ oss << static_cast<int>(getNow());
Name keyName = Name(identityName).append(oss.str());
if (doesPublicKeyExist(keyName))
- throw Error("Key name already exists");
+ throw Error("Key name already exists: " + keyName.toUri());
return keyName;
}
@@ -374,7 +399,6 @@
defaultCertificate_ = getCertificate(certName);
}
-
}
#endif