[gnome-online-accounts/wip/rishi/owncloud-gssapi: 2/7] httpclient: Enable Negotiate when there is no password



commit c927f32aa50a0a25fd02c142c7153d1ea0e805bc
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Feb 15 18:44:15 2016 +0100

    httpclient: Enable Negotiate when there is no password
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762097

 src/goabackend/goahttpclient.c |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/src/goabackend/goahttpclient.c b/src/goabackend/goahttpclient.c
index 4f19f65..bdc9d4c 100644
--- a/src/goabackend/goahttpclient.c
+++ b/src/goabackend/goahttpclient.c
@@ -218,13 +218,10 @@ goa_http_client_check (GoaHttpClient       *self,
                        gpointer             user_data)
 {
   CheckData *data;
-  CheckAuthData *auth;
   SoupLogger *logger;
 
   g_return_if_fail (GOA_IS_HTTP_CLIENT (self));
   g_return_if_fail (uri != NULL && uri[0] != '\0');
-  g_return_if_fail (username != NULL && username[0] != '\0');
-  g_return_if_fail (password != NULL && password[0] != '\0');
   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
 
   data = g_slice_new0 (CheckData);
@@ -232,6 +229,29 @@ goa_http_client_check (GoaHttpClient       *self,
   data->session = soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, FALSE,
                                                  NULL);
 
+  if (password == NULL || password[0] == '\0')
+    {
+      if (soup_auth_negotiate_supported)
+        {
+          soup_session_add_feature_by_type (data->session, SOUP_TYPE_AUTH_NEGOTIATE);
+          soup_session_add_feature_by_type (data->session, SOUP_TYPE_COOKIE_JAR);
+        }
+    }
+  else
+    {
+      CheckAuthData *auth;
+
+      auth = g_slice_new0 (CheckAuthData);
+      auth->username = g_strdup (username);
+      auth->password = g_strdup (password);
+      g_signal_connect_data (data->session,
+                             "authenticate",
+                             G_CALLBACK (http_client_authenticate),
+                             auth,
+                             http_client_check_auth_data_free,
+                             0);
+    }
+
   logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
   soup_logger_set_printer (logger, http_client_log_printer, NULL, NULL);
   soup_session_add_feature (data->session, SOUP_SESSION_FEATURE (logger));
@@ -250,16 +270,6 @@ goa_http_client_check (GoaHttpClient       *self,
       g_simple_async_result_set_check_cancellable (data->res, data->cancellable);
     }
 
-  auth = g_slice_new0 (CheckAuthData);
-  auth->username = g_strdup (username);
-  auth->password = g_strdup (password);
-  g_signal_connect_data (data->session,
-                         "authenticate",
-                         G_CALLBACK (http_client_authenticate),
-                         auth,
-                         http_client_check_auth_data_free,
-                         0);
-
   g_signal_connect (data->session, "request-started", G_CALLBACK (http_client_request_started), data);
   soup_session_queue_message (data->session, data->msg, http_client_check_response_cb, data);
 }


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