dbus: merge dbus interface
authorJussi Laako <jussi.laako@linux.intel.com>
Tue, 11 Dec 2012 15:36:15 +0000 (17:36 +0200)
committerJussi Laako <jussi.laako@linux.intel.com>
Tue, 11 Dec 2012 15:36:15 +0000 (17:36 +0200)
config: merge config object
interfaces: relocate

39 files changed:
ChangeLog [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/common/Makefile.am [new file with mode: 0644]
src/common/gsignond-log.h [new file with mode: 0644]
src/daemon/Makefile.am [new file with mode: 0644]
src/daemon/db/Makefile.am [new file with mode: 0644]
src/daemon/dbus/Makefile.am [new file with mode: 0644]
src/daemon/dbus/gsignond-dbus-auth-service-adapter.c [new file with mode: 0644]
src/daemon/dbus/gsignond-dbus-auth-service-adapter.h [new file with mode: 0644]
src/daemon/dbus/gsignond-dbus-auth-session-adapter.c [new file with mode: 0644]
src/daemon/dbus/gsignond-dbus-auth-session-adapter.h [new file with mode: 0644]
src/daemon/dbus/gsignond-dbus-identity-adapter.c [new file with mode: 0644]
src/daemon/dbus/gsignond-dbus-identity-adapter.h [new file with mode: 0644]
src/daemon/dbus/gsignond-dbus.h [new file with mode: 0644]
src/daemon/dbus/interfaces/com.google.code.AccountsSSO.SingleSignOn.AuthService.xml [moved from interfaces/com.google.code.AccountsSSO.SingleSignOn.AuthService.xml with 90% similarity]
src/daemon/dbus/interfaces/com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml [moved from interfaces/com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml with 100% similarity]
src/daemon/dbus/interfaces/com.google.code.AccountsSSO.SingleSignOn.Identity.xml [moved from interfaces/com.google.code.AccountsSSO.SingleSignOn.Identity.xml with 100% similarity]
src/daemon/dbus/services/com.google.code.AccountsSSO.SingleSignOn.service.in [new file with mode: 0644]
src/daemon/gsignond-auth-service-iface.c [new file with mode: 0644]
src/daemon/gsignond-auth-service-iface.h [new file with mode: 0644]
src/daemon/gsignond-auth-session-iface.c [new file with mode: 0644]
src/daemon/gsignond-auth-session-iface.h [new file with mode: 0644]
src/daemon/gsignond-config-db.h [new file with mode: 0644]
src/daemon/gsignond-config-dbus.h [new file with mode: 0644]
src/daemon/gsignond-config-general.h [new file with mode: 0644]
src/daemon/gsignond-config.c [new file with mode: 0644]
src/daemon/gsignond-config.h [new file with mode: 0644]
src/daemon/gsignond-daemon.c [new file with mode: 0644]
src/daemon/gsignond-daemon.h [new file with mode: 0644]
src/daemon/gsignond-identity-iface.c [new file with mode: 0644]
src/daemon/gsignond-identity-iface.h [new file with mode: 0644]
src/daemon/gsignond-identity.c [new file with mode: 0644]
src/daemon/gsignond-identity.h [new file with mode: 0644]
src/daemon/main.c [new file with mode: 0644]

diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..782933e
--- /dev/null
@@ -0,0 +1,4 @@
+ACLOCAL_AMFLAGS = -I m4
+
+SUBDIRS = src
+
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..7609c1f
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh -e
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+aclocal #-I m4 
+autoheader 
+libtoolize --copy --force 
+autoconf 
+automake --add-missing --copy
+autoreconf --install --force
+. $srcdir/configure "$@"
+
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..b79d436
--- /dev/null
@@ -0,0 +1,50 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.60])
+AC_INIT([gsignond], [0.1], [])
+AC_CONFIG_SRCDIR([src/daemon/main.c])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
+
+AM_INIT_AUTOMAKE([1.11 -Wall nostdinc silent-rules subdir-objects])
+
+# Checks for programs.
+AC_PROG_CC
+AM_PROG_AR
+
+#libtool
+LT_PREREQ([2.2])
+LT_INIT([disable-static])
+
+# Checks for libraries.
+PKG_CHECK_MODULES([GSIGNOND], 
+                  [glib-2.0 >= 2.30
+                   gio-2.0
+                   gio-unix-2.0
+                   sqlite3])
+AC_SUBST(GSIGNOND_CFLAGS)
+AC_SUBST(GSIGNOND_LIBS)
+
+DBUS_SERVICES_DIR="`pkg-config --variable session_bus_services_dir dbus-1`"
+AC_SUBST(DBUS_SERVICES_DIR)
+DBUS_INTERFACES_DIR="`pkg-config --variable interfaces_dir dbus-1`"
+AC_SUBST(DBUS_INTERFACES_DIR)
+
+# Checks for header files.
+AC_CHECK_HEADERS([string.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+
+AC_OUTPUT([
+Makefile
+src/Makefile
+src/common/Makefile
+src/daemon/Makefile
+src/daemon/db/Makefile
+src/daemon/dbus/Makefile
+src/daemon/dbus/services/com.google.code.AccountsSSO.SingleSignOn.service
+])
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..e9500d6
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS=common daemon
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
new file mode 100644 (file)
index 0000000..c97ef72
--- /dev/null
@@ -0,0 +1,22 @@
+lib_LTLIBRARIES = libgsignond-common.la
+NULL=
+
+libgsignond_common_la_CPPFLAGS = \
+    -I$(top_srcdir) \
+    -I$(top_srcdir)/src \
+    -I$(top_srcdir)/include \
+    $(GSIGNOND_CFLAGS) \
+    $(NULL)
+
+libgsignond_common_la_LIBS = \
+    $(GSIGNOND_LIBS)
+    $(NULL)
+
+libgsignond_common_la_SOURCES = \
+    gsignond-security-context.c \
+    gsignond-error.c \
+    gsignond-error.h \
+    gsignond-log.h \
+    $(NULL)
+
+CLEANFILES = 
diff --git a/src/common/gsignond-log.h b/src/common/gsignond-log.h
new file mode 100644 (file)
index 0000000..57e1430
--- /dev/null
@@ -0,0 +1,35 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of signon
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_LOG_H_
+#define __GSIGNOND_LOG_H_
+/*
+ * TODO: Currently logging is directed to stdio, should resolve this properly
+ */
+#define INFO(frmt, args...) g_print("[I] %s:%d  " frmt "\n", __func__, __LINE__, ##args)
+#define ERR(frmt, args...)  g_print("[E] %s:%d  " frmt "\n", __func__, __LINE__, ##args)
+#define WARN(frmt, args...)  g_print("[W] %s:%d  " frmt "\n", __func__, __LINE__, ##args)
+#define DBG(frmt, args...)  g_print("[D] %s:%d  " frmt "\n", __func__, __LINE__, ##args)
+
+#endif /* __GSIGNOND_LOG_H_ */
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
new file mode 100644 (file)
index 0000000..ef56d9d
--- /dev/null
@@ -0,0 +1,37 @@
+SUBDIRS = db dbus
+NULL=
+
+bin_PROGRAMS = gsignond
+
+gsignond_SOURCES = \
+    main.c \
+    gsignond-config.c \
+    gsignond-config.h \
+    gsignond-auth-service-iface.c \
+    gsignond-auth-service-iface.h \
+    gsignond-auth-session-iface.c \
+    gsignond-auth-session-iface.h \
+    gsignond-identity-iface.c \
+    gsignond-identity-iface.h \
+    gsignond-daemon.c \
+    gsignond-daemon.h \
+    gsignond-identity.c \
+    gsignond-identity.h \
+    $(NULL)
+
+gsignond_CFLAGS = \
+    -DG_LOG_DOMAIN=\"gsignon-daemon\" \
+    -DGSIGNOND_EXTENSIONS_DIR="\"$(libdir)/signon/extensions\"" \
+    -I$(top_srcdir) \
+    -I$(top_builddir)/include/ \
+    -I$(top_builddir)/src/ \
+    $(GSIGNOND_CFLAGS) \
+    $(NULL)
+
+gsignond_LDADD = \
+    $(top_builddir)/src/common/libgsignond-common.la \
+    $(top_builddir)/src/daemon/db/libgsignond-db.la \
+    $(top_builddir)/src/daemon/dbus/libgsignond-dbus.la \
+    $(GSIGNOND_LIBS) \
+    $(NULL)
+
diff --git a/src/daemon/db/Makefile.am b/src/daemon/db/Makefile.am
new file mode 100644 (file)
index 0000000..537f52a
--- /dev/null
@@ -0,0 +1,17 @@
+lib_LTLIBRARIES = libgsignond-db.la
+
+libgsignond_db_la_CPPFLAGS = \
+    -I$(top_srcdir) \
+    -I$(top_srcdir)/src \
+    -I$(top_srcdir)/include \
+    $(GSIGNOND_CFLAGS)
+
+libgsignond_db_la_LIBS = \
+    $(top_srcdir)/src/common/libgsignond-common.la \
+    $(GSIGNOND_LIBS)
+
+libgsignond_db_la_SOURCES = \
+   gsignond-db-error.c \
+   gsignond-db-error.h 
+
+CLEANFILES = 
diff --git a/src/daemon/dbus/Makefile.am b/src/daemon/dbus/Makefile.am
new file mode 100644 (file)
index 0000000..3032930
--- /dev/null
@@ -0,0 +1,80 @@
+NULL=
+INTERFACES_DIR = $(top_srcdir)/src/daemon/dbus/interfaces
+SERVCIES_DIR   = $(top_srcdir)/src/daemon/dbus/services
+DBUS_BUILT_SOURCES = \
+    gsignond-dbus-auth-service-gen.c \
+    gsignond-dbus-auth-service-gen.h \
+    gsignond-dbus-auth-session-gen.c \
+    gsignond-dbus-auth-session-gen.h \
+    gsignond-dbus-identity-gen.c \
+    gsignond-dbus-identity-gen.h \
+    $(NULL)
+
+DBUS_BUILT_DOCS = \
+    gsignond-dbus-auth-service-doc-gen-com.google.code.AccountsSSO.SingleSignOn.AuthService.xml \
+    gsignond-dbus-auth-session-doc-gen-com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml \
+    gsignond-dbus-identity-doc-gen-com.google.code.AccountsSSO.SingleSignOn.Identity.xml \
+    $(NULL)
+
+DBUS_INTERFACE_PREFIX="com.google.code.AccountsSSO.SingleSignOn."
+gsignond-dbus-auth-service-gen.c gsignond-dbus-auth-service-gen.h : $(INTERFACES_DIR)/com.google.code.AccountsSSO.SingleSignOn.AuthService.xml
+       gdbus-codegen                                       \
+       --interface-prefix $(DBUS_INTERFACE_PREFIX)      \
+       --c-namespace GSignondDbus                       \
+       --generate-c-code  gsignond-dbus-auth-service-gen     \
+       --generate-docbook gsignond-dbus-auth-service-doc-gen \
+       $<
+
+gsignond-dbus-auth-session-gen.c gsignond-dbus-auth-session-gen.h : $(INTERFACES_DIR)/com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml
+       gdbus-codegen                                       \
+       --interface-prefix $(DBUS_INTERFACE_PREFIX)      \
+       --c-namespace GSignondDbus                           \
+       --generate-c-code  gsignond-dbus-auth-session-gen     \
+       --generate-docbook gsignond-dbus-auth-session-doc-gen \
+       $<
+
+gsignond-dbus-identity-gen.c gsignond-dbus-identity-gen.h : $(INTERFACES_DIR)/com.google.code.AccountsSSO.SingleSignOn.Identity.xml
+       gdbus-codegen                                       \
+       --interface-prefix $(DBUS_INTERFACE_PREFIX)      \
+       --c-namespace GSignondDbus                           \
+       --generate-c-code  gsignond-dbus-identity-gen         \
+       --generate-docbook gsignond-dbus-identity-doc-gen     \
+       $<
+
+lib_LTLIBRARIES = libgsignond-dbus.la
+
+libgsignond_dbus_la_CPPFLAGS = \
+    -I$(top_srcdir) \
+    -I$(top_srcdir)/src \
+    $(GSIGNOND_CFLAGS) \
+    $(NULL)
+
+libgsignond_dbus_la_LIBS = \
+    $(GSIGNOND_LIBS) \
+    $(NULL)
+
+libgsignond_dbus_la_SOURCES = \
+   $(DBUS_BUILT_SOURCES) \
+   gsignond-dbus.h \
+   gsignond-dbus-auth-service-adapter.c \
+   gsignond-dbus-auth-service-adapter.h \
+   gsignond-dbus-auth-session-adapter.c \
+   gsignond-dbus-auth-session-adapter.h \
+   gsignond-dbus-identity-adapter.c \
+   gsignond-dbus-identity-adapter.h \
+   $(NULL)
+
+dbusservicedir = $(DBUS_SERVICES_DIR)
+dbusservice_DATA = $(SERVCIES_DIR)/com.google.code.AccountsSSO.SingleSignOn.service
+
+dbusinterfacesdir = $(DBUS_INTERFACES_DIR)
+dbusinterfaces_DATA = \
+    $(INTERFACES_DIR)/com.google.code.AccountsSSO.SingleSignOn.AuthService.xml \
+    $(INTERFACES_DIR)/com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml \
+    $(INTERFACES_DIR)/com.google.code.AccountsSSO.SingleSignOn.Identity.xml 
+
+EXTRA_DIST = dbusservice
+
+clean-local :
+       rm -f *~ $(DBUS_BUILT_SOURCES) $(DBUS_BUILT_DOCS)
+
diff --git a/src/daemon/dbus/gsignond-dbus-auth-service-adapter.c b/src/daemon/dbus/gsignond-dbus-auth-service-adapter.c
new file mode 100644 (file)
index 0000000..d948e2f
--- /dev/null
@@ -0,0 +1,307 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of signon
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-dbus-auth-service-adapter.h"
+#include "gsignond-dbus.h"
+#include <common/gsignond-log.h>
+
+enum
+{
+    PROP_0,
+
+    PROP_IMPL,
+    N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES];
+
+struct _GSignondDbusAuthServiceAdapterPrivate
+{
+    GDBusConnection     *connection;
+    GSignondAuthServiceIface *parent;
+};
+
+G_DEFINE_TYPE (GSignondDbusAuthServiceAdapter, gsignond_dbus_auth_service_adapter, GSIGNOND_DBUS_TYPE_AUTH_SERVICE_SKELETON)
+
+
+#define GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER_GET_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_AUTH_SERVICE_ADAPTER, GSignondDbusAuthServiceAdapterPrivate)
+
+static void _handle_register_new_identity (GSignondDbusAuthServiceAdapter *, GDBusMethodInvocation *, 
+                                           const GVariant *, gpointer);
+static void _handle_get_identity (GSignondDbusAuthServiceAdapter *, GDBusMethodInvocation *, guint32, 
+                                  const GVariant *, gpointer);
+static void _handle_get_auth_session_object_path (GSignondDbusAuthServiceAdapter *,
+                                                  GDBusMethodInvocation *,
+                                                  guint32, const gchar *, const GVariant *, gpointer);
+static void _handle_query_methods (GSignondDbusAuthServiceAdapter *,
+                                   GDBusMethodInvocation *,
+                                   gpointer);
+static void _handle_query_mechanisms (GSignondDbusAuthServiceAdapter *,
+                                      GDBusMethodInvocation *,
+                                      const gchar *, gpointer);
+static void _handle_query_identities (GSignondDbusAuthServiceAdapter *,
+                                      GDBusMethodInvocation *,
+                                      const GVariant*, gpointer);
+static void _handle_clear (GSignondDbusAuthServiceAdapter *, GDBusMethodInvocation *, gpointer);
+
+static void
+gsignond_dbus_auth_service_adapter_set_property (GObject *object,
+        guint property_id,
+        const GValue *value, GParamSpec *pspec)
+{
+    GSignondDbusAuthServiceAdapter *self = GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER (object);
+
+    switch (property_id) {
+        case PROP_IMPL: {
+            gpointer iface = g_value_peek_pointer (value);
+            if (iface) {
+                if (self->priv->parent) g_object_unref (self->priv->parent);
+                self->priv->parent = GSIGNOND_AUTH_SERVICE_IFACE (g_object_ref (iface));
+            }
+            break;
+        }
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+gsignond_dbus_auth_service_adapter_get_property (GObject *object,
+        guint property_id,
+        GValue *value, 
+        GParamSpec *pspec)
+{
+    GSignondDbusAuthServiceAdapter *self = GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER (object);
+
+    switch (property_id) {
+        case PROP_IMPL: {
+            g_value_set_instance (value, g_object_ref (self->priv->parent));
+            break;
+        }
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+gsignond_dbus_auth_service_adapter_dispose (GObject *object)
+{
+    GSignondDbusAuthServiceAdapter *self = GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER (object);
+
+    if (self->priv->parent) {
+        g_object_unref (self->priv->parent);
+        self->priv->parent = NULL;
+    }
+
+    if (self->priv->connection) {
+        g_object_unref (self->priv->connection);
+        self->priv->connection = NULL;
+    }
+}
+
+static void
+gsignond_dbus_auth_service_adapter_finalize (GObject *object)
+{
+    g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (object));
+
+    G_OBJECT_CLASS (gsignond_dbus_auth_service_adapter_parent_class)->finalize (object);
+}
+
+static void
+gsignond_dbus_auth_service_adapter_class_init (GSignondDbusAuthServiceAdapterClass *klass)
+{
+    GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+    g_type_class_add_private (object_class, sizeof (GSignondDbusAuthServiceAdapterPrivate));
+
+    object_class->get_property = gsignond_dbus_auth_service_adapter_get_property;
+    object_class->set_property = gsignond_dbus_auth_service_adapter_set_property;
+    object_class->dispose = gsignond_dbus_auth_service_adapter_dispose;
+    object_class->finalize = gsignond_dbus_auth_service_adapter_finalize;
+
+    properties[PROP_IMPL] = g_param_spec_object ("auth-session-impl",
+                                                  "Auth session impl",
+                                                  "AuthSessionIface implementation object",
+                                                  GSIGNOND_TYPE_AUTH_SERVICE_IFACE,
+                                                  G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+    g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static void
+gsignond_dbus_auth_service_adapter_init (GSignondDbusAuthServiceAdapter *self)
+{
+    GError *err = 0;
+
+    self->priv = GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER_GET_PRIV(self);
+
+    self->priv->connection = 0;
+    self->priv->parent = 0;
+
+    self->priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &err);
+    if (err) {
+        ERR ("Error getting session bus :%s", err->message);
+        g_error_free (err);
+        return;
+    }
+
+    if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self),
+                                           self->priv->connection,
+                                           GSIGNOND_DAEMON_OBJECTPATH,
+                                           &err)) {
+        ERR ("failed to register object: %s", err->message);
+        g_error_free (err);
+        return ;
+    }
+
+    g_signal_connect (self, "handle-register-new-identity", G_CALLBACK (_handle_register_new_identity), NULL);
+    g_signal_connect (self, "handle-get-identity", G_CALLBACK(_handle_get_identity), NULL);
+    g_signal_connect (self, "handle-get-auth-session-object-path", G_CALLBACK(_handle_get_auth_session_object_path), NULL);
+    g_signal_connect (self, "handle-query-methods", G_CALLBACK(_handle_query_methods), NULL);
+    g_signal_connect (self, "handle-query-mechanisms", G_CALLBACK(_handle_query_mechanisms), NULL);
+    g_signal_connect (self, "handle-query-identities", G_CALLBACK(_handle_query_identities), NULL);
+    g_signal_connect (self, "handle-clear", G_CALLBACK(_handle_clear), NULL);
+
+}
+
+static void
+_handle_register_new_identity (GSignondDbusAuthServiceAdapter *self,
+                               GDBusMethodInvocation *invocation,
+                               const GVariant *app_context,
+                               gpointer user_data)
+{
+    GSignondDbusAuthService *iface = GSIGNOND_DBUS_AUTH_SERVICE (self);
+    const gchar *object_path = gsignond_auth_service_iface_register_new_identity (self->priv->parent, app_context);
+    if (object_path) {
+        gsignond_dbus_auth_service_complete_register_new_identity (iface, invocation, object_path);
+    }
+    else {
+        /* 
+         * TODO: Prepare error
+         * GError *err = g_error_new ();
+         * g_dbus_method_invocation_return_gerror (invocation, err);
+         * g_error_free (err);
+         */
+    }
+}
+
+static void
+_handle_get_identity (GSignondDbusAuthServiceAdapter *self,
+                      GDBusMethodInvocation *invocation,
+                      guint32 id,
+                      const GVariant *app_context,
+                      gpointer user_data)
+{
+    gchar *object_path = 0;
+    GVariant *identity_data = 0;
+    gboolean res;
+    GSignondDbusAuthService *iface = GSIGNOND_DBUS_AUTH_SERVICE (self);
+
+    res = gsignond_auth_service_iface_get_identity (self->priv->parent, id, app_context, &object_path, &identity_data);
+
+    if (res = TRUE) {
+        gsignond_dbus_auth_service_complete_get_identity (iface, invocation, object_path, identity_data);
+    }
+    else {
+        /*
+         * TODO: Prepare error
+         * GError *err = g_error_new ();
+         * g_dbus_method_invocation_return_gerror (invocation, err);
+         * g_error_free (err);
+         */
+    }
+}
+
+static void
+_handle_get_auth_session_object_path (GSignondDbusAuthServiceAdapter *self,
+                                      GDBusMethodInvocation *invocation,
+                                      guint32 id,
+                                      const gchar *type,
+                                      const GVariant *app_context,
+                                      gpointer user_data)
+{
+    GSignondDbusAuthService *iface = GSIGNOND_DBUS_AUTH_SERVICE (self);
+    const gchar *object_path = gsignond_auth_service_iface_get_auth_session_object_path (self->priv->parent, id, type, app_context);
+
+    gsignond_dbus_auth_service_complete_get_auth_session_object_path (iface, invocation, object_path);
+}
+
+static void
+_handle_query_methods (GSignondDbusAuthServiceAdapter   *self,
+                       GDBusMethodInvocation *invocation,
+                       gpointer               user_data)
+{
+    GSignondDbusAuthService *iface = GSIGNOND_DBUS_AUTH_SERVICE (self);
+    gchar **methods = gsignond_auth_service_iface_query_methods (self->priv->parent);
+
+    gsignond_dbus_auth_service_complete_query_methods (iface, invocation, (const gchar * const*)methods);
+    if (methods) g_strfreev(methods);
+}
+
+static void
+_handle_query_mechanisms (GSignondDbusAuthServiceAdapter *self,
+                          GDBusMethodInvocation *invocation,
+                          const gchar *method,
+                          gpointer user_data)
+{
+    gchar **mechanisms = 0;
+    GSignondDbusAuthService *iface = GSIGNOND_DBUS_AUTH_SERVICE (self);
+
+    mechanisms = gsignond_auth_service_iface_query_mechanisms (self->priv->parent, method);
+
+    gsignond_dbus_auth_service_complete_query_mechanisms (iface, invocation, (const gchar* const*)mechanisms);
+
+    if (mechanisms) g_strfreev(mechanisms);
+}
+
+static void
+_handle_query_identities (GSignondDbusAuthServiceAdapter *self,
+                          GDBusMethodInvocation *invocation,
+                          const GVariant *filter,
+                          gpointer user_data)
+{
+    GSignondDbusAuthService *iface = GSIGNOND_DBUS_AUTH_SERVICE (self);
+    GVariant *identities = gsignond_auth_service_iface_query_identities (self->priv->parent, filter);
+
+    gsignond_dbus_auth_service_complete_query_identities (iface, invocation, identities);
+}
+
+static void
+_handle_clear (GSignondDbusAuthServiceAdapter *self,
+               GDBusMethodInvocation *invocation,
+               gpointer user_data)
+{
+    gboolean res ;
+    GSignondDbusAuthService *iface = GSIGNOND_DBUS_AUTH_SERVICE (self);
+
+    res = gsignond_auth_service_iface_clear (self->priv->parent);
+
+    gsignond_dbus_auth_service_complete_clear (iface, invocation, res);
+}
+
+GSignondDbusAuthServiceAdapter * gsignond_dbus_auth_service_adapter_new (GSignondAuthServiceIface *impl)
+{
+    return GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER (g_object_new (GSIGNOND_TYPE_AUTH_SERVICE_ADAPTER, "auth-session-impl", impl, NULL));
+}
+
diff --git a/src/daemon/dbus/gsignond-dbus-auth-service-adapter.h b/src/daemon/dbus/gsignond-dbus-auth-service-adapter.h
new file mode 100644 (file)
index 0000000..23ee780
--- /dev/null
@@ -0,0 +1,64 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of signon
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER_H_
+#define __GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER_H_
+
+#include <glib.h>
+#include <daemon/gsignond-auth-service-iface.h>
+#include "gsignond-dbus-auth-service-gen.h"
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_AUTH_SERVICE_ADAPTER            (gsignond_dbus_auth_service_adapter_get_type())
+#define GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GSIGNOND_TYPE_AUTH_SERVICE_ADAPTER, GSignondDbusAuthServiceAdapter))
+#define GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), GSIGNOND_TYPE_AUTH_SERVICE_ADAPTER, GSignondDbusAuthServiceAdapterClass))
+#define GSIGNOND_IS_AUTH_SERVICE_ADAPTER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSIGNOND_TYPE_AUTH_SERVICE_ADAPTER))
+#define GSIGNOND_IS_AUTH_SERVICE_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSIGNOND_TYPE_AUTH_SERVICE_ADAPTER))
+#define GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GSIGNOND_TYPE_AUTH_SERVICE_ADAPTER, GSignondDbusAuthServiceAdapterClass))
+
+typedef struct _GSignondDbusAuthServiceAdapter GSignondDbusAuthServiceAdapter;
+typedef struct _GSignondDbusAuthServiceAdapterClass GSignondDbusAuthServiceAdapterClass;
+typedef struct _GSignondDbusAuthServiceAdapterPrivate GSignondDbusAuthServiceAdapterPrivate;
+
+struct _GSignondDbusAuthServiceAdapter
+{
+    GSignondDbusAuthServiceSkeleton parent;
+
+    /* priv */
+    GSignondDbusAuthServiceAdapterPrivate *priv;
+};
+
+struct _GSignondDbusAuthServiceAdapterClass
+{
+    GSignondDbusAuthServiceSkeletonClass parent_class;
+};
+
+GType gsignond_dbus_auth_service_adapter_get_type (void) G_GNUC_CONST;
+
+GSignondDbusAuthServiceAdapter * gsignond_dbus_auth_service_adapter_new (GSignondAuthServiceIface *parent);
+
+G_END_DECLS
+
+#endif /* __GSIGNOND_DBUS_AUTH_SERVICE_ADAPTER_H_ */
diff --git a/src/daemon/dbus/gsignond-dbus-auth-session-adapter.c b/src/daemon/dbus/gsignond-dbus-auth-session-adapter.c
new file mode 100644 (file)
index 0000000..3138ff5
--- /dev/null
@@ -0,0 +1,269 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of signon
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-dbus-auth-session-adapter.h"
+#include "gsignond-dbus.h"
+#include <common/gsignond-log.h>
+
+enum
+{
+    PROP_0,
+
+    PROP_IMPL,
+    PROP_OBJECT_PATH,
+    N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES];
+
+struct _GSignondDbusAuthSessionAdapterPrivate
+{
+    GDBusConnection     *connection;
+    GSignondAuthSessionIface *parent;
+    gchar *object_path;
+};
+
+G_DEFINE_TYPE (GSignondDbusAuthSessionAdapter, gsignond_dbus_auth_session_adapter, GSIGNOND_DBUS_TYPE_AUTH_SESSION_SKELETON)
+
+
+#define GSIGNOND_DBUS_AUTH_SESSION_ADAPTER_GET_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_AUTH_SESSION_ADAPTER, GSignondDbusAuthSessionAdapterPrivate)
+
+static void _handle_query_available_mechanisms (GSignondDbusAuthSessionAdapter *, GDBusMethodInvocation *, const gchar **, gpointer);
+static void _handle_process (GSignondDbusAuthSessionAdapter *, GDBusMethodInvocation *, const GVariant *, const gchar *, gpointer);
+static void _handle_cancel (GSignondDbusAuthSessionAdapter *, GDBusMethodInvocation *, gpointer);
+static void _handle_set_id (GSignondDbusAuthSessionAdapter *, GDBusMethodInvocation *, guint32, gpointer);
+
+static void
+gsignond_dbus_auth_session_adapter_set_property (GObject *object,
+        guint property_id,
+        const GValue *value, GParamSpec *pspec)
+{
+    GSignondDbusAuthSessionAdapter *self = GSIGNOND_DBUS_AUTH_SESSION_ADAPTER (object);
+
+    switch (property_id) {
+        case PROP_IMPL: {
+            gpointer iface = g_value_peek_pointer (value);
+            if (iface) {
+                if (self->priv->parent) g_object_unref (self->priv->parent);
+                self->priv->parent = GSIGNOND_AUTH_SESSION_IFACE (g_object_ref (iface));
+            }
+            break;
+        }
+        case PROP_OBJECT_PATH: {
+            const gchar *name = g_value_get_string (value);
+            if (name) {
+                if (self->priv->object_path) g_free (self->priv->object_path);
+
+                self->priv->object_path = g_strdup (name);
+            }
+            break;
+        }
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+gsignond_dbus_auth_session_adapter_get_property (GObject *object,
+        guint property_id,
+        GValue *value, 
+        GParamSpec *pspec)
+{
+    GSignondDbusAuthSessionAdapter *self = GSIGNOND_DBUS_AUTH_SESSION_ADAPTER (object);
+
+    switch (property_id) {
+        case PROP_IMPL: {
+            g_value_set_instance (value, g_object_ref (self->priv->parent));
+            break;
+        }
+        case PROP_OBJECT_PATH: {
+            g_value_set_string (value, self->priv->object_path);
+            break;
+        }
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+gsignond_dbus_auth_session_adapter_dispose (GObject *object)
+{
+    GSignondDbusAuthSessionAdapter *self = GSIGNOND_DBUS_AUTH_SESSION_ADAPTER (object);
+
+    if (self->priv->parent) {
+        g_object_unref (self->priv->parent);
+        self->priv->parent = NULL;
+    }
+
+    if (self->priv->connection) {
+        g_object_unref (self->priv->connection);
+        self->priv->connection = NULL;
+    }
+}
+
+static void
+gsignond_dbus_auth_session_adapter_finalize (GObject *object)
+{
+    GSignondDbusAuthSessionAdapter *self = GSIGNOND_DBUS_AUTH_SESSION_ADAPTER (object);
+
+    g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (object));
+
+    if (self->priv->object_path) {
+        g_free (self->priv->object_path);
+        self->priv->object_path = NULL;
+    }
+
+    G_OBJECT_CLASS (gsignond_dbus_auth_session_adapter_parent_class)->finalize (object);
+}
+
+static void
+gsignond_dbus_auth_session_adapter_class_init (GSignondDbusAuthSessionAdapterClass *klass)
+{
+    GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+    g_type_class_add_private (object_class, sizeof (GSignondDbusAuthSessionAdapterPrivate));
+
+    object_class->get_property = gsignond_dbus_auth_session_adapter_get_property;
+    object_class->set_property = gsignond_dbus_auth_session_adapter_set_property;
+    object_class->dispose = gsignond_dbus_auth_session_adapter_dispose;
+    object_class->finalize = gsignond_dbus_auth_session_adapter_finalize;
+
+    properties[PROP_IMPL] = g_param_spec_object ("auth-session-impl",
+                                                  "Auth session impl",
+                                                  "AuthSessionIface implementation object",
+                                                  GSIGNOND_TYPE_AUTH_SESSION_IFACE,
+                                                  G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+    g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static void
+gsignond_dbus_auth_session_adapter_init (GSignondDbusAuthSessionAdapter *self)
+{
+    static guint32 object_counter;
+    GError *err = 0;
+
+    self->priv = GSIGNOND_DBUS_AUTH_SESSION_ADAPTER_GET_PRIV(self);
+
+    self->priv->connection = 0;
+    self->priv->parent = 0;
+    self->priv->object_path = g_strdup_printf ("%s/AuthSession_%d", GSIGNOND_DAEMON_OBJECTPATH, object_counter++);
+
+
+    self->priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &err);
+    if (err) {
+        ERR ("Error getting session bus :%s", err->message);
+        g_error_free (err);
+        return;
+    }
+
+    if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self),
+                                           self->priv->connection,
+                                           self->priv->object_path,
+                                           &err)) {
+        ERR ("failed to register object: %s", err->message);
+        g_error_free (err);
+        return ;
+    }
+
+    g_signal_connect (self, "handle-query-available-mechanisms", G_CALLBACK (_handle_query_available_mechanisms), NULL);
+    g_signal_connect (self, "handle-process", G_CALLBACK(_handle_process), NULL);
+    g_signal_connect (self, "handle-cancel", G_CALLBACK(_handle_cancel), NULL);
+    g_signal_connect (self, "handle-set-id", G_CALLBACK(_handle_set_id), NULL);
+}
+
+static void
+_handle_query_available_mechanisms (GSignondDbusAuthSessionAdapter *self,
+                                    GDBusMethodInvocation *invocation,
+                                    const gchar **wanted_mechanisms,
+                                    gpointer user_data)
+{
+    GSignondDbusAuthSession *iface = GSIGNOND_DBUS_AUTH_SESSION (self);
+    gchar **mechanisms = gsignond_auth_session_iface_query_available_mechanisms (self->priv->parent, wanted_mechanisms);
+
+    if (mechanisms) {
+        gsignond_dbus_auth_session_complete_query_available_mechanisms (iface, invocation, (const gchar * const *)mechanisms);
+        g_strfreev (mechanisms);
+    }
+    else {
+        /* 
+         * TODO: Prepare error
+         * GError *err = g_error_new ();
+         * g_dbus_method_invocation_return_gerror (invocation, err);
+         * g_error_free (err);
+         */
+    }
+}
+
+static void
+_handle_process (GSignondDbusAuthSessionAdapter *self,
+                 GDBusMethodInvocation *invocation,
+                 const GVariant *session_data,
+                 const gchar *mechanisms,
+                 gpointer user_data)
+{
+    GSignondDbusAuthSession *iface = GSIGNOND_DBUS_AUTH_SESSION (self);
+    GVariant *data = 0;
+
+    data = gsignond_auth_session_iface_process (self->priv->parent, session_data, mechanisms);
+
+    if (data) {
+        gsignond_dbus_auth_session_complete_process (iface, invocation, data);
+        g_variant_unref (data);
+    }
+    else {
+        /*
+         * TODO: Prepare error
+         * GError *err = g_error_new ();
+         * g_dbus_method_invocation_return_gerror (invocation, err);
+         * g_error_free (err);
+         */
+    }
+}
+
+static void
+_handle_cancel (GSignondDbusAuthSessionAdapter *self,
+                GDBusMethodInvocation *invocation,
+                gpointer user_data)
+{
+    GSignondDbusAuthSession *iface = GSIGNOND_DBUS_AUTH_SESSION (self);
+    
+    gsignond_auth_session_iface_cancel (self->priv->parent);
+
+    gsignond_dbus_auth_session_complete_cancel (iface, invocation);
+}
+
+static void
+_handle_set_id (GSignondDbusAuthSessionAdapter   *self,
+                GDBusMethodInvocation *invocation,
+                guint32 id,
+                gpointer user_data)
+{
+    GSignondDbusAuthSession *iface = GSIGNOND_DBUS_AUTH_SESSION (self);
+
+    gsignond_auth_session_iface_set_id (self->priv->parent, id);
+
+    gsignond_dbus_auth_session_complete_set_id (iface, invocation);
+}
+
diff --git a/src/daemon/dbus/gsignond-dbus-auth-session-adapter.h b/src/daemon/dbus/gsignond-dbus-auth-session-adapter.h
new file mode 100644 (file)
index 0000000..db5a472
--- /dev/null
@@ -0,0 +1,64 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of signon
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_DBUS_AUTH_SESSION_ADAPTER_H_
+#define __GSIGNOND_DBUS_AUTH_SESSION_ADAPTER_H_
+
+#include <glib.h>
+#include <daemon/gsignond-auth-session-iface.h>
+#include "gsignond-dbus-auth-session-gen.h"
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_AUTH_SESSION_ADAPTER            (gsignond_dbus_auth_session_adapter_get_type())
+#define GSIGNOND_DBUS_AUTH_SESSION_ADAPTER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GSIGNOND_TYPE_AUTH_SESSION_ADAPTER, GSignondDbusAuthSessionAdapter))
+#define GSIGNOND_DBUS_AUTH_SESSION_ADAPTER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), GSIGNOND_TYPE_AUTH_SESSION_ADAPTER, GSignondDbusAuthSessionAdapterClass))
+#define GSIGNOND_IS_AUTH_SESSION_ADAPTER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSIGNOND_TYPE_AUTH_SESSION_ADAPTER))
+#define GSIGNOND_IS_AUTH_SESSION_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSIGNOND_TYPE_AUTH_SESSION_ADAPTER))
+#define GSIGNOND_DBUS_AUTH_SESSION_ADAPTER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GSIGNOND_TYPE_AUTH_SESSION_ADAPTER, GSignondDbusAuthSessionAdapterClass))
+
+typedef struct _GSignondDbusAuthSessionAdapter GSignondDbusAuthSessionAdapter;
+typedef struct _GSignondDbusAuthSessionAdapterClass GSignondDbusAuthSessionAdapterClass;
+typedef struct _GSignondDbusAuthSessionAdapterPrivate GSignondDbusAuthSessionAdapterPrivate;
+
+struct _GSignondDbusAuthSessionAdapter
+{
+    GSignondDbusAuthSessionSkeleton parent;
+
+    /* priv */
+    GSignondDbusAuthSessionAdapterPrivate *priv;
+};
+
+struct _GSignondDbusAuthSessionAdapterClass
+{
+    GSignondDbusAuthSessionSkeletonClass parent_class;
+};
+
+GType gsignond_dbus_auth_session_adapter_get_type (void) G_GNUC_CONST;
+
+GSignondDbusAuthSessionAdapter * gsignond_dbus_auth_session_adapter_new (GSignondAuthSessionIface *parent);
+
+G_END_DECLS
+
+#endif /* __GSIGNOND_DBUS_AUTH_SESSION_ADAPTER_H_ */
diff --git a/src/daemon/dbus/gsignond-dbus-identity-adapter.c b/src/daemon/dbus/gsignond-dbus-identity-adapter.c
new file mode 100644 (file)
index 0000000..0cd398f
--- /dev/null
@@ -0,0 +1,349 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of signon
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-dbus-identity-adapter.h"
+#include "gsignond-dbus.h"
+#include <common/gsignond-log.h>
+
+enum
+{
+    PROP_0,
+
+    PROP_IMPL,
+    PROP_OBJECT_PATH,
+    N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES];
+
+struct _GSignondDbusIdentityAdapterPrivate
+{
+    GDBusConnection       *connection;
+    GSignondIdentityIface *parent;
+    gchar *object_path;
+};
+
+G_DEFINE_TYPE (GSignondDbusIdentityAdapter, gsignond_dbus_identity_adapter, GSIGNOND_DBUS_TYPE_IDENTITY_SKELETON)
+
+
+#define GSIGNOND_DBUS_IDENTITY_ADAPTER_GET_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_IDENTITY_ADAPTER, GSignondDbusIdentityAdapterPrivate)
+
+static void _handle_request_credentials_update (GSignondDbusIdentityAdapter *, GDBusMethodInvocation *, const gchar*, gpointer);
+static void _handle_get_info (GSignondDbusIdentityAdapter *, GDBusMethodInvocation *, gpointer);
+static void _handle_verify_user (GSignondDbusIdentityAdapter *, GDBusMethodInvocation *, const GVariant *, gpointer);
+static void _handle_verify_secret (GSignondDbusIdentityAdapter *, GDBusMethodInvocation *, const gchar *, gpointer);
+static void _handle_remove (GSignondDbusIdentityAdapter *, GDBusMethodInvocation *, gpointer);
+static void _handle_sign_out (GSignondDbusIdentityAdapter *, GDBusMethodInvocation *, gpointer);
+static void _handle_store (GSignondDbusIdentityAdapter *, GDBusMethodInvocation *, const GVariant *, gpointer);
+static void _handle_add_reference (GSignondDbusIdentityAdapter *, GDBusMethodInvocation *, const gchar *, gpointer);
+static void _handle_remove_reference (GSignondDbusIdentityAdapter *, GDBusMethodInvocation *, const gchar *, gpointer);
+
+static void
+gsignond_dbus_identity_adapter_set_property (GObject *object,
+        guint property_id,
+        const GValue *value, GParamSpec *pspec)
+{
+    GSignondDbusIdentityAdapter *self = GSIGNOND_DBUS_IDENTITY_ADAPTER (object);
+
+    switch (property_id) {
+        case PROP_IMPL: {
+            gpointer iface = g_value_peek_pointer (value);
+            if (iface) {
+                if (self->priv->parent) g_object_unref (self->priv->parent);
+                self->priv->parent = GSIGNOND_IDENTITY_IFACE (g_object_ref (iface));
+            }
+            break;
+        }
+        case PROP_OBJECT_PATH: {
+            const gchar *name = g_value_get_string (value);
+            if (name) {
+                if (self->priv->object_path) g_free (self->priv->object_path);
+
+                self->priv->object_path = g_strdup (name);
+            }
+            break;
+        }
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+gsignond_dbus_identity_adapter_get_property (GObject *object,
+        guint property_id,
+        GValue *value, 
+        GParamSpec *pspec)
+{
+    GSignondDbusIdentityAdapter *self = GSIGNOND_DBUS_IDENTITY_ADAPTER (object);
+
+    switch (property_id) {
+        case PROP_IMPL: {
+            g_value_set_instance (value, g_object_ref (self->priv->parent));
+            break;
+        }
+        case PROP_OBJECT_PATH: {
+            g_value_set_string (value, self->priv->object_path);
+            break;
+        }
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+gsignond_dbus_identity_adapter_dispose (GObject *object)
+{
+    GSignondDbusIdentityAdapter *self = GSIGNOND_DBUS_IDENTITY_ADAPTER (object);
+
+    if (self->priv->parent) {
+        g_object_unref (self->priv->parent);
+        self->priv->parent = NULL;
+    }
+
+    if (self->priv->connection) {
+        g_object_unref (self->priv->connection);
+        self->priv->connection = NULL;
+    }
+}
+
+static void
+gsignond_dbus_identity_adapter_finalize (GObject *object)
+{
+    GSignondDbusIdentityAdapter *self = GSIGNOND_DBUS_IDENTITY_ADAPTER (object);
+
+    g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (object));
+
+    if (self->priv->object_path) {
+        g_free (self->priv->object_path);
+        self->priv->object_path = NULL;
+    }
+
+    G_OBJECT_CLASS (gsignond_dbus_identity_adapter_parent_class)->finalize (object);
+}
+
+static void
+gsignond_dbus_identity_adapter_class_init (GSignondDbusIdentityAdapterClass *klass)
+{
+    GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+    g_type_class_add_private (object_class, sizeof (GSignondDbusIdentityAdapterPrivate));
+
+    object_class->get_property = gsignond_dbus_identity_adapter_get_property;
+    object_class->set_property = gsignond_dbus_identity_adapter_set_property;
+    object_class->dispose = gsignond_dbus_identity_adapter_dispose;
+    object_class->finalize = gsignond_dbus_identity_adapter_finalize;
+
+    properties[PROP_IMPL] = g_param_spec_object ("auth-session-impl",
+                                                  "Auth session impl",
+                                                  "AuthSessionIface implementation object",
+                                                  GSIGNOND_TYPE_IDENTITY_IFACE,
+                                                  G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+    properties[PROP_OBJECT_PATH] = g_param_spec_string ("object-path",
+                                                        "Object path",
+                                                        "dbus object path of the identity",
+                                                        NULL,
+                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+    g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static void
+gsignond_dbus_identity_adapter_init (GSignondDbusIdentityAdapter *self)
+{
+    static guint32 object_counter;
+    GError *err = 0;
+
+    self->priv = GSIGNOND_DBUS_IDENTITY_ADAPTER_GET_PRIV(self);
+
+    self->priv->connection = 0;
+    self->priv->parent = 0;
+    self->priv->object_path = g_strdup_printf ("%s/Identity_%d", GSIGNOND_DAEMON_OBJECTPATH, object_counter++);
+
+
+    self->priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &err);
+    if (err) {
+        ERR ("Error getting session bus :%s", err->message);
+        g_error_free (err);
+        return;
+    }
+
+    if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self),
+                                           self->priv->connection,
+                                           self->priv->object_path,
+                                           &err)) {
+        ERR ("failed to register object: %s", err->message);
+        g_error_free (err);
+        return ;
+    }
+
+    g_signal_connect (self, "handle-request-credentials-update", G_CALLBACK (_handle_request_credentials_update), NULL);
+    g_signal_connect (self, "handle-get-info", G_CALLBACK(_handle_get_info), NULL);
+    g_signal_connect (self, "handle-verify-user", G_CALLBACK(_handle_verify_user), NULL);
+    g_signal_connect (self, "handle-verify-secret", G_CALLBACK(_handle_verify_secret), NULL);
+    g_signal_connect (self, "handle-remvoe", G_CALLBACK(_handle_remove), NULL);
+    g_signal_connect (self, "handle-sign-out", G_CALLBACK(_handle_sign_out), NULL);
+    g_signal_connect (self, "handle-store", G_CALLBACK(_handle_store), NULL);
+    g_signal_connect (self, "handle-add-reference", G_CALLBACK(_handle_add_reference), NULL);
+    g_signal_connect (self, "handle-remove-reference", G_CALLBACK(_handle_remove_reference), NULL);
+
+}
+
+static void
+_handle_request_credentials_update (GSignondDbusIdentityAdapter *self,
+                                    GDBusMethodInvocation *invocation,
+                                    const gchar *message,
+                                    gpointer user_data)
+{
+    GSignondDbusIdentity *iface = GSIGNOND_DBUS_IDENTITY (self);
+    guint32 id = gsignond_identity_iface_request_credentials_update (self->priv->parent, message);
+    if (id) {
+        gsignond_dbus_identity_complete_request_credentials_update (iface, invocation, id);
+    }
+    else {
+        /* 
+         * TODO: Prepare error
+         * GError *err = g_error_new ();
+         * g_dbus_method_invocation_return_gerror (invocation, err);
+         * g_error_free (err);
+         */
+    }
+}
+
+static void
+_handle_get_info (GSignondDbusIdentityAdapter *self,
+                  GDBusMethodInvocation *invocation,
+                  gpointer user_data)
+{
+    GVariant *identity_data = 0;
+    GSignondDbusIdentity *iface = GSIGNOND_DBUS_IDENTITY (self);
+
+    identity_data = gsignond_identity_iface_get_info (self->priv->parent);
+
+    if (identity_data) {
+        gsignond_dbus_identity_complete_get_info (iface, invocation, identity_data);
+    }
+    else {
+        /*
+         * TODO: Prepare error
+         * GError *err = g_error_new ();
+         * g_dbus_method_invocation_return_gerror (invocation, err);
+         * g_error_free (err);
+         */
+    }
+}
+
+static void
+_handle_verify_user (GSignondDbusIdentityAdapter *self,
+                     GDBusMethodInvocation *invocation,
+                     const GVariant *params,
+                     gpointer user_data)
+{
+    GSignondDbusIdentity *iface = GSIGNOND_DBUS_IDENTITY (self);
+    gboolean res = gsignond_identity_iface_verify_user (self->priv->parent, params);
+
+    gsignond_dbus_identity_complete_verify_user (iface, invocation, res);
+}
+
+static void
+_handle_verify_secret (GSignondDbusIdentityAdapter *self,
+                      GDBusMethodInvocation *invocation,
+                      const gchar *secret,
+                      gpointer user_data)
+{
+    GSignondDbusIdentity *iface = GSIGNOND_DBUS_IDENTITY (self);
+    gboolean res = gsignond_identity_iface_verify_secret (self->priv->parent, secret);
+
+    gsignond_dbus_identity_complete_verify_secret (iface, invocation, res);
+}
+
+static void
+_handle_remove (GSignondDbusIdentityAdapter   *self,
+                GDBusMethodInvocation *invocation,
+                gpointer               user_data)
+{
+    GSignondDbusIdentity *iface = GSIGNOND_DBUS_IDENTITY (self);
+    
+    gsignond_identity_iface_remove (self->priv->parent);
+
+    gsignond_dbus_identity_complete_remove (iface, invocation);
+}
+
+static void
+_handle_sign_out (GSignondDbusIdentityAdapter *self,
+                  GDBusMethodInvocation *invocation,
+                  gpointer user_data)
+{
+    GSignondDbusIdentity *iface = GSIGNOND_DBUS_IDENTITY (self);
+
+    gboolean res = gsignond_identity_iface_sign_out (self->priv->parent);
+
+    gsignond_dbus_identity_complete_sign_out (iface, invocation, res);
+}
+
+static void
+_handle_store (GSignondDbusIdentityAdapter *self,
+               GDBusMethodInvocation *invocation,
+               const GVariant *info,
+               gpointer user_data)
+{
+    GSignondDbusIdentity *iface = GSIGNOND_DBUS_IDENTITY (self);
+    guint id = gsignond_identity_iface_store (self->priv->parent, info);
+
+    gsignond_dbus_identity_complete_store (iface, invocation, id);
+}
+
+static void
+_handle_add_reference (GSignondDbusIdentityAdapter *self,
+                       GDBusMethodInvocation *invocation,
+                       const gchar *reference,
+                       gpointer user_data)
+{
+    GSignondDbusIdentity *iface = GSIGNOND_DBUS_IDENTITY (self);
+    gint32 id ;
+
+    id = gsignond_identity_iface_add_reference (self->priv->parent, reference);
+
+    gsignond_dbus_identity_complete_add_reference (iface, invocation, id);
+}
+
+static void
+_handle_remove_reference (GSignondDbusIdentityAdapter *self,
+                          GDBusMethodInvocation *invocation,
+                          const gchar *reference,
+                          gpointer user_data)
+{
+    GSignondDbusIdentity *iface = GSIGNOND_DBUS_IDENTITY (self);
+    gint32 id ;
+
+    id = gsignond_identity_iface_remove_reference (self->priv->parent, reference);
+
+    gsignond_dbus_identity_complete_remove_reference (iface, invocation, id);
+}
+
+GSignondDbusIdentityAdapter * gsignond_dbus_identity_adapter_new (GSignondIdentityIface *impl)
+{
+    return GSIGNOND_DBUS_IDENTITY_ADAPTER (g_object_new (GSIGNOND_TYPE_IDENTITY_ADAPTER, "identity-impl", impl, NULL));
+}
+
diff --git a/src/daemon/dbus/gsignond-dbus-identity-adapter.h b/src/daemon/dbus/gsignond-dbus-identity-adapter.h
new file mode 100644 (file)
index 0000000..5d1bc7a
--- /dev/null
@@ -0,0 +1,64 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of signon
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_IDENTITY_ADAPTER_H_
+#define __GSIGNOND_IDENTITY_ADAPTER_H_
+
+#include <glib.h>
+#include <daemon/gsignond-identity-iface.h>
+#include "gsignond-dbus-identity-gen.h"
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_IDENTITY_ADAPTER            (gsignond_dbus_identity_adapter_get_type())
+#define GSIGNOND_DBUS_IDENTITY_ADAPTER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GSIGNOND_TYPE_IDENTITY_ADAPTER, GSignondDbusIdentityAdapter))
+#define GSIGNOND_DBUS_IDENTITY_ADAPTER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), GSIGNOND_TYPE_IDENTITY_ADAPTER, GSignondDbusIdentityAdapterClass))
+#define GSIGNOND_IS_IDENTITY_ADAPTER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSIGNOND_TYPE_IDENTITY_ADAPTER))
+#define GSIGNOND_IS_IDENTITY_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSIGNOND_TYPE_IDENTITY_ADAPTER))
+#define GSIGNOND_DBUS_IDENTITY_ADAPTER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GSIGNOND_TYPE_IDENTITY_ADAPTER, GSignondDbusIdentityAdapterClass))
+
+typedef struct _GSignondDbusIdentityAdapter GSignondDbusIdentityAdapter;
+typedef struct _GSignondDbusIdentityAdapterClass GSignondDbusIdentityAdapterClass;
+typedef struct _GSignondDbusIdentityAdapterPrivate GSignondDbusIdentityAdapterPrivate;
+
+struct _GSignondDbusIdentityAdapter
+{
+    GSignondDbusIdentitySkeleton parent;
+
+    /* priv */
+    GSignondDbusIdentityAdapterPrivate *priv;
+};
+
+struct _GSignondDbusIdentityAdapterClass
+{
+    GSignondDbusIdentitySkeletonClass parent_class;
+};
+
+GType gsignond_dbus_identity_adapter_get_type (void) G_GNUC_CONST;
+
+GSignondDbusIdentityAdapter * gsignond_dbus_identity_adapter_new (GSignondIdentityIface *parent);
+
+G_END_DECLS
+
+#endif /* __GSIGNOND_IDENTITY_ADAPTER_H_ */
diff --git a/src/daemon/dbus/gsignond-dbus.h b/src/daemon/dbus/gsignond-dbus.h
new file mode 100644 (file)
index 0000000..ce5a606
--- /dev/null
@@ -0,0 +1,38 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of signon
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_DBUS_H_
+#define __GSIGNOND_DBUS_H_
+
+/*
+ * Common DBUS definitions
+ */
+#define GSIGNOND_SERVICE_PREFIX          "com.google.code.AccountsSSO.SingleSignOn"
+#define GSIGNOND_SERVICE                 GSIGNOND_SERVICE_PREFIX
+#define GSIGNOND_DAEMON_OBJECTPATH       "/com/google/code/AccountsSSO/SingleSignOn"
+#define GSIGNOND_DAEMON_INTERFACE        GSIGNOND_SERVICE_PREFIX ".AuthService"
+#define GSIGNOND_IDENTITY_INTERFACE      GSIGNOND_SERVICE_PREFIX ".Identity"
+#define GSIGNOND_AUTH_SESSION_INTERFACE  GSIGNOND_SERVICE_PREFIX ".AuthSession"
+
+#endif /* __GSIGNOND_DBUS_H_ */
       <arg name="applicationContext" type="s" direction="in"/>
     </method>
     <method name="queryMethods">
-      <arg type="as" direction="out"/>
+      <arg name="authMethods" type="as" direction="out"/>
     </method>
     <method name="queryMechanisms">
-      <arg type="as" direction="out"/>
+      <arg name="mechanisms" type="as" direction="out"/>
       <arg name="method" type="s" direction="in"/>
     </method>
     <method name="queryIdentities">
-      <arg type="aa{sv}" direction="out"/>
+      <arg name="identities" type="aa{sv}" direction="out"/>
       <arg name="filter" type="a{sv}" direction="in"/>
       <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
     </method>
diff --git a/src/daemon/dbus/services/com.google.code.AccountsSSO.SingleSignOn.service.in b/src/daemon/dbus/services/com.google.code.AccountsSSO.SingleSignOn.service.in
new file mode 100644 (file)
index 0000000..a99a9ac
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=com.google.code.AccountsSSO.SingleSignOn
+Exec=@prefix@/bin/gsignond
diff --git a/src/daemon/gsignond-auth-service-iface.c b/src/daemon/gsignond-auth-service-iface.c
new file mode 100644 (file)
index 0000000..e34a152
--- /dev/null
@@ -0,0 +1,165 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-auth-service-iface.h"
+
+G_DEFINE_INTERFACE (GSignondAuthServiceIface, gsignond_auth_service_iface, G_TYPE_OBJECT)
+
+static const gchar * 
+_dummy_register_new_identity (GSignondAuthServiceIface *self,
+                              const GVariant *app_context)
+{
+    (void) self;
+    (void) app_context;
+    return 0;
+}
+
+static gboolean
+_dummy_get_identity (GSignondAuthServiceIface *self, guint32 id,
+                     const GVariant *app_context, gchar **object_path,
+                     GVariant **identity_data)
+{
+    (void) self;
+    (void) id;
+    (void) app_context;
+    (void) object_path;
+    (void) identity_data;
+    return FALSE;
+}
+
+static const gchar *
+_dummy_get_auth_session_object_path (GSignondAuthServiceIface *self,
+                                     guint32 id, const gchar *type,
+                                     const GVariant *app_context)
+{
+    (void) self;
+    (void) id;
+    (void) type;
+    (void) app_context;
+    return 0;
+}
+
+static gchar **
+_dummy_query_methods (GSignondAuthServiceIface *self)
+{
+    (void) self;
+    return NULL;
+}
+
+static gchar **
+_dummy_query_mechanisms (GSignondAuthServiceIface *self, const gchar *method)
+{
+    (void) self;
+    (void) method;
+    return NULL;
+}
+
+static GVariant *
+_dummy_query_identities (GSignondAuthServiceIface *self, const GVariant *filter)
+{
+    (void) self;
+    (void) filter;
+    return NULL;
+}
+
+static gboolean
+_dummy_clear (GSignondAuthServiceIface *self)
+{
+    (void) self;
+
+    return FALSE;
+}
+
+static void
+gsignond_auth_service_iface_default_init (
+                                        GSignondAuthServiceIfaceInterface *self)
+{
+    self->register_new_identity = _dummy_register_new_identity;
+    self->get_identity = _dummy_get_identity;
+    self->get_auth_session_object_path = _dummy_get_auth_session_object_path;
+    self->query_methods = _dummy_query_methods;
+    self->query_mechanisms = _dummy_query_mechanisms;
+    self->query_identities = _dummy_query_identities;
+    self->clear = _dummy_clear;
+}
+
+const gchar *
+gsignond_auth_service_iface_register_new_identity (
+                                                 GSignondAuthServiceIface *self,
+                                                 const GVariant *app_context)
+{
+    return GSIGNOND_AUTH_SERVICE_GET_INTERFACE (self)->
+        register_new_identity (self, app_context);
+}
+
+gboolean
+gsignond_auth_service_iface_get_identity (GSignondAuthServiceIface *self,
+                                          guint32 id,
+                                          const GVariant *app_context,
+                                          gchar **object_path,
+                                          GVariant **identity_data)
+{
+    return GSIGNOND_AUTH_SERVICE_GET_INTERFACE(self)->
+        get_identity (self, id, app_context, object_path, identity_data);
+}
+
+const gchar *
+gsignond_auth_service_iface_get_auth_session_object_path (
+                                                 GSignondAuthServiceIface *self,
+                                                 guint32 id,
+                                                 const gchar *type,
+                                                 const GVariant *app_context)
+{
+    return GSIGNOND_AUTH_SERVICE_GET_INTERFACE (self)->
+        get_auth_session_object_path (self, id, type, app_context);
+}
+
+gchar **
+gsignond_auth_service_iface_query_methods (GSignondAuthServiceIface *self)
+{
+    return GSIGNOND_AUTH_SERVICE_GET_INTERFACE (self)->query_methods (self);
+}
+
+gchar **
+gsignond_auth_service_iface_query_mechanisms (GSignondAuthServiceIface *self,
+                                              const gchar *method)
+{
+    return GSIGNOND_AUTH_SERVICE_GET_INTERFACE (self)->
+        query_mechanisms (self, method);
+}
+
+GVariant *
+gsignond_auth_service_iface_query_identities (GSignondAuthServiceIface *self,
+                                              const GVariant *filter)
+{
+    return GSIGNOND_AUTH_SERVICE_GET_INTERFACE (self)->
+        query_identities (self, filter);
+}
+
+gboolean
+gsignond_auth_service_iface_clear (GSignondAuthServiceIface *self)
+{
+    return GSIGNOND_AUTH_SERVICE_GET_INTERFACE (self)->clear(self);
+}
+
diff --git a/src/daemon/gsignond-auth-service-iface.h b/src/daemon/gsignond-auth-service-iface.h
new file mode 100644 (file)
index 0000000..dda5fb3
--- /dev/null
@@ -0,0 +1,82 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_AUTH_SERVICE_IFACE_H_
+#define __GSIGNOND_AUTH_SERVICE_IFACE_H_
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_AUTH_SERVICE_IFACE          (gsignond_auth_service_iface_get_type ())
+#define GSIGNOND_AUTH_SERVICE_IFACE(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSIGNOND_TYPE_AUTH_SERVICE_IFACE, GSignondAuthServiceIface))
+#define GSIGNOND_IS_AUTH_SERVICE_IFACE(obj)       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSIGNOND_TYPE_AUTH_SERVICE_IFACE))
+#define GSIGNOND_AUTH_SERVICE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GSIGNOND_TYPE_AUTH_SERVICE_IFACE, GSignondAuthServiceIfaceInterface))
+
+typedef struct _GSignondAuthServiceIface GSignondAuthServiceIface; /* dummy */
+typedef struct _GSignondAuthServiceIfaceInterface GSignondAuthServiceIfaceInterface;
+
+struct _GSignondAuthServiceIfaceInterface {
+    GTypeInterface parent;
+
+    const gchar * (*register_new_identity) (GSignondAuthServiceIface *iface, const GVariant *app_context);
+    gboolean (*get_identity) (GSignondAuthServiceIface *iface, guint32 id, const GVariant *app_context, gchar **object_path, GVariant **identity_data);
+    const gchar * (*get_auth_session_object_path) (GSignondAuthServiceIface *iface, guint32 id, const gchar *type, const GVariant *app_context);
+    gchar ** (*query_methods) (GSignondAuthServiceIface *iface);
+    gchar ** (*query_mechanisms) (GSignondAuthServiceIface *iface, const gchar *method);
+    GVariant * (*query_identities) (GSignondAuthServiceIface *iface, const GVariant *filter);
+    gboolean (*clear) (GSignondAuthServiceIface *iface);
+
+};
+
+GType gsignond_auth_service_iface_get_type (void);
+
+const gchar * gsignond_auth_service_iface_register_new_identity (
+                                                GSignondAuthServiceIface *self,
+                                                const GVariant *app_context);
+gboolean gsignond_auth_service_iface_get_identity (
+                                                GSignondAuthServiceIface *self,
+                                                guint32 id,
+                                                const GVariant *app_context, 
+                                                gchar **object_path,
+                                                GVariant **identity_data);
+const gchar * gsignond_auth_service_iface_get_auth_session_object_path (
+                                                GSignondAuthServiceIface *self,
+                                                guint32 id,
+                                                const gchar *type,
+                                                const GVariant *app_context);
+gchar ** gsignond_auth_service_iface_query_methods (
+                                                GSignondAuthServiceIface *self);
+gchar ** gsignond_auth_service_iface_query_mechanisms (
+                                                GSignondAuthServiceIface *self,
+                                                const gchar *method);
+GVariant * gsignond_auth_service_iface_query_identities (
+                                                GSignondAuthServiceIface *self,
+                                                const GVariant *filter);
+gboolean gsignond_auth_service_iface_clear (GSignondAuthServiceIface *self);
+
+G_END_DECLS
+
+#endif /* __GSIGNOND_AUTH_SERVICE_IFACE_H_ */
diff --git a/src/daemon/gsignond-auth-session-iface.c b/src/daemon/gsignond-auth-session-iface.c
new file mode 100644 (file)
index 0000000..52a0203
--- /dev/null
@@ -0,0 +1,102 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-auth-session-iface.h"
+
+G_DEFINE_INTERFACE (GSignondAuthSessionIface, gsignond_auth_session_iface, G_TYPE_OBJECT)
+
+static gchar **
+_dummy_query_available_mechanisms (GSignondAuthSessionIface *self,
+                                   const gchar **wanted_mechanisms)
+{
+    (void) self;
+    (void) wanted_mechanisms;
+    return NULL;
+}
+
+static GVariant *
+_dummy_process (GSignondAuthSessionIface *self, const GVariant *session_data,
+                const gchar *mechanism)
+{
+    (void) self;
+    (void) session_data;
+    (void) mechanism;
+
+    return NULL;
+}
+
+static void
+_dummy_cancel (GSignondAuthSessionIface *self)
+{
+    (void) self;
+}
+
+static void
+_dummy_set_id (GSignondAuthSessionIface *self, guint32 id)
+{
+    (void) self;
+    (void) id;
+}
+
+static void
+gsignond_auth_session_iface_default_init (
+                                        GSignondAuthSessionIfaceInterface *self)
+{
+    self->query_available_mechanisms = _dummy_query_available_mechanisms;
+    self->process = _dummy_process;
+    self->cancel = _dummy_cancel;
+    self->set_id = _dummy_set_id;
+}
+
+
+gchar **
+gsignond_auth_session_iface_query_available_mechanisms (
+                                                GSignondAuthSessionIface *self,
+                                                const gchar **wanted_mechanisms)
+{
+    return GSIGNOND_AUTH_SESSION_GET_INTERFACE (self)->
+        query_available_mechanisms (self, wanted_mechanisms);
+}
+
+GVariant *
+gsignond_auth_session_iface_process (GSignondAuthSessionIface *self,
+                                     const GVariant *session_data,
+                                     const gchar *mechanism)
+{
+    return GSIGNOND_AUTH_SESSION_GET_INTERFACE (self)->
+        process (self, session_data, mechanism);
+}
+
+void
+gsignond_auth_session_iface_cancel (GSignondAuthSessionIface *self)
+{
+    return GSIGNOND_AUTH_SESSION_GET_INTERFACE (self)->cancel (self);
+}
+
+void
+gsignond_auth_session_iface_set_id (GSignondAuthSessionIface *self, guint32 id)
+{
+    return GSIGNOND_AUTH_SESSION_GET_INTERFACE (self)->set_id (self, id);
+}
+
diff --git a/src/daemon/gsignond-auth-session-iface.h b/src/daemon/gsignond-auth-session-iface.h
new file mode 100644 (file)
index 0000000..d02eafc
--- /dev/null
@@ -0,0 +1,64 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_AUTH_SESSION_IFACE_H_
+#define __GSIGNOND_AUTH_SESSION_IFACE_H_
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_AUTH_SESSION_IFACE          (gsignond_auth_session_iface_get_type ())
+#define GSIGNOND_AUTH_SESSION_IFACE(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSIGNOND_TYPE_AUTH_SESSION_IFACE, GSignondAuthSessionIface))
+#define GSIGNOND_IS_AUTH_SESSION_IFACE(obj)       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSIGNOND_TYPE_AUTH_SESSION_IFACE))
+#define GSIGNOND_AUTH_SESSION_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GSIGNOND_TYPE_AUTH_SESSION_IFACE, GSignondAuthSessionIfaceInterface))
+
+typedef struct _GSignondAuthSessionIface GSignondAuthSessionIface; /* dummy */
+typedef struct _GSignondAuthSessionIfaceInterface GSignondAuthSessionIfaceInterface;
+
+struct _GSignondAuthSessionIfaceInterface {
+    GTypeInterface parent;
+
+    gchar **   (*query_available_mechanisms) (GSignondAuthSessionIface *iface, const gchar **wanted_mechansims);
+    GVariant * (*process) (GSignondAuthSessionIface *iface, const GVariant *session_data, const gchar *mechanism);
+    void       (*cancel) (GSignondAuthSessionIface *iface);
+    void       (*set_id) (GSignondAuthSessionIface *iface, guint32 id);
+};
+
+GType gsignond_auth_session_iface_get_type (void);
+
+gchar ** gsignond_auth_session_iface_query_available_mechanisms (
+                                            GSignondAuthSessionIface *self,
+                                            const gchar **wanted_mechanisms);
+GVariant * gsignond_auth_session_iface_process (GSignondAuthSessionIface *self,
+                                                const GVariant *session_data,
+                                                const gchar *mechanism);
+void gsignond_auth_session_iface_cancel (GSignondAuthSessionIface *self);
+void gsignond_auth_session_iface_set_id (GSignondAuthSessionIface *self,
+                                         guint32 id);
+
+G_END_DECLS
+
+#endif /* __GSIGNOND_AUTH_SESSION_IFACE_H_ */
diff --git a/src/daemon/gsignond-config-db.h b/src/daemon/gsignond-config-db.h
new file mode 100644 (file)
index 0000000..74a3d30
--- /dev/null
@@ -0,0 +1,38 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_CONFIG_DB_H_
+#define __GSIGNOND_CONFIG_DB_H_
+
+#define GSIGNOND_CONFIG_DB_SSO              "SecureStorage"
+#define GSIGNOND_CONFIG_DB_FILE_SYSTEM_NAME GSIGNOND_CONFIG_DB_SSO \
+                                            "/FileSystemName"
+#define GSIGNOND_CONFIG_DB_SIZE             GSIGNOND_CONFIG_DB_SSO \
+                                            "/Size"
+#define GSIGNOND_CONFIG_DB_FILE_SYSTEM_TYPE GSIGNOND_CONFIG_DB_SSO \
+                                            "/FileSystemType"
+#define GSIGNOND_CONFIG_DB_SECRETS_STORAGE  GSIGNOND_CONFIG_DB_SSO \
+                                            "/SecretsStorage"
+
+#endif /* __GSIGNOND_DB_CONFIG_H_ */
diff --git a/src/daemon/gsignond-config-dbus.h b/src/daemon/gsignond-config-dbus.h
new file mode 100644 (file)
index 0000000..04139a3
--- /dev/null
@@ -0,0 +1,37 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_CONFIG_DBUS_H_
+#define __GSIGNOND_CONFIG_DBUS_H_
+
+#define GSINGOND_CONFIG_DBUS_TIMEOUTS  "ObjectTimeouts"
+
+#define GSIGNOND_CONFIG_DBUS_DAEMON_TIMEOUT     GSINGOND_CONFIG_DBUS_TIMEOUTS \
+                                                "/DaemonTimeout"
+#define GSIGNOND_CONFIG_DBUS_IDENTITY_TIMEOUT   GSINGOND_CONFIG_DBUS_TIMEOUTS \
+                                                "/IdentityTimeout"
+#define GSIGNOND_CONFIG_DBUS_AUTH_SESSION_TIMEOUT GSINGOND_CONFIG_DBUS_TIMEOUTS \
+                                                  "/AuthSessionTimeout"
+
+#endif /* __GSIGNOND_CONFIG_DBUS_H_ */
diff --git a/src/daemon/gsignond-config-general.h b/src/daemon/gsignond-config-general.h
new file mode 100644 (file)
index 0000000..5f0d3e3
--- /dev/null
@@ -0,0 +1,40 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_CONFIG_GENERAL_H_
+#define __GSIGNOND_CONFIG_GENERAL_H_
+
+#define GSIGNOND_CONFIG_GENERAL                 "General"
+#define GSIGNOND_CONFIG_GENERAL_STORAGE_PATH    GSIGNOND_CONFIG_GENERAL \
+                                                "/StoragePath"
+#define GSIGNOND_CONFIG_GENERAL_LOG_LEVEL       GSIGNOND_CONFIG_GENERAL \
+                                                "/LoggingLevel"
+#define GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR  GSIGNOND_CONFIG_GENERAL \
+                                                "/ExtensionsDir"
+#define GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR     GSIGNOND_CONFIG_GENERAL \
+                                                "/PluginsDir"
+#define GSIGNOND_CONFIG_GENERAL_ACM             GSIGNOND_CONFIG_GENERAL \
+                                                "/AccessControlManager"
+
+#endif /* __GSIGNOND_GENERAL_CONFIG_H_ */
diff --git a/src/daemon/gsignond-config.c b/src/daemon/gsignond-config.c
new file mode 100644 (file)
index 0000000..7561b34
--- /dev/null
@@ -0,0 +1,549 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-config.h"
+#include "gsignond-config-general.h"
+#include "gsignond-config-db.h"
+#include "gsignond-config-dbus.h"
+#include <common/gsignond-log.h>
+#include <stdlib.h>
+
+enum
+{
+    PROP_0,
+    PROP_CONFIG_TABLE,         /* key-value pair of all config options */
+    PROP_CONFIG_FILE_PATH,     /* configuration file path */
+    PROP_PLUGINS_DIR,          /* plugins direcotry location */
+    PROP_EXTENSIONS_DIR,       /* extensions directory location */
+    PROP_DAEMON_TIMEOUT,       /* daemon dbus timeout */
+    PROP_IDENTITY_TIMEOUT,     /* identities dbus timeout */
+    PROP_AUTH_SESSION_TIMEOUT, /* session dbus timeout */
+    N_PROPERTIES
+};
+static GParamSpec *properties[N_PROPERTIES];
+
+struct _GSignondConfigPrivate
+{
+    gchar *config_file_path;
+    GHashTable *config_table;
+};
+
+#define GSIGNOND_CONFIG_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_CONFIG, GSignondConfigPrivate)
+
+G_DEFINE_TYPE (GSignondConfig, gsignond_config, G_TYPE_OBJECT);
+
+
+#define GSIGNOND_CONFIG_PATH "/etc/signond.conf"
+
+static gboolean gsignond_config_load (GSignondConfig *config);
+static gboolean gsignond_config_load_environment (GSignondConfig *config);
+
+static gint
+gsignond_config_get_integer (GSignondConfig *config, const gchar *key)
+{
+    const gchar *value = g_hash_table_lookup (config->priv->config_table, key);
+    if (!value) return 0;
+
+    return (guint) atoi (value);
+}
+
+static gboolean
+gsignond_config_set_integer (GSignondConfig *config, const gchar *key,
+                             gint value) 
+{
+    gchar *s_value = 0;
+    g_return_val_if_fail (config && GSIGNOND_IS_CONFIG(config), FALSE);
+
+    s_value = g_strdup_printf ("%d", value);
+    if (!s_value) return FALSE;
+
+    g_hash_table_replace (config->priv->config_table,
+                          (gpointer) key,
+                          (gpointer) s_value);
+
+    g_free (s_value);
+
+    return FALSE;
+}
+
+
+static void
+gsignond_config_get_property (GObject    *object,
+                              guint       property_id,
+                              GValue     *value,
+                              GParamSpec *pspec)
+{
+    GSignondConfig *self = GSIGNOND_CONFIG (object);
+
+    switch (property_id)
+    {
+        case PROP_CONFIG_TABLE: {
+            g_value_set_pointer (value, self->priv->config_table);
+            break;
+        }
+        case PROP_CONFIG_FILE_PATH: {
+            g_value_set_string (value, self->priv->config_file_path);
+            break;
+        }
+        case PROP_PLUGINS_DIR: {
+            g_value_set_string (value, gsignond_config_get_plugins_dir (self));
+            break;
+        }
+        case PROP_EXTENSIONS_DIR: {
+            g_value_set_string (value,
+                                gsignond_config_get_extensions_dir (self));
+            break;
+        }
+        case PROP_DAEMON_TIMEOUT: {
+            g_value_set_uint (value,
+                              gsignond_config_get_daemon_timeout (self));
+            break;
+        }
+        case PROP_IDENTITY_TIMEOUT: {
+            g_value_set_uint (value,
+                              gsignond_config_get_identity_timeout (self));
+            break;
+        }
+        case PROP_AUTH_SESSION_TIMEOUT: {
+            g_value_set_uint (value,
+                              gsignond_config_get_auth_session_timeout (self));
+            break;
+        }
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+gsignond_config_set_property (GObject      *object,
+                              guint         property_id,
+                              const GValue *value,
+                              GParamSpec   *pspec)
+{
+    GSignondConfig *self = GSIGNOND_CONFIG (object);
+
+    switch (property_id)
+    {
+        case PROP_CONFIG_FILE_PATH:{
+            self->priv->config_file_path =
+                g_strdup (g_value_get_string (value));
+            gsignond_config_load (self);
+            break;
+        }
+        case PROP_PLUGINS_DIR: {
+            gsignond_config_set_plugins_dir (self, g_value_get_string (value));
+            break;
+        }
+        case PROP_EXTENSIONS_DIR: {
+            gsignond_config_set_extensions_dir (self,
+                                                g_value_get_string (value));
+            break;
+        }
+        case PROP_DAEMON_TIMEOUT: {
+            gsignond_config_set_daemon_timeout (self, g_value_get_uint (value));
+            break;
+        }
+        case PROP_IDENTITY_TIMEOUT: {
+            gsignond_config_set_identity_timeout (self,
+                                                  g_value_get_uint (value));
+            break;
+        }
+        case PROP_AUTH_SESSION_TIMEOUT: {
+            gsignond_config_set_auth_session_timeout (self,
+                                                      g_value_get_uint (value));
+            break;
+        }
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+gsignond_config_dispose (GObject *object)
+{
+    GSignondConfig *self = 0;
+    g_return_if_fail (object && GSIGNOND_IS_CONFIG (object));
+
+    self = GSIGNOND_CONFIG (object);
+
+    if (self->priv->config_table) {
+        g_hash_table_unref (self->priv->config_table);
+        self->priv->config_table = NULL;
+    }
+
+    G_OBJECT_CLASS (gsignond_config_parent_class)->dispose (object);
+}
+
+static void
+gsignond_config_finalize (GObject *object)
+{
+    GSignondConfig *self = 0;
+    g_return_if_fail (object && GSIGNOND_IS_CONFIG (object));
+
+    self = GSIGNOND_CONFIG (object);
+
+    if (self->priv->config_file_path) {
+        g_free (self->priv->config_file_path);
+        self->priv->config_file_path = NULL;
+    }
+
+    G_OBJECT_CLASS (gsignond_config_parent_class)->finalize (object);
+}
+
+static void
+gsignond_config_init (GSignondConfig *self)
+{
+    self->priv = GSIGNOND_CONFIG_PRIV (self);
+
+    self->priv->config_file_path = NULL;
+    self->priv->config_table = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                                      g_free, g_free);
+}
+
+static void
+gsignond_config_class_init (GSignondConfigClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    g_type_class_add_private (object_class, sizeof (GSignondConfigPrivate));
+
+    object_class->get_property = gsignond_config_get_property;
+    object_class->set_property = gsignond_config_set_property;
+    object_class->dispose = gsignond_config_dispose;
+    object_class->finalize = gsignond_config_finalize;
+
+    properties[PROP_CONFIG_TABLE] =
+        g_param_spec_pointer ("config-table",
+                              "configuration key-value pairs",
+                              "All configuration options",
+                              G_PARAM_READABLE);
+
+    properties[PROP_CONFIG_FILE_PATH] =
+        g_param_spec_string ("config-file-path",
+                             "Daemon Config Path",
+                             "Daemon configuration file path",
+                             GSIGNOND_CONFIG_PATH,
+                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+    properties[PROP_PLUGINS_DIR] =
+        g_param_spec_string ("plugins-dir",
+                             "Plugins Directory",
+                             "Plugins direcotry",
+                             GSIGNOND_PLUGINS_DIR, 
+                             G_PARAM_READWRITE);
+
+    properties[PROP_EXTENSIONS_DIR] =
+        g_param_spec_string ("extensions-dir",
+                             "Extensions Directroy",
+                             "Extensions directory",
+                             GSIGNOND_EXTENSIONS_DIR, 
+                             G_PARAM_READWRITE);
+
+    properties[PROP_DAEMON_TIMEOUT] =
+        g_param_spec_uint ("daemon-timeout",
+                           "Daemon Timeout",
+                           "Daemon timeout",
+                           0, /* TODO: replace with minimum timeout */
+                           G_MAXINT, /* TODO: replace with maximum timeout */
+                           0, /* no timeout */
+                           G_PARAM_READWRITE);
+
+    properties[PROP_IDENTITY_TIMEOUT] =
+        g_param_spec_uint ("identity-timeout",
+                           "Identity Timeout",
+                           "Identity timeout",
+                           0, /* TODO: replace with minimum timeout */
+                           G_MAXUINT, /* TODO: replace with maximum timeout */
+                           300, /* 5 minutes */
+                           G_PARAM_READWRITE);
+
+    properties[PROP_AUTH_SESSION_TIMEOUT] =
+        g_param_spec_uint ("auth-session-timeout",
+                           "Auth Session Timeout",
+                           "Authentication session timeout",
+                           0, /* TODO: replace with minimum timeout */
+                           G_MAXUINT, /* TODO: replace with maximum timeout */
+                           300, /* 5 minutes */
+                           G_PARAM_READWRITE);
+
+    g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static gboolean
+gsignond_config_load (GSignondConfig *self)
+{
+    GError *err = NULL;
+    gchar **groups = NULL;
+    gsize n_groups = 0;
+    int i,j;
+    GKeyFile *settings = g_key_file_new ();
+
+    DBG ("Loading SSO config from %s", self->priv->config_file_path);
+
+    if (!g_key_file_load_from_file (settings, self->priv->config_file_path,
+                                    G_KEY_FILE_NONE, &err)) {
+        WARN ("error reading config file at '%s': %s",
+             self->priv->config_file_path, err->message);
+        g_error_free (err);
+        g_key_file_free (settings);
+        return FALSE;
+    }
+
+    groups = g_key_file_get_groups (settings, &n_groups);
+
+    for (i = 0; i<n_groups; i++) {
+        GError *err = NULL;
+        gsize n_keys =0;
+        gchar **keys = g_key_file_get_keys (settings, groups[i], &n_keys, &err);
+
+        if (err) {
+            WARN ("fail to read group '%s': %s", groups[i], err->message);
+            g_error_free (err);
+            continue;
+        }
+
+        for (j=0; j<n_keys; j++) {
+            gchar *key = g_strdup_printf ("%s/%s", groups[i], keys[j]);
+            gchar *value = g_key_file_get_value (settings, groups[i], keys[j],
+                                                 &err);
+
+            if (err) {
+                WARN ("fail to read key '%s/%s': %s", groups[i], keys[j], err->message);
+                g_error_free (err);
+                continue;
+            }
+
+            INFO ("found config : '%s/%s' - '%s'", groups[i], keys[j], value);
+
+            g_hash_table_insert (self->priv->config_table, key, value);
+
+            g_free (key);
+            g_free (value);
+        }
+
+        g_strfreev (keys);
+    }
+
+    g_strfreev (groups);
+
+    g_key_file_free (settings);
+
+    /*
+     * FIXME: Find the right place to load environment
+     */
+    gsignond_config_load_environment (self);
+
+    return TRUE;
+}
+
+static gboolean
+gsignond_config_load_environment (GSignondConfig *config)
+{
+    const char *e_val = 0;
+    guint timeout = 0;
+    gint level = 0;
+    
+    e_val = g_getenv ("SSO_DAEMON_TIMEOUT");
+    if (e_val && (timeout = atoi(e_val)))
+        g_hash_table_insert (config->priv->config_table,
+                             GSIGNOND_CONFIG_DBUS_DAEMON_TIMEOUT,
+                             (gpointer) e_val);
+
+    e_val = g_getenv ("SSO_IDENTITY_TIMEOUT");
+    if (e_val && (timeout = atoi(e_val)))
+        g_hash_table_insert (config->priv->config_table,
+                             GSIGNOND_CONFIG_DBUS_IDENTITY_TIMEOUT,
+                             (gpointer) e_val);
+
+    e_val = g_getenv ("SSO_AUTHSESSION_TIMEOUT");
+    if (e_val && (timeout = atoi(e_val)))
+        g_hash_table_insert (config->priv->config_table,
+                             GSIGNOND_CONFIG_DBUS_AUTH_SESSION_TIMEOUT,
+                             (gpointer) e_val);
+
+    e_val = g_getenv ("SSO_LOGGING_LEVEL");
+    if (e_val && (level = atoi(e_val)))
+        g_hash_table_insert (config->priv->config_table,
+                             GSIGNOND_CONFIG_GENERAL_LOG_LEVEL,
+                             (gpointer) e_val);
+        //set_logging_level (level);
+    
+    e_val = g_getenv ("SSO_PLUGINS_DIR");
+    if (e_val) 
+        g_hash_table_insert (config->priv->config_table,
+                             GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR,
+                             (gpointer) e_val);
+
+    e_val = g_getenv ("SSO_EXTENSIONS_DIR");
+    if (e_val) 
+        g_hash_table_insert (config->priv->config_table,
+                             GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR,
+                             (gpointer) e_val);
+
+    e_val = g_getenv ("SSO_STORAGE_PATH");
+    if (e_val) {
+        g_hash_table_insert (config->priv->config_table,
+                             GSIGNOND_CONFIG_GENERAL_STORAGE_PATH,
+                             (gpointer) e_val);
+        /* cam_config_set_storage_path (e_val); */
+    }
+}
+
+gboolean
+gsignond_config_set_plugins_dir (GSignondConfig *config, const gchar *dir)
+{
+    g_return_val_if_fail (config && GSIGNOND_IS_CONFIG (config), FALSE);
+    g_return_val_if_fail (dir, FALSE);
+
+    const gchar *plugins_dir =
+        g_hash_table_lookup (config->priv->config_table,
+                             GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR);
+
+    if (plugins_dir && !g_strcmp0 (plugins_dir, dir)) {
+        return FALSE;
+    }
+
+    g_hash_table_replace (config->priv->config_table,
+                          GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR, (gpointer) dir);
+    g_object_notify_by_pspec (G_OBJECT (config), properties[PROP_PLUGINS_DIR]);
+
+    return TRUE;
+}
+
+const gchar *
+gsignond_config_get_plugins_dir (GSignondConfig *config)
+{
+    g_return_val_if_fail (config && GSIGNOND_IS_CONFIG (config), 0);
+
+    return (const gchar *) g_hash_table_lookup (config->priv->config_table,
+                                           GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR);
+}
+
+gboolean
+gsignond_config_set_extensions_dir (GSignondConfig *config, const gchar *dir)
+{
+    g_return_val_if_fail (config && GSIGNOND_IS_CONFIG (config), FALSE);
+    g_return_val_if_fail (dir, FALSE);
+
+    const gchar *extensions_dir =
+        g_hash_table_lookup (config->priv->config_table,
+                             GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR);
+
+    if (extensions_dir && !g_strcmp0 (extensions_dir, dir)) {
+        return FALSE;
+    }
+
+    g_hash_table_replace (config->priv->config_table,
+                          GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR,
+                          (gpointer) dir);
+    g_object_notify_by_pspec (G_OBJECT (config),
+                              properties[PROP_EXTENSIONS_DIR]);
+
+    return TRUE;
+}
+
+const gchar *
+gsignond_config_get_extensions_dir (GSignondConfig *config)
+{
+    g_return_val_if_fail (config && GSIGNOND_IS_CONFIG(config), 0);
+
+    return (const gchar *) g_hash_table_lookup (config->priv->config_table,
+                                        GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR);
+}
+
+gboolean
+gsignond_config_set_daemon_timeout (GSignondConfig *config, guint timeout)
+{
+    gboolean res =
+        gsignond_config_set_integer (config,
+                                     GSIGNOND_CONFIG_DBUS_DAEMON_TIMEOUT,
+                                     timeout);
+    
+    if (res) g_object_notify_by_pspec (G_OBJECT (config),
+                                       properties[PROP_DAEMON_TIMEOUT]);
+
+    return res;
+}
+
+guint
+gsignond_config_get_daemon_timeout (GSignondConfig *config)
+{
+    return gsignond_config_get_integer (config,
+                                        GSIGNOND_CONFIG_DBUS_DAEMON_TIMEOUT);
+}
+
+gboolean
+gsignond_config_set_identity_timeout (GSignondConfig *config, guint timeout)
+{
+    gboolean res =
+        gsignond_config_set_integer (config,
+                                     GSIGNOND_CONFIG_DBUS_IDENTITY_TIMEOUT,
+                                     timeout);
+
+    if (res) g_object_notify_by_pspec (G_OBJECT (config),
+                                       properties[PROP_IDENTITY_TIMEOUT]);
+
+    return res;
+}
+
+guint
+gsignond_config_get_identity_timeout (GSignondConfig *config)
+{
+    return gsignond_config_get_integer (config,
+                                        GSIGNOND_CONFIG_DBUS_IDENTITY_TIMEOUT);
+}
+
+gboolean
+gsignond_config_set_auth_session_timeout (GSignondConfig *config, guint timeout)
+{
+    gboolean res =
+        gsignond_config_set_integer (config,
+                                     GSIGNOND_CONFIG_DBUS_AUTH_SESSION_TIMEOUT,
+                                     timeout);
+
+    if (res) g_object_notify_by_pspec (G_OBJECT (config),
+                                       properties[PROP_AUTH_SESSION_TIMEOUT]);
+
+    return res;
+}
+
+guint
+gsignond_config_get_auth_session_timeout (GSignondConfig *config)
+{
+    return gsignond_config_get_integer (config,
+                                     GSIGNOND_CONFIG_DBUS_AUTH_SESSION_TIMEOUT);
+}
+
+const GHashTable *
+gsignond_config_get_config_table (GSignondConfig *config)
+{
+    return config->priv->config_table;
+}
+
+GSignondConfig *
+gsignond_config_new ()
+{
+    return GSIGNOND_CONFIG (g_object_new (GSIGNOND_TYPE_CONFIG, NULL));
+}
+
diff --git a/src/daemon/gsignond-config.h b/src/daemon/gsignond-config.h
new file mode 100644 (file)
index 0000000..58375e9
--- /dev/null
@@ -0,0 +1,99 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_CONFIG_H_
+#define __GSIGNOND_CONFIG_H_
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_CONFIG            (gsignond_config_get_type())
+#define GSIGNOND_CONFIG(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GSIGNOND_TYPE_CONFIG, GSignondConfig))
+#define GSIGNOND_CONFIG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), GSIGNOND_TYPE_CONFIG, GSignondConfigClass))
+#define GSIGNOND_IS_CONFIG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSIGNOND_TYPE_CONFIG))
+#define GSIGNOND_IS_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSIGNOND_TYPE_CONFIG))
+#define GSIGNOND_CONFIG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GSIGNOND_TYPE_CONFIG, GSignondConfigClass))
+
+typedef struct _GSignondConfig GSignondConfig;
+typedef struct _GSignondConfigClass GSignondConfigClass;
+typedef struct _GSignondConfigPrivate GSignondConfigPrivate;
+
+
+#ifndef GSIGNOND_PLUGINS_DIR
+#   define GSIGNOND_PLUGINS_DIR "/usr/lib/signon"
+#endif
+
+#ifndef GSIGNOND_PLUGIN_PREFIX
+#   define GSIGNOND_PLUGIN_PREFIX "lib"
+#endif
+
+#ifndef GSIGNOND_PLUGIN_SUFFIX
+#   define GSIGNOND_PLUGIN_SUFFIX "plugin.so"
+#endif
+
+
+struct _GSignondConfig
+{
+    GObject parent;
+
+    /* priv */
+    GSignondConfigPrivate *priv;
+};
+
+struct _GSignondConfigClass
+{
+    GObjectClass parent_class;
+};
+
+GType gsignond_config_get_type (void) G_GNUC_CONST;
+
+GSignondConfig * gsignond_config_new ();
+
+gboolean gsignond_config_set_plugins_dir (GSignondConfig *config,
+                                          const gchar *dir);
+const gchar * gsignond_config_get_plugins_dir (GSignondConfig *config) G_GNUC_CONST;
+
+gboolean gsignond_config_set_extensions_dir (GSignondConfig *config,
+                                             const gchar *dir);
+const gchar * gsignond_config_get_extensions_dir (GSignondConfig *config) G_GNUC_CONST;
+
+gboolean gsignond_config_set_daemon_timeout (GSignondConfig *config,
+                                             guint timeout);
+guint gsignond_config_get_daemon_timeout (GSignondConfig *config) G_GNUC_CONST;
+
+gboolean gsignond_config_set_identity_timeout (GSignondConfig *config,
+                                               guint timeout);
+guint gsignond_config_get_identity_timeout (GSignondConfig *config) G_GNUC_CONST;
+
+gboolean gsignond_config_set_auth_session_timeout (GSignondConfig *config,
+                                                   guint timeout);
+guint gsignond_config_get_auth_session_timeout (GSignondConfig *config) G_GNUC_CONST;
+
+const GHashTable * gsignond_config_get_config_table (GSignondConfig *config);
+
+G_END_DECLS
+
+#endif /* __GSIGNOND_CONFIG_H_ */
diff --git a/src/daemon/gsignond-daemon.c b/src/daemon/gsignond-daemon.c
new file mode 100644 (file)
index 0000000..fcff75f
--- /dev/null
@@ -0,0 +1,421 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-daemon.h"
+#include "gsignond-config.h"
+#include "gsignond-auth-service-iface.h"
+#include <common/gsignond-log.h>
+#include <daemon/dbus/gsignond-dbus-auth-service-adapter.h>
+#include <sys/socket.h>
+#include <gio/gio.h>
+
+enum 
+{
+    PROP_0,
+    N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES];
+
+struct _GSignondDaemonPrivate
+{
+    GIOChannel          *sig_channel;
+    GSignondConfig      *config;
+    GSignondDbusAuthServiceAdapter *auth_service;
+};
+
+static void gsignond_daemon_auth_service_iface_init (gpointer g_iface,
+                                                     gpointer iface_data);
+
+G_DEFINE_TYPE_EXTENDED (GSignondDaemon, gsignond_daemon, G_TYPE_OBJECT, 0,
+                        G_IMPLEMENT_INTERFACE (GSIGNOND_TYPE_AUTH_SERVICE_IFACE, 
+                                               gsignond_daemon_auth_service_iface_init));
+
+
+#define GSINGON_DAEMON_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_DAEMON, GSignondDaemonPrivate)
+
+static const gchar* gsignond_daemon_register_new_identity(
+                                                 GSignondAuthServiceIface *self,
+                                                 const GVariant *app_cntxt);
+static gboolean gsignond_daemon_get_identity (GSignondAuthServiceIface *self,
+                                              const guint32 id,
+                                              const GVariant *app_context,
+                                              gchar **object_path,
+                                              GVariant **identity_data);
+static const gchar * gsignond_daemon_get_auth_session_object_path (
+                                                 GSignondAuthServiceIface *self,
+                                                 const guint32 id,
+                                                 const gchar *type,
+                                                 const GVariant *app_context);
+static gchar ** gsignond_daemon_query_methods (GSignondAuthServiceIface *self);
+static gchar ** gsignond_daemon_query_mechanisms (
+                                                 GSignondAuthServiceIface *self,
+                                                 const gchar *method);
+/* "(@aa{sv})" */
+static GVariant * gsignond_daemon_query_identities (
+                                                 GSignondAuthServiceIface *self,
+                                                 const GVariant *filter);
+static gboolean gsignond_daemon_clear (GSignondAuthServiceIface *self);
+
+
+static gboolean gsignond_daemon_init_extension (GSignondDaemon *daemon,
+                                                const gchar *path);
+static gboolean gsignond_daemon_init_extensions (GSignondDaemon *daemon);
+static gboolean gsignond_daemon_init_storage (GSignondDaemon *daemon);
+
+static sig_fd[2];
+
+static gboolean 
+_handle_unix_signal (GIOChannel *channel,
+                     GIOCondition condition,
+                     gpointer data)
+{
+    GSignondDaemon *self = GSIGNOND_DAEMON (data);
+
+    int signal;
+    int ret = read (sig_fd[1], &signal, sizeof(signal));
+
+    switch (signal) {
+        case SIGHUP: {
+            DBG ("Received SIGHUP");
+            //TODO: restart daemon
+            break;
+        }
+        case SIGTERM: {
+            DBG ("Received SIGTERM");
+            //TODO: stop daemon
+            break;
+        }
+        case SIGINT:  {
+            DBG ("Received SIGINT");
+            //TODO: stop daemon
+            break;
+        }
+        default: break;
+    }
+
+    return TRUE;
+}
+
+static void
+_setup_signal_handlers (GSignondDaemon *self)
+{
+    g_return_if_fail (self);
+
+    if (socketpair (AF_UNIX, SOCK_STREAM, 0, sig_fd) != 0) {
+        ERR( "Couldn't create HUP socketpair");
+        return;
+    }
+
+    self->priv->sig_channel = g_io_channel_unix_new (sig_fd[0]);
+    g_io_add_watch (self->priv->sig_channel, 
+                    G_IO_IN, 
+                    _handle_unix_signal, 
+                    self);
+
+}
+
+static void 
+_signal_handler (int signal)
+{
+    write(sig_fd[0], &signal, sizeof(signal));
+}
+
+static GObject*
+gsignond_daemon_constructor (GType type,
+                             guint n_construct_params,
+                             GObjectConstructParam *construct_params)
+{
+    /*
+     * Signleton daemon
+     */
+    static GObject *self = 0;
+
+    if (!self) {
+        self = G_OBJECT_CLASS (gsignond_daemon_parent_class)->constructor (
+                  type, n_construct_params, construct_params);
+        
+        g_object_add_weak_pointer (self, (gpointer) &self);
+    }
+    else {
+        g_object_ref (self);
+    }
+
+    return self;
+}
+
+static void
+gsignond_daemon_get_property (GObject *object, 
+                              guint property_id,
+                              GValue *value, GParamSpec *pspec)
+{
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+gsignond_daemon_set_property (GObject *object, 
+                              guint property_id,
+                              const GValue *value, GParamSpec *pspec)
+{
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+gsignond_daemon_dispose (GObject *object)
+{
+    GSignondDaemon *self = GSIGNOND_DAEMON(object);
+
+    if (self->priv->sig_channel) {
+        g_io_channel_unref (self->priv->sig_channel);
+        self->priv->sig_channel = NULL;
+    }
+
+    if (self->priv->config) {
+        g_object_unref (self->priv->config);
+        self->priv->config = NULL;
+    }
+
+    if (self->priv->auth_service) {
+        g_object_unref (self->priv->auth_service);
+        self->priv->auth_service = NULL;
+    }
+    G_OBJECT_CLASS (gsignond_daemon_parent_class)->dispose (object);
+}
+
+static void
+gsignond_daemon_finalize (GObject *object)
+{
+    close(sig_fd[0]);
+    close(sig_fd[1]);
+
+    G_OBJECT_CLASS (gsignond_daemon_parent_class)->finalize (object);
+}
+
+static void
+gsignond_daemon_init (GSignondDaemon *self)
+{
+    GError *err = NULL;
+    self->priv = GSINGON_DAEMON_PRIV(self);
+
+    _setup_signal_handlers (self);
+
+    self->priv->config = gsignond_config_new ();
+
+    gsignond_daemon_init_extensions (self);
+
+    gsignond_daemon_init_storage (self);
+
+    self->priv->auth_service =
+        gsignond_dbus_auth_service_adapter_new (
+                                            GSIGNOND_AUTH_SERVICE_IFACE (self));
+}
+
+static void
+gsignond_daemon_class_init (GSignondDaemonClass *klass)
+{
+    GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+    g_type_class_add_private (object_class, sizeof (GSignondDaemonPrivate));
+
+    object_class->constructor = gsignond_daemon_constructor;
+    object_class->get_property = gsignond_daemon_get_property;
+    object_class->set_property = gsignond_daemon_set_property;
+    object_class->dispose = gsignond_daemon_dispose;
+    object_class->finalize = gsignond_daemon_finalize;
+
+    //g_object_class_install_properties (object_class,
+    //                                   N_PROPERTIES,
+    //                                   properties);
+}
+
+static void
+gsignond_daemon_auth_service_iface_init (gpointer g_iface, gpointer iface_data)
+{
+    GSignondAuthServiceIfaceInterface *auth_service_iface = (GSignondAuthServiceIfaceInterface *)g_iface;
+
+    (void)iface_data;
+
+    auth_service_iface->register_new_identity =
+        gsignond_daemon_register_new_identity;
+    auth_service_iface->get_identity = gsignond_daemon_get_identity;
+    auth_service_iface->get_auth_session_object_path =
+        gsignond_daemon_get_auth_session_object_path;
+    auth_service_iface->query_identities = gsignond_daemon_query_identities;
+    auth_service_iface->query_methods = gsignond_daemon_query_methods;
+    auth_service_iface->query_mechanisms = gsignond_daemon_query_mechanisms;
+    auth_service_iface->clear = gsignond_daemon_clear;
+}
+
+static gboolean
+gsignond_daemon_init_extension (GSignondDaemon *self, const gchar *file_path)
+{
+    DBG ("Loading plugin '%s'", file_path);
+
+    /* TODO: load plugin */
+
+    /* TODO: init extension */
+
+    return TRUE;
+}
+
+static gboolean
+gsignond_daemon_init_extensions (GSignondDaemon *self)
+{
+    GError *err = 0;
+    const gchar *ext_path = 0;
+    const gchar *file_name = 0;
+    GDir *dir = 0;
+    gboolean res = TRUE;
+
+    ext_path = gsignond_config_get_extensions_dir (self->priv->config);
+    if (!ext_path) return FALSE;
+
+    dir = g_dir_open (ext_path, 0, &err);
+    if (!dir) {
+        WARN ("fail to load extensions at : %s", err->message);
+        g_error_free (err);
+        return FALSE;
+    }
+
+    while ((file_name = g_dir_read_name (dir)) != NULL) {
+        if (!g_str_has_prefix (file_name, "lib"))
+            continue;
+        
+        if (!g_str_has_suffix (file_name, ".so"))
+            continue;
+
+        if (!g_file_test (file_name, G_FILE_TEST_IS_REGULAR))
+            continue;
+
+        if (!gsignond_daemon_init_extension (self, file_name))
+            res = FALSE;
+    }
+
+    g_dir_close (dir);
+
+    return res;
+}
+
+static gboolean
+gsignond_daemon_init_storage (GSignondDaemon *self)
+{
+    DBG("Initializing storage");
+
+    /* TODO: Initialize storage */
+
+    return FALSE;
+}
+
+guint gsignond_daemon_identity_timeout (GSignondDaemon *self)
+{
+    return gsignond_config_get_identity_timeout (self->priv->config);
+}
+
+guint gsignond_daemon_auth_session_timeout (GSignondDaemon *self)
+{
+    return gsignond_config_get_auth_session_timeout (self->priv->config);
+}
+
+static const gchar * 
+gsignond_daemon_register_new_identity (GSignondAuthServiceIface *self,
+                                       const GVariant *app_context) {
+    (void)self;
+    (void)app_context;
+    return NULL;
+}
+
+static gboolean 
+gsignond_daemon_get_identity (GSignondAuthServiceIface *self, const guint32 id,
+                              const GVariant *app_context, gchar **object_path,
+                              GVariant **identity_data)
+{
+    (void)self;
+    (void)id;
+    (void)app_context;
+
+    if (object_path) *object_path = NULL;
+    if (identity_data) *identity_data = NULL;
+
+    return FALSE;
+}
+
+static const gchar * 
+gsignond_daemon_get_auth_session_object_path (GSignondAuthServiceIface *self,
+                                              const guint32 id,
+                                              const gchar *type,
+                                              const GVariant *app_context)
+{
+    (void)self;
+    (void)id;
+    (void)type;
+    (void)app_context;
+
+    return NULL;
+}
+
+static gchar ** 
+gsignond_daemon_query_methods (GSignondAuthServiceIface *self)
+{
+    (void) self;
+
+    /*
+     * returning test methods 
+     */
+    gchar **methods = g_strsplit ("test_method_1:test_method_2", ":" ,2);
+
+    return methods;
+}
+
+static gchar ** 
+gsignond_daemon_query_mechanisms (GSignondAuthServiceIface *self, const gchar *method) 
+{
+    (void)self;
+    (void)method;
+
+    return NULL;
+}
+
+static GVariant * 
+gsignond_daemon_query_identities (GSignondAuthServiceIface *self, const GVariant *filter)
+{
+    (void)self;
+    (void)filter;
+
+    return NULL;
+}
+
+static gboolean 
+gsignond_daemon_clear (GSignondAuthServiceIface *self)
+{
+    (void)self;
+
+    return FALSE;
+}
+
+GSignondDaemon *
+gsignond_daemon_new ()
+{
+    return GSIGNOND_DAEMON(g_object_new (GSIGNOND_TYPE_DAEMON, NULL));
+}
+
diff --git a/src/daemon/gsignond-daemon.h b/src/daemon/gsignond-daemon.h
new file mode 100644 (file)
index 0000000..8c0655f
--- /dev/null
@@ -0,0 +1,66 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_DAEMON_H_
+#define __GSIGNOND_DAEMON_H_
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_DAEMON            (gsignond_daemon_get_type())
+#define GSIGNOND_DAEMON(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GSIGNOND_TYPE_DAEMON, GSignondDaemon))
+#define GSIGNOND_DAEMON_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), GSIGNOND_TYPE_DAEMON, GSignondDaemonClass))
+#define GSIGNOND_IS_DAEMON(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSIGNOND_TYPE_DAEMON))
+#define GSIGNOND_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSIGNOND_TYPE_DAEMON))
+#define GSIGNOND_DAEMON_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GSIGNOND_TYPE_DAEMON, GSignondDaemonClass))
+
+typedef struct _GSignondDaemon GSignondDaemon;
+typedef struct _GSignondDaemonClass GSignondDaemonClass;
+typedef struct _GSignondDaemonPrivate GSignondDaemonPrivate;
+
+struct _GSignondDaemon
+{
+    GObject parent;
+
+    /* priv */
+    GSignondDaemonPrivate *priv;
+};
+
+struct _GSignondDaemonClass
+{
+    GObjectClass parent_class;
+};
+
+GType gsignond_daemon_get_type (void) G_GNUC_CONST;
+
+GSignondDaemon * gsignond_daemon_new ();
+
+guint gsignond_daemon_identity_timeout (GSignondDaemon *daemon);
+
+guint gsignond_daemon_auth_session_timeout (GSignondDaemon *daemon);
+G_END_DECLS
+
+#endif /* __GSIGNOND_DAEMON_H_ */
diff --git a/src/daemon/gsignond-identity-iface.c b/src/daemon/gsignond-identity-iface.c
new file mode 100644 (file)
index 0000000..a47e645
--- /dev/null
@@ -0,0 +1,189 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-identity-iface.h"
+
+enum 
+{
+    SIGNAL_UNREGISTERED,
+    SIGNAL_INFO_UPDATED
+};
+
+G_DEFINE_INTERFACE (GSignondIdentityIface, gsignond_identity_iface, G_TYPE_OBJECT)
+
+static guint32
+_dummy_request_credentials_update (GSignondIdentityIface *self,
+                                   const gchar *message)
+{
+    (void) self;
+    (void) message;
+
+    return 0;
+}
+
+static GVariant *
+_dummy_get_info (GSignondIdentityIface *self)
+{
+    (void) self;
+
+    return 0;
+}
+
+static gboolean
+_dummy_verify_user (GSignondIdentityIface *self, const GVariant *params)
+{
+    (void) self;
+    (void) params;
+
+    return FALSE;
+}
+
+static gboolean
+_dummy_verify_secret (GSignondIdentityIface *self, const gchar *secret)
+{
+    (void) self;
+    (void) secret;
+
+    return FALSE;
+}
+
+static void
+_dummy_remove (GSignondIdentityIface *self)
+{
+    (void) self;
+}
+
+static gboolean
+_dummy_sign_out (GSignondIdentityIface *self)
+{
+    (void) self;
+
+    return FALSE;
+}
+
+static guint32
+_dummy_store (GSignondIdentityIface *self, const GVariant *info)
+{
+    (void) self;
+    (void) info;
+
+    return 0;
+}
+
+static gint32
+_dummy_add_reference (GSignondIdentityIface *self, const gchar *reference)
+{
+    (void) self;
+    (void) reference;
+
+    return 0;
+}
+
+static gint32
+_dummy_remove_reference (GSignondIdentityIface *self, const gchar *reference)
+{
+    (void) self;
+    (void) reference;
+
+    return 0;
+}
+
+static void
+gsignond_identity_iface_default_init (GSignondIdentityIfaceInterface *self)
+{
+    self->request_credentials_update = _dummy_request_credentials_update;
+    self->get_info = _dummy_get_info;
+    self->verify_user = _dummy_verify_user;
+    self->verify_secret = _dummy_verify_secret;
+    self->remove = _dummy_remove;
+    self->sign_out = _dummy_sign_out;
+    self->store = _dummy_store;
+    self->add_reference = _dummy_add_reference;
+    self->remove_reference = _dummy_remove_reference;
+}
+
+guint32
+gsignond_identity_iface_request_credentials_update (GSignondIdentityIface *self,
+                                                    const gchar *message)
+{
+    return GSIGNOND_IDENTITY_IFACE_GET_INTERFACE (self)->
+        request_credentials_update (self, message);
+}
+
+GVariant *
+gsignond_identity_iface_get_info (GSignondIdentityIface *self)
+{
+    return GSIGNOND_IDENTITY_IFACE_GET_INTERFACE (self)->get_info (self);
+}
+
+gboolean
+gsignond_identity_iface_verify_user (GSignondIdentityIface *self,
+                                     const GVariant *params)
+{
+    return GSIGNOND_IDENTITY_IFACE_GET_INTERFACE (self)->
+        verify_user (self, params);
+}
+
+gboolean
+gsignond_identity_iface_verify_secret (GSignondIdentityIface *self,
+                                       const gchar *secret)
+{
+    return GSIGNOND_IDENTITY_IFACE_GET_INTERFACE (self)->
+        verify_secret (self, secret);
+}
+
+void
+gsignond_identity_iface_remove (GSignondIdentityIface *self)
+{
+    GSIGNOND_IDENTITY_IFACE_GET_INTERFACE (self)->remove (self);
+}
+
+gboolean
+gsignond_identity_iface_sign_out (GSignondIdentityIface *self)
+{
+    return GSIGNOND_IDENTITY_IFACE_GET_INTERFACE (self)->sign_out (self);
+}
+
+guint32
+gsignond_identity_iface_store (GSignondIdentityIface *self,
+                               const GVariant *info)
+{
+    return GSIGNOND_IDENTITY_IFACE_GET_INTERFACE (self)->store (self, info);
+}
+
+gint32
+gsignond_identity_iface_add_reference (GSignondIdentityIface *self,
+                                       const gchar *reference)
+{
+    return GSIGNOND_IDENTITY_IFACE_GET_INTERFACE (self)->
+        add_reference (self, reference);
+}
+
+gint32
+gsignond_identity_iface_remove_reference (GSignondIdentityIface *self,
+                                          const gchar *reference)
+{
+    return GSIGNOND_IDENTITY_IFACE_GET_INTERFACE (self)->
+        add_reference (self, reference);
+}
diff --git a/src/daemon/gsignond-identity-iface.h b/src/daemon/gsignond-identity-iface.h
new file mode 100644 (file)
index 0000000..f99c36c
--- /dev/null
@@ -0,0 +1,77 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_IDENTITY_IFACE_H_
+#define __GSIGNOND_IDENTITY_IFACE_H_
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_IDENTITY_IFACE          (gsignond_identity_iface_get_type ())
+#define GSIGNOND_IDENTITY_IFACE(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSIGNOND_TYPE_IDENTITY_IFACE, GSignondIdentityIface))
+#define GSIGNOND_IS_IDENTITY_IFACE(obj)       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSIGNOND_TYPE_IDENTITY_IFACE))
+#define GSIGNOND_IDENTITY_IFACE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GSIGNOND_TYPE_IDENTITY_IFACE, GSignondIdentityIfaceInterface))
+
+typedef struct _GSignondIdentityIface GSignondIdentityIface; /* dummy */
+typedef struct _GSignondIdentityIfaceInterface GSignondIdentityIfaceInterface;
+
+struct _GSignondIdentityIfaceInterface {
+    GTypeInterface parent;
+
+    guint32   (*request_credentials_update) (GSignondIdentityIface *iface, const gchar *message);
+    GVariant *(*get_info) (GSignondIdentityIface *iface);
+    gboolean  (*verify_user) (GSignondIdentityIface *iface, const GVariant *params);
+    gboolean  (*verify_secret) (GSignondIdentityIface *iface, const gchar *secret);
+    void      (*remove) (GSignondIdentityIface *iface);
+    gboolean  (*sign_out) (GSignondIdentityIface *iface);
+    guint32   (*store) (GSignondIdentityIface *iface, const GVariant *info);
+    gint32    (*add_reference) (GSignondIdentityIface *iface, const gchar *reference);
+    gint32    (*remove_reference) (GSignondIdentityIface *iface, const gchar *reference);
+
+};
+
+GType gsignond_identity_iface_get_type (void);
+
+guint32 gsignond_identity_iface_request_credentials_update (
+                                                    GSignondIdentityIface *self,
+                                                    const gchar *message);
+GVariant * gsignond_identity_iface_get_info (GSignondIdentityIface *self);
+gboolean gsignond_identity_iface_verify_user (GSignondIdentityIface *self,
+                                              const GVariant *params);
+gboolean gsignond_identity_iface_verify_secret (GSignondIdentityIface *self,
+                                                const gchar *secret);
+void gsignond_identity_iface_remove (GSignondIdentityIface *self);
+gboolean gsignond_identity_iface_sign_out (GSignondIdentityIface *self);
+guint32 gsignond_identity_iface_store (GSignondIdentityIface *self,
+                                       const GVariant *info);
+gint32 gsignond_identity_iface_add_reference (GSignondIdentityIface *self,
+                                              const gchar *reference);
+gint32 gsignond_identity_iface_remove_reference (GSignondIdentityIface *self,
+                                                 const gchar *reference);
+
+G_END_DECLS
+
+#endif /* __GSIGNOND_IDENTITY_IFACE_H_ */
diff --git a/src/daemon/gsignond-identity.c b/src/daemon/gsignond-identity.c
new file mode 100644 (file)
index 0000000..2510c50
--- /dev/null
@@ -0,0 +1,301 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-identity.h"
+#include <daemon/gsignond-identity-iface.h>
+#include <daemon/dbus/gsignond-dbus.h>
+#include <daemon/dbus/gsignond-dbus-identity-adapter.h>
+#include <common/gsignond-log.h>
+
+enum 
+{
+    PROP_0,
+    PROP_ID,
+    N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES];
+
+struct _GSignondIdentityPrivate
+{
+    guint32 id;
+    GSignondDaemon *parent;
+    GSignondDbusIdentityAdapter *identity_adapter;
+};
+
+static void gsignond_identity_iface_init (gpointer g_iface, gpointer iface_data);
+
+G_DEFINE_TYPE_EXTENDED (GSignondIdentity, gsignond_identity, G_TYPE_OBJECT, 0,
+                        G_IMPLEMENT_INTERFACE (GSIGNOND_TYPE_IDENTITY_IFACE, 
+                                               gsignond_identity_iface_init));
+
+
+#define GSINGON_IDENTITY_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_IDENTITY, GSignondIdentityPrivate)
+
+static guint32 gsignond_identity_request_credentials_update (
+                                                    GSignondIdentityIface *self,
+                                                    const gchar *message);
+static GVariant * gsignond_identity_get_info (GSignondIdentityIface *self);
+static gboolean gsignond_identity_verify_user (GSignondIdentityIface *self,
+                                               const GVariant *params);
+static gboolean gsignond_identity_verify_secret (GSignondIdentityIface *self,
+                                                 const gchar *secret);
+static void gsignond_identity_remove (GSignondIdentityIface *self);
+static gboolean gsignond_identity_sing_out (GSignondIdentityIface *self);
+static guint32 gsignond_identity_store (GSignondIdentityIface *self,
+                                        const GVariant *info);
+static gint32 gsignond_identity_add_reference (GSignondIdentityIface *self,
+                                               const gchar *reference);
+static gint32 gsignond_identity_remove_reference (GSignondIdentityIface *self,
+                                                  const gchar *reference);
+
+
+static GObject*
+gsignond_identity_constructor (GType type,
+                               guint n_construct_params,
+                               GObjectConstructParam *construct_params)
+{
+    return G_OBJECT_CLASS (gsignond_identity_parent_class)->constructor (
+                  type, n_construct_params, construct_params);
+        
+}
+
+static void
+gsignond_identity_get_property (GObject *object, 
+                                guint property_id,
+                                GValue *value, GParamSpec *pspec)
+{
+    GSignondIdentity *self = GSIGNOND_IDENTITY (object);
+
+    switch (property_id)
+    {
+        case PROP_ID: {
+            guint32 id = gsignond_identity_get_id (self);
+            g_value_set_uint (value, id);
+            break;
+        }
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+gsignond_identity_set_property (GObject *object, 
+                                guint property_id,
+                                const GValue *value, GParamSpec *pspec)
+{
+    GSignondIdentity *self = GSIGNOND_IDENTITY (object);
+
+    switch (property_id)
+    {
+        case PROP_ID: {
+            guint32 id = g_value_get_uint (value);
+            gsignond_identity_set_id (self, id);
+            break;
+        }
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+gsignond_identity_dispose (GObject *object)
+{
+    GSignondIdentity *self = GSIGNOND_IDENTITY(object);
+
+    if (self->priv->identity_adapter) {
+        g_object_unref (self->priv->identity_adapter);
+        self->priv->identity_adapter = NULL;
+    }
+
+    if (self->priv->parent) {
+        g_object_unref (self->priv->parent);
+        self->priv->parent = NULL;
+    }
+   
+    G_OBJECT_CLASS (gsignond_identity_parent_class)->dispose (object);
+}
+
+static void
+gsignond_identity_finalize (GObject *object)
+{
+    G_OBJECT_CLASS (gsignond_identity_parent_class)->finalize (object);
+}
+
+static void
+gsignond_identity_init (GSignondIdentity *self)
+{
+    GError *err = NULL;
+    self->priv = GSINGON_IDENTITY_PRIV(self);
+
+    self->priv->identity_adapter =
+        gsignond_dbus_identity_adapter_new (GSIGNOND_IDENTITY_IFACE (self));
+
+}
+
+static void
+gsignond_identity_class_init (GSignondIdentityClass *klass)
+{
+    GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+    g_type_class_add_private (object_class, sizeof (GSignondIdentityPrivate));
+
+    object_class->constructor = gsignond_identity_constructor;
+    object_class->get_property = gsignond_identity_get_property;
+    object_class->set_property = gsignond_identity_set_property;
+    object_class->dispose = gsignond_identity_dispose;
+    object_class->finalize = gsignond_identity_finalize;
+
+    properties[PROP_ID] =
+        g_param_spec_uint ("id", 
+                           "unique id", 
+                           "Unique identity id", 
+                           0, 
+                           G_MAXINT, 
+                           0, 
+                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+    g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static void
+gsignond_identity_iface_init (gpointer g_iface, gpointer iface_data)
+{
+    GSignondIdentityIfaceInterface *identity_iface =
+        (GSignondIdentityIfaceInterface *) g_iface;
+
+    (void)iface_data;
+
+    identity_iface->request_credentials_update =
+        gsignond_identity_request_credentials_update;
+    identity_iface->get_info = gsignond_identity_get_info;
+    identity_iface->verify_user = gsignond_identity_verify_user;
+    identity_iface->verify_secret = gsignond_identity_verify_secret;
+    identity_iface->remove = gsignond_identity_remove;
+    identity_iface->sign_out = gsignond_identity_sing_out;
+    identity_iface->store = gsignond_identity_store;
+    identity_iface->add_reference = gsignond_identity_add_reference;
+    identity_iface->remove_reference = gsignond_identity_remove_reference;
+}
+
+static guint32
+gsignond_identity_request_credentials_update (GSignondIdentityIface *self,
+                                              const gchar *message) 
+{
+    (void) self;
+    (void) message;
+
+    return 0;
+}
+
+static GVariant * 
+gsignond_identity_get_info (GSignondIdentityIface *self)
+{
+    (void) self;
+
+    return NULL;
+}
+
+static gboolean 
+gsignond_identity_verify_user (GSignondIdentityIface *self,
+                               const GVariant *params)
+{
+    (void) self;
+    (void) params;
+
+    return FALSE;
+}
+
+static gboolean
+gsignond_identity_verify_secret (GSignondIdentityIface *self,
+                                 const gchar *secret)
+{
+    (void) self;
+    (void) secret;
+
+    return FALSE;
+}
+
+static void
+gsignond_identity_remove (GSignondIdentityIface *self)
+{
+    (void) self;
+}
+
+static gboolean 
+gsignond_identity_sing_out (GSignondIdentityIface *self)
+{
+    (void) self;
+
+    return FALSE;
+}
+
+static guint32
+gsignond_identity_store (GSignondIdentityIface *self, const GVariant *info)
+{
+    (void) self;
+    (void) info;
+
+    return 0;
+}
+
+static gint32
+gsignond_identity_add_reference (GSignondIdentityIface *self,
+                                 const gchar *reference)
+{
+    (void) self;
+    (void) reference;
+
+    return 0;
+}
+
+static gint32
+gsignond_identity_remove_reference (GSignondIdentityIface *self,
+                                    const gchar *reference)
+{
+    (void) self;
+    (void) reference;
+
+    return 0;
+}
+
+guint32 gsignond_identity_get_id (GSignondIdentity *self)
+{
+    return self->priv->id;
+}
+
+gboolean gsignond_identity_set_id (GSignondIdentity *self, guint32 id)
+{
+    self->priv->id = id;
+
+    return TRUE;
+}
+
+GSignondIdentity * gsignond_identity_new (guint32 id, GSignondDaemon *parent)
+{
+    GSignondIdentity *identity =
+        GSIGNOND_IDENTITY(g_object_new (GSIGNOND_TYPE_IDENTITY, "id", id, NULL));
+
+    identity->priv->parent = g_object_ref (parent);
+}
+
diff --git a/src/daemon/gsignond-identity.h b/src/daemon/gsignond-identity.h
new file mode 100644 (file)
index 0000000..942d5d4
--- /dev/null
@@ -0,0 +1,69 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_IDENTITY_H_
+#define __GSIGNOND_IDENTITY_H_
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "gsignond-daemon.h"
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_IDENTITY            (gsignond_identity_get_type())
+#define GSIGNOND_IDENTITY(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GSIGNOND_TYPE_IDENTITY, GSignondIdentity))
+#define GSIGNOND_IDENTITY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), GSIGNOND_TYPE_IDENTITY, GSignondIdentityClass))
+#define GSIGNOND_IS_IDENTITY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSIGNOND_TYPE_IDENTITY))
+#define GSIGNOND_IS_IDENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSIGNOND_TYPE_IDENTITY))
+#define GSIGNOND_IDENTITY_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GSIGNOND_TYPE_IDENTITY, GSignondIdentityClass))
+
+typedef struct _GSignondIdentity GSignondIdentity;
+typedef struct _GSignondIdentityClass GSignondIdentityClass;
+typedef struct _GSignondIdentityPrivate GSignondIdentityPrivate;
+
+struct _GSignondIdentity
+{
+    GObject parent;
+
+    /* priv */
+    GSignondIdentityPrivate *priv;
+};
+
+struct _GSignondIdentityClass
+{
+    GObjectClass parent_class;
+};
+
+GType gsignond_identity_get_type (void) G_GNUC_CONST;
+
+GSignondIdentity * gsignond_identity_new (guint32 id, GSignondDaemon *parent);
+
+guint32 gsignond_identity_get_id (GSignondIdentity *identity);
+
+gboolean gsignond_identity_set_id (GSignondIdentity *identity, guint32 id);
+
+G_END_DECLS
+
+#endif /* __GSIGNOND_IDENTITY_H_ */
diff --git a/src/daemon/main.c b/src/daemon/main.c
new file mode 100644 (file)
index 0000000..20b3e54
--- /dev/null
@@ -0,0 +1,123 @@
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <signal.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <common/gsignond-log.h>
+#include <daemon/gsignond-daemon.h>
+
+GSignondDaemon *_daemon;
+
+static void _signal_handler (int sig)
+{
+    (void) sig;
+}
+
+static void _install_sighandlers()
+{
+    struct sigaction act;
+
+    act.sa_handler = _signal_handler;
+    sigemptyset (&act.sa_mask);
+    act.sa_flags = SA_RESTART;
+
+    sigaction (SIGHUP, &act, 0);
+    sigaction (SIGTERM, &act, 0);
+    sigaction (SIGINT, &act, 0);
+}
+
+static void
+_on_bus_acquired (GDBusConnection *connection,
+                  const gchar     *name,
+                  gpointer         user_data)
+{
+    INFO ("Connected to the session bus");
+    if (connection != NULL) 
+        _daemon = gsignond_daemon_new ();
+}
+
+static void
+_on_name_lost (GDBusConnection *connection,
+               const gchar     *name,
+               gpointer         user_data)
+{
+    GMainLoop *loop = (GMainLoop *) user_data;
+    INFO ("Lost (or failed to acquire) the name '%s' on the session message bus", name);
+    g_main_loop_quit (loop);
+}
+
+static void
+_on_name_acquired (GDBusConnection *connection,
+                   const gchar     *name,
+                   gpointer         user_data)
+{
+    INFO ("Acquired the name %s on the session message bus", name);
+}
+
+
+int main (int argc, char **argv)
+{
+    GError *error = NULL;
+    GOptionContext *opt_context = NULL;
+    gint ret = 0;
+    guint name_owner_id = 0;
+    guint sigint_id =  0;
+    GOptionEntry opt_entries[] = {
+        {NULL }
+    };
+    GMainLoop *loop = 0;
+
+    g_type_init ();
+
+    opt_context = g_option_context_new ("SSO daemon");
+    g_option_context_add_main_entries (opt_context, opt_entries, NULL);
+    if (!g_option_context_parse (opt_context, &argc, &argv, &error)) {
+        ERR ("Error parsing options: %s", error->message);
+        g_error_free (error);
+        return -1;
+    }
+
+    //_install_sighandlers();
+
+    loop = g_main_loop_new (NULL, FALSE);
+
+    name_owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
+            "com.google.code.AccountsSSO.SingleSignOn",
+            G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
+            G_BUS_NAME_OWNER_FLAGS_REPLACE,
+            _on_bus_acquired,
+            _on_name_acquired,
+            _on_name_lost,
+            loop, NULL);
+
+    INFO ("Entering main event loop");
+
+    g_main_loop_run (loop);
+
+    if (_daemon) g_object_unref (_daemon);
+
+    return 0;
+}