Support creation/deletion of D-Bus certificate object

During certificate upload through REST or through POST on
CertificateCollection create certificate object, validate
certificate and copy certficate to the system.

Supported deletion of certificate object, thought it is
available only for REST based systems

Tested:
1. Verified certificate object is created if certificate exists
2. Verified certificate object is created during install
3. Verified certificate properties
Change-Id: If31aa939c9cb75b5d683a7614ddc55ad38297874
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
diff --git a/certs_manager.cpp b/certs_manager.cpp
index 7170605..b55363f 100644
--- a/certs_manager.cpp
+++ b/certs_manager.cpp
@@ -8,10 +8,8 @@
 namespace certs
 {
 
-using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-using InvalidCertificate =
-    sdbusplus::xyz::openbmc_project::Certs::Install::Error::InvalidCertificate;
-using Reason = xyz::openbmc_project::Certs::Install::InvalidCertificate::REASON;
+using InternalFailure =
+    sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
 
 /** @brief Constructor to put object onto bus at a dbus path.
  *  @param[in] bus - Bus to attach to.
@@ -27,6 +25,10 @@
     bus(bus), objectPath(path), certType(type), unitToRestart(std::move(unit)),
     certInstallPath(std::move(installPath))
 {
+    using InvalidCertificate = sdbusplus::xyz::openbmc_project::Certs::Install::
+        Error::InvalidCertificate;
+    using Reason =
+        xyz::openbmc_project::Certs::Install::InvalidCertificate::REASON;
     if (fs::exists(certInstallPath))
     {
         try
@@ -41,12 +43,10 @@
         }
         catch (const InternalFailure& e)
         {
-            certificatePtr.reset(nullptr);
             report<InternalFailure>();
         }
         catch (const InvalidCertificate& e)
         {
-            certificatePtr.reset(nullptr);
             report<InvalidCertificate>(
                 Reason("Existing certificate file is corrupted"));
         }
@@ -55,6 +55,20 @@
 
 void Manager::install(const std::string filePath)
 {
+    using NotAllowed =
+        sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
+    using Reason = xyz::openbmc_project::Common::NotAllowed::REASON;
+    // TODO: Issue#3 At present supporting only one certificate to be
+    // uploaded this need to be revisited to support multiple
+    // certificates
+    if (certificatePtr != nullptr)
+    {
+        elog<NotAllowed>(Reason("Certificate already exist"));
+    }
+    auto certObjectPath = objectPath + '/' + '1';
+    certificatePtr =
+        std::make_unique<Certificate>(bus, certObjectPath, certType,
+                                      unitToRestart, certInstallPath, filePath);
 }
 
 void Manager::delete_()