diff --git a/configure.ac b/configure.ac index 6be518dc..7770127f 100644 --- a/configure.ac +++ b/configure.ac @@ -840,6 +840,7 @@ lasso/xml/saml-2.0/Makefile lasso/xml/soap-1.1/Makefile lasso/xml/id-wsf-2.0/Makefile lasso/xml/ws/Makefile +lasso/xml/dsig/Makefile tests/Makefile tests/data/Makefile lasso.pc diff --git a/lasso/Makefile.am b/lasso/Makefile.am index 93b90d37..042419da 100644 --- a/lasso/Makefile.am +++ b/lasso/Makefile.am @@ -57,6 +57,7 @@ if MINGW liblasso_la_LIBADD = \ $(top_builddir)/lasso/xml/liblasso-xml.la \ $(top_builddir)/lasso/xml/saml-2.0/liblasso-xml-saml2.la \ + $(top_builddir)/lasso/xml/dsig/liblasso-xml-dsig.la \ $(top_builddir)/lasso/id-ff/liblasso-id-ff.la \ $(top_builddir)/lasso/saml-2.0/liblasso-saml-20.la \ $(WSF_LIB_FILE) \ @@ -73,6 +74,7 @@ liblasso_la_LIBADD = \ $(top_builddir)/lasso/xml/liblasso-xml.la \ $(top_builddir)/lasso/xml/saml-2.0/liblasso-xml-saml2.la \ $(top_builddir)/lasso/xml/soap-1.1/liblasso-xml-soap11.la \ + $(top_builddir)/lasso/xml/dsig/liblasso-xml-dsig.la \ $(top_builddir)/lasso/id-ff/liblasso-id-ff.la \ $(top_builddir)/lasso/saml-2.0/liblasso-saml-20.la \ $(WSF_LIB_FILE) \ diff --git a/lasso/xml/Makefile.am b/lasso/xml/Makefile.am index d12e2391..515c3c5b 100644 --- a/lasso/xml/Makefile.am +++ b/lasso/xml/Makefile.am @@ -1,5 +1,5 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = saml-2.0 soap-1.1 +SUBDIRS = saml-2.0 soap-1.1 dsig if WSF_ENABLED SUBDIRS += id-wsf-2.0 ws endif @@ -140,9 +140,6 @@ endif liblasso_xml_la_SOURCES = \ tools.c \ xml.c \ - ds_key_info.c \ - ds_key_value.c \ - ds_rsa_key_value.c \ lib_assertion.c \ lib_authentication_statement.c \ lib_authn_context.c \ @@ -194,9 +191,6 @@ liblasso_xml_la_SOURCES = \ liblassoinclude_HEADERS = \ strings.h \ xml.h \ - ds_key_info.h \ - ds_key_value.h \ - ds_rsa_key_value.h \ lib_assertion.h \ lib_authentication_statement.h \ lib_authn_context.h \ diff --git a/lasso/xml/dsig/Makefile.am b/lasso/xml/dsig/Makefile.am new file mode 100644 index 00000000..3afe8de0 --- /dev/null +++ b/lasso/xml/dsig/Makefile.am @@ -0,0 +1,23 @@ +EXTRA_DIST = xml_saml2.h +MAINTAINERCLEANFILES = Makefile.in +liblassoincludedir = $(includedir)/lasso/xml/dsig + +INCLUDES = \ + -I$(top_builddir) \ + -I$(top_srcdir) \ + $(LASSO_CORE_CFLAGS) \ + -DG_LOG_DOMAIN=\"lasso\" + +noinst_LTLIBRARIES = liblasso-xml-dsig.la + +liblasso_xml_dsig_la_SOURCES = \ + ds_key_info.c \ + ds_key_value.c \ + ds_rsa_key_value.c \ + ds_x509_data.c + +liblassoinclude_HEADERS = \ + ds_key_info.h \ + ds_key_value.h \ + ds_rsa_key_value.h \ + ds_x509_data.h diff --git a/lasso/xml/ds_key_info.c b/lasso/xml/dsig/ds_key_info.c similarity index 98% rename from lasso/xml/ds_key_info.c rename to lasso/xml/dsig/ds_key_info.c index 6036c70d..b5009cb2 100644 --- a/lasso/xml/ds_key_info.c +++ b/lasso/xml/dsig/ds_key_info.c @@ -22,8 +22,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "private.h" -#include "ds_key_info.h" +#include "../private.h" +#include "./ds_key_info.h" /** * SECTION:ds_key_info diff --git a/lasso/xml/ds_key_info.h b/lasso/xml/dsig/ds_key_info.h similarity index 97% rename from lasso/xml/ds_key_info.h rename to lasso/xml/dsig/ds_key_info.h index 059e6ef5..2e7359c6 100644 --- a/lasso/xml/ds_key_info.h +++ b/lasso/xml/dsig/ds_key_info.h @@ -29,8 +29,8 @@ extern "C" { #endif /* __cplusplus */ -#include "xml.h" -#include "ds_key_value.h" +#include "../xml.h" +#include "./ds_key_value.h" #define LASSO_TYPE_DS_KEY_INFO (lasso_ds_key_info_get_type()) #define LASSO_DS_KEY_INFO(obj) \ diff --git a/lasso/xml/ds_key_value.c b/lasso/xml/dsig/ds_key_value.c similarity index 69% rename from lasso/xml/ds_key_value.c rename to lasso/xml/dsig/ds_key_value.c index 1303b575..86b66141 100644 --- a/lasso/xml/ds_key_value.c +++ b/lasso/xml/dsig/ds_key_value.c @@ -22,8 +22,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "private.h" -#include "ds_key_value.h" +#include "../private.h" +#include "./ds_key_value.h" /** * SECTION:ds_key_value @@ -31,12 +31,22 @@ * */ +struct _LassoDsKeyValuePrivate { + LassoDsX509Data *X509Data; +}; + +typedef struct _LassoDsKeyValuePrivate LassoDsKeyValuePrivate; + +#define LASSO_DS_KEY_VALUE_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), LASSO_TYPE_DS_KEY_VALUE, LassoDsKeyValuePrivate)) + /*****************************************************************************/ /* private methods */ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { { "RSAKeyValue", SNIPPET_NODE, G_STRUCT_OFFSET(LassoDsKeyValue, RSAKeyValue), NULL, NULL, NULL}, + { "X509Data", SNIPPET_NODE|SNIPPET_PRIVATE, G_STRUCT_OFFSET(LassoDsKeyValuePrivate, X509Data), NULL, NULL, NULL}, {NULL, 0, 0, NULL, NULL, NULL} }; @@ -54,6 +64,7 @@ class_init(LassoDsKeyValueClass *klass) lasso_node_class_set_nodename(nclass, "KeyValue"); lasso_node_class_set_ns(nclass, LASSO_DS_HREF, LASSO_DS_PREFIX); lasso_node_class_add_snippets(nclass, schema_snippets); + g_type_class_add_private(klass, sizeof(LassoDsKeyValuePrivate)); } GType @@ -93,3 +104,32 @@ lasso_ds_key_value_new() { return g_object_new(LASSO_TYPE_DS_KEY_VALUE, NULL); } + +/** + * lasso_ds_key_value_get_x509_data: + * + * Get the X509 Data node if there is one. + * + * Return value:(transfer none): the internal value of the X509Data field + */ +LassoDsX509Data* +lasso_ds_key_value_get_x509_data(LassoDsKeyValue *key_value) +{ + lasso_return_val_if_fail(LASSO_IS_DS_KEY_VALUE(key_value), NULL); + + return LASSO_DS_KEY_VALUE_GET_PRIVATE(key_value)->X509Data; +} + +/** + * lasso_ds_key_value_set_x509_data: + * + * Set the X509 Data node. + * + */ +void +lasso_ds_key_value_set_x509_data(LassoDsKeyValue *key_value, LassoDsX509Data *x509_data) +{ + lasso_return_if_fail(LASSO_IS_DS_KEY_VALUE(key_value)); + + lasso_assign_gobject(LASSO_DS_KEY_VALUE_GET_PRIVATE(key_value)->X509Data, x509_data); +} diff --git a/lasso/xml/ds_key_value.h b/lasso/xml/dsig/ds_key_value.h similarity index 88% rename from lasso/xml/ds_key_value.h rename to lasso/xml/dsig/ds_key_value.h index 48a2e8fc..e72a2141 100644 --- a/lasso/xml/ds_key_value.h +++ b/lasso/xml/dsig/ds_key_value.h @@ -29,8 +29,9 @@ extern "C" { #endif /* __cplusplus */ -#include "xml.h" -#include "ds_rsa_key_value.h" +#include "../xml.h" +#include "./ds_rsa_key_value.h" +#include "./ds_x509_data.h" #define LASSO_TYPE_DS_KEY_VALUE (lasso_ds_key_value_get_type()) #define LASSO_DS_KEY_VALUE(obj) \ @@ -62,6 +63,9 @@ struct _LassoDsKeyValueClass { LASSO_EXPORT GType lasso_ds_key_value_get_type(void); LASSO_EXPORT LassoDsKeyValue* lasso_ds_key_value_new(void); +LASSO_EXPORT LassoDsX509Data *lasso_ds_key_value_get_x509_data(LassoDsKeyValue *key_value); +LASSO_EXPORT void lasso_ds_key_value_set_x509_data(LassoDsKeyValue *key_value, LassoDsX509Data + *x509_data); #ifdef __cplusplus } diff --git a/lasso/xml/ds_rsa_key_value.c b/lasso/xml/dsig/ds_rsa_key_value.c similarity index 98% rename from lasso/xml/ds_rsa_key_value.c rename to lasso/xml/dsig/ds_rsa_key_value.c index 5e393966..790f5ce2 100644 --- a/lasso/xml/ds_rsa_key_value.c +++ b/lasso/xml/dsig/ds_rsa_key_value.c @@ -22,8 +22,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "private.h" -#include "ds_rsa_key_value.h" +#include "../private.h" +#include "./ds_rsa_key_value.h" /* * SECTION:ds_rsa_key_value diff --git a/lasso/xml/ds_rsa_key_value.h b/lasso/xml/dsig/ds_rsa_key_value.h similarity index 99% rename from lasso/xml/ds_rsa_key_value.h rename to lasso/xml/dsig/ds_rsa_key_value.h index 1add7310..51bf4f70 100644 --- a/lasso/xml/ds_rsa_key_value.h +++ b/lasso/xml/dsig/ds_rsa_key_value.h @@ -29,7 +29,7 @@ extern "C" { #endif /* __cplusplus */ -#include "xml.h" +#include "../xml.h" #define LASSO_TYPE_DS_RSA_KEY_VALUE (lasso_ds_rsa_key_value_get_type()) #define LASSO_DS_RSA_KEY_VALUE(obj) \ diff --git a/lasso/xml/dsig/ds_x509_data.c b/lasso/xml/dsig/ds_x509_data.c new file mode 100644 index 00000000..c45a1c1b --- /dev/null +++ b/lasso/xml/dsig/ds_x509_data.c @@ -0,0 +1,204 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004-2007 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: See AUTHORS file in top-level directory. + * + * 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 "../private.h" +#include "./ds_x509_data.h" + +/** + * SECTION:ds_x509_data + * @short_description: object mapping for an XML DSIG KeyValue element + * + */ + +struct _LassoDsX509DataPrivate { + char *X509Certificate; + char *X509SubjectName; + char *X509CRL; +}; +#define LASSO_DS_X509_DATA_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), LASSO_TYPE_DS_X509_DATA, LassoDsX509DataPrivate)) + +/*****************************************************************************/ +/* private methods */ +/*****************************************************************************/ + +static struct XmlSnippet schema_snippets[] = { + { "X509Certificate", SNIPPET_CONTENT|SNIPPET_PRIVATE, + G_STRUCT_OFFSET(LassoDsX509DataPrivate, X509Certificate), NULL, NULL, NULL}, + { "X509SubjectName", SNIPPET_CONTENT|SNIPPET_PRIVATE, + G_STRUCT_OFFSET(LassoDsX509DataPrivate, X509SubjectName), NULL, NULL, NULL}, + { "X509CRL", SNIPPET_CONTENT|SNIPPET_PRIVATE, G_STRUCT_OFFSET(LassoDsX509DataPrivate, + X509CRL), NULL, NULL, NULL}, + {NULL, 0, 0, NULL, NULL, NULL} +}; + +static LassoNodeClass *parent_class = NULL; + +/*****************************************************************************/ +/* instance and class init functions */ +/*****************************************************************************/ + +static void +instance_init(LassoDsX509Data *x509_data) +{ + x509_data->private_data = LASSO_DS_X509_DATA_GET_PRIVATE(x509_data); +} + +static void +class_init(LassoDsX509DataClass *klass) +{ + LassoNodeClass *nclass = LASSO_NODE_CLASS(klass); + + parent_class = g_type_class_peek_parent(klass); + nclass->node_data = g_new0(LassoNodeClassData, 1); + lasso_node_class_set_nodename(nclass, "X509Data"); + lasso_node_class_set_ns(nclass, LASSO_DS_HREF, LASSO_DS_PREFIX); + lasso_node_class_add_snippets(nclass, schema_snippets); + g_type_class_add_private(klass, sizeof(LassoDsX509DataPrivate)); +} + +GType +lasso_ds_x509_data_get_type() +{ + static GType this_type = 0; + + if (!this_type) { + static const GTypeInfo this_info = { + sizeof (LassoDsX509DataClass), + NULL, + NULL, + (GClassInitFunc) class_init, + NULL, + NULL, + sizeof(LassoDsX509Data), + 0, + (GInstanceInitFunc)instance_init, + NULL + }; + + this_type = g_type_register_static(LASSO_TYPE_NODE, + "LassoDsX509Data", &this_info, 0); + } + return this_type; +} + +/** + * lasso_ds_x509_data_new: + * + * Creates a new #LassoDsX509Data object. + * + * Return value: a newly created #LassoDsX509Data object + **/ +LassoDsX509Data* +lasso_ds_x509_data_new() +{ + return g_object_new(LASSO_TYPE_DS_X509_DATA, NULL); +} + +/** + * lasso_ds_x509_data_get_certificate: + * @x509_data: a #LassoDsX509Data object + * + * Return the content of the X509Certificate sub-element, it should be a base64 encoded string. + * + * Return value:(transfer none): the string currently set in the X509Certificate private field of + * the #LassoDsX509Data structure. + */ +const char* +lasso_ds_x509_data_get_certificate(LassoDsX509Data *x509_data) { + lasso_return_val_if_fail(LASSO_IS_DS_X509_DATA(x509_data), NULL); + return x509_data->private_data->X509Certificate; +} + +/** + * lasso_ds_x509_data_set_certificate: + * @x509_data: a #LassoDsX509Data object + * @certificate: a base64 encoded string of the DER representation of the X509 certificate + * + * Set the content of the X509Certificate sub-element, it should be a base64 encoded string. + * + */ +void +lasso_ds_x509_data_set_certificate(LassoDsX509Data *x509_data, const char *certificate) { + lasso_return_if_fail(LASSO_IS_DS_X509_DATA(x509_data)); + lasso_assign_string(x509_data->private_data->X509Certificate, certificate); +} + +/** + * lasso_ds_x509_data_get_subject_name: + * @x509_data: a #LassoDsX509Data object + * + * Return the content of the X509SubjectName sub-element, it should be a base64 encoded string. + * + * Return value:(transfer none): the string currently set in the X509SubjectName private field of + * the #LassoDsX509Data structure. + */ +const char* +lasso_ds_x509_data_get_subject_name(LassoDsX509Data *x509_data) { + lasso_return_val_if_fail(LASSO_IS_DS_X509_DATA(x509_data), NULL); + return x509_data->private_data->X509SubjectName; +} + +/** + * lasso_ds_x509_data_set_subject_name: + * @x509_data: a #LassoDsX509Data object + * @subject_name: a base64 encoded string of the DER representation of the X509 subject_name + * + * Set the content of the X509SubjectName sub-element, it should be a base64 encoded string. + * + */ +void +lasso_ds_x509_data_set_subject_name(LassoDsX509Data *x509_data, const char *subject_name) { + lasso_return_if_fail(LASSO_IS_DS_X509_DATA(x509_data)); + lasso_assign_string(x509_data->private_data->X509SubjectName, subject_name); +} + +/** + * lasso_ds_x509_data_get_crl: + * @x509_data: a #LassoDsX509Data object + * + * Return the content of the X509CRL sub-element, it should be a base64 encoded string. + * + * Return value:(transfer none): the string currently set in the X509CRL private field of + * the #LassoDsX509Data structure. + */ +const char* +lasso_ds_x509_data_get_crl(LassoDsX509Data *x509_data) { + lasso_return_val_if_fail(LASSO_IS_DS_X509_DATA(x509_data), NULL); + return x509_data->private_data->X509CRL; +} + +/** + * lasso_ds_x509_data_set_crl: + * @x509_data: a #LassoDsX509Data object + * @crl: a base64 encoded string of the DER representation of the X509 CRL + * + * Set the content of the X509CRL sub-element, it should be a base64 encoded string. + * + */ +void +lasso_ds_x509_data_set_crl(LassoDsX509Data *x509_data, const char *crl) { + lasso_return_if_fail(LASSO_IS_DS_X509_DATA(x509_data)); + lasso_assign_string(x509_data->private_data->X509CRL, crl); +} diff --git a/lasso/xml/dsig/ds_x509_data.h b/lasso/xml/dsig/ds_x509_data.h new file mode 100644 index 00000000..a6d2e451 --- /dev/null +++ b/lasso/xml/dsig/ds_x509_data.h @@ -0,0 +1,76 @@ +/* $Id + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004-2007 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: See AUTHORS file in top-level directory. + * + * 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_DS_X509_DATA_H__ +#define __LASSO_DS_X509_DATA_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "../xml.h" + +#define LASSO_TYPE_DS_X509_DATA (lasso_ds_x509_data_get_type()) +#define LASSO_DS_X509_DATA(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_DS_X509_DATA, \ + LassoDsX509Data)) +#define LASSO_DS_X509_DATA_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_DS_X509_DATA, \ + LassoDsX509DataClass)) +#define LASSO_IS_DS_X509_DATA(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_DS_X509_DATA)) +#define LASSO_IS_DS_X509_DATA_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_DS_X509_DATA)) +#define LASSO_DS_X509_DATA_GET_CLASS(o) \ + (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_DS_X509_DATA, \ + LassoDsX509DataClass)) + +typedef struct _LassoDsX509Data LassoDsX509Data; +typedef struct _LassoDsX509DataClass LassoDsX509DataClass; +typedef struct _LassoDsX509DataPrivate LassoDsX509DataPrivate; + +struct _LassoDsX509Data { + LassoNode parent; + /*< private >*/ + LassoDsX509DataPrivate *private_data; +}; + +struct _LassoDsX509DataClass { + LassoNodeClass parent; +}; + +LASSO_EXPORT GType lasso_ds_x509_data_get_type(void); +LASSO_EXPORT LassoDsX509Data* lasso_ds_x509_data_new(void); +LASSO_EXPORT const char *lasso_ds_x509_data_get_certificate(LassoDsX509Data *x509_data); +LASSO_EXPORT void lasso_ds_x509_data_set_certificate(LassoDsX509Data *x509_data, const char *certificate); +LASSO_EXPORT const char *lasso_ds_x509_data_get_subject_name(LassoDsX509Data *x509_data); +LASSO_EXPORT void lasso_ds_x509_data_set_subject_name(LassoDsX509Data *x509_data, const char *subject_name); +LASSO_EXPORT const char *lasso_ds_x509_data_get_crl(LassoDsX509Data *x509_data); +LASSO_EXPORT void lasso_ds_x509_data_set_crl(LassoDsX509Data *x509_data, const char *crl); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LASSO_DS_X509_DATA_H__ */ diff --git a/lasso/xml/dsig/strings.h b/lasso/xml/dsig/strings.h new file mode 100644 index 00000000..a4c534a8 --- /dev/null +++ b/lasso/xml/dsig/strings.h @@ -0,0 +1,61 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004-2007 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: See AUTHORS file in top-level directory. + * + * 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 + * + */ + +/* + * This header file copy part of the SOAP 1.1 specification you can found there: + * http://www.w3.org/TR/soap12-part1/ + * whom copyright is: + * Copyright © 2007 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and + * document use rules apply. + */ + + +/** + * SECTION:dsig_strings + * @short_description: General strings constants for XMLDsig + * @include: lasso/xml/dsig/strings.h + * + **/ + +#ifndef __LASSO_DSIG_STRINGS_H__ +#define __LASSO_DSIG_STRINGS_H__ + +/* xmldsig prefix & href */ +/** + * LASSO_DS_HREF: + * + * Namespace for FIXME + * + */ +#define LASSO_DS_HREF "http://www.w3.org/2000/09/xmldsig#" +/** + * LASSO_DS_PREFIX: + * + * Preferred prefix for namespace of FIXME + * + */ +#define LASSO_DS_PREFIX "ds" + +#endif /* __LASSO_DSIG_STRINGS_H__ */ diff --git a/lasso/xml/saml-2.0/saml2_key_info_confirmation_data_type.c b/lasso/xml/saml-2.0/saml2_key_info_confirmation_data_type.c index ecccc654..50f3c46a 100644 --- a/lasso/xml/saml-2.0/saml2_key_info_confirmation_data_type.c +++ b/lasso/xml/saml-2.0/saml2_key_info_confirmation_data_type.c @@ -25,7 +25,7 @@ #include "../private.h" #include "saml2_key_info_confirmation_data_type.h" #include "../../registry.h" -#include "../ds_key_info.h" +#include "../dsig/ds_key_info.h" #include "../../utils.h" /** diff --git a/lasso/xml/saml-2.0/saml2_key_info_confirmation_data_type.h b/lasso/xml/saml-2.0/saml2_key_info_confirmation_data_type.h index a30610c8..6ebd0f64 100644 --- a/lasso/xml/saml-2.0/saml2_key_info_confirmation_data_type.h +++ b/lasso/xml/saml-2.0/saml2_key_info_confirmation_data_type.h @@ -30,7 +30,7 @@ extern "C" { #endif /* __cplusplus */ #include "../xml.h" -#include "../ds_key_info.h" +#include "../dsig/ds_key_info.h" #include "./saml2_subject_confirmation_data.h" #define LASSO_TYPE_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE \ diff --git a/lasso/xml/saml_subject_confirmation.h b/lasso/xml/saml_subject_confirmation.h index ca08882f..648b961c 100644 --- a/lasso/xml/saml_subject_confirmation.h +++ b/lasso/xml/saml_subject_confirmation.h @@ -30,7 +30,7 @@ extern "C" { #endif /* __cplusplus */ #include "xml.h" -#include "ds_key_info.h" +#include "./dsig/ds_key_info.h" #define LASSO_TYPE_SAML_SUBJECT_CONFIRMATION (lasso_saml_subject_confirmation_get_type()) #define LASSO_SAML_SUBJECT_CONFIRMATION(obj) \ diff --git a/lasso/xml/strings.h b/lasso/xml/strings.h index 86800325..1fe6bc95 100644 --- a/lasso/xml/strings.h +++ b/lasso/xml/strings.h @@ -43,6 +43,7 @@ #define __LASSO_STRINGS_H__ #include "./saml-2.0/saml2_strings.h" +#include "./dsig/strings.h" /*****************************************************************************/ /* SOAP 1.1 */ @@ -955,22 +956,6 @@ /* Others */ /*****************************************************************************/ -/* xmldsig prefix & href */ -/** - * LASSO_DS_HREF: - * - * Namespace for FIXME - * - */ -#define LASSO_DS_HREF "http://www.w3.org/2000/09/xmldsig#" -/** - * LASSO_DS_PREFIX: - * - * Preferred prefix for namespace of FIXME - * - */ -#define LASSO_DS_PREFIX "ds" - /* xsi prefix & href */ /** * LASSO_XSI_HREF: diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index ed6aa5ce..265236a8 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -2094,6 +2094,8 @@ prefix_from_href_and_nodename(const xmlChar *href, G_GNUC_UNUSED const xmlChar * prefix = "Samlp2"; else if (strcmp((char*)href, LASSO_SOAP_ENV_HREF) == 0) prefix = "Soap"; + else if (strcmp((char*)href, LASSO_DS_HREF) == 0) + prefix = "Ds"; #ifdef LASSO_WSF_ENABLED else if (strcmp((char*)href, LASSO_SOAP_BINDING_HREF) == 0) prefix = "SoapBinding"; @@ -2101,8 +2103,6 @@ prefix_from_href_and_nodename(const xmlChar *href, G_GNUC_UNUSED const xmlChar * prefix = "SoapBindingExt"; else if (strcmp((char*)href, LASSO_DISCO_HREF) == 0) prefix = "Disco"; - else if (strcmp((char*)href, LASSO_DS_HREF) == 0) - prefix = "Ds"; else if (strcmp((char*)href, LASSO_IS_HREF) == 0) prefix = "Is"; else if (strcmp((char*)href, LASSO_SA_HREF) == 0) diff --git a/lasso/xml/xml_idff.h b/lasso/xml/xml_idff.h index 5fc0f0bc..6ae04e29 100644 --- a/lasso/xml/xml_idff.h +++ b/lasso/xml/xml_idff.h @@ -26,9 +26,10 @@ #define __LASSO_XML_IDFF_H__ #include "./xml.h" -#include "./ds_key_info.h" -#include "./ds_key_value.h" -#include "./ds_rsa_key_value.h" +#include "./dsig/ds_key_info.h" +#include "./dsig/ds_key_value.h" +#include "./dsig/ds_rsa_key_value.h" +#include "./dsig/ds_x509_data.h" #include "./lib_assertion.h" #include "./lib_authentication_statement.h" #include "./lib_authn_context.h" diff --git a/tests/basic_tests.c b/tests/basic_tests.c index f2d3e51c..cb96a3c4 100644 --- a/tests/basic_tests.c +++ b/tests/basic_tests.c @@ -2012,6 +2012,34 @@ START_TEST(test14_lasso_key) } END_TEST +/* test load federation */ +START_TEST(test15_ds_key_info) +{ + LassoDsKeyInfo *ds_key_info = lasso_ds_key_info_new(); + LassoDsKeyValue *ds_key_value = lasso_ds_key_value_new(); + LassoDsX509Data *x509_data = lasso_ds_x509_data_new(); + char *dump; + + lasso_ds_x509_data_set_certificate(x509_data, "coucou"); + lasso_ds_key_value_set_x509_data(ds_key_value, x509_data); + ds_key_info->KeyValue = g_object_ref(ds_key_value); + dump = lasso_node_debug((LassoNode*)ds_key_info, 10); + lasso_release_gobject(ds_key_info); + lasso_release_gobject(ds_key_value); + lasso_release_gobject(x509_data); + ds_key_info = (LassoDsKeyInfo*)lasso_node_new_from_dump(dump); + check_not_null(ds_key_info); + check_true(LASSO_IS_DS_KEY_INFO(ds_key_info)); + check_not_null(ds_key_info->KeyValue); + check_true(LASSO_IS_DS_KEY_VALUE(ds_key_info->KeyValue)); + x509_data = lasso_ds_key_value_get_x509_data(ds_key_info->KeyValue); + check_not_null(x509_data); + check_true(LASSO_IS_DS_X509_DATA(x509_data)); + check_str_equals(lasso_ds_x509_data_get_certificate(x509_data), "coucou"); + lasso_release_gobject(ds_key_info); +} +END_TEST + Suite* basic_suite() { @@ -2028,6 +2056,7 @@ basic_suite() TCase *tc_custom_namespace = tcase_create("Test custom namespace handling"); TCase *tc_load_metadata = tcase_create("Test loading a federation metadata file"); TCase *tc_key = tcase_create("Test loading and manipulating LassoKey objects"); + TCase *tc_key_info = tcase_create("Test creating and dumping ds:KeyInfo nodes"); suite_add_tcase(s, tc_server_load_dump_empty_string); suite_add_tcase(s, tc_server_load_dump_random_string); @@ -2041,6 +2070,7 @@ basic_suite() suite_add_tcase(s, tc_custom_namespace); suite_add_tcase(s, tc_load_metadata); suite_add_tcase(s, tc_key); + suite_add_tcase(s, tc_key_info); tcase_add_test(tc_server_load_dump_empty_string, test01_server_load_dump_empty_string); tcase_add_test(tc_server_load_dump_random_string, test02_server_load_dump_random_string); @@ -2056,6 +2086,7 @@ basic_suite() tcase_add_test(tc_custom_namespace, test12_custom_namespace); tcase_add_test(tc_load_metadata, test13_test_lasso_server_load_metadata); tcase_add_test(tc_key, test14_lasso_key); + tcase_add_test(tc_key_info, test15_ds_key_info); tcase_set_timeout(tc_load_metadata, 10); return s; }