1 /* GDBus - GLib D-Bus Library
3 * Copyright (C) 2008-2010 Red Hat, Inc.
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 * Author: David Zeuthen <davidz@redhat.com>
23 #ifndef __G_DBUS_AUTH_MECHANISM_H__
24 #define __G_DBUS_AUTH_MECHANISM_H__
26 #if !defined (GIO_COMPILATION)
27 #error "gdbusauthmechanism.h is a private header file."
30 #include <gio/giotypes.h>
34 #define G_TYPE_DBUS_AUTH_MECHANISM (_g_dbus_auth_mechanism_get_type ())
35 #define G_DBUS_AUTH_MECHANISM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_AUTH_MECHANISM, GDBusAuthMechanism))
36 #define G_DBUS_AUTH_MECHANISM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_AUTH_MECHANISM, GDBusAuthMechanismClass))
37 #define G_DBUS_AUTH_MECHANISM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_AUTH_MECHANISM, GDBusAuthMechanismClass))
38 #define G_IS_DBUS_AUTH_MECHANISM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_AUTH_MECHANISM))
39 #define G_IS_DBUS_AUTH_MECHANISM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_AUTH_MECHANISM))
41 typedef struct _GDBusAuthMechanism GDBusAuthMechanism;
42 typedef struct _GDBusAuthMechanismClass GDBusAuthMechanismClass;
43 typedef struct _GDBusAuthMechanismPrivate GDBusAuthMechanismPrivate;
46 G_DBUS_AUTH_MECHANISM_STATE_INVALID,
47 G_DBUS_AUTH_MECHANISM_STATE_WAITING_FOR_DATA,
48 G_DBUS_AUTH_MECHANISM_STATE_HAVE_DATA_TO_SEND,
49 G_DBUS_AUTH_MECHANISM_STATE_REJECTED,
50 G_DBUS_AUTH_MECHANISM_STATE_ACCEPTED,
51 } GDBusAuthMechanismState;
53 struct _GDBusAuthMechanismClass
56 GObjectClass parent_class;
62 /* TODO: server_initiate and client_initiate probably needs to have a
63 * GCredentials parameter...
66 gint (*get_priority) (void);
67 const gchar *(*get_name) (void);
69 /* functions shared by server/client */
70 gboolean (*is_supported) (GDBusAuthMechanism *mechanism);
71 gchar *(*encode_data) (GDBusAuthMechanism *mechanism,
75 gchar *(*decode_data) (GDBusAuthMechanism *mechanism,
80 /* functions for server-side authentication */
81 GDBusAuthMechanismState (*server_get_state) (GDBusAuthMechanism *mechanism);
82 void (*server_initiate) (GDBusAuthMechanism *mechanism,
83 const gchar *initial_response,
84 gsize initial_response_len);
85 void (*server_data_receive) (GDBusAuthMechanism *mechanism,
88 gchar *(*server_data_send) (GDBusAuthMechanism *mechanism,
90 gchar *(*server_get_reject_reason) (GDBusAuthMechanism *mechanism);
91 void (*server_shutdown) (GDBusAuthMechanism *mechanism);
93 /* functions for client-side authentication */
94 GDBusAuthMechanismState (*client_get_state) (GDBusAuthMechanism *mechanism);
95 gchar *(*client_initiate) (GDBusAuthMechanism *mechanism,
96 GDBusConnectionFlags conn_flags,
97 gsize *out_initial_response_len);
98 void (*client_data_receive) (GDBusAuthMechanism *mechanism,
101 gchar *(*client_data_send) (GDBusAuthMechanism *mechanism,
102 gsize *out_data_len);
103 void (*client_shutdown) (GDBusAuthMechanism *mechanism);
106 struct _GDBusAuthMechanism
108 GObject parent_instance;
109 GDBusAuthMechanismPrivate *priv;
112 GType _g_dbus_auth_mechanism_get_type (void) G_GNUC_CONST;
114 gint _g_dbus_auth_mechanism_get_priority (GType mechanism_type);
115 const gchar *_g_dbus_auth_mechanism_get_name (GType mechanism_type);
117 GIOStream *_g_dbus_auth_mechanism_get_stream (GDBusAuthMechanism *mechanism);
118 GCredentials *_g_dbus_auth_mechanism_get_credentials (GDBusAuthMechanism *mechanism);
120 gboolean _g_dbus_auth_mechanism_is_supported (GDBusAuthMechanism *mechanism);
121 gchar *_g_dbus_auth_mechanism_encode_data (GDBusAuthMechanism *mechanism,
124 gsize *out_data_len);
125 gchar *_g_dbus_auth_mechanism_decode_data (GDBusAuthMechanism *mechanism,
128 gsize *out_data_len);
130 GDBusAuthMechanismState _g_dbus_auth_mechanism_server_get_state (GDBusAuthMechanism *mechanism);
131 void _g_dbus_auth_mechanism_server_initiate (GDBusAuthMechanism *mechanism,
132 const gchar *initial_response,
133 gsize initial_response_len);
134 void _g_dbus_auth_mechanism_server_data_receive (GDBusAuthMechanism *mechanism,
137 gchar *_g_dbus_auth_mechanism_server_data_send (GDBusAuthMechanism *mechanism,
138 gsize *out_data_len);
139 gchar *_g_dbus_auth_mechanism_server_get_reject_reason (GDBusAuthMechanism *mechanism);
140 void _g_dbus_auth_mechanism_server_shutdown (GDBusAuthMechanism *mechanism);
142 GDBusAuthMechanismState _g_dbus_auth_mechanism_client_get_state (GDBusAuthMechanism *mechanism);
143 gchar *_g_dbus_auth_mechanism_client_initiate (GDBusAuthMechanism *mechanism,
144 GDBusConnectionFlags conn_flags,
145 gsize *out_initial_response_len);
146 void _g_dbus_auth_mechanism_client_data_receive (GDBusAuthMechanism *mechanism,
149 gchar *_g_dbus_auth_mechanism_client_data_send (GDBusAuthMechanism *mechanism,
150 gsize *out_data_len);
151 void _g_dbus_auth_mechanism_client_shutdown (GDBusAuthMechanism *mechanism);
156 #endif /* __G_DBUS_AUTH_MECHANISM_H__ */