daemon: handled 'store' token data request from plugins.
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Thu, 2 May 2013 10:50:56 +0000 (13:50 +0300)
committerAmarnath Valluri <amarnath.valluri@linux.intel.com>
Wed, 8 May 2013 07:35:31 +0000 (10:35 +0300)
Token data type is changed to GSignondDictionary.

include/gsignond/gsignond-plugin-interface.h
src/common/gsignond-plugin-interface.c
src/daemon/gsignond-auth-session.c
src/daemon/gsignond-auth-session.h
src/daemon/gsignond-daemon.c
src/daemon/gsignond-daemon.h
src/daemon/gsignond-identity.c
src/daemon/plugins/gsignond-plugin-proxy.c

index 37d4ba5..ad15c0e 100644 (file)
@@ -119,7 +119,7 @@ gsignond_plugin_response_final (GSignondPlugin *self,
                              GSignondSessionData *session_data);
 void 
 gsignond_plugin_store (GSignondPlugin *self, 
-                            GSignondSessionData *session_data);
+                       GSignondDictionary *token_data);
 void 
 gsignond_plugin_error (GSignondPlugin *self, GError *error);
 void 
index d8fbd36..664f1f9 100644 (file)
@@ -56,7 +56,7 @@ static void gsignond_plugin_default_init (GSignondPluginInterface *g_class)
 
     signals[STORE] = g_signal_new ("store", G_TYPE_FROM_CLASS (g_class),
         G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE,
-        1, GSIGNOND_TYPE_SESSION_DATA);
+        1, GSIGNOND_TYPE_DICTIONARY);
 
     signals[ERROR] = g_signal_new ("error", G_TYPE_FROM_CLASS (g_class),
         G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE,
@@ -149,9 +149,9 @@ void gsignond_plugin_response_final (GSignondPlugin *self,
 }
 
 void gsignond_plugin_store (GSignondPlugin *self, 
-                            GSignondSessionData *session_data)
+                            GSignondDictionary *token_data)
 {
-    g_signal_emit (self, signals[STORE], 0, session_data);
+    g_signal_emit (self, signals[STORE], 0, token_data);
 }
 
 void gsignond_plugin_error (GSignondPlugin *self, GError *error)
index 8a31978..ec371fe 100644 (file)
@@ -398,8 +398,8 @@ gsignond_auth_session_class_init (GSignondAuthSessionClass *klass)
             NULL,
             G_TYPE_NONE,
             1,
