summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-01-01 11:43:28 -0500
committerDan Winship <danw@gnome.org>2013-01-02 15:34:12 -0500
commit2a6100c60c0cde68cbb37ff11075525df222b5da (patch)
treeffa213caadb4ffffee71105f4bb1d4929930ee27
parent586aef885f64352bbd3c1b9e68ae2020f33d5833 (diff)
downloadlibsoup-2a6100c60c0cde68cbb37ff11075525df222b5da.tar.gz
SoupAuthManager: make this public
-rw-r--r--docs/reference/Makefile.am2
-rw-r--r--docs/reference/libsoup-2.4-docs.sgml1
-rw-r--r--docs/reference/libsoup-2.4-sections.txt16
-rw-r--r--libsoup/Makefile.am2
-rw-r--r--libsoup/libsoup-2.4.sym1
-rw-r--r--libsoup/soup-auth-manager.c80
-rw-r--r--libsoup/soup-auth-manager.h3
-rw-r--r--libsoup/soup.h1
8 files changed, 87 insertions, 19 deletions
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 17ae6caf..adb475de 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -32,7 +32,7 @@ CFILE_GLOB=
IGNORE_HFILES= soup.h soup-marshal.h soup-enum-types.h \
soup-message-private.h soup-session-private.h \
soup-auth-basic.h soup-auth-digest.h soup-auth-ntlm.h \
- soup-connection.h soup-auth-manager.h soup-connection-auth.h \
+ soup-connection.h soup-connection-auth.h \
soup-message-queue.h soup-path-map.h soup-gnome-features.h \
soup-proxy-resolver.h soup-proxy-resolver-gnome.h \
soup-proxy-resolver-static.h soup-directory-input-stream.h \
diff --git a/docs/reference/libsoup-2.4-docs.sgml b/docs/reference/libsoup-2.4-docs.sgml
index f19848f5..f28c6059 100644
--- a/docs/reference/libsoup-2.4-docs.sgml
+++ b/docs/reference/libsoup-2.4-docs.sgml
@@ -46,6 +46,7 @@
<chapter>
<title>Additional Features</title>
<xi:include href="xml/soup-session-feature.xml"/>
+ <xi:include href="xml/soup-auth-manager.xml"/>
<xi:include href="xml/soup-content-decoder.xml"/>
<xi:include href="xml/soup-content-sniffer.xml"/>
<xi:include href="xml/soup-cookie-jar.xml"/>
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index e1bbbffb..fc56dc50 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -567,6 +567,22 @@ soup_auth_save_password
</SECTION>
<SECTION>
+<FILE>soup-auth-manager</FILE>
+<TITLE>SoupAuthManager</TITLE>
+SoupAuthManager
+SOUP_TYPE_AUTH_MANAGER
+<SUBSECTION Standard>
+SoupAuthManagerPrivate
+SoupAuthManagerClass
+SOUP_AUTH_MANAGER
+SOUP_IS_AUTH_MANAGER
+SOUP_AUTH_MANAGER_CLASS
+SOUP_IS_AUTH_MANAGER_CLASS
+SOUP_AUTH_MANAGER_GET_CLASS
+soup_auth_manager_get_type
+</SECTION>
+
+<SECTION>
<FILE>soup-socket</FILE>
<TITLE>SoupSocket</TITLE>
SoupSocket
diff --git a/libsoup/Makefile.am b/libsoup/Makefile.am
index 59747441..d2e2cde3 100644
--- a/libsoup/Makefile.am
+++ b/libsoup/Makefile.am
@@ -29,6 +29,7 @@ soup_headers = \
soup-auth-domain.h \
soup-auth-domain-basic.h \
soup-auth-domain-digest.h \
+ soup-auth-manager.h \
soup-cache.h \
soup-content-decoder.h \
soup-content-sniffer.h \
@@ -105,7 +106,6 @@ libsoup_2_4_la_SOURCES = \
soup-auth-domain.c \
soup-auth-domain-basic.c \
soup-auth-domain-digest.c \
- soup-auth-manager.h \
soup-auth-manager.c \
soup-body-input-stream.h \
soup-body-input-stream.c \
diff --git a/libsoup/libsoup-2.4.sym b/libsoup/libsoup-2.4.sym
index 521a5f71..d3631b22 100644
--- a/libsoup/libsoup-2.4.sym
+++ b/libsoup/libsoup-2.4.sym
@@ -54,6 +54,7 @@ soup_auth_has_saved_password
soup_auth_is_authenticated
soup_auth_is_for_proxy
soup_auth_is_ready
+soup_auth_manager_get_type
soup_auth_new
soup_auth_ntlm_get_type
soup_auth_save_password
diff --git a/libsoup/soup-auth-manager.c b/libsoup/soup-auth-manager.c
index 773291b6..c4cf783a 100644
--- a/libsoup/soup-auth-manager.c
+++ b/libsoup/soup-auth-manager.c
@@ -20,6 +20,37 @@
#include "soup-path-map.h"
#include "soup-session-private.h"
+/**
+ * SECTION:soup-auth-manager
+ * @short_description: HTTP client-side authentication handler
+ * @see_also: #SoupSession, #SoupAuth
+ *
+ * #SoupAuthManager is the #SoupSessionFeature that handles HTTP
+ * authentication for a #SoupSession.
+ *
+ * A #SoupAuthManager is added to the session by default, and normally
+ * you don't need to worry about it at all. However, if you want to
+ * disable HTTP authentication, you can remove the feature from the
+ * session with soup_session_remove_feature_by_type(), or disable it on
+ * individual requests with soup_message_disable_feature().
+ *
+ * Since: 2.42
+ **/
+
+/**
+ * SOUP_TYPE_AUTH_MANAGER:
+ *
+ * The #GType of #SoupAuthManager; you can use this with
+ * soup_session_remove_feature_by_type() or
+ * soup_message_disable_feature().
+ *
+ * (Although this type has only been publicly visible since libsoup
+ * 2.42, it has always existed in the background, and you can use
+ * <literal><code>g_type_from_name ("SoupAuthManager")</code></literal>
+ * to get its #GType in earlier releases.)
+ *
+ * Since: 2.42
+ */
static void soup_auth_manager_session_feature_init (SoupSessionFeatureInterface *feature_interface, gpointer interface_data);
static SoupSessionFeatureInterface *soup_session_feature_default_interface;
@@ -34,15 +65,14 @@ G_DEFINE_TYPE_WITH_CODE (SoupAuthManager, soup_auth_manager, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE,
soup_auth_manager_session_feature_init))
-typedef struct {
+struct SoupAuthManagerPrivate {
SoupSession *session;
GPtrArray *auth_types;
gboolean auto_ntlm;
SoupAuth *proxy_auth;
GHashTable *auth_hosts;
-} SoupAuthManagerPrivate;
-#define SOUP_AUTH_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_AUTH_MANAGER, SoupAuthManagerPrivate))
+};
typedef struct {
SoupURI *uri;
@@ -57,7 +87,9 @@ static SoupAuth *record_auth_for_uri (SoupAuthManagerPrivate *priv,
static void
soup_auth_manager_init (SoupAuthManager *manager)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager);
+ SoupAuthManagerPrivate *priv;
+
+ priv = manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, SOUP_TYPE_AUTH_MANAGER, SoupAuthManagerPrivate);
priv->auth_types = g_ptr_array_new_with_free_func ((GDestroyNotify)g_type_class_unref);
priv->auth_hosts = g_hash_table_new_full (soup_uri_host_hash,
@@ -69,7 +101,7 @@ soup_auth_manager_init (SoupAuthManager *manager)
static void
soup_auth_manager_finalize (GObject *object)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (object);
+ SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (object)->priv;
g_ptr_array_free (priv->auth_types, TRUE);
@@ -89,6 +121,20 @@ soup_auth_manager_class_init (SoupAuthManagerClass *auth_manager_class)
object_class->finalize = soup_auth_manager_finalize;
+ /**
+ * SoupAuthManager::authenticate:
+ * @manager: the #SoupAuthManager
+ * @msg: the #SoupMessage being sent
+ * @auth: the #SoupAuth to authenticate
+ * @retrying: %TRUE if this is the second (or later) attempt
+ *
+ * Emitted when the manager requires the application to
+ * provide authentication credentials.
+ *
+ * #SoupSession connects to this signal and emits its own
+ * #SoupSession::authenticate signal when it is emitted, so
+ * you shouldn't need to use this signal directly.
+ */
signals[AUTHENTICATE] =
g_signal_new ("authenticate",
G_OBJECT_CLASS_TYPE (object_class),
@@ -115,7 +161,7 @@ auth_type_compare_func (gconstpointer a, gconstpointer b)
static gboolean
soup_auth_manager_add_feature (SoupSessionFeature *feature, GType type)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (feature);
+ SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (feature)->priv;
SoupAuthClass *auth_class;
if (!g_type_is_a (type, SOUP_TYPE_AUTH))
@@ -134,7 +180,7 @@ soup_auth_manager_add_feature (SoupSessionFeature *feature, GType type)
static gboolean
soup_auth_manager_remove_feature (SoupSessionFeature *feature, GType type)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (feature);
+ SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (feature)->priv;
SoupAuthClass *auth_class;
int i;
@@ -159,7 +205,7 @@ soup_auth_manager_remove_feature (SoupSessionFeature *feature, GType type)
static gboolean
soup_auth_manager_has_feature (SoupSessionFeature *feature, GType type)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (feature);
+ SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (feature)->priv;
SoupAuthClass *auth_class;
int i;
@@ -175,14 +221,14 @@ soup_auth_manager_has_feature (SoupSessionFeature *feature, GType type)
}
static void
-soup_auth_manager_attach (SoupSessionFeature *manager, SoupSession *session)
+soup_auth_manager_attach (SoupSessionFeature *feature, SoupSession *session)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager);
+ SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (feature)->priv;
/* FIXME: should support multiple sessions */
priv->session = session;
- soup_session_feature_default_interface->attach (manager, session);
+ soup_session_feature_default_interface->attach (feature, session);
}
static inline const char *
@@ -408,7 +454,7 @@ authenticate_auth (SoupAuthManager *manager, SoupAuth *auth,
SoupMessage *msg, gboolean prior_auth_failed,
gboolean proxy, gboolean can_interact)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager);
+ SoupAuthManagerPrivate *priv = manager->priv;
SoupURI *uri;
if (proxy) {
@@ -494,7 +540,7 @@ record_auth_for_uri (SoupAuthManagerPrivate *priv, SoupURI *uri,
static void
auth_got_headers (SoupMessage *msg, gpointer manager)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager);
+ SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (manager)->priv;
SoupAuth *auth, *prior_auth, *new_auth;
gboolean prior_auth_failed = FALSE;
@@ -522,7 +568,7 @@ auth_got_headers (SoupMessage *msg, gpointer manager)
static void
auth_got_body (SoupMessage *msg, gpointer manager)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager);
+ SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (manager)->priv;
SoupAuth *auth;
auth = lookup_auth (priv, msg);
@@ -541,7 +587,7 @@ auth_got_body (SoupMessage *msg, gpointer manager)
static void
proxy_auth_got_headers (SoupMessage *msg, gpointer manager)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager);
+ SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (manager)->priv;
SoupAuth *prior_auth;
gboolean prior_auth_failed = FALSE;
@@ -566,7 +612,7 @@ proxy_auth_got_headers (SoupMessage *msg, gpointer manager)
static void
proxy_auth_got_body (SoupMessage *msg, gpointer manager)
{
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager);
+ SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER (manager)->priv;
SoupAuth *auth = priv->proxy_auth;
if (auth && soup_auth_is_ready (auth, msg))
@@ -600,7 +646,7 @@ soup_auth_manager_request_started (SoupSessionFeature *feature,
SoupSocket *socket)
{
SoupAuthManager *manager = SOUP_AUTH_MANAGER (feature);
- SoupAuthManagerPrivate *priv = SOUP_AUTH_MANAGER_GET_PRIVATE (manager);
+ SoupAuthManagerPrivate *priv = manager->priv;
SoupAuth *auth;
auth = lookup_auth (priv, msg);
diff --git a/libsoup/soup-auth-manager.h b/libsoup/soup-auth-manager.h
index a4ee3165..a9436bde 100644
--- a/libsoup/soup-auth-manager.h
+++ b/libsoup/soup-auth-manager.h
@@ -18,9 +18,12 @@ G_BEGIN_DECLS
#define SOUP_IS_AUTH_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SOUP_TYPE_AUTH_MANAGER))
#define SOUP_AUTH_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_AUTH_MANAGER, SoupAuthManagerClass))
+typedef struct SoupAuthManagerPrivate SoupAuthManagerPrivate;
+
typedef struct {
GObject parent;
+ SoupAuthManagerPrivate *priv;
} SoupAuthManager;
typedef struct {
diff --git a/libsoup/soup.h b/libsoup/soup.h
index fd836feb..0a7944ee 100644
--- a/libsoup/soup.h
+++ b/libsoup/soup.h
@@ -15,6 +15,7 @@ extern "C" {
#include <libsoup/soup-auth-domain.h>
#include <libsoup/soup-auth-domain-basic.h>
#include <libsoup/soup-auth-domain-digest.h>
+#include <libsoup/soup-auth-manager.h>
#include <libsoup/soup-cache.h>
#include <libsoup/soup-content-decoder.h>
#include <libsoup/soup-content-sniffer.h>