daemon/dbus: Identity signout implemented
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Tue, 30 Apr 2013 07:55:36 +0000 (10:55 +0300)
committerAmarnath Valluri <amarnath.valluri@linux.intel.com>
Tue, 7 May 2013 07:45:25 +0000 (10:45 +0300)
src/daemon/dbus/gsignond-dbus-identity-adapter.c
src/daemon/gsignond-daemon.c
src/daemon/gsignond-daemon.h
src/daemon/gsignond-identity.c

index 5dd4574..f3bc47d 100644 (file)
@@ -641,7 +641,7 @@ _handle_sign_out (GSignondDbusIdentityAdapter *self,
         g_dbus_method_invocation_return_gerror (invocation, error);
         g_error_free (error);
     }
-        
+
     gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE(self));
 
     return TRUE;
@@ -740,6 +740,12 @@ _emit_info_updated (GSignondIdentity *identity,
 
     if (change == GSIGNOND_IDENTITY_REMOVED)
         gsignond_disposable_delete_later (GSIGNOND_DISPOSABLE (self));
+    else if (change == GSIGNOND_IDENTITY_SIGNED_OUT && self->priv->sessions) {
+        /* destroy all sessions on this identity as it's signed out */
+        g_list_foreach (self->priv->sessions, _destroy_session, NULL);
+        g_list_free (self->priv->sessions);
+        self->priv->sessions = NULL;
+    }
 }
 
 const gchar *
index 23b1237..5a56ebc 100644 (file)
@@ -377,6 +377,22 @@ gsignond_daemon_remove_identity_reference (GSignondDaemon *daemon, guint32 ident
     return gsignond_db_credentials_database_remove_reference (daemon->priv->db, identity_id, owner, reference);
 }
 
+gboolean
+gsignond_daemon_store_identity_data (GSignondDaemon *daemon, guint32 identity_id, const gchar *method, GHashTable *data)
+{
+    g_return_val_if_fail (daemon && GSIGNOND_IS_DAEMON (daemon), FALSE);
+
+    return gsignond_db_credentials_database_update_data (daemon->priv->db, identity_id, method, data);
+}
+
+gboolean
+gsignond_daemon_clear_identity_data (GSignondDaemon *daemon, guint32 identity_id)
+{
+    g_return_val_if_fail (daemon && GSIGNOND_IS_DAEMON (daemon), FALSE);
+
+    return gsignond_db_credentials_database_remove_data (daemon->priv->db, identity_id, NULL);
+}
+
 GSignondIdentity *
 gsignond_daemon_register_new_identity (GSignondDaemon *daemon,
                                        const GSignondSecurityContext *ctx,
index a3aff37..0b68fc4 100644 (file)
@@ -105,6 +105,12 @@ gsignond_daemon_add_identity_reference (GSignondDaemon *daemon, guint32 identity
 gboolean
 gsignond_daemon_remove_identity_reference (GSignondDaemon *daemon, guint32 identity_id, const GSignondSecurityContext *owner, const gchar *ref);
 
+gboolean
+gsignond_daemon_store_identity_data (GSignondDaemon *daemon, guint32 identity_id, const gchar *method, GHashTable *data);
+
+gboolean
+gsignond_daemon_clear_identity_data (GSignondDaemon *daemon, guint32 identity_id);
+
 guint
 gsignond_daemon_get_timeout (GSignondDaemon *self) G_GNUC_CONST;
 
index 170ab57..ad34bcb 100644 (file)
@@ -34,6 +34,7 @@
 #include "gsignond-auth-session.h"
 #include "gsignond/gsignond-config-dbus.h"
 #include "gsignond/gsignond-signonui.h"
+#include "common/gsignond-identity-info-internal.h"
 #include "plugins/gsignond-plugin-proxy-factory.h"
 
 enum 
@@ -44,9 +45,6 @@ enum
 };
 
 enum {
-    SIG_VERIFY_USER,
-    SIG_VERIFY_SECRET,
-    SIG_SIGNOUT,
     SIG_USER_VERIFIED,
     SIG_SECRET_VERIFIED,
     SIG_CREDENTIALS_UPDATED,
@@ -222,15 +220,6 @@ gsignond_identity_class_init (GSignondIdentityClass *klass)
     
     g_object_class_install_properties (object_class, N_PROPERTIES, properties);
 
-    signals[SIG_SIGNOUT] = g_signal_new ("signout",
-                  GSIGNOND_TYPE_IDENTITY,
-                  G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-                  0,
-                  NULL, NULL,
-                  NULL,
-                  G_TYPE_BOOLEAN,
-                  0,
-                  G_TYPE_NONE);
     signals[SIG_USER_VERIFIED] =  g_signal_new ("user-verified",
                 GSIGNOND_TYPE_IDENTITY,
                 G_SIGNAL_RUN_LAST,
@@ -693,18 +682,25 @@ gsignond_identity_sign_out (GSignondIdentity *identity,
         return FALSE;
     }
     gboolean success = FALSE;
+    guint32 identity_id = GSIGNOND_IDENTITY_INFO_NEW_IDENTITY;
 
     VALIDATE_IDENTITY_READ_ACCESS (identity, ctx, FALSE);
 
-    /*
-     * TODO: close all auth_sessions and emit "identity-signed-out"
-     */
-    g_signal_emit (identity,
-                   signals[SIG_SIGNOUT],
-                   0,
-                   &success);
+    identity_id = gsignond_identity_info_get_id (identity->priv->info);
 
-    if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_UNKNOWN, "Not supported");
+    if (identity_id == GSIGNOND_IDENTITY_INFO_NEW_IDENTITY) {
+        /* TODO; clear the cached secret for unstored identity */
+        success = TRUE;
+    }
+    else {
+        success = gsignond_daemon_clear_identity_data (identity->priv->owner, identity_id);
+    }
+    if(!success) {
+        if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_UNKNOWN, "Failed to clear data");
+        return FALSE;
+    }
+
+    g_signal_emit (identity, signals[SIG_INFO_UPDATED], 0, GSIGNOND_IDENTITY_SIGNED_OUT, NULL);
 
     return success;
 }