-            GSIGNOND_TYPE_SESSION_DATA);
-    
+            GSIGNOND_TYPE_DICTIONARY);
+
     signals[SIG_PROCESS_USER_ACTION_REQUIRED] =  g_signal_new ("process-user-action-required",
             GSIGNOND_TYPE_AUTH_SESSION,
             G_SIGNAL_RUN_LAST,
@@ -488,9 +488,9 @@ gsignond_auth_session_notify_state_changed (GSignondAuthSession *self,
 
 void 
 gsignond_auth_session_notify_store (GSignondAuthSession *self, 
-                                    GSignondSessionData *session_data)
+                                    GSignondDictionary *token_data)
 {
-    g_signal_emit (self, signals[SIG_PROCESS_STORE], 0, session_data);
+    g_signal_emit (self, signals[SIG_PROCESS_STORE], 0, token_data);
 }
 
 void 
index 45710c5..0045f2c 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <glib-object.h>
 
+#include <gsignond/gsignond-dictionary.h>
 #include <gsignond/gsignond-identity-info.h>
 #include <gsignond/gsignond-signonui-data.h>
 #include <gsignond/gsignond-session-data.h>
@@ -129,7 +130,7 @@ gsignond_auth_session_notify_state_changed (GSignondAuthSession *self,
 
 void 
 gsignond_auth_session_notify_store (GSignondAuthSession *self, 
-                                    GSignondSessionData *session_data);
+                                    GSignondDictionary *token_data);
 
 void 
 gsignond_auth_session_notify_user_action_required (GSignondAuthSession *self, 
index 5a56ebc..81d14d5 100644 (file)
@@ -378,7 +378,7 @@ gsignond_daemon_remove_identity_reference (GSignondDaemon *daemon, guint32 ident
 }
 
 gboolean
-gsignond_daemon_store_identity_data (GSignondDaemon *daemon, guint32 identity_id, const gchar *method, GHashTable *data)
+gsignond_daemon_store_identity_data (GSignondDaemon *daemon, guint32 identity_id, const gchar *method, GSignondDictionary *data)
 {
     g_return_val_if_fail (daemon && GSIGNOND_IS_DAEMON (daemon), FALSE);
 
@@ -393,6 +393,16 @@ gsignond_daemon_clear_identity_data (GSignondDaemon *daemon, guint32 identity_id
     return gsignond_db_credentials_database_remove_data (daemon->priv->db, identity_id, NULL);
 }
 
+GSignondDictionary *
+gsignond_daemon_load_identity_data (GSignondDaemon *daemon, guint32 identity_id, const gchar *method)
+{
+    g_return_val_if_fail (daemon && GSIGNOND_IS_DAEMON (daemon), NULL);
+    g_return_val_if_fail (identity_id, NULL);
+    g_return_val_if_fail (method, NULL);
+
+    return gsignond_db_credentials_database_load_data (daemon->priv->db, identity_id, method);
+}
+
 GSignondIdentity *
 gsignond_daemon_register_new_identity (GSignondDaemon *daemon,
                                        const GSignondSecurityContext *ctx,
index 0b68fc4..1feac51 100644 (file)
@@ -106,11 +106,14 @@ 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);
+gsignond_daemon_store_identity_data (GSignondDaemon *daemon, guint32 identity_id, const gchar *method, GSignondDictionary *data);
 
 gboolean
 gsignond_daemon_clear_identity_data (GSignondDaemon *daemon, guint32 identity_id);
 
+GSignondDictionary *
+gsignond_daemon_load_identity_data (GSignondDaemon *daemon, guint32 identity_id, const gchar *method);
+
 guint
 gsignond_daemon_get_timeout (GSignondDaemon *self) G_GNUC_CONST;
 
index ad34bcb..cd702f7 100644 (file)
@@ -367,6 +367,24 @@ _on_user_action_required (GSignondAuthSession *session, GSignondSignonuiData *ui
             ui_data, _on_user_action_completed, _on_refresh_requested, session);
 }
 
+static void
+_on_store_token (GSignondAuthSession *session, GSignondDictionary *token_data, gpointer userdata)
+{
+    GSignondIdentity *identity = GSIGNOND_IDENTITY (userdata);
+    guint32 identity_id = GSIGNOND_IDENTITY_INFO_NEW_IDENTITY;
+
+    g_return_if_fail (identity && session && GSIGNOND_IS_AUTH_SESSION (session));
+
+    identity_id = gsignond_identity_info_get_id (identity->priv->info);
+
+    if (identity_id == GSIGNOND_IDENTITY_INFO_NEW_IDENTITY)
+        /* TODO; cache token */
+        ;
+    else
+        gsignond_daemon_store_identity_data (identity->priv->owner, identity_id, 
+            gsignond_auth_session_get_method (session), token_data);
+}
+
 static gboolean
 _compare_session_by_pointer (gpointer key, gpointer value, gpointer dead_object)
 {
@@ -454,6 +472,7 @@ gsignond_identity_get_auth_session (GSignondIdentity *identity,
     /* Handle 'ui' signanls on session */
     g_signal_connect (session, "process-user-action-required", G_CALLBACK (_on_user_action_required), identity);
     g_signal_connect (session, "process-refreshed", G_CALLBACK (_on_refresh_dialog), identity);
+    g_signal_connect (session, "process-store", G_CALLBACK (_on_store_token), identity);
 
     g_hash_table_insert (identity->priv->auth_sessions, g_strdup (method), session);
     g_object_weak_ref (G_OBJECT (session), _on_session_close, identity);
index a4b8b0f..6289054 100644 (file)
@@ -74,7 +74,7 @@ static void gsignond_plugin_proxy_response_callback(GSignondPlugin* plugin,
                                                   GSignondSessionData* result,
                                                   gpointer user_data);
 static void gsignond_plugin_proxy_store_callback(GSignondPlugin* plugin, 
-                                                  GSignondSessionData* result,
+                                                  GSignondDictionary* token_data,
                                                   gpointer user_data);
 static void gsignond_plugin_proxy_refreshed_callback(GSignondPlugin* plugin, 
                                                   GSignondSessionData* result,
@@ -518,7 +518,7 @@ gsignond_plugin_proxy_response_callback(GSignondPlugin *plugin,
 
 static void
 gsignond_plugin_proxy_store_callback (GSignondPlugin *plugin, 
-                                      GSignondSessionData *result,
+                                      GSignondDictionary *token_data,
                                       gpointer user_data)
 {    
     GSignondPluginProxy *self = GSIGNOND_PLUGIN_PROXY (user_data);
@@ -529,7 +529,7 @@ gsignond_plugin_proxy_store_callback (GSignondPlugin *plugin,
             in plugin proxy", priv->plugin_type);
         return;
     }
-    gsignond_auth_session_notify_store (priv->active_session, result);
+    gsignond_auth_session_notify_store (priv->active_session, token_data);
 }
 
 static void