Git init
[profile/ivi/libsoup2.4.git] / libsoup / soup-auth.h
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    *auth_params);
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         /* Padding for future expansion */
48         void (*_libsoup_reserved1) (void);
49         void (*_libsoup_reserved2) (void);
50         void (*_libsoup_reserved3) (void);
51         void (*_libsoup_reserved4) (void);
52 } SoupAuthClass;
53
54 #define SOUP_AUTH_SCHEME_NAME      "scheme-name"
55 #define SOUP_AUTH_REALM            "realm"
56 #define SOUP_AUTH_HOST             "host"
57 #define SOUP_AUTH_IS_FOR_PROXY     "is-for-proxy"
58 #define SOUP_AUTH_IS_AUTHENTICATED "is-authenticated"
59
60 GType       soup_auth_get_type              (void);
61
62 SoupAuth   *soup_auth_new                   (GType          type,
63                                              SoupMessage   *msg,
64                                              const char    *auth_header);
65 gboolean    soup_auth_update                (SoupAuth      *auth,
66                                              SoupMessage   *msg,
67                                              const char    *auth_header);
68
69 gboolean    soup_auth_is_for_proxy          (SoupAuth      *auth);
70 const char *soup_auth_get_scheme_name       (SoupAuth      *auth);
71 const char *soup_auth_get_host              (SoupAuth      *auth);
72 const char *soup_auth_get_realm             (SoupAuth      *auth);
73 char       *soup_auth_get_info              (SoupAuth      *auth);
74
75 #ifdef LIBSOUP_I_HAVE_READ_BUG_594377_AND_KNOW_SOUP_PASSWORD_MANAGER_MIGHT_GO_AWAY
76 GSList     *soup_auth_get_saved_users       (SoupAuth      *auth);
77 const char *soup_auth_get_saved_password    (SoupAuth      *auth,
78                                              const char    *user);
79 void        soup_auth_save_password         (SoupAuth      *auth,
80                                              const char    *username,
81                                              const char    *password);
82 #endif
83
84 void        soup_auth_authenticate          (SoupAuth      *auth,
85                                              const char    *username,
86                                              const char    *password);
87 gboolean    soup_auth_is_authenticated      (SoupAuth      *auth);
88
89 char       *soup_auth_get_authorization     (SoupAuth      *auth, 
90                                              SoupMessage   *msg);
91
92 GSList     *soup_auth_get_protection_space  (SoupAuth      *auth,
93                                              SoupURI       *source_uri);
94 void        soup_auth_free_protection_space (SoupAuth      *auth,
95                                              GSList        *space);
96
97 #ifdef LIBSOUP_I_HAVE_READ_BUG_594377_AND_KNOW_SOUP_PASSWORD_MANAGER_MIGHT_GO_AWAY
98 void        soup_auth_has_saved_password    (SoupAuth      *auth,
99                                              const char    *username,
100                                              const char    *password);
101 #endif
102
103 /* The actual auth types, which can be added/removed as features */
104
105 #define SOUP_TYPE_AUTH_BASIC  (soup_auth_basic_get_type ())
106 GType soup_auth_basic_get_type  (void);
107 #define SOUP_TYPE_AUTH_DIGEST (soup_auth_digest_get_type ())
108 GType soup_auth_digest_get_type (void);
109 #define SOUP_TYPE_AUTH_NTLM   (soup_auth_ntlm_get_type ())
110 GType soup_auth_ntlm_get_type   (void);
111
112 G_END_DECLS
113
114 #endif /* SOUP_AUTH_H */