Mir
application_authorizer.h
Go to the documentation of this file.
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 or 3 as
6 * 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIRAL_APPLICATION_AUTHORIZER_H
20#define MIRAL_APPLICATION_AUTHORIZER_H
21
22#include <sys/types.h>
23#include <functional>
24#include <memory>
25
26namespace mir { class Server; }
27namespace mir { namespace frontend { class SessionCredentials; } }
28
29namespace miral
30{
32{
33public:
34 ApplicationCredentials(mir::frontend::SessionCredentials const& creds);
35
36 pid_t pid() const;
37 uid_t uid() const;
38 gid_t gid() const;
39
40private:
41 ApplicationCredentials() = delete;
42
43 mir::frontend::SessionCredentials const& creds;
44};
45
47{
48public:
50 virtual ~ApplicationAuthorizer() = default;
53
54 virtual bool connection_is_allowed(ApplicationCredentials const& creds) = 0;
57 virtual bool screencast_is_allowed(ApplicationCredentials const& creds) = 0;
58 virtual bool prompt_session_is_allowed(ApplicationCredentials const& creds) = 0;
59 virtual bool configure_input_is_allowed(ApplicationCredentials const& creds) = 0;
61};
62
64{
65public:
66 explicit BasicSetApplicationAuthorizer(std::function<std::shared_ptr<ApplicationAuthorizer>()> const& builder);
68
69 void operator()(mir::Server& server);
71
72private:
73 struct Self;
74 std::shared_ptr<Self> self;
75};
76
77template<typename Policy>
79{
80public:
81 template<typename ...Args>
82 explicit SetApplicationAuthorizer(Args const& ...args) :
83 BasicSetApplicationAuthorizer{[&args...]() { return std::make_shared<Policy>(args...); }} {}
84
85 auto the_custom_application_authorizer() const -> std::shared_ptr<Policy>
86 { return std::static_pointer_cast<Policy>(the_application_authorizer()); }
87};
88}
89
90#endif //MIRAL_APPLICATION_AUTHORIZER_H
Definition: application_authorizer.h:47
virtual bool set_base_display_configuration_is_allowed(ApplicationCredentials const &creds)=0
virtual ~ApplicationAuthorizer()=default
virtual bool prompt_session_is_allowed(ApplicationCredentials const &creds)=0
virtual bool configure_display_is_allowed(ApplicationCredentials const &creds)=0
virtual bool set_base_input_configuration_is_allowed(ApplicationCredentials const &creds)=0
virtual bool screencast_is_allowed(ApplicationCredentials const &creds)=0
virtual bool connection_is_allowed(ApplicationCredentials const &creds)=0
ApplicationAuthorizer & operator=(ApplicationAuthorizer const &)=delete
virtual bool configure_input_is_allowed(ApplicationCredentials const &creds)=0
ApplicationAuthorizer(ApplicationAuthorizer const &)=delete
Definition: application_authorizer.h:32
ApplicationCredentials(mir::frontend::SessionCredentials const &creds)
Definition: application_authorizer.h:64
void operator()(mir::Server &server)
auto the_application_authorizer() const -> std::shared_ptr< ApplicationAuthorizer >
BasicSetApplicationAuthorizer(std::function< std::shared_ptr< ApplicationAuthorizer >()> const &builder)
Definition: application_authorizer.h:79
SetApplicationAuthorizer(Args const &...args)
Definition: application_authorizer.h:82
auto the_custom_application_authorizer() const -> std::shared_ptr< Policy >
Definition: application_authorizer.h:85
Definition: splash_session.h:24
Mir Abstraction Layer.
Definition: floating_window_manager.h:29
STL namespace.

Copyright © 2012-2022 Canonical Ltd.
Generated on Sun Oct 9 06:13:38 UTC 2022
This documentation is licensed under the GPL version 2 or 3.