• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender / 1022567176

02 Oct 2023 07:50AM UTC coverage: 80.127% (+2.5%) from 77.645%
1022567176

push

gitlab-ci

kacf
chore: Centralize selection of `std::filesystem` library.

Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>

6447 of 8046 relevant lines covered (80.13%)

9912.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/mender-auth/ipc/server.hpp
1
// Copyright 2023 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15

16
#ifndef MENDER_AUTH_IPC_SERVER_HPP
17
#define MENDER_AUTH_IPC_SERVER_HPP
18

19
#include <functional>
20
#include <string>
21

22
#include <common/conf.hpp>
23
#include <common/dbus.hpp>
24
#include <common/error.hpp>
25
#include <common/events.hpp>
26
#include <common/http.hpp>
27
#include <common/path.hpp>
28

29
#include <api/api.hpp>
30
#include <api/auth.hpp>
31

32
namespace mender {
33
namespace auth {
34
namespace ipc {
35

36

37
using namespace std;
38

39
namespace auth_client = mender::api::auth;
40
namespace conf = mender::common::conf;
41
namespace dbus = mender::common::dbus;
42
namespace error = mender::common::error;
43
namespace events = mender::common::events;
44
namespace log = mender::common::log;
45
namespace path = mender::common::path;
46

47
class Caching {
48
public:
49
        Caching(events::EventLoop &loop, const conf::MenderConfig &config) :
×
50
                server_url_ {config.server_url},
×
51
                tenant_token_ {config.tenant_token},
×
52
                client_config_ {
53
                        config.server_certificate, config.https_client.certificate, config.https_client.key},
×
54
                client_ {client_config_, loop},
55
                default_identity_script_path_ {config.paths.GetIdentityScript()},
56
                dbus_server_ {loop, "io.mender.AuthenticationManager"} {};
×
57

58
        error::Error Listen(
59
                const string &identity_script_path = "", const string &private_key_path = "");
60

61
        string GetServerURL() {
62
                return this->cached_server_url_;
63
        }
64

65
        string GetJWTToken() {
66
                return this->cached_jwt_token_;
67
        }
68

69
        void Cache(const string &token, const string &url) {
70
                this->cached_jwt_token_ = token;
71
                this->cached_server_url_ = url;
72
        }
73

74
private:
75
        void ClearCache() {
76
                Cache("", "");
77
        }
78

79
        void CacheAPIResponse(const string &server_url, auth_client::APIResponse resp) {
80
                if (resp) {
81
                        Cache(resp.value(), server_url);
82
                        return;
83
                }
84
                ClearCache();
85
        };
86

87
        string cached_jwt_token_;
88
        string cached_server_url_;
89

90
        const string server_url_;
91
        const string tenant_token_;
92
        http::ClientConfig client_config_;
93
        http::Client client_;
94
        string default_identity_script_path_;
95
        dbus::DBusServer dbus_server_;
96
};
97

98
using Server = Caching;
99

100
} // namespace ipc
101
} // namespace auth
102
} // namespace mender
103

104

105
#endif // MENDER_AUTH_IPC_SERVER_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc