[evolution-mapi] Teach collection backend about Kerberos authentication



commit 3be93fb0e9f6a391b5b334997526d226befb64e9
Author: Milan Crha <mcrha redhat com>
Date:   Mon Feb 25 18:20:29 2013 +0100

    Teach collection backend about Kerberos authentication

 src/collection/e-mapi-backend.c    |   43 ++++++++++++++++++++++++++++++++---
 src/libexchangemapi/e-mapi-utils.c |   18 +++++++++++++++
 src/libexchangemapi/e-mapi-utils.h |    3 ++
 3 files changed, 60 insertions(+), 4 deletions(-)
---
diff --git a/src/collection/e-mapi-backend.c b/src/collection/e-mapi-backend.c
index c15bdeb..2608584 100644
--- a/src/collection/e-mapi-backend.c
+++ b/src/collection/e-mapi-backend.c
@@ -303,19 +303,44 @@ mapi_backend_sync_folders_idle_cb (gpointer user_data)
        return FALSE;
 }
 
+static ESourceAuthenticationResult
+mapi_backend_try_password_sync (ESourceAuthenticator *authenticator,
+                               const GString *password,
+                               GCancellable *cancellable,
+                               GError **error);
+
+static gpointer
+mapi_backend_authenticate_kerberos_thread (gpointer user_data)
+{
+       EMapiBackend *mapi_backend = user_data;
+       CamelMapiSettings *mapi_settings;
+
+       g_return_val_if_fail (E_IS_MAPI_BACKEND (mapi_backend), NULL);
+
+       mapi_settings = mapi_backend_get_settings (mapi_backend);
+       e_mapi_util_trigger_krb_auth_from_settings (mapi_settings, NULL);
+
+       mapi_backend_try_password_sync (E_SOURCE_AUTHENTICATOR (mapi_backend), NULL, NULL, NULL);
+
+       g_object_unref (mapi_backend);
+
+       return NULL;
+}
+
 static void
 mapi_backend_queue_auth_session (EMapiBackend *backend)
 {
+       CamelMapiSettings *mapi_settings;
+
+       mapi_settings = mapi_backend_get_settings (backend);
+
        if (!e_backend_get_online (E_BACKEND (backend))) {
                struct SyndFoldersData *sfd;
-               CamelMapiSettings *settings;
-
-               settings = mapi_backend_get_settings (backend);
 
                sfd = g_new0 (struct SyndFoldersData, 1);
                sfd->folders = NULL;
                sfd->backend = g_object_ref (backend);
-               sfd->profile = camel_mapi_settings_dup_profile (settings);
+               sfd->profile = camel_mapi_settings_dup_profile (mapi_settings);
 
                mapi_backend_sync_folders_idle_cb (sfd);
                sync_folders_data_free (sfd);
@@ -325,6 +350,16 @@ mapi_backend_queue_auth_session (EMapiBackend *backend)
 
        backend->priv->need_update_folders = FALSE;
 
+       /* kerberos doesn't use passwords, do it directly */
+       if (camel_mapi_settings_get_kerberos (mapi_settings)) {
+               GThread *thread;
+
+               thread = g_thread_new (NULL, mapi_backend_authenticate_kerberos_thread, g_object_ref 
(backend));
+               g_thread_unref (thread);
+
+               return;
+       }
+
        /* For now at least, we don't need to know the
         * results, so no callback function is needed. */
        e_backend_authenticate (
diff --git a/src/libexchangemapi/e-mapi-utils.c b/src/libexchangemapi/e-mapi-utils.c
index de79e05..d71831d 100644
--- a/src/libexchangemapi/e-mapi-utils.c
+++ b/src/libexchangemapi/e-mapi-utils.c
@@ -865,6 +865,24 @@ e_mapi_util_trigger_krb_auth (const EMapiProfileData *empd,
        return success && !local_error;
 }
 
+gboolean
+e_mapi_util_trigger_krb_auth_from_settings (CamelMapiSettings *mapi_settings,
+                                           GError **error)
+{
+       EMapiProfileData empd = { 0 };
+       CamelNetworkSettings *network_settings;
+
+       g_return_val_if_fail (CAMEL_IS_MAPI_SETTINGS (mapi_settings), FALSE);
+
+       network_settings = CAMEL_NETWORK_SETTINGS (mapi_settings);
+
+       empd.server = camel_network_settings_get_host (network_settings);
+       empd.username = camel_network_settings_get_user (network_settings);
+
+       e_mapi_util_profiledata_from_settings (&empd, mapi_settings);
+
+       return e_mapi_util_trigger_krb_auth (&empd, error);
+}
 
 /**
  * e_mapi_util_profile_name:
diff --git a/src/libexchangemapi/e-mapi-utils.h b/src/libexchangemapi/e-mapi-utils.h
index f24a336..17e0bd5 100644
--- a/src/libexchangemapi/e-mapi-utils.h
+++ b/src/libexchangemapi/e-mapi-utils.h
@@ -87,6 +87,9 @@ gchar *               e_mapi_util_profile_name                (struct mapi_context 
*mapi_ctx,
                                                         gboolean migrate);
 gboolean       e_mapi_util_trigger_krb_auth            (const EMapiProfileData *empd,
                                                         GError **error);
+gboolean       e_mapi_util_trigger_krb_auth_from_settings
+                                                       (CamelMapiSettings *mapi_settings,
+                                                        GError **error);
 
 gboolean       e_mapi_utils_add_spropvalue             (TALLOC_CTX *mem_ctx,
                                                         struct SPropValue **values_array,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]