/* 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 .
*/
#include
#include
#include
_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 Glib::RefPtr& credentials)
* {
* bool authorized = false;
*
* if (credentials)
* {
* Glib::RefPtr 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& stream, const Glib::RefPtr& 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&', `Glib::wrap($3, true)')
#m4 _CONVERSION(`GCredentials*', `const Glib::RefPtr&', `Glib::wrap($3, true)')
_WRAP_SIGNAL(bool authorize_authenticated_peer(const Glib::RefPtr& stream, const Glib::RefPtr& 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