trust-store  2.0.0
Provides a common implementation of a trust store to be used by trusted helpers.
request.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 
19 #ifndef CORE_TRUST_REQUEST_H_
20 #define CORE_TRUST_REQUEST_H_
21 
23 #include <core/trust/visibility.h>
24 
25 #include <cstdint>
26 
27 #include <chrono>
28 #include <memory>
29 #include <ostream>
30 #include <string>
31 
32 namespace core
33 {
34 namespace trust
35 {
36 // Forward declarations
37 class Agent;
38 class Store;
39 
55 {
57  typedef std::chrono::system_clock::duration Duration;
59  typedef std::chrono::system_clock::time_point Timestamp;
60 
62  static constexpr const unsigned int default_feature = 0;
63 
65  enum class Answer : std::int32_t
66  {
67  denied,
68  granted,
69  };
70 
72  std::string from;
79 };
86 CORE_TRUST_DLL_PUBLIC bool operator==(const Request& lhs, const Request& rhs);
87 
94 CORE_TRUST_DLL_PUBLIC std::ostream& operator<<(std::ostream& out, const Request::Answer& a);
95 
102 CORE_TRUST_DLL_PUBLIC std::ostream& operator<<(std::ostream& out, const Request& r);
103 
106 {
108  std::shared_ptr<Agent> agent;
110  std::shared_ptr<Store> store;
116  std::string application_id;
120  std::string description;
121 };
122 
178 }
179 }
180 
181 #endif // CORE_TRUST_REQUEST_H_
core::trust::Request::answer
Answer answer
Definition: request.h:78
core::trust::Request
The Request struct encapsulates information about a trust request answered by the user.
Definition: request.h:55
core::trust::RequestParameters::agent
std::shared_ptr< Agent > agent
The Agent implementation to dispatch a request to the user.
Definition: request.h:108
core::trust::Request::Duration
std::chrono::system_clock::duration Duration
Duration in wallclock time.
Definition: request.h:57
visibility.h
core::trust::TaggedInteger< tag::Feature, std::uint64_t >
core::trust::RequestParameters::application_pid
core::trust::Pid application_pid
The process id of the requesting application.
Definition: request.h:114
core::trust::RequestParameters
Summarizes all parameters for processing a trust request.
Definition: request.h:106
core::trust::RequestParameters::store
std::shared_ptr< Store > store
The trust store to be used for caching purposes.
Definition: request.h:110
core::trust::Request::when
Timestamp when
Definition: request.h:76
core::trust::Request::feature
Feature feature
Definition: request.h:74
tagged_integer.h
core::trust::operator<<
CORE_TRUST_DLL_PUBLIC std::ostream & operator<<(std::ostream &out, const Request::Answer &a)
operator << pretty prints answers to the provided output stream.
core
Definition: agent.h:29
core::trust::Request::Answer
Answer
Enumerates the possible answers given by a user.
Definition: request.h:66
core::trust::Request::from
std::string from
Definition: request.h:72
core::trust::RequestParameters::application_id
std::string application_id
The id of the requesting application.
Definition: request.h:116
core::trust::operator==
CORE_TRUST_DLL_PUBLIC bool operator==(const Agent::RequestParameters &lhs, const Agent::RequestParameters &rhs)
Returns true iff lhs and rhs are equal.
CORE_TRUST_DLL_PUBLIC
#define CORE_TRUST_DLL_PUBLIC
Definition: visibility.h:26
core::trust::Request::Timestamp
std::chrono::system_clock::time_point Timestamp
Requests are timestamped with wallclock time.
Definition: request.h:59
core::trust::RequestParameters::description
std::string description
An extended description that should be presented to the user on prompting.
Definition: request.h:120
core::trust::RequestParameters::feature
Feature feature
The service-specific feature identifier.
Definition: request.h:118
core::trust::process_trust_request
CORE_TRUST_DLL_PUBLIC Request::Answer process_trust_request(const RequestParameters &params)
Processes an incoming trust-request by an application, tries to lookup a previous reply before issuin...
core::trust::RequestParameters::application_uid
core::trust::Uid application_uid
The user id under which the requesting application runs.
Definition: request.h:112