From 6b50bbba7b7a0191e9a3ee924474289df50accff Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Fri, 21 Jun 2019 12:37:08 +0300 Subject: [PATCH 1/3] OTA-2481: Get rid of SecondaryFactory Signed-off-by: Mike Sul --- .../aktualizr_secondary.cc | 1 - src/hmi_stub/main.cc | 1 - src/libaktualizr/primary/aktualizr_test.cc | 8 ++--- src/libaktualizr/primary/sotauptaneclient.cc | 34 +++++++++++++------ src/libaktualizr/uptane/CMakeLists.txt | 2 -- src/libaktualizr/uptane/secondaryconfig.h | 2 -- src/libaktualizr/uptane/secondaryfactory.cc | 32 ----------------- src/libaktualizr/uptane/secondaryfactory.h | 16 --------- .../uptane/uptane_secondary_test.cc | 30 ++++------------ 9 files changed, 33 insertions(+), 93 deletions(-) delete mode 100644 src/libaktualizr/uptane/secondaryfactory.cc delete mode 100644 src/libaktualizr/uptane/secondaryfactory.h diff --git a/src/aktualizr_secondary/aktualizr_secondary.cc b/src/aktualizr_secondary/aktualizr_secondary.cc index c5fc0cdb38..8600a40f3d 100644 --- a/src/aktualizr_secondary/aktualizr_secondary.cc +++ b/src/aktualizr_secondary/aktualizr_secondary.cc @@ -9,7 +9,6 @@ #endif #include "socket_activation/socket_activation.h" #include "socket_server.h" -#include "uptane/secondaryfactory.h" #include "utilities/utils.h" class SecondaryAdapter : public Uptane::SecondaryInterface { diff --git a/src/hmi_stub/main.cc b/src/hmi_stub/main.cc index defb3ccc2c..b88bb83c55 100644 --- a/src/hmi_stub/main.cc +++ b/src/hmi_stub/main.cc @@ -14,7 +14,6 @@ #include "config/config.h" #include "logging/logging.h" #include "primary/aktualizr.h" -#include "uptane/secondaryfactory.h" #include "utilities/utils.h" namespace bpo = boost::program_options; diff --git a/src/libaktualizr/primary/aktualizr_test.cc b/src/libaktualizr/primary/aktualizr_test.cc index 2828e424a1..2baf886727 100644 --- a/src/libaktualizr/primary/aktualizr_test.cc +++ b/src/libaktualizr/primary/aktualizr_test.cc @@ -14,7 +14,7 @@ #include "primary/aktualizr.h" #include "primary/events.h" #include "primary/sotauptaneclient.h" -#include "uptane/secondaryfactory.h" +#include "uptane/virtualsecondary.h" #include "uptane_test_common.h" #include "utilities/utils.h" @@ -136,7 +136,7 @@ TEST(Aktualizr, AddSecondary) { Uptane::SecondaryConfig ecu_config = virtual_configuration(temp_dir.Path()); - aktualizr.AddSecondary(Uptane::SecondaryFactory::makeSecondary(ecu_config)); + aktualizr.AddSecondary(std::make_shared(ecu_config)); aktualizr.Initialize(); @@ -156,7 +156,7 @@ TEST(Aktualizr, AddSecondary) { EXPECT_EQ(expected_ecus.size(), 0); ecu_config.ecu_serial = "ecuserial4"; - auto sec4 = Uptane::SecondaryFactory::makeSecondary(ecu_config); + auto sec4 = std::make_shared(ecu_config); EXPECT_THROW(aktualizr.AddSecondary(sec4), std::logic_error); } @@ -180,7 +180,7 @@ TEST(Aktualizr, DeviceInstallationResult) { Uptane::SecondaryConfig ecu_config = virtual_configuration(temp_dir.Path()); - aktualizr.AddSecondary(Uptane::SecondaryFactory::makeSecondary(ecu_config)); + aktualizr.AddSecondary(std::make_shared(ecu_config)); aktualizr.Initialize(); diff --git a/src/libaktualizr/primary/sotauptaneclient.cc b/src/libaktualizr/primary/sotauptaneclient.cc index 62697eb7df..da9c1127d2 100644 --- a/src/libaktualizr/primary/sotauptaneclient.cc +++ b/src/libaktualizr/primary/sotauptaneclient.cc @@ -13,7 +13,7 @@ #include "package_manager/packagemanagerfactory.h" #include "uptane/exceptions.h" #include "uptane/secondaryconfig.h" -#include "uptane/secondaryfactory.h" +#include "uptane/virtualsecondary.h" #include "utilities/fault_injection.h" #include "utilities/utils.h" @@ -32,8 +32,17 @@ std::shared_ptr SotaUptaneClient::newDefaultClient( std::shared_ptr bootloader_in = std::make_shared(config_in.bootloader, *storage_in); std::shared_ptr report_queue_in = std::make_shared(config_in, http_client_in); - return std::make_shared(config_in, storage_in, http_client_in, bootloader_in, report_queue_in, - events_channel_in); + auto sota_uptane_client = std::make_shared(config_in, storage_in, http_client_in, bootloader_in, + report_queue_in, events_channel_in); + + // This factory method is used just for manual testing of VirtualSecondaries, so calling VirtualSecondary ctor + // directly here is fine for now until the virtual secondary implementation is moved out of libaktualizr + std::vector::const_iterator it; + for (it = config_in.uptane.secondary_configs.begin(); it != config_in.uptane.secondary_configs.end(); ++it) { + sota_uptane_client->addSecondary(std::make_shared(*it)); + } + + return sota_uptane_client; } std::shared_ptr SotaUptaneClient::newTestClient(Config &config_in, @@ -42,8 +51,17 @@ std::shared_ptr SotaUptaneClient::newTestClient(Config &config std::shared_ptr events_channel_in) { std::shared_ptr bootloader_in = std::make_shared(config_in.bootloader, *storage_in); std::shared_ptr report_queue_in = std::make_shared(config_in, http_client_in); - return std::make_shared(config_in, storage_in, http_client_in, bootloader_in, report_queue_in, - events_channel_in); + auto sota_uptane_client = std::make_shared(config_in, storage_in, http_client_in, bootloader_in, + report_queue_in, events_channel_in); + + // This factory method is used just for automated tests, so calling VirtualSecondary ctor directly here is fine + // for now until the virtual secondary implementation is moved out of libaktualizr + std::vector::const_iterator it; + for (it = config_in.uptane.secondary_configs.begin(); it != config_in.uptane.secondary_configs.end(); ++it) { + sota_uptane_client->addSecondary(std::make_shared(*it)); + } + + return sota_uptane_client; } SotaUptaneClient::SotaUptaneClient(Config &config_in, std::shared_ptr storage_in, @@ -66,12 +84,6 @@ SotaUptaneClient::SotaUptaneClient(Config &config_in, std::shared_ptrimageUpdated()) { bootloader->setBootOK(); } - - std::vector::const_iterator it; - for (it = config.uptane.secondary_configs.begin(); it != config.uptane.secondary_configs.end(); ++it) { - auto sec = Uptane::SecondaryFactory::makeSecondary(*it); - addSecondary(sec); - } } SotaUptaneClient::~SotaUptaneClient() { conn.disconnect(); } diff --git a/src/libaktualizr/uptane/CMakeLists.txt b/src/libaktualizr/uptane/CMakeLists.txt index eed82d1ec4..7d6be4c159 100644 --- a/src/libaktualizr/uptane/CMakeLists.txt +++ b/src/libaktualizr/uptane/CMakeLists.txt @@ -6,7 +6,6 @@ set(SOURCES partialverificationsecondary.cc role.cc root.cc - secondaryfactory.cc tuf.cc uptanerepository.cc directorrepository.cc @@ -20,7 +19,6 @@ set(HEADERS managedsecondary.h partialverificationsecondary.h secondaryconfig.h - secondaryfactory.h secondaryinterface.h tuf.h uptanerepository.h diff --git a/src/libaktualizr/uptane/secondaryconfig.h b/src/libaktualizr/uptane/secondaryconfig.h index db88f0103e..39afaef320 100644 --- a/src/libaktualizr/uptane/secondaryconfig.h +++ b/src/libaktualizr/uptane/secondaryconfig.h @@ -16,8 +16,6 @@ enum class SecondaryType { kVirtual, // Virtual secondary (in-process fake implementation). - kLegacy, // Deprecated. Do not use. - kIpUptane, // Custom Uptane protocol over TCP/IP network kVirtualUptane, // Partial UPTANE secondary implemented inside primary diff --git a/src/libaktualizr/uptane/secondaryfactory.cc b/src/libaktualizr/uptane/secondaryfactory.cc deleted file mode 100644 index 229f45c6bf..0000000000 --- a/src/libaktualizr/uptane/secondaryfactory.cc +++ /dev/null @@ -1,32 +0,0 @@ -#include "uptane/secondaryfactory.h" - -#include "logging/logging.h" -#include "uptane/virtualsecondary.h" - -#ifdef ISOTP_SECONDARY_ENABLED -#include "isotpsecondary.h" -#endif - -namespace Uptane { - -std::shared_ptr SecondaryFactory::makeSecondary(const SecondaryConfig& sconfig) { - switch (sconfig.secondary_type) { - case SecondaryType::kVirtual: - return std::make_shared(sconfig); - case SecondaryType::kLegacy: - LOG_ERROR << "Legacy secondary support is deprecated."; - return std::shared_ptr(); // NULL-equivalent - case SecondaryType::kIsoTpUptane: -#ifdef ISOTP_SECONDARY_ENABLED - return std::make_shared(sconfig); -#else - LOG_ERROR << "libaktualizr was built without ISO/TP secondary support."; - return std::shared_ptr(); // NULL-equivalent -#endif - default: - LOG_ERROR << "Unrecognized secondary type: " << static_cast(sconfig.secondary_type); - return std::shared_ptr(); // NULL-equivalent - } -} - -} // namespace Uptane diff --git a/src/libaktualizr/uptane/secondaryfactory.h b/src/libaktualizr/uptane/secondaryfactory.h deleted file mode 100644 index a2f6da67ea..0000000000 --- a/src/libaktualizr/uptane/secondaryfactory.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef UPTANE_SECONDARYFACTORY_H_ -#define UPTANE_SECONDARYFACTORY_H_ - -#include -#include "uptane/secondaryconfig.h" -#include "uptane/secondaryinterface.h" - -namespace Uptane { - -class SecondaryFactory { - public: - static std::shared_ptr makeSecondary(const SecondaryConfig& sconfig); -}; -} // namespace Uptane - -#endif // UPTANE_SECONDARYFACTORY_H_ diff --git a/src/libaktualizr/uptane/uptane_secondary_test.cc b/src/libaktualizr/uptane/uptane_secondary_test.cc index fbc486ecf3..fdabca78da 100644 --- a/src/libaktualizr/uptane/uptane_secondary_test.cc +++ b/src/libaktualizr/uptane/uptane_secondary_test.cc @@ -2,11 +2,11 @@ #include "uptane/partialverificationsecondary.h" #include "uptane/secondaryconfig.h" -#include "uptane/secondaryfactory.h" #include "uptane/secondaryinterface.h" +#include "uptane/virtualsecondary.h" /* Create a virtual secondary for testing. */ -TEST(SecondaryFactory, Virtual) { +TEST(VirtualSecondary, Instantiation) { TemporaryDirectory temp_dir; Uptane::SecondaryConfig sconfig; sconfig.secondary_type = Uptane::SecondaryType::kVirtual; @@ -19,29 +19,11 @@ TEST(SecondaryFactory, Virtual) { sconfig.firmware_path = temp_dir.Path() / "firmware.txt"; sconfig.target_name_path = temp_dir.Path() / "firmware_name.txt"; sconfig.metadata_path = temp_dir.Path() / "metadata"; - std::shared_ptr sec = Uptane::SecondaryFactory::makeSecondary(sconfig); - EXPECT_TRUE(sec); -} - -/* Legacy secondaries are deprecated and no longer supported. */ -TEST(SecondaryFactory, Legacy) { - TemporaryDirectory temp_dir; - Uptane::SecondaryConfig sconfig; - sconfig.secondary_type = Uptane::SecondaryType::kLegacy; - std::shared_ptr sec = Uptane::SecondaryFactory::makeSecondary(sconfig); - EXPECT_FALSE(sec); -} - -/* Invalid secondary types are ignored. */ -TEST(SecondaryFactory, Bad) { - Uptane::SecondaryConfig sconfig; - sconfig.secondary_type = (Uptane::SecondaryType)-1; - std::shared_ptr sec = Uptane::SecondaryFactory::makeSecondary(sconfig); - EXPECT_FALSE(sec); + EXPECT_NO_THROW(Uptane::VirtualSecondary virtual_sec(sconfig)); } /* Partial verification secondaries generate and store public keys. */ -TEST(SecondaryFactory, Uptane_get_key) { +TEST(PartialVerificationSecondary, Uptane_get_key) { TemporaryDirectory temp_dir; Uptane::SecondaryConfig sconfig; sconfig.secondary_type = Uptane::SecondaryType::kVirtualUptane; @@ -63,7 +45,7 @@ TEST(SecondaryFactory, Uptane_get_key) { } /* Partial verification secondaries can verify Uptane metadata. */ -TEST(SecondaryFactory, Uptane_putMetadata_good) { +TEST(PartialVerificationSecondary, Uptane_putMetadata_good) { TemporaryDirectory temp_dir; Uptane::SecondaryConfig sconfig; sconfig.secondary_type = Uptane::SecondaryType::kVirtualUptane; @@ -85,7 +67,7 @@ TEST(SecondaryFactory, Uptane_putMetadata_good) { } /* Partial verification secondaries reject invalid Uptane metadata. */ -TEST(SecondaryFactory, Uptane_putMetadata_bad) { +TEST(PartialVerificationSecondary, Uptane_putMetadata_bad) { TemporaryDirectory temp_dir; Uptane::SecondaryConfig sconfig; sconfig.secondary_type = Uptane::SecondaryType::kVirtualUptane; From fc4d6d07dbfb3fe2076ce0a68d4d2452a2ef9745 Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Tue, 25 Jun 2019 16:11:58 +0300 Subject: [PATCH 2/3] OTA-2488: Initial move of the virtual secondary implementation out of libaktualizr Signed-off-by: Mike Sul --- src/CMakeLists.txt | 1 + src/libaktualizr/CMakeLists.txt | 3 +++ src/libaktualizr/primary/CMakeLists.txt | 7 +++++++ src/libaktualizr/primary/aktualizr_test.cc | 2 +- src/libaktualizr/primary/sotauptaneclient.cc | 2 +- .../{uptane => primary}/uptane_key_test.cc | 2 +- src/libaktualizr/uptane/CMakeLists.txt | 13 ++----------- src/virtual_secondary/CMakeLists.txt | 15 +++++++++++++++ .../managedsecondary.cc | 2 +- .../managedsecondary.h | 0 .../virtual_secondary_test.cc} | 2 +- .../virtualsecondary.cc | 2 +- .../virtualsecondary.h | 2 +- 13 files changed, 35 insertions(+), 18 deletions(-) rename src/libaktualizr/{uptane => primary}/uptane_key_test.cc (99%) create mode 100644 src/virtual_secondary/CMakeLists.txt rename src/{libaktualizr/uptane => virtual_secondary}/managedsecondary.cc (99%) rename src/{libaktualizr/uptane => virtual_secondary}/managedsecondary.h (100%) rename src/{libaktualizr/uptane/uptane_secondary_test.cc => virtual_secondary/virtual_secondary_test.cc} (99%) rename src/{libaktualizr/uptane => virtual_secondary}/virtualsecondary.cc (97%) rename src/{libaktualizr/uptane => virtual_secondary}/virtualsecondary.h (93%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6475310c8..e5da11bace 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,7 @@ if(BUILD_WITH_CODE_COVERAGE) endif() add_subdirectory("libaktualizr") +add_subdirectory("virtual_secondary") add_subdirectory("sota_tools") add_subdirectory("aktualizr_primary") add_subdirectory("libaktualizr-posix") diff --git a/src/libaktualizr/CMakeLists.txt b/src/libaktualizr/CMakeLists.txt index f6163b9383..b9c57fb76b 100644 --- a/src/libaktualizr/CMakeLists.txt +++ b/src/libaktualizr/CMakeLists.txt @@ -41,3 +41,6 @@ endif (BUILD_ISOTP) target_include_directories(aktualizr_static_lib PUBLIC $) + +# To be removed once the refactoring is completed +target_link_libraries(aktualizr_static_lib virtual-secondary) diff --git a/src/libaktualizr/primary/CMakeLists.txt b/src/libaktualizr/primary/CMakeLists.txt index 507277e6b3..b8f1c000aa 100644 --- a/src/libaktualizr/primary/CMakeLists.txt +++ b/src/libaktualizr/primary/CMakeLists.txt @@ -12,9 +12,12 @@ set(HEADERS aktualizr.h add_library(primary OBJECT ${SOURCES}) +target_include_directories(primary PUBLIC ${PROJECT_SOURCE_DIR}/src/virtual_secondary) add_aktualizr_test(NAME aktualizr SOURCES aktualizr_test.cc PROJECT_WORKING_DIRECTORY ARGS ${PROJECT_BINARY_DIR}/uptane_repos) add_dependencies(t_aktualizr uptane_repo_full_no_correlation_id) +target_include_directories(t_aktualizr PUBLIC ${PROJECT_SOURCE_DIR}/src/virtual_secondary) +target_link_libraries(t_aktualizr virtual-secondary) if (BUILD_OSTREE) add_aktualizr_test(NAME aktualizr_fullostree SOURCES aktualizr_fullostree_test.cc PROJECT_WORKING_DIRECTORY ARGS $ ${PROJECT_BINARY_DIR}/ostree_repo) @@ -31,5 +34,9 @@ add_aktualizr_test(NAME emptytargets SOURCES empty_targets_test.cc PROJECT_WORKI add_aktualizr_test(NAME device_cred_prov SOURCES device_cred_prov_test.cc PROJECT_WORKING_DIRECTORY) set_tests_properties(test_device_cred_prov PROPERTIES LABELS "crypto") +add_aktualizr_test(NAME uptane_key SOURCES uptane_key_test.cc PROJECT_WORKING_DIRECTORY) +set_tests_properties(test_uptane_key PROPERTIES LABELS "crypto") +target_include_directories(t_uptane_key PUBLIC ${PROJECT_SOURCE_DIR}/src/virtual_secondary) +target_link_libraries(t_uptane_key virtual-secondary) aktualizr_source_file_checks(${SOURCES} ${HEADERS} ${TEST_SOURCES}) diff --git a/src/libaktualizr/primary/aktualizr_test.cc b/src/libaktualizr/primary/aktualizr_test.cc index 2baf886727..5a2ec0a451 100644 --- a/src/libaktualizr/primary/aktualizr_test.cc +++ b/src/libaktualizr/primary/aktualizr_test.cc @@ -14,9 +14,9 @@ #include "primary/aktualizr.h" #include "primary/events.h" #include "primary/sotauptaneclient.h" -#include "uptane/virtualsecondary.h" #include "uptane_test_common.h" #include "utilities/utils.h" +#include "virtualsecondary.h" #include "utilities/fault_injection.h" diff --git a/src/libaktualizr/primary/sotauptaneclient.cc b/src/libaktualizr/primary/sotauptaneclient.cc index da9c1127d2..231670f946 100644 --- a/src/libaktualizr/primary/sotauptaneclient.cc +++ b/src/libaktualizr/primary/sotauptaneclient.cc @@ -13,9 +13,9 @@ #include "package_manager/packagemanagerfactory.h" #include "uptane/exceptions.h" #include "uptane/secondaryconfig.h" -#include "uptane/virtualsecondary.h" #include "utilities/fault_injection.h" #include "utilities/utils.h" +#include "virtualsecondary.h" static void report_progress_cb(event::Channel *channel, const Uptane::Target &target, const std::string &description, unsigned int progress) { diff --git a/src/libaktualizr/uptane/uptane_key_test.cc b/src/libaktualizr/primary/uptane_key_test.cc similarity index 99% rename from src/libaktualizr/uptane/uptane_key_test.cc rename to src/libaktualizr/primary/uptane_key_test.cc index 440c6a373e..319c91e906 100644 --- a/src/libaktualizr/uptane/uptane_key_test.cc +++ b/src/libaktualizr/primary/uptane_key_test.cc @@ -10,10 +10,10 @@ #include "httpfake.h" #include "logging/logging.h" +#include "managedsecondary.h" #include "primary/reportqueue.h" #include "primary/sotauptaneclient.h" #include "storage/invstorage.h" -#include "uptane/managedsecondary.h" #include "uptane/secondaryconfig.h" #include "uptane/uptanerepository.h" diff --git a/src/libaktualizr/uptane/CMakeLists.txt b/src/libaktualizr/uptane/CMakeLists.txt index 7d6be4c159..15c99548ff 100644 --- a/src/libaktualizr/uptane/CMakeLists.txt +++ b/src/libaktualizr/uptane/CMakeLists.txt @@ -1,7 +1,6 @@ set(SOURCES fetcher.cc iterator.cc - managedsecondary.cc metawithkeys.cc partialverificationsecondary.cc role.cc @@ -9,22 +8,19 @@ set(SOURCES tuf.cc uptanerepository.cc directorrepository.cc - imagesrepository.cc - virtualsecondary.cc) + imagesrepository.cc) set(HEADERS exceptions.h fetcher.h iterator.h - managedsecondary.h partialverificationsecondary.h secondaryconfig.h secondaryinterface.h tuf.h uptanerepository.h directorrepository.h - imagesrepository.h - virtualsecondary.h) + imagesrepository.h) add_library(uptane OBJECT ${SOURCES}) @@ -55,14 +51,9 @@ add_aktualizr_test(NAME uptane_delegation SOURCES uptane_delegation_test.cc PROJ add_dependencies(t_uptane_delegation aktualizr-repo) set_tests_properties(test_uptane_delegation PROPERTIES LABELS "crypto") -add_aktualizr_test(NAME uptane_key SOURCES uptane_key_test.cc PROJECT_WORKING_DIRECTORY) -set_tests_properties(test_uptane_key PROPERTIES LABELS "crypto") - add_aktualizr_test(NAME uptane_network SOURCES uptane_network_test.cc PROJECT_WORKING_DIRECTORY) set_tests_properties(test_uptane_network PROPERTIES LABELS "crypto") -add_aktualizr_test(NAME uptane_secondary SOURCES uptane_secondary_test.cc PROJECT_WORKING_DIRECTORY) - add_aktualizr_test(NAME uptane_serial SOURCES uptane_serial_test.cc ARGS ${PROJECT_BINARY_DIR} PROJECT_WORKING_DIRECTORY) diff --git a/src/virtual_secondary/CMakeLists.txt b/src/virtual_secondary/CMakeLists.txt new file mode 100644 index 0000000000..6d5b5e6c2c --- /dev/null +++ b/src/virtual_secondary/CMakeLists.txt @@ -0,0 +1,15 @@ +set(SOURCES managedsecondary.cc virtualsecondary.cc) + +set(HEADERS managedsecondary.h virtualsecondary.h) + +set(TARGET virtual-secondary) + +add_library(${TARGET} STATIC + ${SOURCES} +) + +# target_link_libraries(${TARGET} aktualizr_static_lib) + +add_aktualizr_test(NAME virtual_secondary SOURCES virtual_secondary_test.cc PROJECT_WORKING_DIRECTORY) + +aktualizr_source_file_checks(${HEADERS} ${SOURCES} ${TEST_SOURCES}) diff --git a/src/libaktualizr/uptane/managedsecondary.cc b/src/virtual_secondary/managedsecondary.cc similarity index 99% rename from src/libaktualizr/uptane/managedsecondary.cc rename to src/virtual_secondary/managedsecondary.cc index 4a8e760070..f253500e09 100644 --- a/src/libaktualizr/uptane/managedsecondary.cc +++ b/src/virtual_secondary/managedsecondary.cc @@ -1,4 +1,4 @@ -#include "uptane/managedsecondary.h" +#include "managedsecondary.h" #include #include diff --git a/src/libaktualizr/uptane/managedsecondary.h b/src/virtual_secondary/managedsecondary.h similarity index 100% rename from src/libaktualizr/uptane/managedsecondary.h rename to src/virtual_secondary/managedsecondary.h diff --git a/src/libaktualizr/uptane/uptane_secondary_test.cc b/src/virtual_secondary/virtual_secondary_test.cc similarity index 99% rename from src/libaktualizr/uptane/uptane_secondary_test.cc rename to src/virtual_secondary/virtual_secondary_test.cc index fdabca78da..4a86842849 100644 --- a/src/libaktualizr/uptane/uptane_secondary_test.cc +++ b/src/virtual_secondary/virtual_secondary_test.cc @@ -3,7 +3,7 @@ #include "uptane/partialverificationsecondary.h" #include "uptane/secondaryconfig.h" #include "uptane/secondaryinterface.h" -#include "uptane/virtualsecondary.h" +#include "virtualsecondary.h" /* Create a virtual secondary for testing. */ TEST(VirtualSecondary, Instantiation) { diff --git a/src/libaktualizr/uptane/virtualsecondary.cc b/src/virtual_secondary/virtualsecondary.cc similarity index 97% rename from src/libaktualizr/uptane/virtualsecondary.cc rename to src/virtual_secondary/virtualsecondary.cc index 8a0f439d6b..36c1452ead 100644 --- a/src/libaktualizr/uptane/virtualsecondary.cc +++ b/src/virtual_secondary/virtualsecondary.cc @@ -1,4 +1,4 @@ -#include "uptane/virtualsecondary.h" +#include "virtualsecondary.h" #include #include diff --git a/src/libaktualizr/uptane/virtualsecondary.h b/src/virtual_secondary/virtualsecondary.h similarity index 93% rename from src/libaktualizr/uptane/virtualsecondary.h rename to src/virtual_secondary/virtualsecondary.h index 7e8166a7e1..296ae2cfa3 100644 --- a/src/libaktualizr/uptane/virtualsecondary.h +++ b/src/virtual_secondary/virtualsecondary.h @@ -3,7 +3,7 @@ #include -#include "uptane/managedsecondary.h" +#include "managedsecondary.h" #include "utilities/types.h" namespace Uptane { From 0c8a129d6ea3c9e7d6e3d69ae91dc2c9d3ce28c8 Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Tue, 25 Jun 2019 17:37:01 +0300 Subject: [PATCH 3/3] OTA-2488: decouple the secondary base & pure virtual ifc from secondary configuration Signed-off-by: Mike Sul --- .../aktualizr_secondary.cc | 6 ++-- src/aktualizr_secondary/update_test.cc | 6 ++-- src/libaktualizr-posix/ipuptanesecondary.h | 3 -- src/libaktualizr/CMakeLists.txt | 2 +- src/libaktualizr/primary/CMakeLists.txt | 5 ++-- src/libaktualizr/primary/initializer.cc | 4 --- src/libaktualizr/primary/uptane_key_test.cc | 1 - src/libaktualizr/uptane/isotpsecondary.cc | 2 +- src/libaktualizr/uptane/isotpsecondary.h | 1 + .../uptane/partialverificationsecondary.cc | 4 +-- .../uptane/partialverificationsecondary.h | 4 ++- src/libaktualizr/uptane/secondaryinterface.h | 17 ++++++----- src/libaktualizr/uptane/uptane_ci_test.cc | 28 +++++++++-------- src/libaktualizr/uptane/uptane_test.cc | 30 +++++++++++++------ src/virtual_secondary/CMakeLists.txt | 5 ++-- src/virtual_secondary/managedsecondary.cc | 3 +- src/virtual_secondary/managedsecondary.h | 8 +++-- 17 files changed, 69 insertions(+), 60 deletions(-) diff --git a/src/aktualizr_secondary/aktualizr_secondary.cc b/src/aktualizr_secondary/aktualizr_secondary.cc index 8600a40f3d..cdf78a2278 100644 --- a/src/aktualizr_secondary/aktualizr_secondary.cc +++ b/src/aktualizr_secondary/aktualizr_secondary.cc @@ -13,8 +13,7 @@ class SecondaryAdapter : public Uptane::SecondaryInterface { public: - SecondaryAdapter(const Uptane::SecondaryConfig& sconfig_in, AktualizrSecondary& sec) - : SecondaryInterface(sconfig_in), secondary(sec) {} + SecondaryAdapter(AktualizrSecondary& sec) : secondary(sec) {} ~SecondaryAdapter() override = default; Uptane::EcuSerial getSerial() override { return secondary.getSerialResp(); } @@ -35,8 +34,7 @@ class SecondaryAdapter : public Uptane::SecondaryInterface { AktualizrSecondary::AktualizrSecondary(const AktualizrSecondaryConfig& config, const std::shared_ptr& storage) : AktualizrSecondaryCommon(config, storage), - socket_server_(std_::make_unique(Uptane::SecondaryConfig(), *this), - SocketFromSystemdOrPort(config.network.port)) { + socket_server_(std_::make_unique(*this), SocketFromSystemdOrPort(config.network.port)) { // note: we don't use TlsConfig here and supply the default to // KeyManagerConf. Maybe we should figure a cleaner way to do that // (split KeyManager?) diff --git a/src/aktualizr_secondary/update_test.cc b/src/aktualizr_secondary/update_test.cc index 697d5d2370..56b63b9b9e 100644 --- a/src/aktualizr_secondary/update_test.cc +++ b/src/aktualizr_secondary/update_test.cc @@ -13,8 +13,7 @@ std::string sysroot; class ShortCircuitSecondary : public Uptane::SecondaryInterface { public: - ShortCircuitSecondary(const Uptane::SecondaryConfig& sconfig_in, AktualizrSecondary& sec) - : SecondaryInterface(sconfig_in), secondary(sec) {} + ShortCircuitSecondary(AktualizrSecondary& sec) : secondary(sec) {} ~ShortCircuitSecondary() override = default; Uptane::EcuSerial getSerial() override { return secondary.getSerialResp(); } @@ -42,8 +41,7 @@ TEST(aktualizr_secondary_protocol, DISABLED_manual_update) { AktualizrSecondary as(config, storage); // secondary interface - Uptane::SecondaryConfig config_iface; - ShortCircuitSecondary sec_iface{config_iface, as}; + ShortCircuitSecondary sec_iface{as}; // storage TemporaryDirectory temp_dir; diff --git a/src/libaktualizr-posix/ipuptanesecondary.h b/src/libaktualizr-posix/ipuptanesecondary.h index 2f1b30bd99..68e423d0cb 100644 --- a/src/libaktualizr-posix/ipuptanesecondary.h +++ b/src/libaktualizr-posix/ipuptanesecondary.h @@ -19,9 +19,6 @@ class IpUptaneSecondary : public SecondaryInterface { explicit IpUptaneSecondary(const std::string& address, unsigned short port, EcuSerial serial, HardwareIdentifier hw_id, PublicKey pub_key); - // what this method for ? Looks like should be removed out of SecondaryInterface - void Initialize() override{}; - // It looks more natural to return const EcuSerial& and const Uptane::HardwareIdentifier& // and they should be 'const' methods EcuSerial getSerial() /*const*/ override { return serial_; }; diff --git a/src/libaktualizr/CMakeLists.txt b/src/libaktualizr/CMakeLists.txt index b9c57fb76b..95d7cb4c74 100644 --- a/src/libaktualizr/CMakeLists.txt +++ b/src/libaktualizr/CMakeLists.txt @@ -43,4 +43,4 @@ target_include_directories(aktualizr_static_lib PUBLIC $) # To be removed once the refactoring is completed -target_link_libraries(aktualizr_static_lib virtual-secondary) +target_link_libraries(aktualizr_static_lib virtual_secondary) diff --git a/src/libaktualizr/primary/CMakeLists.txt b/src/libaktualizr/primary/CMakeLists.txt index b8f1c000aa..6d00e0d53e 100644 --- a/src/libaktualizr/primary/CMakeLists.txt +++ b/src/libaktualizr/primary/CMakeLists.txt @@ -16,8 +16,7 @@ target_include_directories(primary PUBLIC ${PROJECT_SOURCE_DIR}/src/virtual_seco add_aktualizr_test(NAME aktualizr SOURCES aktualizr_test.cc PROJECT_WORKING_DIRECTORY ARGS ${PROJECT_BINARY_DIR}/uptane_repos) add_dependencies(t_aktualizr uptane_repo_full_no_correlation_id) -target_include_directories(t_aktualizr PUBLIC ${PROJECT_SOURCE_DIR}/src/virtual_secondary) -target_link_libraries(t_aktualizr virtual-secondary) +target_link_libraries(t_aktualizr virtual_secondary) if (BUILD_OSTREE) add_aktualizr_test(NAME aktualizr_fullostree SOURCES aktualizr_fullostree_test.cc PROJECT_WORKING_DIRECTORY ARGS $ ${PROJECT_BINARY_DIR}/ostree_repo) @@ -37,6 +36,6 @@ set_tests_properties(test_device_cred_prov PROPERTIES LABELS "crypto") add_aktualizr_test(NAME uptane_key SOURCES uptane_key_test.cc PROJECT_WORKING_DIRECTORY) set_tests_properties(test_uptane_key PROPERTIES LABELS "crypto") target_include_directories(t_uptane_key PUBLIC ${PROJECT_SOURCE_DIR}/src/virtual_secondary) -target_link_libraries(t_uptane_key virtual-secondary) +target_link_libraries(t_uptane_key virtual_secondary) aktualizr_source_file_checks(${SOURCES} ${HEADERS} ${TEST_SOURCES}) diff --git a/src/libaktualizr/primary/initializer.cc b/src/libaktualizr/primary/initializer.cc index 0a16ffddfd..8cf4c81594 100644 --- a/src/libaktualizr/primary/initializer.cc +++ b/src/libaktualizr/primary/initializer.cc @@ -252,10 +252,6 @@ Initializer::Initializer( return; } - for (auto it = secondary_info_.begin(); it != secondary_info_.end(); ++it) { - it->second->Initialize(); - } - // TODO: acknowledge on server _before_ setting the flag storage_->storeEcuRegistered(); success_ = true; diff --git a/src/libaktualizr/primary/uptane_key_test.cc b/src/libaktualizr/primary/uptane_key_test.cc index 319c91e906..92c271930a 100644 --- a/src/libaktualizr/primary/uptane_key_test.cc +++ b/src/libaktualizr/primary/uptane_key_test.cc @@ -87,7 +87,6 @@ class UptaneKey_Check_Test { // Verify that each secondary has valid keys. std::map >::iterator it; for (it = sota_client->secondaries.begin(); it != sota_client->secondaries.end(); it++) { - EXPECT_TRUE(it->second->sconfig.secondary_type == Uptane::SecondaryType::kVirtual); std::shared_ptr managed = boost::polymorphic_pointer_downcast(it->second); std::string public_key; diff --git a/src/libaktualizr/uptane/isotpsecondary.cc b/src/libaktualizr/uptane/isotpsecondary.cc index bee0f0857a..ffc259c100 100644 --- a/src/libaktualizr/uptane/isotpsecondary.cc +++ b/src/libaktualizr/uptane/isotpsecondary.cc @@ -33,7 +33,7 @@ enum class IsoTpUptaneMesType { namespace Uptane { IsoTpSecondary::IsoTpSecondary(const SecondaryConfig& sconfig_in) - : SecondaryInterface(sconfig_in), conn(sconfig.can_iface, LIBUPTINY_ISOTP_PRIMARY_CANID, sconfig_in.can_id) {} + : conn(sconfig_in.can_iface, LIBUPTINY_ISOTP_PRIMARY_CANID, sconfig_in.can_id) {} EcuSerial IsoTpSecondary::getSerial() { std::string out; diff --git a/src/libaktualizr/uptane/isotpsecondary.h b/src/libaktualizr/uptane/isotpsecondary.h index 119c03e155..cb85100a11 100644 --- a/src/libaktualizr/uptane/isotpsecondary.h +++ b/src/libaktualizr/uptane/isotpsecondary.h @@ -2,6 +2,7 @@ #define UPTANE_ISOTPSECONDARY_H_ #include "isotp_conn/isotp_conn.h" +#include "secondaryconfig.h" #include "secondaryinterface.h" namespace Uptane { diff --git a/src/libaktualizr/uptane/partialverificationsecondary.cc b/src/libaktualizr/uptane/partialverificationsecondary.cc index d92966ebb9..1a739e0e9c 100644 --- a/src/libaktualizr/uptane/partialverificationsecondary.cc +++ b/src/libaktualizr/uptane/partialverificationsecondary.cc @@ -14,8 +14,8 @@ namespace Uptane { -PartialVerificationSecondary::PartialVerificationSecondary(const SecondaryConfig &sconfig_in) - : SecondaryInterface(sconfig_in), root_(Root::Policy::kAcceptAll) { +PartialVerificationSecondary::PartialVerificationSecondary(SecondaryConfig sconfig_in) + : sconfig(std::move(sconfig_in)), root_(Root::Policy::kAcceptAll) { boost::filesystem::create_directories(sconfig.metadata_path); // FIXME Probably we need to generate keys on the secondary diff --git a/src/libaktualizr/uptane/partialverificationsecondary.h b/src/libaktualizr/uptane/partialverificationsecondary.h index ba6e2b5b5b..51012d8deb 100644 --- a/src/libaktualizr/uptane/partialverificationsecondary.h +++ b/src/libaktualizr/uptane/partialverificationsecondary.h @@ -15,7 +15,7 @@ namespace Uptane { class PartialVerificationSecondary : public SecondaryInterface { public: - explicit PartialVerificationSecondary(const SecondaryConfig& sconfig_in); + explicit PartialVerificationSecondary(SecondaryConfig sconfig_in); EcuSerial getSerial() override { if (!sconfig.ecu_serial.empty()) { @@ -23,6 +23,7 @@ class PartialVerificationSecondary : public SecondaryInterface { } return Uptane::EcuSerial(public_key_.KeyId()); } + Uptane::HardwareIdentifier getHwId() override { return Uptane::HardwareIdentifier(sconfig.ecu_hardware_id); } PublicKey getPublicKey() override { return public_key_; } bool putMetadata(const RawMetaPack& meta) override; @@ -36,6 +37,7 @@ class PartialVerificationSecondary : public SecondaryInterface { void storeKeys(const std::string& public_key, const std::string& private_key); bool loadKeys(std::string* public_key, std::string* private_key); + SecondaryConfig sconfig; Uptane::Root root_; PublicKey public_key_; std::string private_key_; diff --git a/src/libaktualizr/uptane/secondaryinterface.h b/src/libaktualizr/uptane/secondaryinterface.h index d87a713658..296eabf1f8 100644 --- a/src/libaktualizr/uptane/secondaryinterface.h +++ b/src/libaktualizr/uptane/secondaryinterface.h @@ -6,7 +6,6 @@ #include "json/json.h" -#include "uptane/secondaryconfig.h" #include "uptane/tuf.h" /* Json snippet returned by sendMetaXXX(): @@ -22,14 +21,16 @@ class SecondaryInterface { public: // This ctor should be removed as the secondary configuration SecondaryConfig // is the secondaries's specific, see SecondaryConfig declaration - explicit SecondaryInterface(SecondaryConfig sconfig_in) : sconfig(std::move(sconfig_in)) {} + // explicit SecondaryInterface(SecondaryConfig sconfig_in) : sconfig(std::move(sconfig_in)) {} virtual ~SecondaryInterface() = default; // not clear what this method for, can be removed - virtual void Initialize(){}; // optional step, called after device registration + // virtual void Initialize(){}; // optional step, called after device registration // should be pure virtual, since the current implementation reads from the secondaries specific config - virtual EcuSerial getSerial() { return Uptane::EcuSerial(sconfig.ecu_serial); } + // virtual EcuSerial getSerial() { return Uptane::EcuSerial(sconfig.ecu_serial); } + virtual EcuSerial getSerial() = 0; // should be pure virtual, since the current implementation reads from the secondaries specific config - virtual Uptane::HardwareIdentifier getHwId() { return Uptane::HardwareIdentifier(sconfig.ecu_hardware_id); } + // virtual Uptane::HardwareIdentifier getHwId() { return Uptane::HardwareIdentifier(sconfig.ecu_hardware_id); } + virtual Uptane::HardwareIdentifier getHwId() = 0; virtual PublicKey getPublicKey() = 0; // getSerial(), getHwId() and getPublicKey() can be moved to seperate interface @@ -42,10 +43,10 @@ class SecondaryInterface { // FIXME: Instead of std::string we should use StorageTargetRHandle virtual bool sendFirmware(const std::shared_ptr& data) = 0; // Should be removes as it's secondary specific - const SecondaryConfig sconfig; + // const SecondaryConfig sconfig; - protected: - SecondaryInterface() : sconfig{} {}; + // protected: + // SecondaryInterface() : sconfig{} {}; }; } // namespace Uptane diff --git a/src/libaktualizr/uptane/uptane_ci_test.cc b/src/libaktualizr/uptane/uptane_ci_test.cc index d169b4df5a..d21544e2ee 100644 --- a/src/libaktualizr/uptane/uptane_ci_test.cc +++ b/src/libaktualizr/uptane/uptane_ci_test.cc @@ -15,7 +15,7 @@ #include "primary/reportqueue.h" #include "primary/sotauptaneclient.h" #include "storage/invstorage.h" -#include "uptane/managedsecondary.h" +//#include "managedsecondary.h" #include "uptane/uptanerepository.h" #include "utilities/utils.h" @@ -86,18 +86,20 @@ TEST(UptaneCI, CheckKeys) { EXPECT_TRUE(primary_public.size() > 0); EXPECT_TRUE(primary_private.size() > 0); - std::map >::iterator it; - for (it = sota_client->secondaries.begin(); it != sota_client->secondaries.end(); it++) { - EXPECT_EQ(it->second->sconfig.secondary_type, Uptane::SecondaryType::kVirtual); - std::shared_ptr managed = - boost::polymorphic_pointer_downcast(it->second); - std::string public_key; - std::string private_key; - EXPECT_TRUE(managed->loadKeys(&public_key, &private_key)); - EXPECT_TRUE(public_key.size() > 0); - EXPECT_TRUE(private_key.size() > 0); - EXPECT_NE(public_key, private_key); - } + // TODO: either remove or move to the virtual secondary folder as it's effectively test of + // the test code (managed secondary is used just for test) + // std::map >::iterator it; + // for (it = sota_client->secondaries.begin(); it != sota_client->secondaries.end(); it++) { + // EXPECT_EQ(it->second->sconfig.secondary_type, Uptane::SecondaryType::kVirtual); + // std::shared_ptr managed = + // boost::polymorphic_pointer_downcast(it->second); + // std::string public_key; + // std::string private_key; + // EXPECT_TRUE(managed->loadKeys(&public_key, &private_key)); + // EXPECT_TRUE(public_key.size() > 0); + // EXPECT_TRUE(private_key.size() > 0); + // EXPECT_NE(public_key, private_key); + // } } #ifndef __NO_MAIN__ diff --git a/src/libaktualizr/uptane/uptane_test.cc b/src/libaktualizr/uptane/uptane_test.cc index ecf4bd5789..a73615b253 100644 --- a/src/libaktualizr/uptane/uptane_test.cc +++ b/src/libaktualizr/uptane/uptane_test.cc @@ -390,8 +390,7 @@ class HttpFakeEvents : public HttpFake { class SecondaryInterfaceMock : public Uptane::SecondaryInterface { public: - explicit SecondaryInterfaceMock(Uptane::SecondaryConfig sconfig_in) - : Uptane::SecondaryInterface(std::move(sconfig_in)) { + explicit SecondaryInterfaceMock(Uptane::SecondaryConfig sconfig_in) : sconfig(std::move(sconfig_in)) { std::string private_key, public_key; Crypto::generateKeyPair(sconfig.key_type, &public_key, &private_key); public_key_ = PublicKey(public_key, sconfig.key_type); @@ -407,15 +406,28 @@ class SecondaryInterfaceMock : public Uptane::SecondaryInterface { manifest_["signed"] = manifest_unsigned; manifest_["signatures"].append(signature); } - PublicKey getPublicKey() { return public_key_; }; + PublicKey getPublicKey() override { return public_key_; } - Json::Value getManifest() { return manifest_; } - MOCK_METHOD1(putMetadata, bool(const Uptane::RawMetaPack &)); - MOCK_METHOD1(getRootVersion, int32_t(bool)); - bool putRoot(const std::string &, bool) { return true; } - bool sendFirmware(const std::shared_ptr &) { return true; } + Uptane::HardwareIdentifier getHwId() override { return Uptane::HardwareIdentifier(sconfig.ecu_hardware_id); } + Uptane::EcuSerial getSerial() override { + if (!sconfig.ecu_serial.empty()) { + return Uptane::EcuSerial(sconfig.ecu_serial); + } + return Uptane::EcuSerial(public_key_.KeyId()); + } + Json::Value getManifest() override { return manifest_; } + MOCK_METHOD1(putMetadataMock, bool(const Uptane::RawMetaPack &)); + MOCK_METHOD1(getRootVersionMock, int32_t(bool)); + + bool putMetadata(const Uptane::RawMetaPack &meta_pack) override { return putMetadataMock(meta_pack); } + int32_t getRootVersion(bool director) override { return getRootVersionMock(director); } + + bool putRoot(const std::string &, bool) override { return true; } + bool sendFirmware(const std::shared_ptr &) override { return true; } PublicKey public_key_; Json::Value manifest_; + + const Uptane::SecondaryConfig sconfig; }; MATCHER_P(matchMeta, meta, "") { @@ -470,7 +482,7 @@ TEST(Uptane, SendMetadataToSeconadry) { storage->loadNonRoot(&meta.image_snapshot, Uptane::RepositoryType::Image(), Uptane::Role::Snapshot()); storage->loadNonRoot(&meta.image_targets, Uptane::RepositoryType::Image(), Uptane::Role::Targets()); - EXPECT_CALL(*sec, putMetadata(matchMeta(meta))); + EXPECT_CALL(*sec, putMetadataMock(matchMeta(meta))); up->uptaneInstall(packages_to_install); EXPECT_TRUE(EcuInstallationStartedReportGot); } diff --git a/src/virtual_secondary/CMakeLists.txt b/src/virtual_secondary/CMakeLists.txt index 6d5b5e6c2c..101bd97e17 100644 --- a/src/virtual_secondary/CMakeLists.txt +++ b/src/virtual_secondary/CMakeLists.txt @@ -2,14 +2,13 @@ set(SOURCES managedsecondary.cc virtualsecondary.cc) set(HEADERS managedsecondary.h virtualsecondary.h) -set(TARGET virtual-secondary) +set(TARGET virtual_secondary) add_library(${TARGET} STATIC ${SOURCES} ) -# target_link_libraries(${TARGET} aktualizr_static_lib) - +target_include_directories(${TARGET} PUBLIC ${PROJECT_SOURCE_DIR}/src/virtual_secondary) add_aktualizr_test(NAME virtual_secondary SOURCES virtual_secondary_test.cc PROJECT_WORKING_DIRECTORY) aktualizr_source_file_checks(${HEADERS} ${SOURCES} ${TEST_SOURCES}) diff --git a/src/virtual_secondary/managedsecondary.cc b/src/virtual_secondary/managedsecondary.cc index f253500e09..ffdd7a6b00 100644 --- a/src/virtual_secondary/managedsecondary.cc +++ b/src/virtual_secondary/managedsecondary.cc @@ -13,7 +13,7 @@ #include namespace Uptane { -ManagedSecondary::ManagedSecondary(const SecondaryConfig &sconfig_in) : SecondaryInterface(sconfig_in) { +ManagedSecondary::ManagedSecondary(SecondaryConfig sconfig_in) : sconfig(std::move(sconfig_in)) { // TODO: FIX // loadMetadata(meta_pack); std::string public_key_string; @@ -28,6 +28,7 @@ ManagedSecondary::ManagedSecondary(const SecondaryConfig &sconfig_in) : Secondar // do not store keys yet, wait until SotaUptaneClient performed device initialization } public_key_ = PublicKey(public_key_string, sconfig.key_type); + Initialize(); } void ManagedSecondary::Initialize() { diff --git a/src/virtual_secondary/managedsecondary.h b/src/virtual_secondary/managedsecondary.h index 6869694341..cfb45dd93d 100644 --- a/src/virtual_secondary/managedsecondary.h +++ b/src/virtual_secondary/managedsecondary.h @@ -20,10 +20,10 @@ namespace Uptane { class ManagedSecondary : public SecondaryInterface { public: - explicit ManagedSecondary(const SecondaryConfig& sconfig_in); + explicit ManagedSecondary(SecondaryConfig sconfig_in); ~ManagedSecondary() override = default; - void Initialize() override; + void Initialize(); EcuSerial getSerial() override { if (!sconfig.ecu_serial.empty()) { @@ -31,6 +31,7 @@ class ManagedSecondary : public SecondaryInterface { } return EcuSerial(public_key_.KeyId()); } + Uptane::HardwareIdentifier getHwId() override { return Uptane::HardwareIdentifier(sconfig.ecu_hardware_id); } PublicKey getPublicKey() override { return public_key_; } bool putMetadata(const RawMetaPack& meta_pack) override; int getRootVersion(bool director) override; @@ -41,6 +42,9 @@ class ManagedSecondary : public SecondaryInterface { bool loadKeys(std::string* pub_key, std::string* priv_key); + protected: + SecondaryConfig sconfig; + private: PublicKey public_key_; std::string private_key;