1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/* Copyright (C) 2010 The giomm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <glibmm/object.h>
#include <giomm/credentials.h>
#include <giomm/iostream.h>
_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)
namespace Gio
{
namespace DBus
{
_GMMPROC_EXTRA_NAMESPACE(DBus)
/** AuthObserver - An object used for authenticating connections.
* The AuthObserver type provides a mechanism for participating in how a
* Server (or a Connection) authenticates remote peers. Simply
* instantiate an AuthObserver and connect to the signals you are
* interested in. Note that new signals may be added in the future.
*
* For example, if you only want to allow D-Bus connections from
* processes owned by the same uid as the server, you would use a
* signal handler like the following:
* @code
* bool on_authorize_authenticated_peer(
* const Glib::RefPtr<const Gio::IOStream>&,
* const Glib::RefPtr<const Gio::Credentials>& credentials)
* {
* bool authorized = false;
*
* if (credentials)
* {
* Glib::RefPtr<Gio::Credentials> own_credentials = Gio::Credentials::create();
* try
* {
* if (credentials->is_same_user(own_credentials))
* authorized = true;
* }
* catch (const Gio::Error& ex)
* {
* std::cerr << "Gio::Error: " << ex.what() << std::endl;
* }
* }
*
* return authorized;
* }
* @endcode
*
* @newin{2,28}
* @ingroup DBus
*/
class GIOMM_API AuthObserver : public Glib::Object
{
_CLASS_GOBJECT(AuthObserver, GDBusAuthObserver, G_DBUS_AUTH_OBSERVER, Glib::Object, GObject, , , GIOMM_API)
protected:
_CTOR_DEFAULT
_IGNORE(g_dbus_auth_observer_new)
public:
_WRAP_CREATE()
_WRAP_METHOD(bool authorize_authenticated_peer(const Glib::RefPtr<const IOStream>& stream, const Glib::RefPtr<const Credentials>& credentials), g_dbus_auth_observer_authorize_authenticated_peer)
_WRAP_METHOD(bool allow_mechanism(const std::string& mechanism), g_dbus_auth_observer_allow_mechanism)
#m4 _CONVERSION(`GIOStream*', `const Glib::RefPtr<const IOStream>&', `Glib::wrap($3, true)')
#m4 _CONVERSION(`GCredentials*', `const Glib::RefPtr<const Credentials>&', `Glib::wrap($3, true)')
_WRAP_SIGNAL(bool authorize_authenticated_peer(const Glib::RefPtr<const IOStream>& stream, const Glib::RefPtr<const Credentials>& credentials), "authorize-authenticated-peer", no_default_handler)
_WRAP_SIGNAL(bool allow_mechanism(const std::string& mechanism), allow_mechanism, no_default_handler)
};
} //namespace DBus
} // namespace Gio
|