diff options
| author | Valery Febvre <vfebvre at easter-eggs.com> | 2004-06-04 12:49:18 +0000 |
|---|---|---|
| committer | Valery Febvre <vfebvre at easter-eggs.com> | 2004-06-04 12:49:18 +0000 |
| commit | 1b922472770621c707afb8e3679ea69302d400a5 (patch) | |
| tree | 20201d7406874f97c483b8643a794d0bb0e6ce38 | |
| parent | 0099e66541566ba8da4462f15da3679b63b93e4e (diff) | |
Initial version
| -rw-r--r-- | lasso/id-ff/.cvsignore | 7 | ||||
| -rw-r--r-- | lasso/id-ff/Makefile.am | 25 | ||||
| -rw-r--r-- | lasso/id-ff/authn_environ.c | 93 | ||||
| -rw-r--r-- | lasso/id-ff/authn_environ.h | 63 | ||||
| -rw-r--r-- | lasso/id-ff/environ.c | 97 | ||||
| -rw-r--r-- | lasso/id-ff/environ.h | 79 | ||||
| -rw-r--r-- | lasso/id-ff/provider.c | 108 | ||||
| -rw-r--r-- | lasso/id-ff/provider.h | 72 |
8 files changed, 544 insertions, 0 deletions
diff --git a/lasso/id-ff/.cvsignore b/lasso/id-ff/.cvsignore new file mode 100644 index 00000000..672b6184 --- /dev/null +++ b/lasso/id-ff/.cvsignore @@ -0,0 +1,7 @@ +Makefile +Makefile.in +*.loT +*.lo +*.la +.deps +.libs diff --git a/lasso/id-ff/Makefile.am b/lasso/id-ff/Makefile.am new file mode 100644 index 00000000..f04e4272 --- /dev/null +++ b/lasso/id-ff/Makefile.am @@ -0,0 +1,25 @@ +SUBDIRS = + +liblassoincludedir = $(includedir)/lasso/environs + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/lasso \ + $(LASSO_DEFINES) \ + $(GLIB_CFLAGS) \ + $(LIBXSLT_CFLAGS) \ + $(LIBXML_CFLAGS) \ + $(XMLSEC1_CFLAGS) \ + -DG_LOG_DOMAIN=\"lasso\" + +noinst_LTLIBRARIES = liblasso-environs.la + +liblasso_environs_la_SOURCES = \ + authn_environ.c \ + environ.c \ + provider.c + +liblassoinclude_HEADERS = \ + authn_environ.h \ + environ.h \ + provider.h diff --git a/lasso/id-ff/authn_environ.c b/lasso/id-ff/authn_environ.c new file mode 100644 index 00000000..fea7f87f --- /dev/null +++ b/lasso/id-ff/authn_environ.c @@ -0,0 +1,93 @@ +/* $Id$ + * + * Lasso - A free implementation of the Samlerty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Author: Valery Febvre <vfebvre@easter-eggs.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <lasso/environs/authn_environ.h> + +/*****************************************************************************/ +/* public methods */ +/*****************************************************************************/ + +char* +lasso_authn_environ_build_request(LassoAuthnEnviron *env) { + LassoEnviron *e = LASSO_ENVIRON(env); + + e->request = lasso_authn_request_new(lasso_node_get_attr_value(LASSO_NODE(e->local_provider), "ProviderID")); +} + +/*****************************************************************************/ +/* instance and class init functions */ +/*****************************************************************************/ + +static void +lasso_authn_environ_instance_init(LassoAuthnEnviron *env) +{ +} + +static void +lasso_authn_environ_class_init(LassoAuthnEnvironClass *klass) +{ +} + +GType lasso_authn_environ_get_type() +{ + static GType this_type = 0; + + if (!this_type) { + static const GTypeInfo this_info = { + sizeof (LassoAuthnEnvironClass), + NULL, + NULL, + (GClassInitFunc) lasso_authn_environ_class_init, + NULL, + NULL, + sizeof(LassoAuthnEnviron), + 0, + (GInstanceInitFunc) lasso_authn_environ_instance_init, + }; + + this_type = g_type_register_static(LASSO_TYPE_ENVIRON, + "LassoAuthnEnviron", + &this_info, 0); + } + return this_type; +} + +LassoEnviron* lasso_authn_environ_new(const gchar *metadata, + const gchar *public_key, + const gchar *private_key, + const gchar *certificate) +{ + LassoEnviron *env; + LassoNode *local_provider; + + env = LASSO_ENVIRON(g_object_new(LASSO_TYPE_AUTHN_ENVIRON, NULL)); + + local_provider = lasso_provider_new(metadata); + lasso_provider_set_public_key(LASSO_PROVIDER(local_provider), public_key); + lasso_provider_set_private_key(LASSO_PROVIDER(local_provider), private_key); + lasso_provider_set_certificate(LASSO_PROVIDER(local_provider), certificate); + env->local_provider = local_provider; + + return LASSO_ENVIRON(g_object_new(LASSO_TYPE_AUTHN_ENVIRON, NULL)); +} diff --git a/lasso/id-ff/authn_environ.h b/lasso/id-ff/authn_environ.h new file mode 100644 index 00000000..2eb42162 --- /dev/null +++ b/lasso/id-ff/authn_environ.h @@ -0,0 +1,63 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Author: Valery Febvre <vfebvre@easter-eggs.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LASSO_AUTHN_ENVIRON_H__ +#define __LASSO_AUTHN_ENVIRON_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <lasso/environs/environ.h> + +#define LASSO_TYPE_AUTHN_ENVIRON (lasso_authn_environ_get_type()) +#define LASSO_AUTHN_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_AUTHN_ENVIRON, LassoAuthnEnviron)) +#define LASSO_AUTHN_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_AUTHN_ENVIRON, LassoAuthnEnvironClass)) +#define LASSO_IS_AUTHN_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_AUTHN_ENVIRON)) +#define LASSO_IS_AUTHN_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_AUTHN_ENVIRON)) +#define LASSO_AUTHN_ENVIRON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_AUTHN_ENVIRON, LassoAuthnEnvironClass)) + +typedef struct _LassoAuthnEnviron LassoAuthnEnviron; +typedef struct _LassoAuthnEnvironClass LassoAuthnEnvironClass; + +struct _LassoAuthnEnviron { + LassoEnviron parent; + /*< private >*/ +}; + +struct _LassoAuthnEnvironClass { + LassoEnvironClass parent; +}; + +LASSO_EXPORT GType lasso_authn_environ_get_type(void); +LASSO_EXPORT LassoEnviron* lasso_authn_environ_new(const gchar *metadata, + const gchar *public_key, + const gchar *private_key, + const gchar *certificate); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LASSO_AUTHN_ENVIRON_H__ */ diff --git a/lasso/id-ff/environ.c b/lasso/id-ff/environ.c new file mode 100644 index 00000000..99e239a9 --- /dev/null +++ b/lasso/id-ff/environ.c @@ -0,0 +1,97 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Author: Valery Febvre <vfebvre@easter-eggs.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <lasso/environs/environ.h> + +/*****************************************************************************/ +/* public methods */ +/*****************************************************************************/ + +void +lasso_environ_add_peer_provider(LassoEnviron *env, + const gchar *metadata, + const gchar *public_key, + const gchar *private_key, + const gchar *certificate) +{ + LassoNode *provider; + + provider = lasso_provider_new(metadata); + lasso_provider_set_public_key(LASSO_PROVIDER(provider), public_key); + lasso_provider_set_private_key(LASSO_PROVIDER(provider), private_key); + lasso_provider_set_certificate(LASSO_PROVIDER(provider), certificate); + g_datalist_set_data(env->peer_providers, + lasso_node_get_attr_value(provider, "ProviderID"), + provider); +} + +/*****************************************************************************/ +/* instance and class init functions */ +/*****************************************************************************/ + +static void +lasso_environ_instance_init(LassoEnviron *env) +{ + g_datalist_init(&(env->peer_providers)); + env->request = NULL; + env->response = NULL; +} + +static void +lasso_environ_class_init(LassoEnvironClass *klass) { +} + +GType lasso_environ_get_type() { + static GType this_type = 0; + + if (!this_type) { + static const GTypeInfo this_info = { + sizeof (LassoEnvironClass), + NULL, + NULL, + (GClassInitFunc) lasso_environ_class_init, + NULL, + NULL, + sizeof(LassoEnviron), + 0, + (GInstanceInitFunc) lasso_environ_instance_init, + }; + + this_type = g_type_register_static(G_TYPE_OBJECT, + "LassoEnviron", + &this_info, 0); + } + return this_type; +} + +LassoEnviron* +lasso_environ_new(LassoProvider *local_provider) +{ + LassoEnviron *env; + + env = LASSO_ENVIRON(g_object_new(LASSO_TYPE_ENVIRON, NULL)); + env->local_provider = local_provider; + + return (env); +} diff --git a/lasso/id-ff/environ.h b/lasso/id-ff/environ.h new file mode 100644 index 00000000..8040785d --- /dev/null +++ b/lasso/id-ff/environ.h @@ -0,0 +1,79 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: Valery Febvre <vfebvre@easter-eggs.com> + * Nicolas Clapies <nclapies@entrouvert.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LASSO_ENVIRON_H__ +#define __LASSO_ENVIRON_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <lasso/xml/xml.h> +#include <lasso/environs/provider.h> + +#define LASSO_TYPE_ENVIRON (lasso_environ_get_type()) +#define LASSO_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_ENVIRON, LassoEnviron)) +#define LASSO_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_ENVIRON, LassoEnvironClass)) +#define LASSO_IS_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_ENVIRON)) +#define LASSP_IS_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_ENVIRON)) +#define LASSO_ENVIRON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_ENVIRON, LassoEnvironClass)) + +typedef enum { + LassoEnvironTypeGet = 1, + LassoEnvironTypePost, + LassoEnvironTypeSoap +} LassoEnvironType; + +typedef struct _LassoEnviron LassoEnviron; +typedef struct _LassoEnvironClass LassoEnvironClass; + +struct _LassoEnviron { + GObject parent; + LassoProvider *local_provider; + GData *peer_providers; + LassoNode *request; + LassoNode *response; + LassoEnvironType type; + /*< private >*/ +}; + +struct _LassoEnvironClass { + GObjectClass parent; +}; + +LASSO_EXPORT GType lasso_environ_get_type(void); +LASSO_EXPORT LassoEnviron* lasso_environ_new(LassoProvider *local_provider); + +LASSO_EXPORT void lasso_environ_add_peer_provider(LassoEnviron *env, + const gchar *metadata, + const gchar *public_key, + const gchar *private_key, + const gchar *certificate); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LASSO_ENVIRON_H__ */ diff --git a/lasso/id-ff/provider.c b/lasso/id-ff/provider.c new file mode 100644 index 00000000..a8874bce --- /dev/null +++ b/lasso/id-ff/provider.c @@ -0,0 +1,108 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Author: Valery Febvre <vfebvre@easter-eggs.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <lasso/environs/provider.h> + +/*****************************************************************************/ +/* public methods */ +/*****************************************************************************/ + +void +lasso_provider_set_public_key(LassoProvider *provider, + const gchar *key) +{ + g_return_if_fail(key != NULL); + + provider->public_key = g_strdup(key); +} + +void +lasso_provider_set_private_key(LassoProvider *provider, + const gchar *key) +{ + g_return_if_fail(key != NULL); + + provider->private_key = g_strdup(key); +} + +void +lasso_provider_set_certificate(LassoProvider *provider, + const gchar *certificate) +{ + g_return_if_fail(certificate != NULL); + + provider->certificate = g_strdup(certificate); +} + +/*****************************************************************************/ +/* instance and class init functions */ +/*****************************************************************************/ + +static void +lasso_provider_instance_init(LassoProvider *provider) +{ +} + +static void +lasso_provider_class_init(LassoProviderClass *klass) { +} + +GType lasso_provider_get_type() { + static GType this_type = 0; + + if (!this_type) { + static const GTypeInfo this_info = { + sizeof (LassoProviderClass), + NULL, + NULL, + (GClassInitFunc) lasso_provider_class_init, + NULL, + NULL, + sizeof(LassoProvider), + 0, + (GInstanceInitFunc) lasso_provider_instance_init, + }; + + this_type = g_type_register_static(LASSO_TYPE_NODE, + "LassoProvider", + &this_info, 0); + } + return this_type; +} + +LassoNode* lasso_provider_new(const gchar *metadata_file) { + LassoNode *provider; + xmlDocPtr doc = xmlParseFile(metadata_file); + xmlNodePtr root; + + provider = LASSO_NODE(g_object_new(LASSO_TYPE_PROVIDER, NULL)); + + /* get root element of doc and duplicate it */ + root = xmlCopyNode(xmlDocGetRootElement(doc), 1); + /* free doc */ + xmlFreeDoc(doc); + LASSO_NODE_GET_CLASS(provider)->set_xmlNode(provider, root); + + return (provider); +} diff --git a/lasso/id-ff/provider.h b/lasso/id-ff/provider.h new file mode 100644 index 00000000..1f038c5e --- /dev/null +++ b/lasso/id-ff/provider.h @@ -0,0 +1,72 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Author: Valery Febvre <vfebvre@easter-eggs.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LASSO_PROVIDER_H__ +#define __LASSO_PROVIDER_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <lasso/xml/xml.h> + +#define LASSO_TYPE_PROVIDER (lasso_provider_get_type()) +#define LASSO_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_PROVIDER, LassoProvider)) +#define LASSO_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_PROVIDER, LassoProviderClass)) +#define LASSO_IS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_PROVIDER)) +#define LASSP_IS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_PROVIDER)) +#define LASSO_PROVIDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_PROVIDER, LassoProviderClass)) + +typedef struct _LassoProvider LassoProvider; +typedef struct _LassoProviderClass LassoProviderClass; + +struct _LassoProvider { + LassoNode parent; + /*< private >*/ + gchar *public_key; + gchar *private_key; + gchar *certificate; +}; + +struct _LassoProviderClass { + LassoNodeClass parent; +}; + +LASSO_EXPORT GType lasso_provider_get_type(void); +LASSO_EXPORT LassoNode* lasso_provider_new(const gchar *metadata_file); + +LASSO_EXPORT void lasso_provider_set_public_key(LassoProvider *provider, + const gchar *key); + +LASSO_EXPORT void lasso_provider_set_private_key(LassoProvider *provider, + const gchar *key); + +LASSO_EXPORT void lasso_provider_set_certificate(LassoProvider *provider, + const gchar *certificate); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LASSO_PROVIDER_H__ */ |
