request.h
Go to the documentation of this file.
/*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*/
#ifndef CORE_TRUST_REQUEST_H_
#define CORE_TRUST_REQUEST_H_
#include <core/trust/tagged_integer.h>
#include <core/trust/visibility.h>
#include <cstdint>
#include <chrono>
#include <memory>
#include <ostream>
#include <string>
namespace core
{
namespace trust
{
// Forward declarations
class Agent;
class Store;
struct CORE_TRUST_DLL_PUBLIC Request
{
typedef std::chrono::system_clock::duration Duration;
typedef std::chrono::system_clock::time_point Timestamp;
static constexpr const unsigned int default_feature = 0;
enum class Answer : std::int32_t
{
denied,
granted,
};
std::string from;
Feature feature;
Timestamp when;
Answer answer;
};
CORE_TRUST_DLL_PUBLIC bool operator==(const Request& lhs, const Request& rhs);
CORE_TRUST_DLL_PUBLIC std::ostream& operator<<(std::ostream& out, const Request::Answer& a);
CORE_TRUST_DLL_PUBLIC std::ostream& operator<<(std::ostream& out, const Request& r);
struct CORE_TRUST_DLL_PUBLIC RequestParameters
{
std::shared_ptr<Agent> agent;
std::shared_ptr<Store> store;
core::trust::Uid application_uid;
core::trust::Pid application_pid;
std::string application_id;
Feature feature;
std::string description;
};
CORE_TRUST_DLL_PUBLIC Request::Answer process_trust_request(const RequestParameters& params);
}
}
#endif // CORE_TRUST_REQUEST_H_
core::trust::Request::feature
Feature feature
Definition: request.h:74
core::trust::process_trust_request
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...
core::trust::RequestParameters::agent
std::shared_ptr< Agent > agent
The Agent implementation to dispatch a request to the user.
Definition: request.h:108
core::trust::Request
The Request struct encapsulates information about a trust request answered by the user...
Definition: request.h:54
core
Definition: agent.h:28
core::trust::RequestParameters::application_pid
core::trust::Pid application_pid
The process id of the requesting application.
Definition: request.h:114
core::trust::TaggedInteger< tag::Feature, std::uint64_t >
core::trust::RequestParameters
Summarizes all parameters for processing a trust request.
Definition: request.h:105
core::trust::Request::Answer
Answer
Enumerates the possible answers given by a user.
Definition: request.h:65
visibility.h
core::trust::operator<<
CORE_TRUST_DLL_PUBLIC std::ostream & operator<<(std::ostream &out, const Request::Answer &a)
operator << pretty prints answers to the provided output stream.
core::trust::RequestParameters::store
std::shared_ptr< Store > store
The trust store to be used for caching purposes.
Definition: request.h:110
core::trust::Request::Duration
std::chrono::system_clock::duration Duration
Duration in wallclock time.
Definition: request.h:57
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::RequestParameters::description
std::string description
An extended description that should be presented to the user on prompting.
Definition: request.h:120
tagged_integer.h
core::trust::Request::Timestamp
std::chrono::system_clock::time_point Timestamp
Requests are timestamped with wallclock time.
Definition: request.h:59
core::trust::Request::answer
Answer answer
Definition: request.h:78
core::trust::RequestParameters::application_id
std::string application_id
The id of the requesting application.
Definition: request.h:116
core::trust::Request::when
Timestamp when
Definition: request.h:76
core::trust::RequestParameters::feature
Feature feature
The service-specific feature identifier.
Definition: request.h:118
core::trust::Request::from
std::string from
Definition: request.h:72
core::trust::RequestParameters::application_uid
core::trust::Uid application_uid
The user id under which the requesting application runs.
Definition: request.h:112
CORE_TRUST_DLL_PUBLIC
#define CORE_TRUST_DLL_PUBLIC
Definition: visibility.h:26