blob: 2e939754099e94bf0266d4a090c41f3b3b756278 [file] [log] [blame]
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -05001#pragma once
Marri Devender Rao6ceec402019-02-01 03:15:19 -06002#include "certificate.hpp"
Jayanth Othayothdd74bd22018-09-28 06:13:35 -05003
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -05004#include <xyz/openbmc_project/Certs/Install/server.hpp>
Deepak Kodihalliae70b3d2018-09-30 05:42:00 -05005#include <xyz/openbmc_project/Object/Delete/server.hpp>
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -05006
7namespace phosphor
8{
9namespace certs
10{
Deepak Kodihalliae70b3d2018-09-30 05:42:00 -050011using Create = sdbusplus::xyz::openbmc_project::Certs::server::Install;
12using Delete = sdbusplus::xyz::openbmc_project::Object::server::Delete;
13using Ifaces = sdbusplus::server::object::object<Create, Delete>;
Jayanth Othayothb50789c2018-10-09 07:13:54 -050014
Deepak Kodihalliae70b3d2018-09-30 05:42:00 -050015class Manager : public Ifaces
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050016{
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 Rao6ceec402019-02-01 03:15:19 -060040 * @param[in] installPath - Certificate installation path.
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050041 */
Marri Devender Rao6ceec402019-02-01 03:15:19 -060042 Manager(sdbusplus::bus::bus& bus, const char* path,
43 const CertificateType& type, UnitsToRestart&& unit,
44 CertInstallPath&& installPath);
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050045
46 /** @brief Implementation for Install
47 * Replace the existing certificate key file with another
48 * (possibly CA signed) Certificate key file.
49 *
Marri Devender Rao6ceec402019-02-01 03:15:19 -060050 * @param[in] filePath - Certificate key file path.
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050051 */
Marri Devender Rao6ceec402019-02-01 03:15:19 -060052 void install(const std::string filePath) override;
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050053
Deepak Kodihalliae70b3d2018-09-30 05:42:00 -050054 /** @brief Delete the certificate (and possibly revert
55 * to a self-signed certificate).
56 */
57 void delete_() override;
58
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050059 private:
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050060 /** @brief sdbusplus handler */
61 sdbusplus::bus::bus& bus;
62
63 /** @brief object path */
Marri Devender Rao6ceec402019-02-01 03:15:19 -060064 std::string objectPath;
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050065
66 /** @brief Type of the certificate **/
Marri Devender Rao6ceec402019-02-01 03:15:19 -060067 CertificateType certType;
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050068
69 /** @brief Unit name associated to the service **/
Marri Devender Rao6ceec402019-02-01 03:15:19 -060070 UnitsToRestart unitToRestart;
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050071
72 /** @brief Certificate file installation path **/
Marri Devender Rao6ceec402019-02-01 03:15:19 -060073 CertInstallPath certInstallPath;
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050074
Marri Devender Rao6ceec402019-02-01 03:15:19 -060075 /** @brief pointer to certificate */
76 std::unique_ptr<Certificate> certificatePtr = nullptr;
Jayanth Othayothcfbc8dc2018-09-03 07:22:27 -050077};
78
79} // namespace certs
80} // namespace phosphor