1 /* vi: set et sw=4 ts=4 cino=t0,(0: */
2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
4 * This file is part of libgsignon-glib
6 * Copyright (C) 2009-2010 Nokia Corporation.
7 * Copyright (C) 2012 Canonical Ltd.
8 * Copyright (C) 2012-2014 Intel Corporation.
10 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
11 * Contact: Jussi Laako <jussi.laako@linux.intel.com>
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public License
15 * version 2.1 as published by the Free Software Foundation.
17 * This library is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
29 * SECTION:signon-auth-session
30 * @title: SignonAuthSession
31 * @short_description: the authentication session object
33 * The #SignonAuthSession object is responsible for handling the client
34 * authentication. #SignonAuthSession objects should be created from existing
35 * identities (via signon_identity_create_session() or by passing a non-NULL identity
36 * to signon_auth_session_new()).
39 #include "signon-internals.h"
40 #include "signon-auth-session.h"
41 #include "signon-dbus-queue.h"
42 #include "signon-errors.h"
43 #include "signon-marshal.h"
44 #include "signon-utils.h"
45 #include "signon-identity.h"
46 #include "sso-auth-service.h"
47 #include "sso-auth-session-gen.h"
50 G_DEFINE_TYPE (SignonAuthSession, signon_auth_session, G_TYPE_OBJECT);
66 static guint auth_session_signals[LAST_SIGNAL] = { 0 };
67 static const gchar auth_session_process_pending_message[] =
68 "The request is added to queue.";
69 static const gchar data_key_process[] = "signon-process";
71 struct _SignonAuthSessionPrivate
73 SsoAuthSession *proxy;
74 SignonIdentity *identity;
75 GCancellable *cancellable;
83 gboolean dispose_has_run;
85 guint signal_state_changed;
86 guint signal_unregistered;
89 typedef struct _AuthSessionQueryAvailableMechanismsData
91 gchar **wanted_mechanisms;
93 } AuthSessionQueryAvailableMechanismsData;
95 typedef struct _AuthSessionProcessData
97 GVariant *session_data;
99 GCancellable *cancellable;
100 } AuthSessionProcessData;
102 typedef struct _AuthSessionQueryAvailableMechanismsCbData
104 SignonAuthSession *self;
105 SignonAuthSessionQueryAvailableMechanismsCb cb;
107 } AuthSessionQueryAvailableMechanismsCbData;
109 typedef struct _AuthSessionProcessCbData
111 SignonAuthSessionProcessCb cb;
113 } AuthSessionProcessCbData;
115 #define SIGNON_AUTH_SESSION_PRIV(obj) (SIGNON_AUTH_SESSION(obj)->priv)
116 #define SIGNON_AUTH_SESSION_GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SIGNON_TYPE_AUTH_SESSION, SignonAuthSessionPrivate))
119 static void auth_session_state_changed_cb (GDBusProxy *proxy, gint state, gchar *message, gpointer user_data);
120 static void auth_session_remote_object_destroyed_cb (GDBusProxy *proxy, gpointer user_data);
122 static gboolean auth_session_priv_init (SignonAuthSession *self, const gchar *method_name, GError **err);
124 static void auth_session_query_available_mechanisms_ready_cb (gpointer object, const GError *error, gpointer user_data);
125 static void auth_session_cancel_ready_cb (gpointer object, const GError *error, gpointer user_data);
127 static void auth_session_check_remote_object(SignonAuthSession *self);
130 auth_session_process_data_free (AuthSessionProcessData *process_data)
132 g_free (process_data->mechanism);
133 g_variant_unref (process_data->session_data);
134 g_slice_free (AuthSessionProcessData, process_data);
138 auth_session_process_reply (GObject *object, GAsyncResult *res,
141 SignonAuthSession *self;
142 SsoAuthSession *proxy = SSO_AUTH_SESSION (object);
143 GSimpleAsyncResult *res_process = (GSimpleAsyncResult *)userdata;
145 GError *error = NULL;
147 g_return_if_fail (res_process != NULL);
148 DEBUG ("%s %d", G_STRFUNC, __LINE__);
150 sso_auth_session_call_process_finish (proxy, &reply, res, &error);
152 self = SIGNON_AUTH_SESSION (g_async_result_get_source_object (
153 (GAsyncResult *)res_process));
154 self->priv->busy = FALSE;
156 if (G_LIKELY (error == NULL))
158 g_simple_async_result_set_op_res_gpointer (res_process, reply,
164 g_simple_async_result_take_error (res_process, error);
167 /* We use the idle variant in order to avoid the following critical
169 * g_main_context_pop_thread_default: assertion `g_queue_peek_head (stack) == context' failed
171 g_simple_async_result_complete_in_idle (res_process);
172 g_object_unref (res_process);
173 g_object_unref (self);
177 auth_session_process_ready_cb (gpointer object, const GError *error, gpointer user_data)
179 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
180 SignonAuthSessionPrivate *priv;
181 GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
182 AuthSessionProcessData *process_data;
184 g_return_if_fail (self != NULL);
189 DEBUG ("AuthSessionError: %s", error->message);
190 g_simple_async_result_set_from_error (res, error);
191 g_simple_async_result_complete (res);
192 g_object_unref (res);
199 priv->canceled = FALSE;
200 g_simple_async_result_set_error (res,
201 signon_error_quark (),
202 SIGNON_ERROR_SESSION_CANCELED,
203 "Authentication session was canceled");
204 g_simple_async_result_complete (res);
205 g_object_unref (res);
209 DEBUG ("%s %d", G_STRFUNC, __LINE__);
211 process_data = g_object_get_data ((GObject *)res, data_key_process);
212 g_return_if_fail (process_data != NULL);
214 sso_auth_session_call_process (priv->proxy,
215 process_data->session_data,
216 process_data->mechanism,
217 process_data->cancellable,
218 auth_session_process_reply,
223 process_async_cb_wrapper (GObject *object, GAsyncResult *res,
226 AuthSessionProcessCbData *cb_data = user_data;
227 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
229 GHashTable *reply = NULL;
230 GError *error = NULL;
233 DEBUG ("%s %d", G_STRFUNC, __LINE__);
235 v_reply = signon_auth_session_process_finish (self, res, &error);
237 cancelled = error != NULL &&
238 error->domain == G_IO_ERROR &&
239 error->code == G_IO_ERROR_CANCELLED;
241 /* Do not invoke the callback if the operation was cancelled */
242 if (cb_data->cb != NULL && !cancelled)
245 reply = signon_hash_table_from_variant (v_reply);
247 cb_data->cb (self, reply, error, cb_data->user_data);
249 g_variant_unref (v_reply);
251 g_slice_free (AuthSessionProcessCbData, cb_data);
252 g_clear_error (&error);
256 auth_session_object_quark ()
258 static GQuark quark = 0;
261 quark = g_quark_from_static_string ("auth_session_object_quark");
267 signon_auth_session_set_property (GObject *object,
272 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
277 self->priv->identity = g_value_dup_object (value);
280 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
285 signon_auth_session_get_property (GObject *object,
290 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
295 g_value_set_object (value, self->priv->identity);
298 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
303 signon_auth_session_init (SignonAuthSession *self)
305 self->priv = SIGNON_AUTH_SESSION_GET_PRIV (self);
306 self->priv->cancellable = g_cancellable_new ();
310 signon_auth_session_dispose (GObject *object)
312 g_return_if_fail (SIGNON_IS_AUTH_SESSION (object));
313 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
314 SignonAuthSessionPrivate *priv = self->priv;
315 g_return_if_fail (priv != NULL);
317 if (priv->dispose_has_run)
320 if (priv->cancellable)
322 g_cancellable_cancel (priv->cancellable);
323 g_object_unref (priv->cancellable);
324 priv->cancellable = NULL;
329 g_signal_handler_disconnect (priv->proxy, priv->signal_state_changed);
330 g_signal_handler_disconnect (priv->proxy, priv->signal_unregistered);
331 g_object_unref (priv->proxy);
336 G_OBJECT_CLASS (signon_auth_session_parent_class)->dispose (object);
338 priv->dispose_has_run = TRUE;
342 signon_auth_session_finalize (GObject *object)
344 g_return_if_fail (SIGNON_IS_AUTH_SESSION(object));
346 SignonAuthSession *self = SIGNON_AUTH_SESSION(object);
347 SignonAuthSessionPrivate *priv = self->priv;
348 g_return_if_fail (priv != NULL);
350 g_free (priv->method_name);
351 g_object_unref (priv->identity);
353 G_OBJECT_CLASS (signon_auth_session_parent_class)->finalize (object);
357 signon_auth_session_class_init (SignonAuthSessionClass *klass)
359 GObjectClass *object_class = G_OBJECT_CLASS (klass);
362 object_class->set_property = signon_auth_session_set_property;
363 object_class->get_property = signon_auth_session_get_property;
365 pspec = g_param_spec_object ("identity",
367 "Identity Object construct parameter",
368 SIGNON_TYPE_IDENTITY,
369 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
370 g_object_class_install_property (object_class,
374 g_type_class_add_private (object_class, sizeof (SignonAuthSessionPrivate));
377 * SignonAuthSession::state-changed:
378 * @auth_session: the #SignonAuthSession
379 * @state: the current state of the #SignonAuthSession
380 * @message: the message associated with the state change
382 * Emitted when the state of the #SignonAuthSession changes. The state change
383 * is initiated by #GSignondPlugin via #GSignondPlugin::status-changed signal.
385 /* FIXME: @state should be registered as a GLib type (or use one from
386 * libgsignond-common)
388 auth_session_signals[STATE_CHANGED] =
389 g_signal_new ("state-changed",
390 G_TYPE_FROM_CLASS (klass),
391 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
395 _signon_marshal_VOID__INT_STRING,
400 object_class->dispose = signon_auth_session_dispose;
401 object_class->finalize = signon_auth_session_finalize;
405 * signon_auth_session_new:
406 * @id: the id of the #SignonIdentity to be used. Can be 0, if this session is
407 * not bound to any stored identity.
408 * @method_name: the name of the authentication method to be used.
409 * @err: a pointer to a location which will contain the error, in case this
412 * Creates a new #SignonAuthSession, which can be used to authenticate using
413 * the specified method.
415 * Returns: a new #SignonAuthSession.
418 signon_auth_session_new (gint id,
419 const gchar *method_name,
422 DEBUG ("%s %d", G_STRFUNC, __LINE__);
424 SignonIdentity *identity = (id == 0) ?
425 signon_identity_new () : signon_identity_new_from_db (id);
426 g_return_val_if_fail (identity, NULL);
428 SignonAuthSession *self =
429 signon_auth_session_new_for_identity (identity, method_name, err);
430 g_object_unref (identity);
436 * signon_auth_session_new_for_identity:
437 * @identity: #SignonIdentity parent object.
438 * @method_name: the name of the authentication method to be used.
439 * @err: a pointer to a location which will contain the error, in case this
442 * Creates a new #SignonAuthSession, which can be used to authenticate using
443 * the specified method.
445 * Returns: a new #SignonAuthSession.
448 signon_auth_session_new_for_identity (SignonIdentity *identity,
449 const gchar *method_name,
452 g_return_val_if_fail (SIGNON_IS_IDENTITY (identity), NULL);
454 DEBUG ("%s %d", G_STRFUNC, __LINE__);
456 SignonAuthSession *self = SIGNON_AUTH_SESSION(g_object_new (
457 SIGNON_TYPE_AUTH_SESSION,
458 "identity", identity,
460 g_return_val_if_fail (self != NULL, NULL);
462 if (!auth_session_priv_init(self, method_name, err))
465 g_warning ("%s returned error: %s", G_STRFUNC, (*err)->message);
467 g_object_unref (self);
475 * signon_auth_session_get_method:
476 * @self: the #SignonAuthSession.
478 * Get the current authentication method.
480 * Returns: the authentication method being used, or %NULL on failure.
483 signon_auth_session_get_method (SignonAuthSession *self)
485 g_return_val_if_fail (SIGNON_IS_AUTH_SESSION (self), NULL);
486 SignonAuthSessionPrivate *priv = self->priv;
488 g_return_val_if_fail (priv != NULL, NULL);
490 return priv->method_name;
494 * SignonAuthSessionQueryAvailableMechanismsCb:
495 * @self: the #SignonAuthSession.
496 * @mechanisms: (transfer full) (type GStrv): list of available mechanisms.
497 * @error: a #GError if an error occurred, %NULL otherwise.
498 * @user_data: the user data that was passed when installing this callback.
500 * Callback to be passed to signon_auth_session_query_available_mechanisms().
504 * signon_auth_session_query_available_mechanisms:
505 * @self: the #SignonAuthSession.
506 * @wanted_mechanisms: a %NULL-terminated list of mechanisms supported by the client.
507 * @cb: (scope async): a callback which will be called with the result.
508 * @user_data: user data to be passed to the callback.
510 * Queries the mechanisms available for this authentication session. The result
511 * will be the intersection between @wanted_mechanisms and the mechanisms
512 * supported by the authentication plugin (and allowed by the #SignonIdentity that this
513 * session belongs to).
516 signon_auth_session_query_available_mechanisms (SignonAuthSession *self,
517 const gchar **wanted_mechanisms,
518 SignonAuthSessionQueryAvailableMechanismsCb cb,
521 g_return_if_fail (SIGNON_IS_AUTH_SESSION (self));
522 SignonAuthSessionPrivate* priv = self->priv;
524 g_return_if_fail (priv != NULL);
526 AuthSessionQueryAvailableMechanismsCbData *cb_data = g_slice_new0 (AuthSessionQueryAvailableMechanismsCbData);
527 cb_data->self = self;
529 cb_data->user_data = user_data;
531 AuthSessionQueryAvailableMechanismsData *operation_data = g_slice_new0 (AuthSessionQueryAvailableMechanismsData);
532 operation_data->wanted_mechanisms = g_strdupv ((gchar **)wanted_mechanisms);
533 operation_data->cb_data = cb_data;
535 auth_session_check_remote_object(self);
536 _signon_object_call_when_ready (self,
537 auth_session_object_quark(),
538 auth_session_query_available_mechanisms_ready_cb,
543 * SignonAuthSessionProcessCb:
544 * @self: the #SignonAuthSession.
545 * @session_data: (transfer full) (element-type utf8 GValue): a dictionary with
547 * @error: a #GError if an error occurred, %NULL otherwise.
548 * @user_data: the user data that was passed when installing this callback.
550 * This callback is invoked when the authentication plugin delivers the result
551 * of the signon_auth_session_process() operation.
555 * signon_auth_session_process:
556 * @self: the #SignonAuthSession.
557 * @session_data: (transfer none) (element-type utf8 GValue): a dictionary of parameters.
558 * @mechanism: the authentication mechanism to be used.
559 * @cb: (scope async): a callback which will be called with the result.
560 * @user_data: user data to be passed to the callback.
562 * Performs one step of the authentication process. If the #SignonIdentity that
563 * this session belongs to contains a username and a password, they will be also
564 * passed to the authentication plugin, otherwise they should be set directly in
566 * @session_data should be used to add additional authentication parameters to the
567 * session, or to override the parameters otherwise taken from the identity.
569 * Deprecated: 1.8: Use signon_auth_session_process_async() instead.
572 signon_auth_session_process (SignonAuthSession *self,
573 GHashTable *session_data,
574 const gchar* mechanism,
575 SignonAuthSessionProcessCb cb,
578 GVariant *v_session_data;
580 g_return_if_fail (SIGNON_IS_AUTH_SESSION (self));
581 DEBUG ("%s %d", G_STRFUNC, __LINE__);
583 AuthSessionProcessCbData *cb_data = g_slice_new0 (AuthSessionProcessCbData);
585 cb_data->user_data = user_data;
587 v_session_data = signon_hash_table_to_variant (session_data);
589 signon_auth_session_process_async (self, v_session_data, mechanism, NULL,
590 process_async_cb_wrapper, cb_data);
594 * signon_auth_session_process_async:
595 * @self: the #SignonAuthSession.
596 * @session_data: (transfer full): a dictionary of parameters.
597 * @mechanism: the authentication mechanism to be used.
598 * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
599 * @callback: (scope async): a callback which will be called when the
600 * authentication reply is available.
601 * @user_data: user data to be passed to the callback.
603 * Performs one step of the authentication process.
604 * @session_data should be used to add additional authentication parameters to the
607 * What specific parameters should be used can be found from authentication plugins'
608 * documentation (look for parameters that are expected in gsignond_plugin_request_initial()
609 * for the first step, and parameters that are expected in gsignond_plugin_request() for
610 * the subsequent steps). See, for example, #GSignondPasswordPlugin and #GSignondDigestPlugin.
612 * If the #SignonIdentity that this session belongs to contains a username and a password,
613 * the daemon will pass them to the authentication plugin, otherwise they should be set directly in
614 * @session_data. The daemon also passes a list of identity's allowed realms to the plugin,
615 * and they cannot be overriden.
620 signon_auth_session_process_async (SignonAuthSession *self,
621 GVariant *session_data,
622 const gchar *mechanism,
623 GCancellable *cancellable,
624 GAsyncReadyCallback callback,
627 SignonAuthSessionPrivate *priv;
628 AuthSessionProcessData *process_data;
629 GSimpleAsyncResult *res;
631 g_return_if_fail (SIGNON_IS_AUTH_SESSION (self));
634 g_return_if_fail (session_data != NULL);
636 res = g_simple_async_result_new ((GObject *)self, callback, user_data,
637 signon_auth_session_process_async);
638 g_simple_async_result_set_check_cancellable (res, cancellable);
640 process_data = g_slice_new0 (AuthSessionProcessData);
641 process_data->session_data = g_variant_ref_sink (session_data);
642 process_data->mechanism = g_strdup (mechanism);
643 process_data->cancellable = cancellable;
644 g_object_set_data_full ((GObject *)res, data_key_process, process_data,
645 (GDestroyNotify)auth_session_process_data_free);
649 auth_session_check_remote_object(self);
650 _signon_object_call_when_ready (self,
651 auth_session_object_quark(),
652 auth_session_process_ready_cb,
657 * signon_auth_session_process_finish:
658 * @self: the #SignonAuthSession.
659 * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to
660 * signon_auth_session_process_async().
661 * @error: return location for error, or %NULL.
663 * Collect the result of the signon_auth_session_process_async() operation.
665 * Returns: a #GVariant of type %G_VARIANT_TYPE_VARDICT containing the
666 * authentication reply. As with signon_auth_session_process_async(), specific
667 * parameters contained in the #GVariant can be found from plugins' documentation:
668 * #GSignondPlugin::response-final for the final response, and #GSignondPlugin::response
669 * for the intermediate responses. See, for example, #GSignondPasswordPlugin
670 * and #GSignondDigestPlugin.
675 signon_auth_session_process_finish (SignonAuthSession *self, GAsyncResult *res,
678 GSimpleAsyncResult *async_result;
681 g_return_val_if_fail (SIGNON_IS_AUTH_SESSION (self), NULL);
683 async_result = (GSimpleAsyncResult *)res;
684 if (g_simple_async_result_propagate_error (async_result, error))
687 reply = g_simple_async_result_get_op_res_gpointer (async_result);
688 return g_variant_ref (reply);
692 * signon_auth_session_cancel:
693 * @self: the #SignonAuthSession.
695 * Cancel the authentication session.
698 signon_auth_session_cancel (SignonAuthSession *self)
700 g_return_if_fail (SIGNON_IS_AUTH_SESSION (self));
701 SignonAuthSessionPrivate *priv = self->priv;
703 g_return_if_fail (priv != NULL);
705 auth_session_check_remote_object(self);
710 priv->canceled = TRUE;
711 _signon_object_call_when_ready (self,
712 auth_session_object_quark(),
713 auth_session_cancel_ready_cb,
718 auth_session_state_changed_cb (GDBusProxy *proxy,
723 g_return_if_fail (SIGNON_IS_AUTH_SESSION (user_data));
724 SignonAuthSession *self = SIGNON_AUTH_SESSION (user_data);
726 g_signal_emit ((GObject *)self,
727 auth_session_signals[STATE_CHANGED],
733 static void auth_session_remote_object_destroyed_cb (GDBusProxy *proxy,
736 g_return_if_fail (SIGNON_IS_AUTH_SESSION (user_data));
737 SignonAuthSession *self = SIGNON_AUTH_SESSION (user_data);
738 SignonAuthSessionPrivate *priv = self->priv;
739 g_return_if_fail (priv != NULL);
740 DEBUG ("remote object unregistered");
744 g_object_unref (priv->proxy);
749 * as remote object is destroyed only
750 * when the session core is destroyed,
751 * so there should not be any processes
755 priv->canceled = FALSE;
756 _signon_object_not_ready(self);
760 auth_session_priv_init (SignonAuthSession *self,
761 const gchar *method_name, GError **err)
763 g_return_val_if_fail (SIGNON_IS_AUTH_SESSION (self), FALSE);
764 SignonAuthSessionPrivate *priv = SIGNON_AUTH_SESSION_PRIV (self);
765 g_return_val_if_fail (priv, FALSE);
767 priv->method_name = g_strdup (method_name);
769 priv->registering = FALSE;
771 priv->canceled = FALSE;
776 auth_session_query_mechanisms_reply (GObject *object, GAsyncResult *res,
779 SsoAuthSession *proxy = SSO_AUTH_SESSION (object);
780 gchar **mechanisms = NULL;
781 GError *error = NULL;
782 AuthSessionQueryAvailableMechanismsCbData *cb_data =
783 (AuthSessionQueryAvailableMechanismsCbData *)userdata;
784 g_return_if_fail (cb_data != NULL);
786 sso_auth_session_call_query_available_mechanisms_finish (proxy,
790 if (SIGNON_IS_NOT_CANCELLED (error))
792 (cb_data->cb) (cb_data->self, mechanisms, error, cb_data->user_data);
795 g_clear_error (&error);
796 g_slice_free (AuthSessionQueryAvailableMechanismsCbData, cb_data);
800 auth_session_query_available_mechanisms_ready_cb (gpointer object, const GError *error,
803 g_return_if_fail (SIGNON_IS_AUTH_SESSION (object));
804 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
805 SignonAuthSessionPrivate *priv = self->priv;
806 g_return_if_fail (priv != NULL);
808 AuthSessionQueryAvailableMechanismsData *operation_data =
809 (AuthSessionQueryAvailableMechanismsData *)user_data;
810 g_return_if_fail (operation_data != NULL);
812 AuthSessionQueryAvailableMechanismsCbData *cb_data = operation_data->cb_data;
813 g_return_if_fail (cb_data != NULL);
818 (self, NULL, error, cb_data->user_data);
820 g_slice_free (AuthSessionQueryAvailableMechanismsCbData, cb_data);
824 g_return_if_fail (priv->proxy != NULL);
825 sso_auth_session_call_query_available_mechanisms (
827 (const char **)operation_data->wanted_mechanisms,
829 auth_session_query_mechanisms_reply,
833 auth_session_signals[STATE_CHANGED],
835 SIGNON_AUTH_SESSION_STATE_PROCESS_PENDING,
836 auth_session_process_pending_message);
839 g_strfreev (operation_data->wanted_mechanisms);
840 g_slice_free (AuthSessionQueryAvailableMechanismsData, operation_data);
844 auth_session_cancel_ready_cb (gpointer object, const GError *error, gpointer user_data)
846 g_return_if_fail (SIGNON_IS_AUTH_SESSION (object));
847 g_return_if_fail (user_data == NULL);
849 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
850 SignonAuthSessionPrivate *priv = self->priv;
851 g_return_if_fail (priv != NULL);
855 //TODO: in general this function does not return any values,
856 // that is why I think it should not emit anything for this particular case
857 DEBUG("error during initialization");
859 else if (priv->proxy && priv->busy)
860 sso_auth_session_call_cancel_sync (priv->proxy,
865 priv->canceled = FALSE;
869 signon_auth_session_complete (SignonAuthSession *self,
871 GDBusConnection *connection,
872 const gchar *bus_name,
873 const gchar *object_path)
875 SignonAuthSessionPrivate *priv = self->priv;
876 g_return_if_fail (priv != NULL);
878 DEBUG ("%s %d", G_STRFUNC, __LINE__);
880 priv->registering = FALSE;
881 if (!g_strcmp0(object_path, "") || error)
884 DEBUG ("Error message is %s", error->message);
886 error = g_error_new (signon_error_quark(),
887 SIGNON_ERROR_RUNTIME,
888 "Cannot create remote AuthSession object");
892 GError *proxy_error = NULL;
895 sso_auth_session_proxy_new_sync (connection,
896 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
901 if (G_UNLIKELY (proxy_error != NULL))
903 g_warning ("Failed to initialize AuthSession proxy: %s",
904 proxy_error->message);
905 g_clear_error (&proxy_error);
908 g_dbus_proxy_set_default_timeout ((GDBusProxy *)priv->proxy,
911 priv->signal_state_changed =
912 g_signal_connect (priv->proxy,
914 G_CALLBACK (auth_session_state_changed_cb),
917 priv->signal_unregistered =
918 g_signal_connect (priv->proxy,
920 G_CALLBACK (auth_session_remote_object_destroyed_cb),
924 DEBUG ("Object path received: %s", object_path);
925 _signon_object_ready (self, auth_session_object_quark (), error);
929 auth_session_check_remote_object(SignonAuthSession *self)
931 g_return_if_fail (self != NULL);
932 SignonAuthSessionPrivate *priv = self->priv;
933 g_return_if_fail (priv != NULL);
935 if (priv->proxy != NULL)
938 g_return_if_fail (priv->identity != NULL);
940 if (!priv->registering)
942 DEBUG ("%s %d", G_STRFUNC, __LINE__);
944 priv->registering = TRUE;
945 signon_identity_get_auth_session (priv->identity,
948 signon_auth_session_complete);