trust-store  1.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 
22 #include <core/trust/visibility.h>
23 
24 #include <cstdint>
25 
26 #include <chrono>
27 #include <memory>
28 #include <ostream>
29 #include <string>
30 
31 namespace core
32 {
33 namespace trust
34 {
35 // Forward declarations
36 class Agent;
37 class Store;
38 
54 {
56  typedef std::chrono::system_clock::duration Duration;
58  typedef std::chrono::system_clock::time_point Timestamp;
59 
61  static constexpr const unsigned int default_feature = 0;
62 
64  enum class Answer
65  {
66  denied,
67  granted,
68  };
69 
71  std::string from;
73  std::uint64_t feature;
78 };
85 CORE_TRUST_DLL_PUBLIC bool operator==(const Request& lhs, const Request& rhs);
86 
93 CORE_TRUST_DLL_PUBLIC std::ostream& operator<<(std::ostream& out, const Request::Answer& a);
94 
101 CORE_TRUST_DLL_PUBLIC std::ostream& operator<<(std::ostream& out, const Request& r);
102 
105 {
107  std::shared_ptr<Agent> agent;
109  std::shared_ptr<Store> store;
113  std::string application_id;
115  std::uint64_t feature;
117  std::string description;
118 };
119 
174 }
175 }
176 
177 #endif // CORE_TRUST_REQUEST_H_
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...
std::shared_ptr< Agent > agent
The Agent implementation to dispatch a request to the user.
Definition: request.h:107
std::uint64_t feature
Definition: request.h:73
The Request struct encapsulates information about a trust request answered by the user...
Definition: request.h:53
Summarizes all parameters for processing a trust request.
Definition: request.h:104
pid_t application_pid
The process id of the requesting application.
Definition: request.h:111
CORE_TRUST_DLL_PUBLIC std::ostream & operator<<(std::ostream &out, const Request::Answer &a)
operator << pretty prints answers to the provided output stream.
std::shared_ptr< Store > store
The trust store to be used for caching purposes.
Definition: request.h:109
std::chrono::system_clock::duration Duration
Duration in wallclock time.
Definition: request.h:56
std::uint64_t feature
The service-specific feature identifier.
Definition: request.h:115
std::string description
An extended description that should be presented to the user on prompting.
Definition: request.h:117
Answer
Enumerates the possible answers given by a user.
Definition: request.h:64
std::chrono::system_clock::time_point Timestamp
Requests are timestamped with wallclock time.
Definition: request.h:58
CORE_TRUST_DLL_PUBLIC bool operator==(const Request &lhs, const Request &rhs)
operator == compares two Requests for equality.
std::string application_id
The id of the requesting application.
Definition: request.h:113
Timestamp when
Definition: request.h:75
std::string from
Definition: request.h:71
#define CORE_TRUST_DLL_PUBLIC
Definition: visibility.h:26