~online-accounts/libsignon-glib/packaging

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/* vi: set et sw=4 ts=4 cino=t0,(0: */
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of libsignon-glib
 *
 * Copyright (C) 2009-2010 Nokia Corporation.
 * Copyright (C) 2012 Canonical Ltd.
 *
 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */

#ifndef SIGNONAUTHSESSION_H_
#define SIGNONAUTHSESSION_H_

#include <gio/gio.h>
#include <glib-object.h>
#include <libsignon-glib/signon-types.h>

G_BEGIN_DECLS

/*
 * Useful session data keys
 */
/**
 * SIGNON_SESSION_DATA_USERNAME:
 *
 * Username.
 */
#define SIGNON_SESSION_DATA_USERNAME      "UserName"
/**
 * SIGNON_SESSION_DATA_SECRET:
 *
 * Secret.
 */
#define SIGNON_SESSION_DATA_SECRET        "Secret"
/**
 * SIGNON_SESSION_DATA_REALM:
 *
 * Realm.
 */
#define SIGNON_SESSION_DATA_REALM         "Realm"
/**
 * SIGNON_SESSION_DATA_PROXY:
 *
 * Proxy.
 */
#define SIGNON_SESSION_DATA_PROXY         "NetworkProxy"

/**
 * SignonSessionDataUiPolicy:
 * @SIGNON_POLICY_DEFAULT: The plugin can decide when to show UI.
 * @SIGNON_POLICY_REQUEST_PASSWORD: Force the user to enter the password.
 * @SIGNON_POLICY_NO_USER_INTERACTION: No UI elements will be shown to the user.
 * @SIGNON_POLICY_VALIDATION: UI elements can be shown to the user only when
 * CAPTCHA-like security measures are required.
 *
 * Policy for the signon process, passed to the UI plugin.
 */
typedef enum {
    SIGNON_POLICY_DEFAULT = 0,
    SIGNON_POLICY_REQUEST_PASSWORD,
    SIGNON_POLICY_NO_USER_INTERACTION,
    SIGNON_POLICY_VALIDATION,
} SignonSessionDataUiPolicy;
/**
 * SIGNON_SESSION_DATA_UI_POLICY:
 * @see_also: #SignonSessionDataUiPolicy
 *
 * Policy for the signon process.
 */
#define SIGNON_SESSION_DATA_UI_POLICY     "UiPolicy"
/**
 * SIGNON_SESSION_DATA_CAPTION:
 *
 * Caption for the UI dialog.
 */
#define SIGNON_SESSION_DATA_CAPTION       "Caption"
/**
 * SIGNON_SESSION_DATA_TIMEOUT:
 *
 * Network timeout, in milliseconds (uint32).
 */
#define SIGNON_SESSION_DATA_TIMEOUT       "NetworkTimeout"
/**
 * SIGNON_SESSION_DATA_WINDOW_ID:
 *
 * Platform-specific window id (for dialog transiency) - uint32.
 */
#define SIGNON_SESSION_DATA_WINDOW_ID     "WindowId"
/**
 * SIGNON_SESSION_DATA_RENEW_TOKEN:
 *
 * Requests the signon plugin to obtain a new token (boolean).
 */
#define SIGNON_SESSION_DATA_RENEW_TOKEN   "RenewToken"


#define SIGNON_TYPE_AUTH_SESSION                 (signon_auth_session_get_type ())
#define SIGNON_AUTH_SESSION(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), SIGNON_TYPE_AUTH_SESSION, SignonAuthSession))
#define SIGNON_AUTH_SESSION_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), SIGNON_TYPE_AUTH_SESSION, SignonAuthSessionClass))
#define SIGNON_IS_AUTH_SESSION(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SIGNON_TYPE_AUTH_SESSION))
#define SIGNON_IS_AUTH_SESSION_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), SIGNON_TYPE_AUTH_SESSION))
#define SIGNON_AUTH_SESSION_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), SIGNON_TYPE_AUTH_SESSION, SignonAuthSessionClass))

typedef struct _SignonAuthSession        SignonAuthSession;
typedef struct _SignonAuthSessionPrivate SignonAuthSessionPrivate;
typedef struct _SignonAuthSessionClass   SignonAuthSessionClass;

/**
 * SignonAuthSession:
 *
 * Opaque struct. Use the accessor functions below.
 */
struct _SignonAuthSession {
    GObject parent;

    SignonAuthSessionPrivate *priv;
};

/**
 * SignonAuthSessionClass:
 *
 * Opaque struct. Use the accessor functions below.
 */
struct _SignonAuthSessionClass {
    GObjectClass parent;
};

GType signon_auth_session_get_type (void) G_GNUC_CONST;

SignonAuthSession *signon_auth_session_new(gint id,
                                           const gchar *method_name,
                                           GError **err);

const gchar *signon_auth_session_get_method (SignonAuthSession *self);

typedef void (*SignonAuthSessionQueryAvailableMechanismsCb) (
                    SignonAuthSession* self,
                    gchar **mechanisms,
                    const GError *error,
                    gpointer user_data);

G_GNUC_DEPRECATED
typedef SignonAuthSessionQueryAvailableMechanismsCb
    SignonAuthSessionQueryAvailableMethodsCb;

void signon_auth_session_query_available_mechanisms(SignonAuthSession *self,
                                                    const gchar **wanted_mechanisms,
                                                    SignonAuthSessionQueryAvailableMechanismsCb cb,
                                                    gpointer user_data);

#ifndef SIGNON_DISABLE_DEPRECATED
typedef void (*SignonAuthSessionProcessCb) (SignonAuthSession *self,
                                            GHashTable *session_data,
                                            const GError *error,
                                            gpointer user_data);
SIGNON_DEPRECATED_FOR(signon_auth_session_process_async)
void signon_auth_session_process(SignonAuthSession *self,
                                const GHashTable *session_data,
                                const gchar *mechanism,
                                SignonAuthSessionProcessCb cb,
                                gpointer user_data);
#endif
void signon_auth_session_process_async (SignonAuthSession *self,
                                        GVariant *session_data,
                                        const gchar *mechanism,
                                        GCancellable *cancellable,
                                        GAsyncReadyCallback callback,
                                        gpointer user_data);
GVariant *signon_auth_session_process_finish (SignonAuthSession *self,
                                              GAsyncResult *res,
                                              GError **error);

void signon_auth_session_cancel(SignonAuthSession *self);

G_END_DECLS

#endif //SIGNONAUTHSESSIONIMPL_H_