1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 2001-2003, Ximian, Inc.
4 */
5
6#ifndef __SOUP_AUTH_H__
7#define __SOUP_AUTH_H__ 1
8
9#include <libsoup/soup-types.h>
10#include <libsoup/soup-headers.h>
11
12G_BEGIN_DECLS
13
14#define SOUP_TYPE_AUTH (soup_auth_get_type ())
15#define SOUP_AUTH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_AUTH, SoupAuth))
16#define SOUP_AUTH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_AUTH, SoupAuthClass))
17#define SOUP_IS_AUTH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_AUTH))
18#define SOUP_IS_AUTH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_AUTH))
19#define SOUP_AUTH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_AUTH, SoupAuthClass))
20
21struct _SoupAuth {
22 GObject parent;
23
24 char *realm;
25};
26
27typedef struct {
28 GObjectClass parent_class;
29
30 const char *scheme_name;
31 guint strength;
32
33 gboolean (*update) (SoupAuth *auth,
34 SoupMessage *msg,
35 GHashTable *auth_header);
36
37 GSList * (*get_protection_space) (SoupAuth *auth,
38 SoupURI *source_uri);
39
40 void (*authenticate) (SoupAuth *auth,
41 const char *username,
42 const char *password);
43 gboolean (*is_authenticated) (SoupAuth *auth);
44
45 char * (*get_authorization) (SoupAuth *auth,
46 SoupMessage *msg);
47
48 gboolean (*is_ready) (SoupAuth *auth,
49 SoupMessage *msg);
50
51 gboolean (*can_authenticate) (SoupAuth *auth);
52
53 /* Padding for future expansion */
54 void (*_libsoup_reserved3) (void);
55 void (*_libsoup_reserved4) (void);
56} SoupAuthClass;
57
58#define SOUP_AUTH_SCHEME_NAME "scheme-name"
59#define SOUP_AUTH_REALM "realm"
60#define SOUP_AUTH_HOST "host"
61#define SOUP_AUTH_IS_FOR_PROXY "is-for-proxy"
62#define SOUP_AUTH_IS_AUTHENTICATED "is-authenticated"
63
64SOUP_AVAILABLE_IN_2_4
65GType soup_auth_get_type (void);
66
67SOUP_AVAILABLE_IN_2_4
68SoupAuth *soup_auth_new (GType type,
69 SoupMessage *msg,
70 const char *auth_header);
71SOUP_AVAILABLE_IN_2_4
72gboolean soup_auth_update (SoupAuth *auth,
73 SoupMessage *msg,
74 const char *auth_header);
75
76SOUP_AVAILABLE_IN_2_4
77gboolean soup_auth_is_for_proxy (SoupAuth *auth);
78SOUP_AVAILABLE_IN_2_4
79const char *soup_auth_get_scheme_name (SoupAuth *auth);
80SOUP_AVAILABLE_IN_2_4
81const char *soup_auth_get_host (SoupAuth *auth);
82SOUP_AVAILABLE_IN_2_4
83const char *soup_auth_get_realm (SoupAuth *auth);
84SOUP_AVAILABLE_IN_2_4
85char *soup_auth_get_info (SoupAuth *auth);
86
87SOUP_AVAILABLE_IN_2_4
88void soup_auth_authenticate (SoupAuth *auth,
89 const char *username,
90 const char *password);
91SOUP_AVAILABLE_IN_2_4
92gboolean soup_auth_is_authenticated (SoupAuth *auth);
93SOUP_AVAILABLE_IN_2_42
94gboolean soup_auth_is_ready (SoupAuth *auth,
95 SoupMessage *msg);
96SOUP_AVAILABLE_IN_2_54
97gboolean soup_auth_can_authenticate (SoupAuth *auth);
98
99SOUP_AVAILABLE_IN_2_4
100char *soup_auth_get_authorization (SoupAuth *auth,
101 SoupMessage *msg);
102
103SOUP_AVAILABLE_IN_2_4
104GSList *soup_auth_get_protection_space (SoupAuth *auth,
105 SoupURI *source_uri);
106SOUP_AVAILABLE_IN_2_4
107void soup_auth_free_protection_space (SoupAuth *auth,
108 GSList *space);
109
110/* The actual auth types, which can be added/removed as features */
111
112#define SOUP_TYPE_AUTH_BASIC (soup_auth_basic_get_type ())
113SOUP_AVAILABLE_IN_2_4
114GType soup_auth_basic_get_type (void);
115#define SOUP_TYPE_AUTH_DIGEST (soup_auth_digest_get_type ())
116SOUP_AVAILABLE_IN_2_4
117GType soup_auth_digest_get_type (void);
118#define SOUP_TYPE_AUTH_NTLM (soup_auth_ntlm_get_type ())
119SOUP_AVAILABLE_IN_2_4
120GType soup_auth_ntlm_get_type (void);
121#define SOUP_TYPE_AUTH_NEGOTIATE (soup_auth_negotiate_get_type ())
122SOUP_AVAILABLE_IN_2_54
123GType soup_auth_negotiate_get_type (void);
124
125/* Deprecated SoupPasswordManager-related APIs: all are now no-ops */
126SOUP_AVAILABLE_IN_2_28
127SOUP_DEPRECATED_IN_2_28
128GSList *soup_auth_get_saved_users (SoupAuth *auth);
129SOUP_AVAILABLE_IN_2_28
130SOUP_DEPRECATED_IN_2_28
131const char *soup_auth_get_saved_password (SoupAuth *auth,
132 const char *user);
133SOUP_AVAILABLE_IN_2_28
134SOUP_DEPRECATED_IN_2_28
135void soup_auth_save_password (SoupAuth *auth,
136 const char *username,
137 const char *password);
138SOUP_AVAILABLE_IN_2_28
139SOUP_DEPRECATED_IN_2_28
140void soup_auth_has_saved_password (SoupAuth *auth,
141 const char *username,
142 const char *password);
143
144SOUP_AVAILABLE_IN_2_54
145gboolean soup_auth_negotiate_supported (void);
146
147G_END_DECLS
148
149#endif /* __SOUP_AUTH_H__ */
150