4 #include "libaktualizr/secondaryinterface.h"
6 #include "crypto/keymanager.h"
7 #include "http/httpinterface.h"
8 #include "libaktualizr/config.h"
9 #include "storage/invstorage.h"
10 #include "uptane/tuf.h"
12 const int MaxInitializationAttempts = 3;
17 std::shared_ptr<HttpInterface> http_client_in,
KeyManager& keys_in,
18 const std::map<
Uptane::EcuSerial, std::shared_ptr<SecondaryInterface> >& secondaries_in);
20 class Error :
public std::runtime_error {
22 Error(
const std::string& what) : std::runtime_error(std::string(
"Initializer error: ") + what) {}
26 KeyGenerationError(
const std::string& what) :
Error(std::string(
"Could not generate Uptane key pair: ") + what) {}
30 StorageError(
const std::string& what) :
Error(std::string(
"Storage error: ") + what) {}
34 ServerError(
const std::string& what) :
Error(std::string(
"Server error: ") + what) {}
44 void initEcuSerials();
45 void initPrimaryEcuKeys();
48 void initSecondaryInfo();
49 void initEcuRegister();
50 bool loadSetTlsCreds();
51 void initEcuReportCounter();
54 std::shared_ptr<INvStorage> storage_;
55 std::shared_ptr<HttpInterface> http_client_;
57 const std::map<Uptane::EcuSerial, SecondaryInterface::Ptr>& secondaries_;
58 std::vector<SecondaryInfo> sec_info_;
59 EcuSerials new_ecu_serials_;
60 bool register_ecus_{
false};
65 explicit EcuCompare(std::pair<Uptane::EcuSerial, Uptane::HardwareIdentifier> ecu_in)
66 : serial(std::move(ecu_in.first)), hardware_id(std::move(ecu_in.second)) {}
67 bool operator()(
const std::pair<Uptane::EcuSerial, Uptane::HardwareIdentifier>& in)
const {
68 return (in.first == serial && in.second == hardware_id);
76 #endif // INITIALIZER_H_