[evolution-mapi/gnome-3-6] Teach collection backend about Kerberos authentication



commit 3594369638f59269a5945c4ddc706d966f00bbdf
Author: Milan Crha <mcrha redhat com>
Date:   Tue Feb 26 09:45:17 2013 +0100

    Teach collection backend about Kerberos authentication

 configure.ac                       |    2 +-
 src/collection/e-mapi-backend.c    |   44 ++++++++++++++++++++++++++++++++++++
 src/libexchangemapi/e-mapi-utils.c |   18 ++++++++++++++
 src/libexchangemapi/e-mapi-utils.h |    3 ++
 4 files changed, 66 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f9cc69f..6f79660 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,7 +63,7 @@ AS_COMPILER_FLAGS(WARNING_FLAGS,
        -Wformat-nonliteral -Wformat-security -Winit-self
        -Wmissing-declarations -Wmissing-include-dirs
        -Wmissing-noreturn -Wnested-externs -Wpointer-arith
-       -Wundef -Wwrite-strings")
+       -Wundef -Wwrite-strings -Wno-deprecated-declarations")
 AC_SUBST(WARNING_FLAGS)
 
 dnl Other useful compiler warnings for test builds only.
diff --git a/src/collection/e-mapi-backend.c b/src/collection/e-mapi-backend.c
index 2fd8ed2..dc51049 100644
--- a/src/collection/e-mapi-backend.c
+++ b/src/collection/e-mapi-backend.c
@@ -69,11 +69,55 @@ mapi_backend_get_settings (EMapiBackend *backend)
        return CAMEL_MAPI_SETTINGS (settings);
 }
 
+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;
+       GError *error = NULL;
+
+       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, &error);
+
+       if (error) {
+               g_warning ("[evolution-mapi] Failed to trigger KrbAuthDialog: %s", error->message);
+               g_clear_error (&error);
+       }
+
+       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);
+
        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 994e2a3..ba75f27 100644
--- a/src/libexchangemapi/e-mapi-utils.c
+++ b/src/libexchangemapi/e-mapi-utils.c
@@ -841,6 +841,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 d376aaf..e469cb8 100644
--- a/src/libexchangemapi/e-mapi-utils.h
+++ b/src/libexchangemapi/e-mapi-utils.h
@@ -85,6 +85,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]