1 /*
2 * librest - RESTful web services access
3 * Copyright (c) 2008, 2009, Intel Corporation.
4 *
5 * Authors: Rob Bradford <rob@linux.intel.com>
6 * Ross Burton <ross@linux.intel.com>
7 * Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU Lesser General Public License,
11 * version 2.1, as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
24 #include <string.h>
25 #include <libsoup/soup.h>
26 #include <rest/rest-proxy-call.h>
27 #include "oauth2-proxy-call.h"
28 #include "oauth2-proxy-private.h"
29 #include "sha1.h"
30
G_DEFINE_TYPE(OAuth2ProxyCall,oauth2_proxy_call,REST_TYPE_PROXY_CALL)31 G_DEFINE_TYPE (OAuth2ProxyCall, oauth2_proxy_call, REST_TYPE_PROXY_CALL)
32
33 static gboolean
34 _prepare (RestProxyCall *call, GError **error)
35 {
36 OAuth2Proxy *proxy = NULL;
37 gboolean result = TRUE;
38
39 g_object_get (call, "proxy", &proxy, NULL);
40
41 if (!proxy->priv->access_token) {
42 g_set_error (error,
43 REST_PROXY_CALL_ERROR,
44 REST_PROXY_CALL_FAILED,
45 "Missing access token, web service not properly authenticated");
46 result = FALSE;
47 } else {
48 rest_proxy_call_add_param (call, "access_token", proxy->priv->access_token);
49 }
50
51 g_object_unref (proxy);
52
53 return result;
54 }
55
56 static void
oauth2_proxy_call_class_init(OAuth2ProxyCallClass * klass)57 oauth2_proxy_call_class_init (OAuth2ProxyCallClass *klass)
58 {
59 RestProxyCallClass *call_class = REST_PROXY_CALL_CLASS (klass);
60
61 call_class->prepare = _prepare;
62 }
63
64 static void
oauth2_proxy_call_init(OAuth2ProxyCall * self)65 oauth2_proxy_call_init (OAuth2ProxyCall *self)
66 {
67 }
68
69