trust-store 2.0.3
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>
25
26#include <cstdint>
27
28namespace core
29{
30namespace trust
31{
34{
35public:
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;
45
47 struct Registry
48 {
50 typedef std::shared_ptr<Registry> Ptr;
51
53 Registry() = default;
54 virtual ~Registry() = default;
56
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
66 {
68 struct
69 {
75 std::string id;
76 } application;
80 std::string description;
81 };
82
88};
89
92}
93}
94
95#endif // CORE_TRUST_AGENT_H_
Abstracts user-prompting functionality.
Definition agent.h:34
virtual Request::Answer authenticate_request_with_parameters(const RequestParameters &parameters)=0
Authenticates the given request and returns the user's answer.
Contains functionality for implementing Ubuntu's trust model.
Definition agent.h:31
TaggedInteger< tag::Feature, std::uint64_t > Feature
Our internal service-feature type.
TaggedInteger< tag::Uid, uid_t > Uid
Our internal user id type.
TaggedInteger< tag::Pid, pid_t > Pid
Our internal process id type.
CORE_TRUST_DLL_PUBLIC bool operator==(const Agent::RequestParameters &lhs, const Agent::RequestParameters &rhs)
Returns true iff lhs and rhs are equal.
Definition agent.h:29
Abstracts functionality for storing agent instances and associating them with a user id.
Definition agent.h:48
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.
std::shared_ptr< Registry > Ptr
Convenience typedef for a shared ptr.
Definition agent.h:50
virtual void unregister_agent_for_user(const core::trust::Uid &uid)=0
Removes the agent for the given uid from the registry.
Summarizes all parameters for processing a trust request.
Definition agent.h:66
core::trust::Pid pid
The process id of the requesting application.
Definition agent.h:73
std::string description
An extended description that should be presented to the user on prompting.
Definition agent.h:80
std::string id
The id of the requesting application.
Definition agent.h:75
core::trust::Uid uid
The user id under which the requesting application runs.
Definition agent.h:71
Feature feature
The service-specific feature identifier.
Definition agent.h:78
Answer
Enumerates the possible answers given by a user.
Definition request.h:66
#define CORE_TRUST_DLL_PUBLIC
Definition visibility.h:26