Certificate delete API – backend.

Till now the Certificate Manager has one-to-one relation with a
Certificate class. And the DELETE API provided by the
Certificate Manager was enough to delete managed by it certificate.

With introducing Mutual-TLS the relation is changing to one-to-many
and current delete API is not sufficient. This commit adds DELETE
interface to Certificate class, so each of them can be removed
individually. This implementation was done on base of current user
account management implementation. The Certificate class exposes the
delete interface on DBus. When the API is called the Certificate
instance calls proper operation on Certificate Manager which
removes it from its internal collection. The rest of the removing
certificate process, including service reset remains as it was.

Tested with uploaded multiple TLS certificates.
Each Certificate exposes Delete interface on dbus and user is able
to delete each of them. The delete API on Certificate Manager object
was replaced with DeleteAll interface and results in deleting all
loaded certificates.

Signed-off-by: Zbigniew Kurzynski <zbigniew.kurzynski@intel.com>
Change-Id: I9dd6fa998e8bd8081fbd13549831bc94a4a7aa54
diff --git a/certificate.cpp b/certificate.cpp
index a070e07..0682216 100644
--- a/certificate.cpp
+++ b/certificate.cpp
@@ -2,6 +2,8 @@
 
 #include "certificate.hpp"
 
+#include "certs_manager.hpp"
+
 #include <openssl/bio.h>
 #include <openssl/crypto.h>
 #include <openssl/err.h>
@@ -87,10 +89,10 @@
                          const CertInstallPath& installPath,
                          const CertUploadPath& uploadPath,
                          bool isSkipUnitReload,
-                         const CertWatchPtr& certWatchPtr) :
+                         const CertWatchPtr& certWatchPtr, Manager& parent) :
     CertIfaces(bus, objPath.c_str(), true),
     bus(bus), objectPath(objPath), certType(type), unitToRestart(unit),
-    certInstallPath(installPath), certWatchPtr(certWatchPtr)
+    certInstallPath(installPath), certWatchPtr(certWatchPtr), manager(parent)
 {
     auto installHelper = [this](const auto& filePath) {
         if (!compareKeys(filePath))
@@ -643,5 +645,10 @@
         elog<InternalFailure>();
     }
 }
+
+void Certificate::delete_()
+{
+    manager.deleteCertificate(getHash());
+}
 } // namespace certs
 } // namespace phosphor