From 80b65d35e719c376bd3a8b7d4a1276c360dbe0f8 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 12 Aug 2003 18:00:14 +0000 Subject: Make this an abstract GObject. Tweak some of the interfaces around a * libsoup/soup-auth.c: Make this an abstract GObject. Tweak some of the interfaces around a little bit. * libsoup/soup-auth-basic.c: subclass for Basic auth * libsoup/soup-auth-digest.c: subclass for Digest auth * libsoup/soup-auth-ntlm.c: subclass for NTLM auth. Move all of the code from soup-ntlm.c here, and make it private. * libsoup/soup-ntlm.c: gone * libsoup/soup-misc.h: Remove the definition of SoupAuthType from here, and change the signature of SoupAuthorizeFn. * libsoup/soup-context.c: Use g_object_unref to free auths, use methods instead of directly access private fields. * libsoup/soup-queue.c: Likewise * libsoup/soup-server-auth.c (soup_server_auth_free): Remove all NTLM references. We have no plans to implement server-side NTLM auth. * tests/auth-test.c (identify_auth): Update for auth api changes --- libsoup/soup-auth.h | 75 +++++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'libsoup/soup-auth.h') diff --git a/libsoup/soup-auth.h b/libsoup/soup-auth.h index 756029ea..017331d0 100644 --- a/libsoup/soup-auth.h +++ b/libsoup/soup-auth.h @@ -1,58 +1,66 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * soup-auth.h: Authentication schemes - * - * Authors: - * Joe Shaw (joe@ximian.com) - * - * Copyright (C) 2001-2002, Ximian, Inc. + * Copyright (C) 2001-2003, Ximian, Inc. */ #ifndef SOUP_AUTH_H #define SOUP_AUTH_H 1 -#include +#include #include -#include +#include -typedef enum _SoupAuthStatus SoupAuthStatus; -typedef struct _SoupAuth SoupAuth; +#define SOUP_TYPE_AUTH (soup_auth_get_type ()) +#define SOUP_AUTH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_AUTH, SoupAuth)) +#define SOUP_AUTH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_AUTH, SoupAuthClass)) +#define SOUP_IS_AUTH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_AUTH)) +#define SOUP_IS_AUTH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_AUTH)) +#define SOUP_AUTH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_AUTH, SoupAuthClass)) -struct _SoupAuth { - SoupAuthType type; - char *realm; - gboolean authenticated; +typedef struct { + GObject parent; - void (*parse_func) (SoupAuth *auth, - const gchar *header); +} SoupAuth; - void (*init_func) (SoupAuth *auth, - const SoupUri *uri); +typedef struct { + GObjectClass parent_class; - gboolean (*invalidate_func) (SoupAuth *auth); + const char *scheme_name; - char *(*auth_func) (SoupAuth *auth, - SoupMessage *message); + void (*construct) (SoupAuth *auth, + const char *header); - GSList *(*pspace_func) (SoupAuth *auth, - const SoupUri *source_uri); + GSList * (*get_protection_space) (SoupAuth *auth, + const SoupUri *source_uri); - void (*free_func) (SoupAuth *auth); -}; + const char * (*get_realm) (SoupAuth *auth); -SoupAuth *soup_auth_new_from_header_list (const SoupUri *uri, - const GSList *header); + void (*authenticate) (SoupAuth *auth, + const char *username, + const char *password); + gboolean (*invalidate) (SoupAuth *auth); + gboolean (*is_authenticated) (SoupAuth *auth); -SoupAuth *soup_auth_new_ntlm (void); + char * (*get_authorization) (SoupAuth *auth, + SoupMessage *msg); +} SoupAuthClass; -void soup_auth_initialize (SoupAuth *auth, - const SoupUri *uri); +GType soup_auth_get_type (void); -gboolean soup_auth_invalidate (SoupAuth *auth); -void soup_auth_free (SoupAuth *auth); +SoupAuth *soup_auth_new_from_header_list (const GSList *header, + const char *pref); + +const char *soup_auth_get_scheme_name (SoupAuth *auth); +const char *soup_auth_get_realm (SoupAuth *auth); -gchar *soup_auth_authorize (SoupAuth *auth, +void soup_auth_authenticate (SoupAuth *auth, + const char *username, + const char *password); +gboolean soup_auth_invalidate (SoupAuth *auth); +gboolean soup_auth_is_authenticated (SoupAuth *auth); + +char *soup_auth_get_authorization (SoupAuth *auth, SoupMessage *msg); GSList *soup_auth_get_protection_space (SoupAuth *auth, @@ -60,5 +68,4 @@ GSList *soup_auth_get_protection_space (SoupAuth *auth, void soup_auth_free_protection_space (SoupAuth *auth, GSList *space); - #endif /* SOUP_AUTH_H */ -- cgit v1.2.1