Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
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  bool 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  bool targetsExpired() const;
25  bool checkMetaOffline(INvStorage& storage);
26  void dropTargets(INvStorage& storage);
27 
28  Exception getLastException() const { return last_exception; }
29  bool updateMeta(INvStorage& storage, const IMetadataFetcher& fetcher) override;
30  bool matchTargetsWithImageTargets(const Uptane::Targets& image_targets) const;
31 
32  private:
33  void resetMeta();
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  Exception last_exception{"", ""};
44 };
45 
46 } // namespace Uptane
47 
48 #endif // DIRECTOR_REPOSITORY_H
Uptane::DirectorRepository
Definition: directorrepository.h:13
Uptane::RepositoryCommon
Definition: uptanerepository.h:10
Uptane::HardwareIdentifier
Definition: tuf.h:143
Uptane::IMetadataFetcher
Definition: fetcher.h:16
Uptane::EcuSerial
Definition: tuf.h:174
Uptane::Targets
Definition: tuf.h:437
Uptane::Exception
Definition: exceptions.h:10
Uptane
Base data types that are used in The Update Framework (TUF), part of UPTANE.
Definition: secondary_tcp_server.h:8
INvStorage
Definition: invstorage.h:109