summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Burton <ross@linux.intel.com>2010-07-06 12:01:06 +0100
committerRoss Burton <ross@linux.intel.com>2010-07-08 21:18:22 +0100
commita06cc142d7aa8e92cd88025a36a6814c0395660f (patch)
tree7ca3e2652555498899baee7ab11fa5a3dde78671
parent77903df0256907073e0d8cadd9bd6acf4ff3d2d4 (diff)
downloadlibrest-a06cc142d7aa8e92cd88025a36a6814c0395660f.tar.gz
oauth: add constructor for OAuth Echo proxies
-rw-r--r--rest/oauth-proxy-private.h7
-rw-r--r--rest/oauth-proxy.c37
-rw-r--r--rest/oauth-proxy.h5
3 files changed, 47 insertions, 2 deletions
diff --git a/rest/oauth-proxy-private.h b/rest/oauth-proxy-private.h
index 6e44619..e3943a9 100644
--- a/rest/oauth-proxy-private.h
+++ b/rest/oauth-proxy-private.h
@@ -26,11 +26,18 @@
(G_TYPE_INSTANCE_GET_PRIVATE ((o), OAUTH_TYPE_PROXY, OAuthProxyPrivate))
typedef struct {
+ /* Application "consumer" keys */
char *consumer_key;
char *consumer_secret;
+ /* Authorisation "user" tokens */
char *token;
char *token_secret;
+ /* How we're signing */
OAuthSignatureMethod method;
+ /* OAuth 1.0a */
gboolean oauth_10a;
char *verifier;
+ /* OAuth Echo */
+ gboolean oauth_echo;
+ char *service_url;
} OAuthProxyPrivate;
diff --git a/rest/oauth-proxy.c b/rest/oauth-proxy.c
index 782dfd5..2cc5224 100644
--- a/rest/oauth-proxy.c
+++ b/rest/oauth-proxy.c
@@ -114,9 +114,9 @@ oauth_proxy_finalize (GObject *object)
g_free (priv->token);
g_free (priv->token_secret);
g_free (priv->verifier);
+ g_free (priv->service_url);
- if (G_OBJECT_CLASS (oauth_proxy_parent_class)->finalize)
- G_OBJECT_CLASS (oauth_proxy_parent_class)->finalize (object);
+ G_OBJECT_CLASS (oauth_proxy_parent_class)->finalize (object);
}
#ifndef G_PARAM_STATIC_STRINGS
@@ -678,3 +678,36 @@ oauth_proxy_is_oauth10a (OAuthProxy *proxy)
return PROXY_GET_PRIVATE (proxy)->oauth_10a;
}
+
+RestProxy *
+oauth_proxy_new_echo_proxy (OAuthProxy *proxy,
+ /* TODO: should this be a function on the base url? */
+ const char *service_url,
+ const gchar *url_format,
+ gboolean binding_required)
+{
+ OAuthProxy *echo_proxy;
+ OAuthProxyPrivate *priv, *echo_priv;
+
+ g_return_val_if_fail (OAUTH_IS_PROXY (proxy), NULL);
+ g_return_val_if_fail (service_url, NULL);
+ g_return_val_if_fail (url_format, NULL);
+
+ priv = PROXY_GET_PRIVATE (proxy);
+
+ echo_proxy = g_object_new (OAUTH_TYPE_PROXY,
+ "url-format", url_format,
+ "binding-required", binding_required,
+ "user-agent", rest_proxy_get_user_agent ((RestProxy *)proxy),
+ "consumer-key", priv->consumer_key,
+ "consumer-secret", priv->consumer_secret,
+ "token", priv->token,
+ "token-secret", priv->token_secret,
+ NULL);
+ echo_priv = PROXY_GET_PRIVATE (echo_proxy);
+
+ echo_priv->oauth_echo = TRUE;
+ echo_priv->service_url = g_strdup (service_url);
+
+ return (RestProxy *)echo_proxy;
+}
diff --git a/rest/oauth-proxy.h b/rest/oauth-proxy.h
index 05511af..0e05965 100644
--- a/rest/oauth-proxy.h
+++ b/rest/oauth-proxy.h
@@ -149,6 +149,11 @@ const char * oauth_proxy_get_token_secret (OAuthProxy *proxy);
void oauth_proxy_set_token_secret (OAuthProxy *proxy, const char *token_secret);
+RestProxy *oauth_proxy_new_echo_proxy (OAuthProxy *proxy,
+ const char *service_url,
+ const gchar *url_format,
+ gboolean binding_required);
+
G_END_DECLS
#endif /* _OAUTH_PROXY */