daemon: Filling stored 'token-data' in session data passed to plugin process.
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Tue, 7 May 2013 12:59:29 +0000 (15:59 +0300)
committerAmarnath Valluri <amarnath.valluri@linux.intel.com>
Wed, 8 May 2013 07:57:15 +0000 (10:57 +0300)
src/daemon/gsignond-auth-session.c
src/daemon/gsignond-auth-session.h
src/daemon/gsignond-identity.c

index ec371fe..83e25d0 100644 (file)
@@ -63,6 +63,7 @@ struct _GSignondAuthSessionPrivate
     GSignondPluginProxy *proxy;
     GSequence *available_mechanisms;
     GSignondIdentityInfo *identity_info;
+    GSignondDictionary *token_data;
 };
 
 G_DEFINE_TYPE (GSignondAuthSession, gsignond_auth_session, G_TYPE_OBJECT)
@@ -232,6 +233,14 @@ gsignond_auth_session_process (GSignondAuthSession *self,
         }
     }
 
+    /* pass token data to session data */
+    if (self->priv->token_data) {
+        GVariant *token_data = gsignond_dictionary_to_variant (self->priv->token_data);
+        /* FIXME: better add API GSignondSessionData to support(set/get) token data.
+                  That will be the cleaner solution */
+        gsignond_dictionary_set (session_data, "Token", token_data);
+    }
+
     _ProcessData * data = g_slice_new0 (_ProcessData);
     data->self = self;
     data->ready_cb = ready_cb;
@@ -335,6 +344,11 @@ _dispose (GObject *object)
         self->priv->identity_info = NULL;
     }
 
+    if (self->priv->token_data) {
+        gsignond_dictionary_unref (self->priv->token_data);
+        self->priv->token_data = NULL;
+    }
+
     G_OBJECT_CLASS (gsignond_auth_session_parent_class)->dispose (object);
 }
 
@@ -512,13 +526,14 @@ gsignond_auth_session_notify_refreshed (GSignondAuthSession *self,
  * gsignond_auth_session_new:
  * @info: instance of #GSignondIdentityInfo
  * @method: authentication method
+ * @token_data: (transfer full) stored token data stored for #method
  *
  * Creates instance of #GSignondAuthSession.
  *
  * Returns: (transfer full) newly created object 
  */
 GSignondAuthSession * 
-gsignond_auth_session_new (GSignondIdentityInfo *info, const gchar *method)
+gsignond_auth_session_new (GSignondIdentityInfo *info, const gchar *method, GSignondDictionary *token_data)
 {
     GSignondPluginProxy* proxy = NULL;
 
@@ -533,6 +548,7 @@ gsignond_auth_session_new (GSignondIdentityInfo *info, const gchar *method)
                       "method", method, NULL);
     auth_session->priv->proxy = proxy;
     auth_session->priv->identity_info = g_hash_table_ref ((GHashTable *)info);
+    auth_session->priv->token_data = token_data;
 
     return auth_session;
 }
index 0045f2c..2863bca 100644 (file)
@@ -142,7 +142,8 @@ gsignond_auth_session_notify_refreshed (GSignondAuthSession *self,
 
 GSignondAuthSession * 
 gsignond_auth_session_new (GSignondIdentityInfo *info,
-                           const gchar *method);
+                           const gchar *method,
+                           GSignondDictionary *token_data);
 
 G_END_DECLS
 
index cd702f7..f399f92 100644 (file)
@@ -416,6 +416,8 @@ gsignond_identity_get_auth_session (GSignondIdentity *identity,
     GSignondAuthSession *session = NULL;
     GHashTable *supported_methods = NULL;
     gboolean method_available = FALSE;
+    guint32 identity_id ;
+    GSignondDictionary *token_data = NULL;
 
     VALIDATE_IDENTITY_READ_ACCESS (identity, ctx, NULL);
 
@@ -462,7 +464,14 @@ gsignond_identity_get_auth_session (GSignondIdentity *identity,
         return NULL;
     }
 
-    session = gsignond_auth_session_new (identity->priv->info, method);
+    if ( (identity_id = gsignond_identity_info_get_id (identity->priv->info)) !=
+            GSIGNOND_IDENTITY_INFO_NEW_IDENTITY) {
+        token_data = gsignond_daemon_load_identity_data (identity->priv->owner, identity_id, method);
+    } else {
+        /* TODO : load cached token data for unsaved identity */
+    }
+
+    session = gsignond_auth_session_new (identity->priv->info, method, token_data);
 
     if (!session) {
         if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_UNKNOWN, "Unknown error");