File size: 2,275 Bytes
2492322 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | // Copyright (c) 2023, QuantStack and Mamba Contributors
//
// Distributed under the terms of the BSD 3-Clause License.
//
// The full license is in the file LICENSE, distributed with this software.
#ifndef MAMBA_VALIDATION_UPDATE_FRAMEWORK_V1_HPP
#define MAMBA_VALIDATION_UPDATE_FRAMEWORK_V1_HPP
#include <set>
#include <string>
#include <nlohmann/json_fwd.hpp>
#include "mamba/validation/keys.hpp"
#include "mamba/validation/update_framework.hpp"
namespace mamba::fs
{
class u8path;
}
namespace mamba::validation::v1
{
/**
* TUF v1 specific implementation.
*/
class SpecImpl final : public SpecBase
{
public:
SpecImpl(std::string sv = "1.0.17");
[[nodiscard]] auto json_key() const -> std::string override;
[[nodiscard]] auto expiration_json_key() const -> std::string override;
[[nodiscard]] auto signatures(const nlohmann::json& j) const
-> std::set<RoleSignature> override;
};
/**
* The Update Frameworkd 'root' role implementation.
*
* TUF v1.0.17 §2.1.1
* https://theupdateframework.github.io/specification/latest/#root
*/
class RootImpl final : public RootRole
{
public:
RootImpl(const fs::u8path& p);
RootImpl(const nlohmann::json& j);
[[nodiscard]] auto self_keys() const -> RoleFullKeys override;
auto build_index_checker(
const Context& context,
const TimeRef& time_reference,
const std::string& url,
const fs::u8path& cache_path
) const -> std::unique_ptr<RepoIndexChecker> override;
friend void to_json(nlohmann::json& j, const RootImpl& r);
friend void from_json(const nlohmann::json& j, RootImpl& r);
private:
void load_from_json(const nlohmann::json& j);
auto create_update(const nlohmann::json& j) -> std::unique_ptr<RootRole> override;
[[nodiscard]] auto mandatory_defined_roles() const -> std::set<std::string> override;
[[nodiscard]] auto optionally_defined_roles() const -> std::set<std::string> override;
void set_defined_roles(
const std::map<std::string, Key>& keys,
const std::map<std::string, RoleKeys>& roles
);
};
}
#endif
|