[xml saml-2.0] add a class to handle the KeyInfoConfirmationData type
* use a direct mapping to map this class to SubjectConfirmationData node having the xsi:type attribute. * overload get_xmlNode method to add the xsi:type attribute on output.
This commit is contained in:
parent
f69b561c47
commit
94a9fe4f02
|
@ -27,6 +27,7 @@ liblasso_xml_saml2_la_SOURCES = \
|
|||
saml2_encrypted_element.c \
|
||||
saml2_evidence.c \
|
||||
saml2_key_info_confirmation_data.c \
|
||||
saml2_key_info_confirmation_data_type.c \
|
||||
saml2_name_id.c \
|
||||
saml2_one_time_use.c \
|
||||
saml2_proxy_restriction.c \
|
||||
|
@ -80,6 +81,7 @@ liblassoinclude_HEADERS = \
|
|||
saml2_encrypted_element.h \
|
||||
saml2_evidence.h \
|
||||
saml2_key_info_confirmation_data.h \
|
||||
saml2_key_info_confirmation_data_type.h \
|
||||
saml2_name_id.h \
|
||||
saml2_one_time_use.h \
|
||||
saml2_proxy_restriction.h \
|
||||
|
|
|
@ -0,0 +1,173 @@
|
|||
/* $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 "saml2_key_info_confirmation_data_type.h"
|
||||
#include "../../registry.h"
|
||||
#include "../ds_key_info.h"
|
||||
#include "../../utils.h"
|
||||
|
||||
/**
|
||||
* SECTION:saml2_key_info_confirmation_data_type
|
||||
* @short_description: <saml2:KeyInfoConfirmationDataType>
|
||||
*
|
||||
* <figure><title>Schema fragment for saml2:KeyInfoConfirmationDataType</title>
|
||||
* <programlisting><![CDATA[
|
||||
*
|
||||
* <complexType name="KeyInfoConfirmationDataTypeType" mixed="true">
|
||||
* <complexContent>
|
||||
* <restriction base="anyType">
|
||||
* <sequence>
|
||||
* <any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
|
||||
* </sequence>
|
||||
* <attribute name="NotBefore" type="dateTime" use="optional"/>
|
||||
* <attribute name="NotOnOrAfter" type="dateTime" use="optional"/>
|
||||
* <attribute name="Recipient" type="anyURI" use="optional"/>
|
||||
* <attribute name="InResponseTo" type="NCName" use="optional"/>
|
||||
* <attribute name="Address" type="string" use="optional"/>
|
||||
* <anyAttribute namespace="##other" processContents="lax"/>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* ]]></programlisting>
|
||||
* </figure>
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* private methods */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
static struct XmlSnippet schema_snippets[] = {
|
||||
{ "KeyInfo", SNIPPET_LIST_NODES,
|
||||
G_STRUCT_OFFSET(LassoSaml2KeyInfoConfirmationDataType, KeyInfo), NULL, NULL, NULL},
|
||||
{NULL, 0, 0, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
static LassoNodeClass *parent_class = NULL;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* instance and class init functions */
|
||||
/*****************************************************************************/
|
||||
|
||||
static xmlNs *
|
||||
ensure_namespace(xmlNode *node, const xmlChar *href, const xmlChar *prefix)
|
||||
{
|
||||
xmlNs *ns;
|
||||
|
||||
ns = xmlSearchNsByHref(node->doc, node, href);
|
||||
if (! ns) {
|
||||
ns = xmlNewNs(node, href, prefix);
|
||||
xmlSetNs(node, ns);
|
||||
}
|
||||
return ns;
|
||||
}
|
||||
|
||||
static void
|
||||
set_qname_attribue(xmlNode *node, xmlChar *attribute_name, const xmlChar *name, const
|
||||
xmlChar *href, const xmlChar *prefix) {
|
||||
xmlNs *type_ns;
|
||||
xmlNs *xsi_ns;
|
||||
xmlChar *value;
|
||||
|
||||
xsi_ns = ensure_namespace(node, BAD_CAST LASSO_XSI_HREF, BAD_CAST LASSO_XSI_PREFIX);
|
||||
type_ns = ensure_namespace(node, href, prefix);
|
||||
value = BAD_CAST g_strdup_printf("%s:%s", type_ns->prefix, name);
|
||||
xmlSetNsProp(node, xsi_ns, attribute_name, value);
|
||||
lasso_release_string(value);
|
||||
}
|
||||
|
||||
static void
|
||||
set_xsi_type(xmlNode *node, const xmlChar *type, const xmlChar *href, const xmlChar *prefix) {
|
||||
set_qname_attribue(node, BAD_CAST "type", type, href, prefix);
|
||||
}
|
||||
|
||||
static xmlNode*
|
||||
get_xmlNode(LassoNode *node, gboolean lasso_dump)
|
||||
{
|
||||
xmlNode *xmlnode = NULL;
|
||||
|
||||
/* add xsi:type="KeyInfoConfirmationDataType" */
|
||||
xmlnode = parent_class->get_xmlNode(node, lasso_dump);
|
||||
set_xsi_type(xmlnode,
|
||||
BAD_CAST "KeyInfoConfirmationDataType",
|
||||
BAD_CAST LASSO_SAML2_ASSERTION_HREF,
|
||||
BAD_CAST LASSO_SAML2_ASSERTION_PREFIX);
|
||||
|
||||
return xmlnode;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
class_init(LassoSaml2KeyInfoConfirmationDataTypeClass *klass)
|
||||
{
|
||||
LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
nclass->node_data = g_new0(LassoNodeClassData, 1);
|
||||
nclass->get_xmlNode = get_xmlNode;
|
||||
lasso_node_class_add_snippets(nclass, schema_snippets);
|
||||
}
|
||||
|
||||
GType
|
||||
lasso_saml2_key_info_confirmation_data_type_get_type()
|
||||
{
|
||||
static GType this_type = 0;
|
||||
|
||||
if (!this_type) {
|
||||
static const GTypeInfo this_info = {
|
||||
sizeof (LassoSaml2KeyInfoConfirmationDataTypeClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(LassoSaml2KeyInfoConfirmationDataType),
|
||||
0,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
this_type = g_type_register_static(LASSO_TYPE_SAML2_SUBJECT_CONFIRMATION_DATA,
|
||||
"LassoSaml2KeyInfoConfirmationDataType", &this_info, 0);
|
||||
lasso_registry_default_add_direct_mapping(LASSO_SAML2_ASSERTION_HREF,
|
||||
"KeyInfoConfirmationDataType", LASSO_LASSO_HREF,
|
||||
"LassoSaml2KeyInfoConfirmationDataType");
|
||||
}
|
||||
return this_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* lasso_saml2_key_info_confirmation_data_type_new:
|
||||
*
|
||||
* Creates a new #LassoSaml2KeyInfoConfirmationDataType object.
|
||||
*
|
||||
* Return value: a newly created #LassoSaml2KeyInfoConfirmationDataType object
|
||||
**/
|
||||
LassoNode*
|
||||
lasso_saml2_key_info_confirmation_data_type_new()
|
||||
{
|
||||
return g_object_new(LASSO_TYPE_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE, NULL);
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/* $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_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE_H__
|
||||
#define __LASSO_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "../xml.h"
|
||||
#include "../ds_key_info.h"
|
||||
#include "./saml2_subject_confirmation_data.h"
|
||||
|
||||
#define LASSO_TYPE_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE \
|
||||
(lasso_saml2_key_info_confirmation_data_type_get_type())
|
||||
#define LASSO_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE, \
|
||||
LassoSaml2KeyInfoConfirmationDataType))
|
||||
#define LASSO_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE, \
|
||||
LassoSaml2KeyInfoConfirmationDataTypeClass))
|
||||
#define LASSO_IS_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE))
|
||||
#define LASSO_IS_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE))
|
||||
#define LASSO_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE, \
|
||||
LassoSaml2KeyInfoConfirmationDataTypeClass))
|
||||
|
||||
typedef struct _LassoSaml2KeyInfoConfirmationDataType LassoSaml2KeyInfoConfirmationDataType;
|
||||
typedef struct _LassoSaml2KeyInfoConfirmationDataTypeClass LassoSaml2KeyInfoConfirmationDataTypeClass;
|
||||
|
||||
|
||||
struct _LassoSaml2KeyInfoConfirmationDataType {
|
||||
LassoSaml2SubjectConfirmationData parent;
|
||||
|
||||
/*< public >*/
|
||||
/* attributes */
|
||||
GList *KeyInfo;
|
||||
};
|
||||
|
||||
|
||||
struct _LassoSaml2KeyInfoConfirmationDataTypeClass {
|
||||
LassoSaml2SubjectConfirmationDataClass parent;
|
||||
};
|
||||
|
||||
LASSO_EXPORT GType lasso_saml2_key_info_confirmation_data_type_get_type(void);
|
||||
LASSO_EXPORT LassoNode* lasso_saml2_key_info_confirmation_data_type_new(void);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __LASSO_SAML2_KEY_INFO_CONFIRMATION_DATA_TYPE_H__ */
|
|
@ -41,6 +41,7 @@
|
|||
#include "./saml2_encrypted_element.h"
|
||||
#include "./saml2_evidence.h"
|
||||
#include "./saml2_key_info_confirmation_data.h"
|
||||
#include "./saml2_key_info_confirmation_data_type.h"
|
||||
#include "./saml2_name_id.h"
|
||||
#include "./saml2_one_time_use.h"
|
||||
#include "./saml2_proxy_restriction.h"
|
||||
|
|
|
@ -1873,6 +1873,10 @@ START_TEST(test10_test_alldumps)
|
|||
lasso_release_doc(xmldoc);
|
||||
++iter;
|
||||
}
|
||||
/* test serialization / deserialization of KeyInfoConfirmationDataType */
|
||||
node = LASSO_NODE(lasso_saml2_key_info_confirmation_data_type_new());
|
||||
printf("%s\n", lasso_node_debug(node, 10));
|
||||
lasso_release_gobject(node);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
Loading…
Reference in New Issue