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-2013 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()), in which case the authentication data such as
37 * username and password will be implicitly taken from the identity.
40 #include "signon-internals.h"
41 #include "signon-auth-session.h"
42 #include "signon-dbus-queue.h"
43 #include "signon-errors.h"
44 #include "signon-marshal.h"
45 #include "signon-utils.h"
46 #include "signon-identity.h"
47 #include "sso-auth-service.h"
48 #include "sso-auth-session-gen.h"
51 G_DEFINE_TYPE (SignonAuthSession, signon_auth_session, G_TYPE_OBJECT);
67 static guint auth_session_signals[LAST_SIGNAL] = { 0 };
68 static const gchar auth_session_process_pending_message[] =
69 "The request is added to queue.";
70 static const gchar data_key_process[] = "signon-process";
72 struct _SignonAuthSessionPrivate
74 SsoAuthSession *proxy;
75 SignonIdentity *identity;
76 GCancellable *cancellable;
84 gboolean dispose_has_run;
86 guint signal_state_changed;
87 guint signal_unregistered;
90 typedef struct _AuthSessionQueryAvailableMechanismsData
92 gchar **wanted_mechanisms;
94 } AuthSessionQueryAvailableMechanismsData;
96 typedef struct _AuthSessionProcessData
98 GVariant *session_data;
100 GCancellable *cancellable;
101 } AuthSessionProcessData;
103 typedef struct _AuthSessionQueryAvailableMechanismsCbData
105 SignonAuthSession *self;
106 SignonAuthSessionQueryAvailableMechanismsCb cb;
108 } AuthSessionQueryAvailableMechanismsCbData;
110 typedef struct _AuthSessionProcessCbData
112 SignonAuthSessionProcessCb cb;
114 } AuthSessionProcessCbData;
116 #define SIGNON_AUTH_SESSION_PRIV(obj) (SIGNON_AUTH_SESSION(obj)->priv)
117 #define SIGNON_AUTH_SESSION_GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SIGNON_TYPE_AUTH_SESSION, SignonAuthSessionPrivate))
120 static void auth_session_state_changed_cb (GDBusProxy *proxy, gint state, gchar *message, gpointer user_data);
121 static void auth_session_remote_object_destroyed_cb (GDBusProxy *proxy, gpointer user_data);
123 static gboolean auth_session_priv_init (SignonAuthSession *self, const gchar *method_name, GError **err);
125 static void auth_session_query_available_mechanisms_ready_cb (gpointer object, const GError *error, gpointer user_data);
126 static void auth_session_cancel_ready_cb (gpointer object, const GError *error, gpointer user_data);
128 static void auth_session_check_remote_object(SignonAuthSession *self);
131 auth_session_process_data_free (AuthSessionProcessData *process_data)
133 g_free (process_data->mechanism);
134 g_variant_unref (process_data->session_data);
135 g_slice_free (AuthSessionProcessData, process_data);
139 auth_session_process_reply (GObject *object, GAsyncResult *res,
142 SignonAuthSession *self;
143 SsoAuthSession *proxy = SSO_AUTH_SESSION (object);
144 GSimpleAsyncResult *res_process = (GSimpleAsyncResult *)userdata;
146 GError *error = NULL;
148 g_return_if_fail (res_process != NULL);
149 DEBUG ("%s %d", G_STRFUNC, __LINE__);
151 sso_auth_session_call_process_finish (proxy, &reply, res, &error);
153 self = SIGNON_AUTH_SESSION (g_async_result_get_source_object (
154 (GAsyncResult *)res_process));
155 self->priv->busy = FALSE;
157 if (G_LIKELY (error == NULL))
159 g_simple_async_result_set_op_res_gpointer (res_process, reply,
165 g_simple_async_result_take_error (res_process, error);
168 /* We use the idle variant in order to avoid the following critical
170 * g_main_context_pop_thread_default: assertion `g_queue_peek_head (stack) == context' failed
172 g_simple_async_result_complete_in_idle (res_process);
173 g_object_unref (res_process);
174 g_object_unref (self);
178 auth_session_process_ready_cb (gpointer object, const GError *error, gpointer user_data)
180 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
181 SignonAuthSessionPrivate *priv;
182 GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
183 AuthSessionProcessData *process_data;
185 g_return_if_fail (self != NULL);
190 DEBUG ("AuthSessionError: %s", error->message);
191 g_simple_async_result_set_from_error (res, error);
192 g_simple_async_result_complete (res);
193 g_object_unref (res);
200 priv->canceled = FALSE;
201 g_simple_async_result_set_error (res,
202 signon_error_quark (),
203 SIGNON_ERROR_SESSION_CANCELED,
204 "Authentication session was canceled");
205 g_simple_async_result_complete (res);
206 g_object_unref (res);
210 DEBUG ("%s %d", G_STRFUNC, __LINE__);
212 process_data = g_object_get_data ((GObject *)res, data_key_process);
213 g_return_if_fail (process_data != NULL);
215 sso_auth_session_call_process (priv->proxy,
216 process_data->session_data,
217 process_data->mechanism,
218 process_data->cancellable,
219 auth_session_process_reply,
224 process_async_cb_wrapper (GObject *object, GAsyncResult *res,
227 AuthSessionProcessCbData *cb_data = user_data;
228 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
230 GHashTable *reply = NULL;
231 GError *error = NULL;
234 DEBUG ("%s %d", G_STRFUNC, __LINE__);
236 v_reply = signon_auth_session_process_finish (self, res, &error);
238 cancelled = error != NULL &&
239 error->domain == G_IO_ERROR &&
240 error->code == G_IO_ERROR_CANCELLED;
242 /* Do not invoke the callback if the operation was cancelled */
243 if (cb_data->cb != NULL && !cancelled)
246 reply = signon_hash_table_from_variant (v_reply);
248 cb_data->cb (self, reply, error, cb_data->user_data);
250 g_variant_unref (v_reply);
252 g_slice_free (AuthSessionProcessCbData, cb_data);
253 g_clear_error (&error);
257 auth_session_object_quark ()
259 static GQuark quark = 0;
262 quark = g_quark_from_static_string ("auth_session_object_quark");
268 signon_auth_session_set_property (GObject *object,
273 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
278 self->priv->identity = g_value_dup_object (value);
281 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
286 signon_auth_session_get_property (GObject *object,
291 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
296 g_value_set_object (value, self->priv->identity);
299 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
304 signon_auth_session_init (SignonAuthSession *self)
306 self->priv = SIGNON_AUTH_SESSION_GET_PRIV (self);
307 self->priv->cancellable = g_cancellable_new ();
311 signon_auth_session_dispose (GObject *object)
313 g_return_if_fail (SIGNON_IS_AUTH_SESSION (object));
314 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
315 SignonAuthSessionPrivate *priv = self->priv;
316 g_return_if_fail (priv != NULL);
318 if (priv->dispose_has_run)
321 if (priv->cancellable)
323 g_cancellable_cancel (priv->cancellable);
324 g_object_unref (priv->cancellable);
325 priv->cancellable = NULL;
330 g_signal_handler_disconnect (priv->proxy, priv->signal_state_changed);
331 g_signal_handler_disconnect (priv->proxy, priv->signal_unregistered);
332 g_object_unref (priv->proxy);
337 G_OBJECT_CLASS (signon_auth_session_parent_class)->dispose (object);
339 priv->dispose_has_run = TRUE;
343 signon_auth_session_finalize (GObject *object)
345 g_return_if_fail (SIGNON_IS_AUTH_SESSION(object));
347 SignonAuthSession *self = SIGNON_AUTH_SESSION(object);
348 SignonAuthSessionPrivate *priv = self->priv;
349 g_return_if_fail (priv != NULL);
351 g_free (priv->method_name);
352 g_object_unref (priv->identity);
354 G_OBJECT_CLASS (signon_auth_session_parent_class)->finalize (object);
358 signon_auth_session_class_init (SignonAuthSessionClass *klass)
360 GObjectClass *object_class = G_OBJECT_CLASS (klass);
363 object_class->set_property = signon_auth_session_set_property;
364 object_class->get_property = signon_auth_session_get_property;
366 pspec = g_param_spec_object ("identity",
368 "Identity Object construct parameter",
369 SIGNON_TYPE_IDENTITY,
370 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
371 g_object_class_install_property (object_class,
375 g_type_class_add_private (object_class, sizeof (SignonAuthSessionPrivate));
378 * SignonAuthSession::state-changed:
379 * @auth_session: the #SignonAuthSession
380 * @state: the current state of the #SignonAuthSession
381 * @message: the message associated with the state change
383 * Emitted when the state of the #SignonAuthSession changes.
384 * FIXME: @state should be registered as a GLib type (or use one from
385 * libgsignond-common)
387 auth_session_signals[STATE_CHANGED] =
388 g_signal_new ("state-changed",
389 G_TYPE_FROM_CLASS (klass),
390 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
394 _signon_marshal_VOID__INT_STRING,
399 object_class->dispose = signon_auth_session_dispose;
400 object_class->finalize = signon_auth_session_finalize;
404 * signon_auth_session_new:
405 * @parent: #SignonIdentity parent object.
406 * @method_name: the name of the authentication method to be used.
407 * @err: a pointer to a location which will contain the error, in case this
410 * Creates a new #SignonAuthSession, which can be used to authenticate using
411 * the specified method.
413 * Returns: a new #SignonAuthSession.
416 signon_auth_session_new (GObject *parent,
417 const gchar *method_name,
420 if (!SIGNON_IS_IDENTITY(parent))
423 signon_error_quark(),
424 SIGNON_ERROR_UNKNOWN,
425 "Parent object is wrong type");
428 SignonIdentity *identity = SIGNON_IDENTITY(parent);
430 DEBUG ("%s %d", G_STRFUNC, __LINE__);
432 SignonAuthSession *self = SIGNON_AUTH_SESSION(g_object_new (
433 SIGNON_TYPE_AUTH_SESSION,
434 "identity", identity,
436 g_return_val_if_fail (self != NULL, NULL);
438 if (!auth_session_priv_init(self, method_name, err))
441 g_warning ("%s returned error: %s", G_STRFUNC, (*err)->message);
443 g_object_unref (self);
451 * signon_auth_session_get_method:
452 * @self: the #SignonAuthSession.
454 * Get the current authentication method.
456 * Returns: the authentication method being used, or %NULL on failure.
459 signon_auth_session_get_method (SignonAuthSession *self)
461 g_return_val_if_fail (SIGNON_IS_AUTH_SESSION (self), NULL);
462 SignonAuthSessionPrivate *priv = self->priv;
464 g_return_val_if_fail (priv != NULL, NULL);
466 return priv->method_name;
470 * SignonAuthSessionQueryAvailableMechanismsCb:
471 * @self: the #SignonAuthSession.
472 * @mechanisms: (transfer full) (type GStrv): list of available mechanisms.
473 * @error: a #GError if an error occurred, %NULL otherwise.
474 * @user_data: the user data that was passed when installing this callback.
476 * Callback to be passed to signon_auth_session_query_available_mechanisms().
480 * signon_auth_session_query_available_mechanisms:
481 * @self: the #SignonAuthSession.
482 * @wanted_mechanisms: a %NULL-terminated list of mechanisms supported by the client.
483 * @cb: (scope async): a callback which will be called with the result.
484 * @user_data: user data to be passed to the callback.
486 * Queries the mechanisms available for this authentication session. The result
487 * will be the intersection between @wanted_mechanisms and the mechanisms
488 * supported by the authentication plugin (and allowed by the #SignonIdentity that this
489 * session belongs to).
492 signon_auth_session_query_available_mechanisms (SignonAuthSession *self,
493 const gchar **wanted_mechanisms,
494 SignonAuthSessionQueryAvailableMechanismsCb cb,
497 g_return_if_fail (SIGNON_IS_AUTH_SESSION (self));
498 SignonAuthSessionPrivate* priv = self->priv;
500 g_return_if_fail (priv != NULL);
502 AuthSessionQueryAvailableMechanismsCbData *cb_data = g_slice_new0 (AuthSessionQueryAvailableMechanismsCbData);
503 cb_data->self = self;
505 cb_data->user_data = user_data;
507 AuthSessionQueryAvailableMechanismsData *operation_data = g_slice_new0 (AuthSessionQueryAvailableMechanismsData);
508 operation_data->wanted_mechanisms = g_strdupv ((gchar **)wanted_mechanisms);
509 operation_data->cb_data = cb_data;
511 auth_session_check_remote_object(self);
512 _signon_object_call_when_ready (self,
513 auth_session_object_quark(),
514 auth_session_query_available_mechanisms_ready_cb,
519 * SignonAuthSessionProcessCb:
520 * @self: the #SignonAuthSession.
521 * @session_data: (transfer full) (element-type utf8 GValue): a dictionary with
523 * @error: a #GError if an error occurred, %NULL otherwise.
524 * @user_data: the user data that was passed when installing this callback.
526 * This callback is invoked when the authentication plugin delivers the result
527 * of the signon_auth_session_process() operation.
531 * signon_auth_session_process:
532 * @self: the #SignonAuthSession.
533 * @session_data: (transfer none) (element-type utf8 GValue): a dictionary of parameters.
534 * @mechanism: the authentication mechanism to be used.
535 * @cb: (scope async): a callback which will be called with the result.
536 * @user_data: user data to be passed to the callback.
538 * Performs one step of the authentication process. If the #SignonIdentity that
539 * this session belongs to contains a username and a password, they will be also
540 * passed to the authentication plugin, otherwise they should be set directly in
542 * @session_data should be used to add additional authentication parameters to the
543 * session, or to override the parameters otherwise taken from the identity.
545 * Deprecated: 1.8: Use signon_auth_session_process_async() instead.
548 signon_auth_session_process (SignonAuthSession *self,
549 const GHashTable *session_data,
550 const gchar* mechanism,
551 SignonAuthSessionProcessCb cb,
554 GVariant *v_session_data;
556 g_return_if_fail (SIGNON_IS_AUTH_SESSION (self));
557 DEBUG ("%s %d", G_STRFUNC, __LINE__);
559 AuthSessionProcessCbData *cb_data = g_slice_new0 (AuthSessionProcessCbData);
561 cb_data->user_data = user_data;
563 v_session_data = signon_hash_table_to_variant (session_data);
565 signon_auth_session_process_async (self, v_session_data, mechanism, NULL,
566 process_async_cb_wrapper, cb_data);
570 * signon_auth_session_process_async:
571 * @self: the #SignonAuthSession.
572 * @session_data: (transfer full): a dictionary of parameters.
573 * @mechanism: the authentication mechanism to be used.
574 * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
575 * @callback: (scope async): a callback which will be called when the
576 * authentication reply is available.
577 * @user_data: user data to be passed to the callback.
579 * Performs one step of the authentication process. If the #SignonIdentity that
580 * this session belongs to contains a username and a password, the daemon will
581 * pass them to the authentication plugin, otherwise they should be set directly in
583 * @session_data should be used to add additional authentication parameters to the
584 * session, or to override the parameters otherwise taken from the identity.
586 * What specific parameters should be used can be found from authentication plugins'
587 * documentation (look for parameters that are expected in gsignond_plugin_request_initial()
588 * for the first step, and parameters that are expected in gsignond_plugin_request() for
589 * the subsequent steps). See, for example, #GSignondPasswordPlugin and #GSignondDigestPlugin.
594 signon_auth_session_process_async (SignonAuthSession *self,
595 GVariant *session_data,
596 const gchar *mechanism,
597 GCancellable *cancellable,
598 GAsyncReadyCallback callback,
601 SignonAuthSessionPrivate *priv;
602 AuthSessionProcessData *process_data;
603 GSimpleAsyncResult *res;
605 g_return_if_fail (SIGNON_IS_AUTH_SESSION (self));
608 g_return_if_fail (session_data != NULL);
610 res = g_simple_async_result_new ((GObject *)self, callback, user_data,
611 signon_auth_session_process_async);
612 g_simple_async_result_set_check_cancellable (res, cancellable);
614 process_data = g_slice_new0 (AuthSessionProcessData);
615 process_data->session_data = g_variant_ref_sink (session_data);
616 process_data->mechanism = g_strdup (mechanism);
617 process_data->cancellable = cancellable;
618 g_object_set_data_full ((GObject *)res, data_key_process, process_data,
619 (GDestroyNotify)auth_session_process_data_free);
623 auth_session_check_remote_object(self);
624 _signon_object_call_when_ready (self,
625 auth_session_object_quark(),
626 auth_session_process_ready_cb,
631 * signon_auth_session_process_finish:
632 * @self: the #SignonAuthSession.
633 * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to
634 * signon_auth_session_process_async().
635 * @error: return location for error, or %NULL.
637 * Collect the result of the signon_auth_session_process_async() operation.
639 * Returns: a #GVariant of type %G_VARIANT_TYPE_VARDICT containing the
640 * authentication reply. As with signon_auth_session_process_async(), specific
641 * parameters contained in the #GVariant can be found from plugins' documentation:
642 * #GSignondPlugin::response-final for the final response, and #GSignondPlugin::response
643 * for the intermediate responses. See, for example, #GSignondPasswordPlugin
644 * and #GSignondDigestPlugin.
649 signon_auth_session_process_finish (SignonAuthSession *self, GAsyncResult *res,
652 GSimpleAsyncResult *async_result;
655 g_return_val_if_fail (SIGNON_IS_AUTH_SESSION (self), NULL);
657 async_result = (GSimpleAsyncResult *)res;
658 if (g_simple_async_result_propagate_error (async_result, error))
661 reply = g_simple_async_result_get_op_res_gpointer (async_result);
662 return g_variant_ref (reply);
666 * signon_auth_session_cancel:
667 * @self: the #SignonAuthSession.
669 * Cancel the authentication session.
672 signon_auth_session_cancel (SignonAuthSession *self)
674 g_return_if_fail (SIGNON_IS_AUTH_SESSION (self));
675 SignonAuthSessionPrivate *priv = self->priv;
677 g_return_if_fail (priv != NULL);
679 auth_session_check_remote_object(self);
684 priv->canceled = TRUE;
685 _signon_object_call_when_ready (self,
686 auth_session_object_quark(),
687 auth_session_cancel_ready_cb,
692 auth_session_state_changed_cb (GDBusProxy *proxy,
697 g_return_if_fail (SIGNON_IS_AUTH_SESSION (user_data));
698 SignonAuthSession *self = SIGNON_AUTH_SESSION (user_data);
700 g_signal_emit ((GObject *)self,
701 auth_session_signals[STATE_CHANGED],
707 static void auth_session_remote_object_destroyed_cb (GDBusProxy *proxy,
710 g_return_if_fail (SIGNON_IS_AUTH_SESSION (user_data));
711 SignonAuthSession *self = SIGNON_AUTH_SESSION (user_data);
712 SignonAuthSessionPrivate *priv = self->priv;
713 g_return_if_fail (priv != NULL);
714 DEBUG ("remote object unregistered");
718 g_object_unref (priv->proxy);
723 * as remote object is destroyed only
724 * when the session core is destroyed,
725 * so there should not be any processes
729 priv->canceled = FALSE;
730 _signon_object_not_ready(self);
734 auth_session_priv_init (SignonAuthSession *self,
735 const gchar *method_name, GError **err)
737 g_return_val_if_fail (SIGNON_IS_AUTH_SESSION (self), FALSE);
738 SignonAuthSessionPrivate *priv = SIGNON_AUTH_SESSION_PRIV (self);
739 g_return_val_if_fail (priv, FALSE);
741 priv->method_name = g_strdup (method_name);
743 priv->registering = FALSE;
745 priv->canceled = FALSE;
750 auth_session_query_mechanisms_reply (GObject *object, GAsyncResult *res,
753 SsoAuthSession *proxy = SSO_AUTH_SESSION (object);
754 gchar **mechanisms = NULL;
755 GError *error = NULL;
756 AuthSessionQueryAvailableMechanismsCbData *cb_data =
757 (AuthSessionQueryAvailableMechanismsCbData *)userdata;
758 g_return_if_fail (cb_data != NULL);
760 sso_auth_session_call_query_available_mechanisms_finish (proxy,
764 if (SIGNON_IS_NOT_CANCELLED (error))
766 (cb_data->cb) (cb_data->self, mechanisms, error, cb_data->user_data);
769 g_clear_error (&error);
770 g_slice_free (AuthSessionQueryAvailableMechanismsCbData, cb_data);
774 auth_session_query_available_mechanisms_ready_cb (gpointer object, const GError *error,
777 g_return_if_fail (SIGNON_IS_AUTH_SESSION (object));
778 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
779 SignonAuthSessionPrivate *priv = self->priv;
780 g_return_if_fail (priv != NULL);
782 AuthSessionQueryAvailableMechanismsData *operation_data =
783 (AuthSessionQueryAvailableMechanismsData *)user_data;
784 g_return_if_fail (operation_data != NULL);
786 AuthSessionQueryAvailableMechanismsCbData *cb_data = operation_data->cb_data;
787 g_return_if_fail (cb_data != NULL);
792 (self, NULL, error, cb_data->user_data);
794 g_slice_free (AuthSessionQueryAvailableMechanismsCbData, cb_data);
798 g_return_if_fail (priv->proxy != NULL);
799 sso_auth_session_call_query_available_mechanisms (
801 (const char **)operation_data->wanted_mechanisms,
803 auth_session_query_mechanisms_reply,
807 auth_session_signals[STATE_CHANGED],
809 SIGNON_AUTH_SESSION_STATE_PROCESS_PENDING,
810 auth_session_process_pending_message);
813 g_strfreev (operation_data->wanted_mechanisms);
814 g_slice_free (AuthSessionQueryAvailableMechanismsData, operation_data);
818 auth_session_cancel_ready_cb (gpointer object, const GError *error, gpointer user_data)
820 g_return_if_fail (SIGNON_IS_AUTH_SESSION (object));
821 g_return_if_fail (user_data == NULL);
823 SignonAuthSession *self = SIGNON_AUTH_SESSION (object);
824 SignonAuthSessionPrivate *priv = self->priv;
825 g_return_if_fail (priv != NULL);
829 //TODO: in general this function does not return any values,
830 // that is why I think it should not emit anything for this particular case
831 DEBUG("error during initialization");
833 else if (priv->proxy && priv->busy)
834 sso_auth_session_call_cancel_sync (priv->proxy,
839 priv->canceled = FALSE;
843 signon_auth_session_complete (SignonAuthSession *self,
845 GDBusConnection *connection,
846 const gchar *bus_name,
847 const gchar *object_path)
849 SignonAuthSessionPrivate *priv = self->priv;
850 g_return_if_fail (priv != NULL);
852 DEBUG ("%s %d", G_STRFUNC, __LINE__);
854 priv->registering = FALSE;
855 if (!g_strcmp0(object_path, "") || error)
858 DEBUG ("Error message is %s", error->message);
860 error = g_error_new (signon_error_quark(),
861 SIGNON_ERROR_RUNTIME,
862 "Cannot create remote AuthSession object");
866 GError *proxy_error = NULL;
869 sso_auth_session_proxy_new_sync (connection,
870 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
875 if (G_UNLIKELY (proxy_error != NULL))
877 g_warning ("Failed to initialize AuthSession proxy: %s",
878 proxy_error->message);
879 g_clear_error (&proxy_error);
882 g_dbus_proxy_set_default_timeout ((GDBusProxy *)priv->proxy,
885 priv->signal_state_changed =
886 g_signal_connect (priv->proxy,
888 G_CALLBACK (auth_session_state_changed_cb),
891 priv->signal_unregistered =
892 g_signal_connect (priv->proxy,
894 G_CALLBACK (auth_session_remote_object_destroyed_cb),
898 DEBUG ("Object path received: %s", object_path);
899 _signon_object_ready (self, auth_session_object_quark (), error);
903 auth_session_check_remote_object(SignonAuthSession *self)
905 g_return_if_fail (self != NULL);
906 SignonAuthSessionPrivate *priv = self->priv;
907 g_return_if_fail (priv != NULL);
909 if (priv->proxy != NULL)
912 g_return_if_fail (priv->identity != NULL);
914 if (!priv->registering)
916 DEBUG ("%s %d", G_STRFUNC, __LINE__);
918 priv->registering = TRUE;
919 signon_identity_get_auth_session (priv->identity,
922 signon_auth_session_complete);