summaryrefslogtreecommitdiff
path: root/src/buildtool/auth/authentication.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-06-27 16:05:05 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-04 16:05:08 +0200
commit0cbc8e226b39ec731373b80024e23cc0580c27ac (patch)
treefa6737a19491b8e062704f728243689429d4069c /src/buildtool/auth/authentication.hpp
parent74f53b444853850144c3e63593f83c424e84a768 (diff)
downloadjustbuild-0cbc8e226b39ec731373b80024e23cc0580c27ac.tar.gz
Use Auth and TLS configurations via Instance()
...to more easily keep track of changes during refactoring.
Diffstat (limited to 'src/buildtool/auth/authentication.hpp')
-rw-r--r--src/buildtool/auth/authentication.hpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/buildtool/auth/authentication.hpp b/src/buildtool/auth/authentication.hpp
index a7e66c05..ae45561a 100644
--- a/src/buildtool/auth/authentication.hpp
+++ b/src/buildtool/auth/authentication.hpp
@@ -34,9 +34,9 @@ class Auth {
return instance;
}
- static void SetAuthMethod(AuthMethod x) { Instance().auth_ = x; }
- [[nodiscard]] static auto GetAuthMethod() noexcept -> AuthMethod {
- return Instance().auth_;
+ void SetAuthMethod(AuthMethod x) { auth_ = x; }
+ [[nodiscard]] auto GetAuthMethod() const noexcept -> AuthMethod {
+ return auth_;
}
class TLS {
@@ -46,54 +46,54 @@ class Auth {
return instance;
}
- [[nodiscard]] static auto CACert() noexcept -> const std::string& {
- return Instance().ca_cert_;
+ [[nodiscard]] auto CACert() const noexcept -> const std::string& {
+ return ca_cert_;
}
- [[nodiscard]] static auto ClientCert() noexcept -> const std::string& {
- return Instance().client_cert_;
+ [[nodiscard]] auto ClientCert() const noexcept -> const std::string& {
+ return client_cert_;
}
- [[nodiscard]] static auto ClientKey() noexcept -> const std::string& {
- return Instance().client_key_;
+ [[nodiscard]] auto ClientKey() const noexcept -> const std::string& {
+ return client_key_;
}
- [[nodiscard]] static auto ServerCert() noexcept -> const std::string& {
- return Instance().server_cert_;
+ [[nodiscard]] auto ServerCert() const noexcept -> const std::string& {
+ return server_cert_;
}
- [[nodiscard]] static auto ServerKey() noexcept -> const std::string& {
- return Instance().server_key_;
+ [[nodiscard]] auto ServerKey() const noexcept -> const std::string& {
+ return server_key_;
}
- [[nodiscard]] static auto SetCACertificate(
+ [[nodiscard]] auto SetCACertificate(
std::filesystem::path const& cert_file) noexcept -> bool {
- return set(cert_file, &Instance().ca_cert_);
+ return set(cert_file, &ca_cert_);
}
- [[nodiscard]] static auto SetClientCertificate(
+ [[nodiscard]] auto SetClientCertificate(
std::filesystem::path const& cert_file) noexcept -> bool {
- return set(cert_file, &Instance().client_cert_);
+ return set(cert_file, &client_cert_);
}
- [[nodiscard]] static auto SetClientKey(
+ [[nodiscard]] auto SetClientKey(
std::filesystem::path const& key_file) noexcept -> bool {
- return set(key_file, &Instance().client_key_);
+ return set(key_file, &client_key_);
}
- [[nodiscard]] static auto SetServerCertificate(
+ [[nodiscard]] auto SetServerCertificate(
std::filesystem::path const& cert_file) noexcept -> bool {
- return set(cert_file, &Instance().server_cert_);
+ return set(cert_file, &server_cert_);
}
- [[nodiscard]] static auto SetServerKey(
+ [[nodiscard]] auto SetServerKey(
std::filesystem::path const& key_file) noexcept -> bool {
- return set(key_file, &Instance().server_key_);
+ return set(key_file, &server_key_);
}
// must be called after the parsing of cmd line arguments
// we ensure that either both tls_client_cert or tls_client_key are set
// or none of the two.
- [[nodiscard]] static auto Validate() noexcept -> bool {
+ [[nodiscard]] auto Validate() const noexcept -> bool {
if (CACert().empty()) {
Logger::Log(LogLevel::Error, "Please provide tls-ca-cert");
return false;
@@ -137,7 +137,7 @@ class Auth {
[[nodiscard]] static auto set(
std::filesystem::path const& x,
gsl::not_null<std::string*> const& member) noexcept -> bool {
- Auth::SetAuthMethod(AuthMethod::kTLS);
+ Auth::Instance().SetAuthMethod(AuthMethod::kTLS);
try {
// if the file does not exist, it will throw an exception
auto file = std::filesystem::canonical(x);