trust-store: /build/trust-store-git/src/trust-store/include/core/trust/agent.h Source File

trust-store 2.0.0 Provides a common implementation of a trust store to be used by trusted helpers.

agent.h
Go to the documentation of this file.
1 /*
2 * Copyright © 2014 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_AGENT_H_
20 #define CORE_TRUST_AGENT_H_
21
22 #include <core/trust/request.h>
23 #include <core/trust/tagged_integer.h>
24 #include <core/trust/visibility.h>
25
26 #include <cstdint>
27
28 namespace core
29 {
30 namespace trust
31 {
33 class CORE_TRUST_DLL_PUBLIC Agent
34 {
35 public:
37 Agent() = default;
38 virtual ~Agent() = default;
39
40 Agent(const Agent&) = delete;
41 Agent(Agent&&) = delete;
42 Agent& operator=(const Agent&) = delete;
43 Agent& operator=(Agent&&) = delete;
47 struct Registry
48 {
50 typedef std::shared_ptr<Registry> Ptr;
51
53 Registry() = default;
54 virtual ~Registry() = default;
58 virtual void register_agent_for_user(const core::trust::Uid& uid, const std::shared_ptr<core::trust::Agent>& agent) = 0;
59
61 virtual void unregister_agent_for_user(const core::trust::Uid& uid) = 0;
62 };
63
65 struct RequestParameters
66 {
68 struct
69 {
71 core::trust::Uid uid;
73 core::trust::Pid pid;
75 std::string id;
76 } application;
78 Feature feature;
80 std::string description;
81 };
82
87 virtual Request::Answer authenticate_request_with_parameters(const RequestParameters& parameters) = 0;
88 };
89
91 CORE_TRUST_DLL_PUBLIC bool operator==(const Agent::RequestParameters& lhs, const Agent::RequestParameters& rhs);
92 }
93 }
94
95 #endif // CORE_TRUST_AGENT_H_
visibility.h
core::trust::TaggedInteger< tag::Uid, uid_t >
core::trust::Agent::authenticate_request_with_parameters
virtual Request::Answer authenticate_request_with_parameters(const RequestParameters &parameters)=0
Authenticates the given request and returns the user's answer.
core::trust::Agent
Abstracts user-prompting functionality.
Definition: agent.h:34
core::trust::Agent::Registry::unregister_agent_for_user
virtual void unregister_agent_for_user(const core::trust::Uid &uid)=0
Removes the agent for the given uid from the registry.
core::trust::Agent::RequestParameters::id
std::string id
The id of the requesting application.
Definition: agent.h:75
option
option(TRUST_STORE_ENABLE_DOC_GENERATION "Generate package documentation with doxygen" ON) if(TRUST_STORE_ENABLE_DOC_GENERATION) find_package(Doxygen) if(DOXYGEN_FOUND) configure_file($
Definition: CMakeLists.txt:17
tagged_integer.h
core
Definition: agent.h:29
request.h
core::trust::Request::Answer
Answer
Enumerates the possible answers given by a user.
Definition: request.h:66
core::trust::Agent::RequestParameters
Summarizes all parameters for processing a trust request.
Definition: agent.h:66
core::trust::Agent::RequestParameters::pid
core::trust::Pid pid
The process id of the requesting application.
Definition: agent.h:73
core::trust::Agent::RequestParameters::description
std::string description
An extended description that should be presented to the user on prompting.
Definition: agent.h:80
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::Agent::RequestParameters::uid
core::trust::Uid uid
The user id under which the requesting application runs.
Definition: agent.h:71
core::trust::Agent::Registry::Ptr
std::shared_ptr< Registry > Ptr
Convenience typedef for a shared ptr.
Definition: agent.h:50
core::trust::Agent::Registry
Abstracts functionality for storing agent instances and associating them with a user id.
Definition: agent.h:48
core::trust::Agent::Registry::register_agent_for_user
virtual void register_agent_for_user(const core::trust::Uid &uid, const std::shared_ptr< core::trust::Agent > &agent)=0
Registers an agent for the given uid.
core::trust::Agent::RequestParameters::feature
Feature feature
The service-specific feature identifier.
Definition: agent.h:78