trust-store  1.1.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;
76  Timestamp when;
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_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:108
The Request struct encapsulates information about a trust request answered by the user...
Definition: request.h:54
Definition: agent.h:28
core::trust::Pid application_pid
The process id of the requesting application.
Definition: request.h:114
Summarizes all parameters for processing a trust request.
Definition: request.h:105
Answer
Enumerates the possible answers given by a user.
Definition: request.h:65
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:110
std::chrono::system_clock::duration Duration
Duration in wallclock time.
Definition: request.h:57
CORE_TRUST_DLL_PUBLIC bool operator==(const Agent::RequestParameters &lhs, const Agent::RequestParameters &rhs)
Returns true iff lhs and rhs are equal.
std::string description
An extended description that should be presented to the user on prompting.
Definition: request.h:120
std::chrono::system_clock::time_point Timestamp
Requests are timestamped with wallclock time.
Definition: request.h:59
std::string application_id
The id of the requesting application.
Definition: request.h:116
Timestamp when
Definition: request.h:76
Feature feature
The service-specific feature identifier.
Definition: request.h:118
std::string from
Definition: request.h:72
core::trust::Uid application_uid
The user id under which the requesting application runs.
Definition: request.h:112
#define CORE_TRUST_DLL_PUBLIC
Definition: visibility.h:26