[libsoup/wip/tpopela/negotiate] soup-auth-negotiate: Reorganize the sources to get rid of some ifdefs
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/tpopela/negotiate] soup-auth-negotiate: Reorganize the sources to get rid of some ifdefs
- Date: Wed, 2 Mar 2016 14:11:45 +0000 (UTC)
commit 0d662aedfeca364657137865d63745d7480bfeb1
Author: Tomas Popela <tpopela redhat com>
Date: Wed Mar 2 15:09:38 2016 +0100
soup-auth-negotiate: Reorganize the sources to get rid of some ifdefs
libsoup/soup-auth-negotiate.c | 176 ++++++++++++++++++++---------------------
1 files changed, 85 insertions(+), 91 deletions(-)
---
diff --git a/libsoup/soup-auth-negotiate.c b/libsoup/soup-auth-negotiate.c
index ed0cb24..6b6471b 100644
--- a/libsoup/soup-auth-negotiate.c
+++ b/libsoup/soup-auth-negotiate.c
@@ -24,11 +24,10 @@
#include "soup-misc-private.h"
#include "soup-uri.h"
-#ifdef LIBSOUP_HAVE_GSSAPI
-const gboolean soup_auth_negotiate_supported = TRUE;
-#else
+#ifndef LIBSOUP_HAVE_GSSAPI
const gboolean soup_auth_negotiate_supported = FALSE;
-#endif /* LIBSOUP_HAVE_GSSAPI */
+#else
+const gboolean soup_auth_negotiate_supported = TRUE;
G_DEFINE_TYPE (SoupAuthNegotiate, soup_auth_negotiate, SOUP_TYPE_CONNECTION_AUTH)
@@ -47,10 +46,8 @@ typedef struct {
gboolean initialized;
gchar *response_header;
-#ifdef LIBSOUP_HAVE_GSSAPI
gss_ctx_id_t context;
gss_name_t server_name;
-#endif /* LIBSOUP_HAVE_GSSAPI */
SoupNegotiateState state;
} SoupNegotiateConnectionState;
@@ -66,7 +63,6 @@ typedef struct {
#define SOUP_AUTH_NEGOTIATE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_AUTH_NEGOTIATE,
SoupAuthNegotiatePrivate))
-#ifdef LIBSOUP_HAVE_GSSAPI
static gboolean check_auth_trusted_uri (SoupConnectionAuth *auth,
SoupMessage *msg);
static gboolean soup_gss_build_response (SoupNegotiateConnectionState *conn,
@@ -87,13 +83,6 @@ static void remove_server_response_handler (SoupMessage *msg, gpointer auth);
static const char spnego_OID[] = "\x2b\x06\x01\x05\x05\x02";
static const gss_OID_desc gss_mech_spnego = { sizeof (spnego_OID) - 1, (void *) &spnego_OID };
-#endif /* LIBSOUP_HAVE_GSSAPI */
-
-static void
-soup_auth_negotiate_init (SoupAuthNegotiate *negotiate)
-{
- g_object_set (G_OBJECT (negotiate), SOUP_AUTH_REALM, "", NULL);
-}
static gpointer
soup_auth_negotiate_create_connection_state (SoupConnectionAuth *auth)
@@ -111,9 +100,7 @@ soup_auth_negotiate_create_connection_state (SoupConnectionAuth *auth)
static void
free_connection_state_data (SoupNegotiateConnectionState *conn)
{
-#ifdef LIBSOUP_HAVE_GSSAPI
soup_gss_client_cleanup (conn);
-#endif /* LIBSOUP_HAVE_GSSAPI */
g_free (conn->response_header);
}
@@ -131,6 +118,78 @@ soup_auth_negotiate_free_connection_state (SoupConnectionAuth *auth,
priv->conn_state = NULL;
}
+static GSList *
+soup_auth_negotiate_get_protection_space (SoupAuth *auth, SoupURI *source_uri)
+{
+ char *space, *p;
+
+ space = g_strdup (source_uri->path);
+
+ /* Strip filename component */
+ p = strrchr (space, '/');
+ if (p && p == space && p[1])
+ p[1] = '\0';
+ else if (p && p[1])
+ *p = '\0';
+
+ return g_slist_prepend (NULL, space);
+}
+
+static void
+soup_auth_negotiate_authenticate (SoupAuth *auth, const char *username,
+ const char *password)
+{
+ SoupAuthNegotiate *negotiate = SOUP_AUTH_NEGOTIATE (auth);
+ SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (negotiate);
+
+ /* It is not possible to authenticate with username and password. */
+ priv->is_authenticated = FALSE;
+}
+
+static gboolean
+soup_auth_negotiate_is_authenticated (SoupAuth *auth)
+{
+ SoupAuthNegotiate *negotiate = SOUP_AUTH_NEGOTIATE (auth);
+ SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (negotiate);
+
+ /* We are authenticated just in case we received the GSS_S_COMPLETE. */
+ return priv->is_authenticated;
+}
+
+static gboolean
+soup_auth_negotiate_can_authenticate (SoupAuth *auth)
+{
+ return FALSE;
+}
+
+static char *
+soup_auth_negotiate_get_connection_authorization (SoupConnectionAuth *auth,
+ SoupMessage *msg,
+ gpointer state)
+{
+ SoupNegotiateConnectionState *conn = state;
+ char *header = NULL;
+
+ if (conn->state == SOUP_NEGOTIATE_RECEIVED_CHALLENGE) {
+ header = conn->response_header;
+ conn->response_header = NULL;
+ conn->state = SOUP_NEGOTIATE_SENT_RESPONSE;
+ }
+
+ return header;
+}
+
+static gboolean
+soup_auth_negotiate_is_connection_ready (SoupConnectionAuth *auth,
+ SoupMessage *msg,
+ gpointer state)
+{
+ SoupNegotiateConnectionState *conn = state;
+
+ return conn->state != SOUP_NEGOTIATE_FAILED;
+}
+#endif /* LIBSOUP_HAVE_GSSAPI */
+
static gboolean
soup_auth_negotiate_update_connection (SoupConnectionAuth *auth, SoupMessage *msg,
const char *header, gpointer state)
@@ -199,75 +258,10 @@ soup_auth_negotiate_update_connection (SoupConnectionAuth *auth, SoupMessage *ms
#endif /* LIBSOUP_HAVE_GSSAPI */
}
-static GSList *
-soup_auth_negotiate_get_protection_space (SoupAuth *auth, SoupURI *source_uri)
-{
- char *space, *p;
-
- space = g_strdup (source_uri->path);
-
- /* Strip filename component */
- p = strrchr (space, '/');
- if (p && p == space && p[1])
- p[1] = '\0';
- else if (p && p[1])
- *p = '\0';
-
- return g_slist_prepend (NULL, space);
-}
-
static void
-soup_auth_negotiate_authenticate (SoupAuth *auth, const char *username,
- const char *password)
-{
- SoupAuthNegotiate *negotiate = SOUP_AUTH_NEGOTIATE (auth);
- SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (negotiate);
-
- /* It is not possible to authenticate with username and password. */
- priv->is_authenticated = FALSE;
-}
-
-static gboolean
-soup_auth_negotiate_is_authenticated (SoupAuth *auth)
-{
- SoupAuthNegotiate *negotiate = SOUP_AUTH_NEGOTIATE (auth);
- SoupAuthNegotiatePrivate *priv = SOUP_AUTH_NEGOTIATE_GET_PRIVATE (negotiate);
-
- /* We are authenticated just in case we received the GSS_S_COMPLETE. */
- return priv->is_authenticated;
-}
-
-static gboolean
-soup_auth_negotiate_can_authenticate (SoupAuth *auth)
-{
- return FALSE;
-}
-
-static char *
-soup_auth_negotiate_get_connection_authorization (SoupConnectionAuth *auth,
- SoupMessage *msg,
- gpointer state)
-{
- SoupNegotiateConnectionState *conn = state;
- char *header = NULL;
-
- if (conn->state == SOUP_NEGOTIATE_RECEIVED_CHALLENGE) {
- header = conn->response_header;
- conn->response_header = NULL;
- conn->state = SOUP_NEGOTIATE_SENT_RESPONSE;
- }
-
- return header;
-}
-
-static gboolean
-soup_auth_negotiate_is_connection_ready (SoupConnectionAuth *auth,
- SoupMessage *msg,
- gpointer state)
+soup_auth_negotiate_init (SoupAuthNegotiate *negotiate)
{
- SoupNegotiateConnectionState *conn = state;
-
- return conn->state != SOUP_NEGOTIATE_FAILED;
+ g_object_set (G_OBJECT (negotiate), SOUP_AUTH_REALM, "", NULL);
}
static void
@@ -277,23 +271,23 @@ soup_auth_negotiate_class_init (SoupAuthNegotiateClass *auth_negotiate_class)
SoupConnectionAuthClass *conn_auth_class =
SOUP_CONNECTION_AUTH_CLASS (auth_negotiate_class);
- g_type_class_add_private (auth_negotiate_class, sizeof (SoupAuthNegotiatePrivate));
-
auth_class->scheme_name = "Negotiate";
auth_class->strength = 7;
+ conn_auth_class->update_connection = soup_auth_negotiate_update_connection;
+#ifdef LIBSOUP_HAVE_GSSAPI
+ conn_auth_class->create_connection_state = soup_auth_negotiate_create_connection_state;
+ conn_auth_class->free_connection_state = soup_auth_negotiate_free_connection_state;
+ conn_auth_class->get_connection_authorization = soup_auth_negotiate_get_connection_authorization;
+ conn_auth_class->is_connection_ready = soup_auth_negotiate_is_connection_ready;
+
auth_class->get_protection_space = soup_auth_negotiate_get_protection_space;
auth_class->authenticate = soup_auth_negotiate_authenticate;
auth_class->is_authenticated = soup_auth_negotiate_is_authenticated;
auth_class->can_authenticate = soup_auth_negotiate_can_authenticate;
- conn_auth_class->create_connection_state = soup_auth_negotiate_create_connection_state;
- conn_auth_class->free_connection_state = soup_auth_negotiate_free_connection_state;
- conn_auth_class->update_connection = soup_auth_negotiate_update_connection;
- conn_auth_class->get_connection_authorization = soup_auth_negotiate_get_connection_authorization;
- conn_auth_class->is_connection_ready = soup_auth_negotiate_is_connection_ready;
+ g_type_class_add_private (auth_negotiate_class, sizeof (SoupAuthNegotiatePrivate));
-#ifdef LIBSOUP_HAVE_GSSAPI
parse_uris_from_env_variable ("SOUP_GSSAPI_TRUSTED_URIS", &trusted_uris);
parse_uris_from_env_variable ("SOUP_GSSAPI_BLACKLISTED_URIS", &blacklisted_uris);
#endif /* LIBSOUP_HAVE_GSSAPI */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]