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

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

cached_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_CACHED_AGENT_H_
20 #define CORE_TRUST_CACHED_AGENT_H_
21
22 #include <core/trust/agent.h>
23
24 namespace core
25 {
26 namespace trust
27 {
29 class CORE_TRUST_DLL_PUBLIC CachedAgent : public core::trust::Agent
30 {
31 public:
33 typedef std::shared_ptr<CachedAgent> Ptr;
34
36 struct Reporter
37 {
39 Reporter() = default;
40 virtual ~Reporter() = default;
44 virtual void report_cached_answer_found(const core::trust::Agent::RequestParameters&, const core::trust::Request&);
45
47 virtual void report_user_prompted_for_trust(const core::trust::Agent::RequestParameters&, const core::trust::Request::Answer&);
48 };
49
51 struct Configuration
52 {
54 std::shared_ptr<Agent> agent;
56 std::shared_ptr<Store> store;
58 std::shared_ptr<Reporter> reporter;
59 };
60
66 CachedAgent(const Configuration& configuration);
68 virtual ~CachedAgent() = default;
72 Request::Answer authenticate_request_with_parameters(const core::trust::Agent::RequestParameters& parameters) override;
73
74 private:
76 Configuration configuration;
77 };
78 }
79 }
80
81 #endif // CORE_TRUST_CACHED_AGENT_H_
core::trust::Request
The Request struct encapsulates information about a trust request answered by the user.
Definition: request.h:55
core::trust::CachedAgent::Configuration::agent
std::shared_ptr< Agent > agent
The actual agent implementation for prompting the user.
Definition: cached_agent.h:54
core::trust::CachedAgent::Configuration::reporter
std::shared_ptr< Reporter > reporter
The reporter implementation.
Definition: cached_agent.h:58
core::trust::CachedAgent::Reporter::report_cached_answer_found
virtual void report_cached_answer_found(const core::trust::Agent::RequestParameters &, const core::trust::Request &)
Invoked whenever the implementation was able to resolve a cached request.
core::trust::CachedAgent::CachedAgent
CachedAgent(const Configuration &configuration)
CachedAgent creates a new agent instance.
core::trust::Agent
Abstracts user-prompting functionality.
Definition: agent.h:34
core::trust::CachedAgent::Reporter
Abstract capturer of internal events for post-mortem debugging/analysis purposes.
Definition: cached_agent.h:37
core::trust::CachedAgent
An agent implementation that uses a trust store instance to cache results.
Definition: cached_agent.h:30
core::trust::CachedAgent::authenticate_request_with_parameters
Request::Answer authenticate_request_with_parameters(const core::trust::Agent::RequestParameters &parameters) override
From core::trust::Agent.
core
Definition: agent.h:29
core::trust::Request::Answer
Answer
Enumerates the possible answers given by a user.
Definition: request.h:66
core::trust::CachedAgent::Configuration::store
std::shared_ptr< Store > store
The store caching user answers to trust prompts.
Definition: cached_agent.h:56
core::trust::Agent::RequestParameters
Summarizes all parameters for processing a trust request.
Definition: agent.h:66
agent.h
core::trust::CachedAgent::Reporter::report_user_prompted_for_trust
virtual void report_user_prompted_for_trust(const core::trust::Agent::RequestParameters &, const core::trust::Request::Answer &)
Invoked whenever the implementation called out to an agent to prompt the user for trust.
core::trust::CachedAgent::Configuration
Creation time parameters.
Definition: cached_agent.h:52
core::trust::CachedAgent::Ptr
std::shared_ptr< CachedAgent > Ptr
To save some typing.
Definition: cached_agent.h:33
CORE_TRUST_DLL_PUBLIC
#define CORE_TRUST_DLL_PUBLIC
Definition: visibility.h:26