Aktualizr
C++ SOTA Client
directorrepository.h
1 #ifndef DIRECTOR_REPOSITORY_H_
2 #define DIRECTOR_REPOSITORY_H_
3 
4 #include "gtest/gtest_prod.h"
5 
6 #include "uptanerepository.h"
7 
8 namespace Uptane {
9 
10 /* Director repository encapsulates state of metadata verification process. Subsequent verificaton steps rely on
11  * previous ones.
12  */
14  public:
15  DirectorRepository() : RepositoryCommon(RepositoryType::Director()) {}
16 
17  void verifyTargets(const std::string& targets_raw);
18  const Targets& getTargets() const { return targets; }
19  std::vector<Uptane::Target> getTargets(const Uptane::EcuSerial& ecu_id,
20  const Uptane::HardwareIdentifier& hw_id) const {
21  return targets.getTargets(ecu_id, hw_id);
22  }
23  const std::string& getCorrelationId() const { return targets.correlation_id(); }
24  void checkMetaOffline(INvStorage& storage);
25  void dropTargets(INvStorage& storage);
26 
27  void updateMeta(INvStorage& storage, const IMetadataFetcher& fetcher) override;
28  bool matchTargetsWithImageTargets(const Uptane::Targets& image_targets) const;
29 
30  private:
31  void resetMeta();
32  void checkTargetsExpired();
33  void targetsSanityCheck();
34  bool usePreviousTargets() const;
35 
36  private:
37  FRIEND_TEST(Director, EmptyTargets);
38  // Since the Director can send us an empty targets list to mean "no new
39  // updates", we have to persist the previous targets list. Use the latest for
40  // checking expiration but the most recent non-empty list for everything else.
41  Uptane::Targets targets; // Only empty if we've never received non-empty targets.
42  Uptane::Targets latest_targets; // Can be an empty list.
43 };
44 
45 } // namespace Uptane
46 
47 #endif // DIRECTOR_REPOSITORY_H
Uptane::DirectorRepository
Definition: directorrepository.h:13
Uptane::RepositoryCommon
Definition: uptanerepository.h:10
Uptane::HardwareIdentifier
Definition: types.h:315
Uptane::IMetadataFetcher
Definition: fetcher.h:16
Uptane::EcuSerial
Definition: types.h:346
Uptane::Targets
Definition: tuf.h:271
Uptane
Base data types that are used in The Update Framework (TUF), part of Uptane.
Definition: packagemanagerinterface.h:18
INvStorage
Definition: invstorage.h:43