Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
server_credentials.h
1 #ifndef SOTA_CLIENT_TOOLS_SERVER_CREDENTIALS_H_
2 #define SOTA_CLIENT_TOOLS_SERVER_CREDENTIALS_H_
3 
4 #include <string>
5 
6 #include <boost/filesystem.hpp>
7 
8 enum class AuthMethod { kNone = 0, kBasic, kOauth2, kTls };
9 
10 class BadCredentialsContent : public std::runtime_error {
11  public:
12  explicit BadCredentialsContent(const std::string &what_arg) : std::runtime_error(what_arg.c_str()) {}
13 };
14 
15 class BadCredentialsJson : public std::runtime_error {
16  public:
17  explicit BadCredentialsJson(const std::string &what_arg) : std::runtime_error(what_arg.c_str()) {}
18 };
19 
20 class BadCredentialsArchive : public std::runtime_error {
21  public:
22  explicit BadCredentialsArchive(const std::string &what_arg) : std::runtime_error(what_arg.c_str()) {}
23 };
24 
26  public:
27  explicit ServerCredentials(const boost::filesystem::path &credentials_path);
28  bool CanSignOffline() const;
29  AuthMethod GetMethod() const { return method_; };
30  std::string GetClientP12() const { return client_p12_; };
31  std::string GetRepoUrl() const { return repo_url_; };
32  std::string GetAuthUser() const { return auth_user_; };
33  std::string GetAuthPassword() const { return auth_password_; };
34  std::string GetAuthServer() const { return auth_server_; };
35  std::string GetOSTreeServer() const { return ostree_server_; };
36  std::string GetClientId() const { return client_id_; };
37  std::string GetClientSecret() const { return client_secret_; };
38  std::string GetScope() const { return scope_; };
39 
40  /**
41  * Path to the original credentials.zip on disk. Needed to hand off to
42  * garage-sign executable.
43  */
44  boost::filesystem::path GetPathOnDisk() const { return credentials_path_; }
45 
46  private:
47  AuthMethod method_;
48  std::string client_p12_;
49  std::string repo_url_;
50  std::string auth_user_;
51  std::string auth_password_;
52  std::string auth_server_;
53  std::string ostree_server_;
54  std::string client_id_;
55  std::string client_secret_;
56  std::string scope_;
57  boost::filesystem::path credentials_path_;
58 };
59 
60 #endif // SOTA_CLIENT_TOOLS_SERVER_CREDENTIALS_H_
ServerCredentials
Definition: server_credentials.h:25
ServerCredentials::GetPathOnDisk
boost::filesystem::path GetPathOnDisk() const
Path to the original credentials.zip on disk.
Definition: server_credentials.h:44
BadCredentialsJson
Definition: server_credentials.h:15
BadCredentialsContent
Definition: server_credentials.h:10
BadCredentialsArchive
Definition: server_credentials.h:20