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 | |
12 | G_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 | |
21 | struct _SoupAuth { |
22 | GObject parent; |
23 | |
24 | char *realm; |
25 | }; |
26 | |
27 | typedef 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 *); |
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 | |
64 | SOUP_AVAILABLE_IN_2_4 |
65 | GType soup_auth_get_type (void); |
66 | |
67 | SOUP_AVAILABLE_IN_2_4 |
68 | SoupAuth *soup_auth_new (GType type, |
69 | SoupMessage *msg, |
70 | const char *); |
71 | SOUP_AVAILABLE_IN_2_4 |
72 | gboolean soup_auth_update (SoupAuth *auth, |
73 | SoupMessage *msg, |
74 | const char *); |
75 | |
76 | SOUP_AVAILABLE_IN_2_4 |
77 | gboolean soup_auth_is_for_proxy (SoupAuth *auth); |
78 | SOUP_AVAILABLE_IN_2_4 |
79 | const char *soup_auth_get_scheme_name (SoupAuth *auth); |
80 | SOUP_AVAILABLE_IN_2_4 |
81 | const char *soup_auth_get_host (SoupAuth *auth); |
82 | SOUP_AVAILABLE_IN_2_4 |
83 | const char *soup_auth_get_realm (SoupAuth *auth); |
84 | SOUP_AVAILABLE_IN_2_4 |
85 | char *soup_auth_get_info (SoupAuth *auth); |
86 | |
87 | SOUP_AVAILABLE_IN_2_4 |
88 | void soup_auth_authenticate (SoupAuth *auth, |
89 | const char *username, |
90 | const char *password); |
91 | SOUP_AVAILABLE_IN_2_4 |
92 | gboolean soup_auth_is_authenticated (SoupAuth *auth); |
93 | SOUP_AVAILABLE_IN_2_42 |
94 | gboolean soup_auth_is_ready (SoupAuth *auth, |
95 | SoupMessage *msg); |
96 | SOUP_AVAILABLE_IN_2_54 |
97 | gboolean soup_auth_can_authenticate (SoupAuth *auth); |
98 | |
99 | SOUP_AVAILABLE_IN_2_4 |
100 | char *soup_auth_get_authorization (SoupAuth *auth, |
101 | SoupMessage *msg); |
102 | |
103 | SOUP_AVAILABLE_IN_2_4 |
104 | GSList *soup_auth_get_protection_space (SoupAuth *auth, |
105 | SoupURI *source_uri); |
106 | SOUP_AVAILABLE_IN_2_4 |
107 | void 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 ()) |
113 | SOUP_AVAILABLE_IN_2_4 |
114 | GType soup_auth_basic_get_type (void); |
115 | #define SOUP_TYPE_AUTH_DIGEST (soup_auth_digest_get_type ()) |
116 | SOUP_AVAILABLE_IN_2_4 |
117 | GType soup_auth_digest_get_type (void); |
118 | #define SOUP_TYPE_AUTH_NTLM (soup_auth_ntlm_get_type ()) |
119 | SOUP_AVAILABLE_IN_2_4 |
120 | GType soup_auth_ntlm_get_type (void); |
121 | #define SOUP_TYPE_AUTH_NEGOTIATE (soup_auth_negotiate_get_type ()) |
122 | SOUP_AVAILABLE_IN_2_54 |
123 | GType soup_auth_negotiate_get_type (void); |
124 | |
125 | /* Deprecated SoupPasswordManager-related APIs: all are now no-ops */ |
126 | SOUP_AVAILABLE_IN_2_28 |
127 | SOUP_DEPRECATED_IN_2_28 |
128 | GSList *soup_auth_get_saved_users (SoupAuth *auth); |
129 | SOUP_AVAILABLE_IN_2_28 |
130 | SOUP_DEPRECATED_IN_2_28 |
131 | const char *soup_auth_get_saved_password (SoupAuth *auth, |
132 | const char *user); |
133 | SOUP_AVAILABLE_IN_2_28 |
134 | SOUP_DEPRECATED_IN_2_28 |
135 | void soup_auth_save_password (SoupAuth *auth, |
136 | const char *username, |
137 | const char *password); |
138 | SOUP_AVAILABLE_IN_2_28 |
139 | SOUP_DEPRECATED_IN_2_28 |
140 | void soup_auth_has_saved_password (SoupAuth *auth, |
141 | const char *username, |
142 | const char *password); |
143 | |
144 | SOUP_AVAILABLE_IN_2_54 |
145 | gboolean soup_auth_negotiate_supported (void); |
146 | |
147 | G_END_DECLS |
148 | |
149 | #endif /* __SOUP_AUTH_H__ */ |
150 | |