[evolution-ews] Bug #677007 - Add Basic authentication type
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug #677007 - Add Basic authentication type
- Date: Fri, 13 Jul 2012 07:43:25 +0000 (UTC)
commit 1020b3254fa745d667e136aa96dfa08cac595b76
Author: Milan Crha <mcrha redhat com>
Date: Fri Jul 13 09:42:48 2012 +0200
Bug #677007 - Add Basic authentication type
.../exchange-ews-account-out-of-office.c | 5 ++++-
.../exchange-ews-account-setup.c | 5 ++++-
src/addressbook/e-book-backend-ews.c | 3 +++
src/calendar/e-cal-backend-ews.c | 1 +
src/camel/camel-ews-provider.c | 19 ++++++++++++++-----
src/camel/camel-ews-store.c | 8 +++-----
src/collection/e-ews-backend.c | 1 +
.../e-mail-config-ews-oal-combo-box.c | 1 +
src/configuration/e-mail-config-ews-ooo-page.c | 5 ++++-
src/server/e-ews-connection.c | 12 +++++++++++-
src/server/e-ews-connection.h | 1 +
src/server/tests/test-autocompletion.c | 2 +-
src/server/tests/test-connection.c | 2 +-
src/server/tests/test-createfolder.c | 2 +-
src/server/tests/test-cuditem.c | 2 +-
src/server/tests/test-deletefolder.c | 2 +-
src/server/tests/test-get-oof-settings.c | 2 +-
src/server/tests/test-getattachment.c | 2 +-
src/server/tests/test-getdelegate.c | 2 +-
src/server/tests/test-set-oof-settings.c | 2 +-
src/server/tests/test-syncfolder.c | 6 +++---
src/utils/ews-test-finditem-query.c | 2 +-
22 files changed, 60 insertions(+), 27 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-ews-account-out-of-office.c b/src/account-setup-eplugin/exchange-ews-account-out-of-office.c
index 690ecdf..634d834 100644
--- a/src/account-setup-eplugin/exchange-ews-account-out-of-office.c
+++ b/src/account-setup-eplugin/exchange-ews-account-out-of-office.c
@@ -288,7 +288,10 @@ get_connection (EMConfigTargetSettings *target)
password = get_password (target->storage_settings);
email = target->email_address;
- cnc = e_ews_connection_new (host_url, user, password, 30, NULL, NULL, &error);
+ cnc = e_ews_connection_new (host_url, user, password,
+ camel_network_settings_get_auth_mechanism (network_settings),
+ camel_ews_settings_get_timeout (ews_settings),
+ NULL, NULL, &error);
if (!cnc) {
g_warning ("Error in connection: %s\n", error->message);
diff --git a/src/account-setup-eplugin/exchange-ews-account-setup.c b/src/account-setup-eplugin/exchange-ews-account-setup.c
index 95bdae2..6f04a97 100644
--- a/src/account-setup-eplugin/exchange-ews-account-setup.c
+++ b/src/account-setup-eplugin/exchange-ews-account-setup.c
@@ -276,7 +276,10 @@ fetch_button_clicked_cb (GtkButton *button,
password = get_password (target);
/* pass user name while creating connection to fetch oals */
- cnc = e_ews_connection_new (oab_url, user, password, 30, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (oab_url, user, password,
+ camel_network_settings_get_auth_mechanism (network_settings),
+ camel_ews_settings_get_timeout (ews_settings),
+ NULL, NULL, NULL);
cbdata->cancellable = cancellable;
e_ews_connection_get_oal_list (
cnc, cancellable, ews_oal_list_ready, cbdata);
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index e6e59b1..38c6da6 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -1693,6 +1693,7 @@ ews_download_full_gal (EBookBackendEws *cbews,
comp_cache_file = g_build_filename (cache_dir, full->filename, NULL);
oab_cnc = e_ews_connection_new (full_url, priv->username, priv->password,
+ camel_network_settings_get_auth_mechanism (CAMEL_NETWORK_SETTINGS (settings)),
camel_ews_settings_get_timeout (settings),
NULL, NULL, NULL);
if (!e_ews_connection_download_oal_file_sync (
@@ -1849,6 +1850,7 @@ ebews_start_gal_sync (gpointer data)
priv = cbews->priv;
oab_cnc = e_ews_connection_new (priv->oab_url, priv->username, priv->password,
+ camel_network_settings_get_auth_mechanism (CAMEL_NETWORK_SETTINGS (settings)),
camel_ews_settings_get_timeout (settings),
NULL, NULL, NULL);
@@ -2950,6 +2952,7 @@ book_backend_ews_try_password_sync (ESourceAuthenticator *authenticator,
connection = e_ews_connection_new (
hosturl, user, password->str,
+ camel_network_settings_get_auth_mechanism (network_settings),
camel_ews_settings_get_timeout (ews_settings),
NULL, NULL, error);
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index ffbcb53..fca4d23 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -4059,6 +4059,7 @@ cal_backend_ews_try_password_sync (ESourceAuthenticator *authenticator,
connection = e_ews_connection_new (
hosturl, user, password->str,
+ camel_network_settings_get_auth_mechanism (network_settings),
camel_ews_settings_get_timeout (ews_settings),
NULL, NULL, error);
diff --git a/src/camel/camel-ews-provider.c b/src/camel/camel-ews-provider.c
index 32d843d..22300f1 100644
--- a/src/camel/camel-ews-provider.c
+++ b/src/camel/camel-ews-provider.c
@@ -88,23 +88,32 @@ static CamelProvider ews_provider = {
/* ... */
};
-/*TODO support more auth types */
-CamelServiceAuthType camel_ews_password_authtype = {
- N_("Password"),
+CamelServiceAuthType camel_ews_ntlm_authtype = {
+ N_("NTLM"),
N_("This option will connect to the Exchange server using a "
- "plaintext password."),
+ "plaintext password with NTLM authentication."),
"",
TRUE
};
+CamelServiceAuthType camel_ews_basic_authtype = {
+ N_("Basic"),
+
+ N_("This option will connect to the Exchange server using a "
+ "plaintext password with Basic authentication."),
+
+ "PLAIN",
+ TRUE
+};
+
void
camel_provider_module_init (void)
{
ews_provider.url_hash = ews_url_hash;
ews_provider.url_equal = ews_url_equal;
- ews_provider.authtypes = g_list_prepend (ews_provider.authtypes, &camel_ews_password_authtype);
+ ews_provider.authtypes = g_list_prepend (g_list_prepend (NULL, &camel_ews_basic_authtype), &camel_ews_ntlm_authtype);
ews_provider.translation_domain = GETTEXT_PACKAGE;
ews_provider.object_types[CAMEL_PROVIDER_STORE] = camel_ews_store_get_type ();
diff --git a/src/camel/camel-ews-store.c b/src/camel/camel-ews-store.c
index f8b9772..e5d2454 100644
--- a/src/camel/camel-ews-store.c
+++ b/src/camel/camel-ews-store.c
@@ -65,7 +65,6 @@ struct _CamelEwsStorePrivate {
EEwsConnection *cnc;
};
-extern CamelServiceAuthType camel_ews_password_authtype; /*for the query_auth_types function */
static gboolean ews_store_construct (CamelService *service, CamelSession *session,
CamelProvider *provider, GError **error);
@@ -284,6 +283,7 @@ ews_connect_sync (CamelService *service,
return TRUE;
priv->cnc = e_ews_connection_new (hosturl, user, NULL,
+ camel_network_settings_get_auth_mechanism (network_settings),
camel_ews_settings_get_timeout (ews_settings),
G_CALLBACK (ews_store_authenticate), service,
error);
@@ -484,11 +484,9 @@ ews_store_query_auth_types_sync (CamelService *service,
GCancellable *cancellable,
GError **error)
{
- GList *auth_types = NULL;
+ g_set_error_literal (error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, _("Query for authentication types is not supported"));
- d(printf("in query auth types\n"));
- auth_types = g_list_prepend (auth_types, &camel_ews_password_authtype);
- return auth_types;
+ return NULL;
}
static CamelFolderInfo * ews_create_folder_sync (CamelStore *store, const gchar *parent_name,const gchar *folder_name, GCancellable *cancellable, GError **error);
diff --git a/src/collection/e-ews-backend.c b/src/collection/e-ews-backend.c
index bc07b31..15d7df3 100644
--- a/src/collection/e-ews-backend.c
+++ b/src/collection/e-ews-backend.c
@@ -613,6 +613,7 @@ ews_backend_try_password_sync (ESourceAuthenticator *authenticator,
connection = e_ews_connection_new (
hosturl, user, password->str,
+ camel_network_settings_get_auth_mechanism (CAMEL_NETWORK_SETTINGS (settings)),
camel_ews_settings_get_timeout (settings),
NULL, NULL, error);
diff --git a/src/configuration/e-mail-config-ews-oal-combo-box.c b/src/configuration/e-mail-config-ews-oal-combo-box.c
index 6da8a4e..0c33f6b 100644
--- a/src/configuration/e-mail-config-ews-oal-combo-box.c
+++ b/src/configuration/e-mail-config-ews-oal-combo-box.c
@@ -162,6 +162,7 @@ mail_config_ews_oal_combo_box_try_password_sync (ESourceAuthenticator *auth,
/* XXX This takes a GError but never fails, so skip it. */
cnc = e_ews_connection_new (
oab_url, user, password->str,
+ camel_network_settings_get_auth_mechanism (network_settings),
camel_ews_settings_get_timeout (ews_settings),
NULL, NULL, NULL);
diff --git a/src/configuration/e-mail-config-ews-ooo-page.c b/src/configuration/e-mail-config-ews-ooo-page.c
index e9f7ac7..feb4502 100644
--- a/src/configuration/e-mail-config-ews-ooo-page.c
+++ b/src/configuration/e-mail-config-ews-ooo-page.c
@@ -327,7 +327,10 @@ get_connection (EMConfigTargetSettings *target)
password = get_password (target->storage_settings);
email = target->email_address;
- cnc = e_ews_connection_new (host_url, user, password, NULL, NULL, &error);
+ cnc = e_ews_connection_new (host_url, user, password,
+ camel_network_settings_get_auth_mechanism (network_settings),
+ camel_ews_settings_get_timeout (ews_settings),
+ NULL, NULL, &error);
if (!cnc) {
g_warning ("Error in connection: %s\n", error->message);
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 1fdf372..41566c3 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -1240,6 +1240,7 @@ EEwsConnection *
e_ews_connection_new (const gchar *uri,
const gchar *username,
const gchar *password,
+ const gchar *auth_mechanism,
guint timeout,
GCallback authenticate_cb,
gpointer authenticate_ctx,
@@ -1265,6 +1266,12 @@ e_ews_connection_new (const gchar *uri,
if (E_IS_EWS_CONNECTION (cnc)) {
g_object_ref (cnc);
+
+ g_object_set (G_OBJECT (cnc->priv->soup_session),
+ SOUP_SESSION_TIMEOUT, timeout,
+ SOUP_SESSION_USE_NTLM, g_strcmp0 (auth_mechanism, "PLAIN") != 0,
+ NULL);
+
g_static_mutex_unlock (&connecting);
return cnc;
}
@@ -1279,6 +1286,7 @@ e_ews_connection_new (const gchar *uri,
g_object_set (G_OBJECT (cnc->priv->soup_session),
SOUP_SESSION_TIMEOUT, timeout,
+ SOUP_SESSION_USE_NTLM, g_strcmp0 (auth_mechanism, "PLAIN") != 0,
NULL);
/* register a handler to the authenticate signal */
@@ -1698,7 +1706,9 @@ e_ews_autodiscover_ws_url (CamelEwsSettings *settings,
user = email_address;
cnc = e_ews_connection_new (url3, user, password,
- camel_ews_settings_get_timeout (settings), NULL, NULL, &error);
+ camel_network_settings_get_auth_mechanism (network_settings),
+ camel_ews_settings_get_timeout (settings),
+ NULL, NULL, &error);
if (cnc == NULL) {
g_free (url1);
g_free (url2);
diff --git a/src/server/e-ews-connection.h b/src/server/e-ews-connection.h
index 60ce0a3..20d956d 100644
--- a/src/server/e-ews-connection.h
+++ b/src/server/e-ews-connection.h
@@ -187,6 +187,7 @@ GType e_ews_connection_get_type (void);
EEwsConnection *e_ews_connection_new (const gchar *uri,
const gchar *username,
const gchar *password,
+ const gchar *auth_mechanism,
guint timeout,
GCallback authenticate_cb,
gpointer authenticate_ctx,
diff --git a/src/server/tests/test-autocompletion.c b/src/server/tests/test-autocompletion.c
index 309dd0a..99fe547 100644
--- a/src/server/tests/test-autocompletion.c
+++ b/src/server/tests/test-autocompletion.c
@@ -88,7 +88,7 @@ op_test_resolve_names ()
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
e_ews_connection_resolve_names (
cnc, EWS_PRIORITY_MEDIUM, username,
diff --git a/src/server/tests/test-connection.c b/src/server/tests/test-connection.c
index bdc1d7a..157dfd6 100644
--- a/src/server/tests/test-connection.c
+++ b/src/server/tests/test-connection.c
@@ -54,7 +54,7 @@ con_test_create_new_connection ()
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
g_print ("\nSuccess : Created a new connection\n");
diff --git a/src/server/tests/test-createfolder.c b/src/server/tests/test-createfolder.c
index db51822..6742f95 100644
--- a/src/server/tests/test-createfolder.c
+++ b/src/server/tests/test-createfolder.c
@@ -85,7 +85,7 @@ op_test_create_folder ()
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
e_ews_connection_create_folder (
cnc, EWS_PRIORITY_MEDIUM, "inbox",
diff --git a/src/server/tests/test-cuditem.c b/src/server/tests/test-cuditem.c
index fc02a60..fec1798 100644
--- a/src/server/tests/test-cuditem.c
+++ b/src/server/tests/test-cuditem.c
@@ -108,7 +108,7 @@ op_test_create_item ()
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
//to check how to change to real data
diff --git a/src/server/tests/test-deletefolder.c b/src/server/tests/test-deletefolder.c
index 2ab1184..d7b9bc7 100644
--- a/src/server/tests/test-deletefolder.c
+++ b/src/server/tests/test-deletefolder.c
@@ -76,7 +76,7 @@ op_test_delete_folder (gpointer data)
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
e_ews_connection_delete_folder (
cnc, EWS_PRIORITY_MEDIUM, (*fid)->id,
diff --git a/src/server/tests/test-get-oof-settings.c b/src/server/tests/test-get-oof-settings.c
index e62ba48..de8d825 100644
--- a/src/server/tests/test-get-oof-settings.c
+++ b/src/server/tests/test-get-oof-settings.c
@@ -77,7 +77,7 @@ op_test_get_oof_settings ()
g_assert_cmpstr (uri, !=, NULL);
g_assert_cmpstr (email, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
e_ews_connection_set_mailbox (cnc, email);
diff --git a/src/server/tests/test-getattachment.c b/src/server/tests/test-getattachment.c
index d8408fa..d772172 100644
--- a/src/server/tests/test-getattachment.c
+++ b/src/server/tests/test-getattachment.c
@@ -81,7 +81,7 @@ op_test_get_attachments ()
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
attachmentid = "AAASAG1hbmR5Lnd1QGludGVsLmNvbQBGAAAAAACdSXexmsgJTpd3WpdX6ulXBwAm9E+BClHfQqEnvCoGvhheAAAAjpb6AACIeDU1D80fTrC3245yXdhOADUAPRB8AAABEgAQAIlh9YZzdzdMtvWW9ZI7+vM=";
diff --git a/src/server/tests/test-getdelegate.c b/src/server/tests/test-getdelegate.c
index 88ce0b7..99b3baa 100644
--- a/src/server/tests/test-getdelegate.c
+++ b/src/server/tests/test-getdelegate.c
@@ -84,7 +84,7 @@ op_test_get_delegate ()
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
e_ews_connection_get_delegate (
cnc, EWS_PRIORITY_MEDIUM, "abc xyz com",
diff --git a/src/server/tests/test-set-oof-settings.c b/src/server/tests/test-set-oof-settings.c
index 4acdec9..76bfbb0 100644
--- a/src/server/tests/test-set-oof-settings.c
+++ b/src/server/tests/test-set-oof-settings.c
@@ -92,7 +92,7 @@ op_test_set_oof_settings ()
g_assert_cmpstr (uri, !=, NULL);
g_assert_cmpstr (email, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
e_ews_connection_set_mailbox (cnc, email);
diff --git a/src/server/tests/test-syncfolder.c b/src/server/tests/test-syncfolder.c
index 9078329..fe0ed7c 100644
--- a/src/server/tests/test-syncfolder.c
+++ b/src/server/tests/test-syncfolder.c
@@ -100,7 +100,7 @@ op_test_sync_folder_items ()
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
e_ews_connection_sync_folder_items (
@@ -173,7 +173,7 @@ op_test_sync_folder_hierarchy ()
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
e_ews_connection_sync_folder_hierarchy (
@@ -234,7 +234,7 @@ op_test_get_item ()
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
ids = g_slist_reverse (ids);
diff --git a/src/utils/ews-test-finditem-query.c b/src/utils/ews-test-finditem-query.c
index 3af2e83..6d0a2ee 100644
--- a/src/utils/ews-test-finditem-query.c
+++ b/src/utils/ews-test-finditem-query.c
@@ -112,7 +112,7 @@ op_test_finditem_run (void)
g_assert_cmpstr (password, !=, NULL);
g_assert_cmpstr (uri, !=, NULL);
- cnc = e_ews_connection_new (uri, username, password, 0, NULL, NULL, NULL);
+ cnc = e_ews_connection_new (uri, username, password, NULL, 30, NULL, NULL, NULL);
g_assert (cnc != NULL);
/*Along with finditem api we check query conversion too*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]