Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 1 | #pragma once |
Marri Devender Rao | 6ceec40 | 2019-02-01 03:15:19 -0600 | [diff] [blame] | 2 | #include "certificate.hpp" |
Jayanth Othayoth | dd74bd2 | 2018-09-28 06:13:35 -0500 | [diff] [blame] | 3 | |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 4 | #include <xyz/openbmc_project/Certs/Install/server.hpp> |
Deepak Kodihalli | ae70b3d | 2018-09-30 05:42:00 -0500 | [diff] [blame] | 5 | #include <xyz/openbmc_project/Object/Delete/server.hpp> |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace certs |
| 10 | { |
Deepak Kodihalli | ae70b3d | 2018-09-30 05:42:00 -0500 | [diff] [blame] | 11 | using Create = sdbusplus::xyz::openbmc_project::Certs::server::Install; |
| 12 | using Delete = sdbusplus::xyz::openbmc_project::Object::server::Delete; |
| 13 | using Ifaces = sdbusplus::server::object::object<Create, Delete>; |
Jayanth Othayoth | b50789c | 2018-10-09 07:13:54 -0500 | [diff] [blame] | 14 | |
Deepak Kodihalli | ae70b3d | 2018-09-30 05:42:00 -0500 | [diff] [blame] | 15 | class Manager : public Ifaces |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 16 | { |
| 17 | public: |
| 18 | /* Define all of the basic class operations: |
| 19 | * Not allowed: |
| 20 | * - Default constructor is not possible due to member |
| 21 | * reference |
| 22 | * - Move operations due to 'this' being registered as the |
| 23 | * 'context' with sdbus. |
| 24 | * Allowed: |
| 25 | * - copy |
| 26 | * - Destructor. |
| 27 | */ |
| 28 | Manager() = delete; |
| 29 | Manager(const Manager&) = default; |
| 30 | Manager& operator=(const Manager&) = delete; |
| 31 | Manager(Manager&&) = delete; |
| 32 | Manager& operator=(Manager&&) = delete; |
| 33 | virtual ~Manager() = default; |
| 34 | |
| 35 | /** @brief Constructor to put object onto bus at a dbus path. |
| 36 | * @param[in] bus - Bus to attach to. |
| 37 | * @param[in] path - Path to attach at. |
| 38 | * @param[in] type - Type of the certificate. |
| 39 | * @param[in] unit - Unit consumed by this certificate. |
Marri Devender Rao | 6ceec40 | 2019-02-01 03:15:19 -0600 | [diff] [blame] | 40 | * @param[in] installPath - Certificate installation path. |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 41 | */ |
Marri Devender Rao | 6ceec40 | 2019-02-01 03:15:19 -0600 | [diff] [blame] | 42 | Manager(sdbusplus::bus::bus& bus, const char* path, |
| 43 | const CertificateType& type, UnitsToRestart&& unit, |
| 44 | CertInstallPath&& installPath); |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 45 | |
| 46 | /** @brief Implementation for Install |
| 47 | * Replace the existing certificate key file with another |
| 48 | * (possibly CA signed) Certificate key file. |
| 49 | * |
Marri Devender Rao | 6ceec40 | 2019-02-01 03:15:19 -0600 | [diff] [blame] | 50 | * @param[in] filePath - Certificate key file path. |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 51 | */ |
Marri Devender Rao | 6ceec40 | 2019-02-01 03:15:19 -0600 | [diff] [blame] | 52 | void install(const std::string filePath) override; |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 53 | |
Deepak Kodihalli | ae70b3d | 2018-09-30 05:42:00 -0500 | [diff] [blame] | 54 | /** @brief Delete the certificate (and possibly revert |
| 55 | * to a self-signed certificate). |
| 56 | */ |
| 57 | void delete_() override; |
| 58 | |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 59 | private: |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 60 | /** @brief sdbusplus handler */ |
| 61 | sdbusplus::bus::bus& bus; |
| 62 | |
| 63 | /** @brief object path */ |
Marri Devender Rao | 6ceec40 | 2019-02-01 03:15:19 -0600 | [diff] [blame] | 64 | std::string objectPath; |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 65 | |
| 66 | /** @brief Type of the certificate **/ |
Marri Devender Rao | 6ceec40 | 2019-02-01 03:15:19 -0600 | [diff] [blame] | 67 | CertificateType certType; |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 68 | |
| 69 | /** @brief Unit name associated to the service **/ |
Marri Devender Rao | 6ceec40 | 2019-02-01 03:15:19 -0600 | [diff] [blame] | 70 | UnitsToRestart unitToRestart; |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 71 | |
| 72 | /** @brief Certificate file installation path **/ |
Marri Devender Rao | 6ceec40 | 2019-02-01 03:15:19 -0600 | [diff] [blame] | 73 | CertInstallPath certInstallPath; |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 74 | |
Marri Devender Rao | 6ceec40 | 2019-02-01 03:15:19 -0600 | [diff] [blame] | 75 | /** @brief pointer to certificate */ |
| 76 | std::unique_ptr<Certificate> certificatePtr = nullptr; |
Jayanth Othayoth | cfbc8dc | 2018-09-03 07:22:27 -0500 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | } // namespace certs |
| 80 | } // namespace phosphor |