Add LassoNode objects for ECP and PAOS

The SAMLv2 protocol defines 5 XML types which we need to map to
LassoNode objectes so thay can be serialized from XML and back into
XML.

ecp:RelayState
ecp:Request
ecp:Response
paos:Request
paso:Response

This patch addes these 5 new LassoNode's and updates the build
configuration to include them.

Signed-off-by: John Dennis <jdennis@redhat.com>
License: MIT
This commit is contained in:
John Dennis 2015-05-27 11:09:33 -04:00 committed by Benjamin Dauvergne
parent 904e23d7ff
commit 9629925c1e
18 changed files with 1443 additions and 7 deletions

View File

@ -500,7 +500,7 @@ def parse_header(header_file):
if member_name == 'parent':
in_struct.parent = member_type
else:
in_struct.members.append(field)
in_struct.members.append(field)
elif line.startswith('LASSO_EXPORT '):
while not line.strip().endswith(';'):
i += 1
@ -640,4 +640,3 @@ def main():
if __name__ == '__main__':
main()

View File

@ -799,6 +799,7 @@ lasso/id-wsf/Makefile
lasso/saml-2.0/Makefile
lasso/id-wsf-2.0/Makefile
lasso/xml/Makefile
lasso/xml/ecp/Makefile
lasso/xml/saml-2.0/Makefile
lasso/xml/soap-1.1/Makefile
lasso/xml/id-wsf-2.0/Makefile

View File

@ -183,6 +183,8 @@ the <ulink url="http://lasso.entrouvert.org/license">GNU General Public License<
<xi:include href="xml/lib_scoping.xml"/>
<xi:include href="xml/lib_status_response.xml"/>
<xi:include href="xml/lib_subject.xml"/>
<xi:include href="xml/paos_request.xml"/>
<xi:include href="xml/paos_response.xml"/>
<xi:include href="xml/saml_advice.xml"/>
<xi:include href="xml/saml_assertion.xml"/>
<xi:include href="xml/saml_attribute_designator.xml"/>
@ -284,6 +286,9 @@ the <ulink url="http://lasso.entrouvert.org/license">GNU General Public License<
<xi:include href="xml/samlp2_status.xml"/>
<xi:include href="xml/samlp2_subject_query_abstract.xml"/>
<xi:include href="xml/samlp2_terminate.xml"/>
<xi:include href="xml/ecp_request.xml"/>
<xi:include href="xml/ecp_response.xml"/>
<xi:include href="xml/ecp_relaystate.xml"/>
</chapter>
<chapter id="idwsf">

View File

@ -6157,3 +6157,38 @@ lasso_soap_envelope_get_sb2_user_interaction_header
lasso_log_set_handler
lasso_log_remove_handler
</SECTION>
<SECTION>
<FILE>paos_request</FILE>
<TITLE>LassoPaosRequest</TITLE>
lasso_paos_request_validate
lasso_paos_request_new
</SECTION>
<SECTION>
<FILE>paos_response</FILE>
<TITLE>LassoPaosResponse</TITLE>
lasso_paos_response_validate
lasso_paos_response_new
</SECTION>
<SECTION>
<FILE>ecp_request</FILE>
<TITLE>LassoEcpRequest</TITLE>
lasso_ecp_request_validate
lasso_ecp_request_new
</SECTION>
<SECTION>
<FILE>ecp_response</FILE>
<TITLE>LassoEcpResponse</TITLE>
lasso_ecp_response_validate
lasso_ecp_response_new
</SECTION>
<SECTION>
<FILE>ecp_relaystate</FILE>
<TITLE>LassoEcpRelayState</TITLE>
lasso_ecp_relay_state_validate
lasso_ecp_relay_state_new
</SECTION>

View File

@ -56,6 +56,7 @@ endif
if MINGW
liblasso_la_LIBADD = \
$(top_builddir)/lasso/xml/liblasso-xml.la \
$(top_builddir)/lasso/xml/ecp/liblasso-xml-ecp.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 \
@ -72,6 +73,7 @@ liblasso_la_LDFLAGS = -no-undefined -version-info @LASSO_VERSION_INFO@ \
-Wl,--add-stdcall-alias
else
liblasso_la_LIBADD = \
$(top_builddir)/lasso/xml/ecp/liblasso-xml-ecp.la \
$(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 \

View File

@ -1,5 +1,5 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = saml-2.0 soap-1.1 dsig
SUBDIRS = saml-2.0 soap-1.1 dsig ecp
if WSF_ENABLED
SUBDIRS += id-wsf-2.0 ws
endif
@ -162,6 +162,8 @@ liblasso_xml_la_SOURCES = \
lib_status_response.c \
lib_subject.c \
misc_text_node.c \
paos_request.c \
paos_response.c \
saml_advice.c \
saml_assertion.c \
saml_attribute.c \
@ -213,6 +215,8 @@ liblassoinclude_HEADERS = \
lib_status_response.h \
lib_subject.h \
misc_text_node.h \
paos_request.h \
paos_response.h \
saml_advice.h \
saml_assertion.h \
saml_attribute.h \

21
lasso/xml/ecp/Makefile.am Normal file
View File

@ -0,0 +1,21 @@
MAINTAINERCLEANFILES = Makefile.in
liblassoincludedir = $(includedir)/lasso/xml/ecp
INCLUDES = \
-I$(top_builddir) \
-I$(top_srcdir) \
$(LASSO_CORE_CFLAGS) \
-DG_LOG_DOMAIN=\"lasso\"
noinst_LTLIBRARIES = liblasso-xml-ecp.la
liblasso_xml_ecp_la_SOURCES = \
ecp_request.c \
ecp_response.c \
ecp_relaystate.c
liblassoinclude_HEADERS = \
ecp_request.h \
ecp_response.h \
ecp_relaystate.h

View File

@ -0,0 +1,197 @@
/* $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, see <http://www.gnu.org/licenses/>.
*/
#include "../private.h"
#include "ecp_relaystate.h"
/**
* SECTION:ecp_relaystate
* @short_description: &lt;ecp:RelayState&gt;
*
* <figure><title>Schema fragment for ecp:RelayState</title>
* <programlisting><![CDATA[
*
* <element name="RelayState" type="ecp:RelayStateType"/>
* <complexType name="RelayStateType">
* <simpleContent>
* <extension base="string">
* <attribute ref="S:mustUnderstand" use="required"/>
* <attribute ref="S:actor" use="required"/>
* </extension>
* </simpleContent>
* </complexType>
* ]]></programlisting>
* </figure>
*/
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
/**
* lasso_ecp_relay_state_validate:
* @relaystate: The #LassoEcpRelayState
*
* Validates the #LassoEcpRelayState object conforms to required values.
*
* <itemizedlist>
* <listitem>RelayState must be non-NULL</listitem>
* <listitem>mustUnderstand must be TRUE</listitem>
* <listitem>actor must be equal to #LASSO_SOAP_ENV_ACTOR</listitem>
* </itemizedlist>
*
* Returns: 0 on success, error code otherwise
**/
int
lasso_ecp_relay_state_validate(LassoEcpRelayState *relaystate)
{
g_return_val_if_fail(LASSO_IS_ECP_RELAYSTATE(relaystate),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
if (relaystate->RelayState == NULL) {
error("%s.RelayState missing", G_OBJECT_CLASS_NAME(relaystate));
return LASSO_XML_ERROR_NODE_CONTENT_NOT_FOUND;
}
if (!relaystate->mustUnderstand) {
error("%s.mustUnderstand must be True", G_OBJECT_CLASS_NAME(relaystate));
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
if (relaystate->actor == NULL) {
error("%s.actor missing", G_OBJECT_CLASS_NAME(relaystate));
return LASSO_XML_ERROR_ATTR_NOT_FOUND;
}
if (lasso_strisnotequal(relaystate->actor, LASSO_SOAP_ENV_ACTOR)) {
error("%s.actor invalid, must be \"%s\" not \"%s\"",
G_OBJECT_CLASS_NAME(relaystate),
LASSO_SOAP_ENV_ACTOR, relaystate->actor);
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
return 0;
}
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static struct XmlSnippet schema_snippets[] = {
{ "RelayState", SNIPPET_TEXT_CHILD, G_STRUCT_OFFSET(LassoEcpRelayState, RelayState), NULL, NULL, NULL},
{ "mustUnderstand", SNIPPET_ATTRIBUTE | SNIPPET_BOOLEAN,
G_STRUCT_OFFSET(LassoEcpRelayState, mustUnderstand), NULL, LASSO_SOAP_ENV_PREFIX, LASSO_SOAP_ENV_HREF},
{ "actor", SNIPPET_ATTRIBUTE,
G_STRUCT_OFFSET(LassoEcpRelayState, actor), NULL, LASSO_SOAP_ENV_PREFIX, LASSO_SOAP_ENV_HREF},
{NULL, 0, 0, NULL, NULL, NULL}
};
static LassoNodeClass *parent_class = NULL;
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
lasso_error_t rc = 0;
LassoEcpRelayState *relaystate = LASSO_ECP_RELAYSTATE(node);
lasso_check_good_rc(parent_class->init_from_xml(node, xmlnode));
lasso_check_good_rc(lasso_ecp_relay_state_validate(relaystate));
cleanup:
return rc;
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
class_init(LassoEcpRelayStateClass *klass)
{
LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
nclass->node_data = g_new0(LassoNodeClassData, 1);
nclass->init_from_xml = init_from_xml;
lasso_node_class_set_nodename(nclass, "RelayState");
lasso_node_class_set_ns(nclass, LASSO_ECP_HREF, LASSO_ECP_PREFIX);
lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
lasso_ecp_relay_state_get_type()
{
static GType ecp_relay_state_type = 0;
if (!ecp_relay_state_type) {
static const GTypeInfo relaystate_info = {
sizeof (LassoEcpRelayStateClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoEcpRelayState),
0,
NULL,
NULL
};
ecp_relay_state_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoEcpRelayState", &relaystate_info, 0);
}
return ecp_relay_state_type;
}
/**
* lasso_ecp_relay_state_new:
* @RelayState: (allow-none):
*
*
* The #LassoEcpRelayState object is initialized as follows:
* <literallayout>
* RelayState = @RelayState (if non-NULL)
* mustUnderstand = TRUE
* actor = #LASSO_SOAP_ENV_ACTOR
* </literallayout>
*
* Returns: a newly created and initialized #LassoEcpRelayState object
**/
LassoNode*
lasso_ecp_relay_state_new(const gchar *RelayState)
{
LassoEcpRelayState *relaystate;
relaystate = g_object_new(LASSO_TYPE_ECP_RELAYSTATE, NULL);
if (RelayState) {
relaystate->RelayState = g_strdup(RelayState);
}
relaystate->mustUnderstand = TRUE;
relaystate->actor = g_strdup(LASSO_SOAP_ENV_ACTOR);
return LASSO_NODE(relaystate);
}

View File

@ -0,0 +1,69 @@
/* $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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LASSO_ECP_RELAYSTATE_H__
#define __LASSO_ECP_RELAYSTATE_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "../xml.h"
#define LASSO_TYPE_ECP_RELAYSTATE (lasso_ecp_relay_state_get_type())
#define LASSO_ECP_RELAYSTATE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_ECP_RELAYSTATE, LassoEcpRelayState))
#define LASSO_ECP_RELAYSTATE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_ECP_RELAYSTATE, LassoEcpRelayStateClass))
#define LASSO_IS_ECP_RELAYSTATE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_ECP_RELAYSTATE))
#define LASSO_IS_ECP_RELAYSTATE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_ECP_RELAYSTATE))
#define LASSO_ECP_RELAYSTATE_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_ECP_RELAYSTATE, LassoEcpRelayStateClass))
typedef struct _LassoEcpRelayState LassoEcpRelayState;
typedef struct _LassoEcpRelayStateClass LassoEcpRelayStateClass;
struct _LassoEcpRelayState {
LassoNode parent;
gchar *RelayState;
gboolean mustUnderstand;
gchar *actor;
};
struct _LassoEcpRelayStateClass {
LassoNodeClass parent;
};
LASSO_EXPORT int lasso_ecp_relay_state_validate(LassoEcpRelayState *relaystate);
LASSO_EXPORT GType lasso_ecp_relay_state_get_type(void);
LASSO_EXPORT LassoNode* lasso_ecp_relay_state_new(const gchar *RelayState);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_ECP_RELAYSTATE_H__ */

219
lasso/xml/ecp/ecp_request.c Normal file
View File

@ -0,0 +1,219 @@
/* $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, see <http://www.gnu.org/licenses/>.
*/
#include "../private.h"
#include "ecp_request.h"
/**
* SECTION:ecp_request
* @short_description: &lt;ecp:Request&gt;
*
* <figure><title>Schema fragment for ecp:Request</title>
* <programlisting><![CDATA[
*
* <element name="Request" type="ecp:RequestType"/>
* <complexType name="RequestType">
* <sequence>
* <element ref="saml:Issuer"/>
* <element ref="samlp:IDPList" minOccurs="0"/>
* </sequence>
* <attribute ref="S:mustUnderstand" use="required"/>
* <attribute ref="S:actor" use="required"/>
* <attribute name="ProviderName" type="string" use="optional"/>
* <attribute name="IsPassive" type="boolean" use="optional"/>
* </complexType>
* ]]></programlisting>
* </figure>
*/
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
/**
* lasso_ecp_request_validate:
* @request: the #LassoEcpRequest object to validate
*
* Validates the #LassoEcpRequest object conforms to required values.
*
* <itemizedlist>
* <listitem>mustUnderstand must be TRUE</listitem>
* <listitem>actor must be equal to #LASSO_SOAP_ENV_ACTOR</listitem>
* </itemizedlist>
*
* Returns: 0 on success, error code otherwise
**/
int
lasso_ecp_request_validate(LassoEcpRequest *request)
{
g_return_val_if_fail(LASSO_IS_ECP_REQUEST(request),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
if (!request->mustUnderstand) {
error("%s.mustUnderstand must be True", G_OBJECT_CLASS_NAME(request));
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
if (request->actor == NULL) {
error("%s.actor missing", G_OBJECT_CLASS_NAME(request));
return LASSO_XML_ERROR_ATTR_NOT_FOUND;
}
if (lasso_strisnotequal(request->actor, LASSO_SOAP_ENV_ACTOR)) {
error("%s.actor invalid, must be \"%s\" not \"%s\"",
G_OBJECT_CLASS_NAME(request),
LASSO_SOAP_ENV_ACTOR, request->actor);
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
return 0;
}
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static struct XmlSnippet schema_snippets[] = {
{ "Issuer", SNIPPET_NODE,
G_STRUCT_OFFSET(LassoEcpRequest, Issuer),
"LassoSaml2NameID", LASSO_SAML2_ASSERTION_PREFIX, LASSO_SAML2_ASSERTION_HREF},
{ "IDPList", SNIPPET_NODE,
G_STRUCT_OFFSET(LassoEcpRequest, IDPList), NULL, LASSO_SAML2_PROTOCOL_PREFIX, LASSO_SAML2_PROTOCOL_HREF},
{ "mustUnderstand", SNIPPET_ATTRIBUTE | SNIPPET_BOOLEAN,
G_STRUCT_OFFSET(LassoEcpRequest, mustUnderstand), NULL, LASSO_SOAP_ENV_PREFIX, LASSO_SOAP_ENV_HREF},
{ "actor", SNIPPET_ATTRIBUTE,
G_STRUCT_OFFSET(LassoEcpRequest, actor), NULL, LASSO_SOAP_ENV_PREFIX, LASSO_SOAP_ENV_HREF},
{ "ProviderName", SNIPPET_ATTRIBUTE,
G_STRUCT_OFFSET(LassoEcpRequest, ProviderName), NULL, NULL, NULL},
{ "IsPassive", SNIPPET_ATTRIBUTE | SNIPPET_BOOLEAN,
G_STRUCT_OFFSET(LassoEcpRequest, IsPassive), NULL, NULL, NULL},
{NULL, 0, 0, NULL, NULL, NULL}
};
static LassoNodeClass *parent_class = NULL;
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
lasso_error_t rc = 0;
LassoEcpRequest *request = LASSO_ECP_REQUEST(node);
lasso_check_good_rc(parent_class->init_from_xml(node, xmlnode));
lasso_check_good_rc(lasso_ecp_request_validate(request));
cleanup:
return rc;
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
instance_init(LassoEcpRequest *node)
{
node->IsPassive = TRUE;
}
static void
class_init(LassoEcpRequestClass *klass)
{
LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
nclass->node_data = g_new0(LassoNodeClassData, 1);
nclass->init_from_xml = init_from_xml;
lasso_node_class_set_nodename(nclass, "Request");
lasso_node_class_set_ns(nclass, LASSO_ECP_HREF, LASSO_ECP_PREFIX);
lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
lasso_ecp_request_get_type()
{
static GType ecp_request_type = 0;
if (!ecp_request_type) {
static const GTypeInfo request_info = {
sizeof (LassoEcpRequestClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoEcpRequest),
0,
(GInstanceInitFunc) instance_init,
NULL
};
ecp_request_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoEcpRequest", &request_info, 0);
}
return ecp_request_type;
}
/**
* lasso_ecp_request_new:
* @Issuer:
* @IsPassive:
* @ProviderName:
* @IDPList: (allow-none):
*
* Creates and intializes new #LassoEcpRequest object.
*
* The #LassoEcpRequest object is initialized as follows:
* <literallayout>
* Issuer = @Issuer
* IsPassive = @IsPassive
* ProviderName = @ProviderName
* IDPList = @IDPList (if non-NULL)
* mustUnderstand = TRUE
* actor = #LASSO_SOAP_ENV_ACTOR
* </literallayout>
*
* Returns: a newly created and initialized #LassoEcpRequest object
**/
LassoNode*
lasso_ecp_request_new(const char *Issuer, gboolean IsPassive,
const gchar *ProviderName, LassoSamlp2IDPList *IDPList)
{
LassoEcpRequest *request;
request = g_object_new(LASSO_TYPE_ECP_REQUEST, NULL);
request->Issuer = LASSO_SAML2_NAME_ID(lasso_saml2_name_id_new_with_string((char*)Issuer));
request->IsPassive = IsPassive;
request->ProviderName = g_strdup(ProviderName);
if (IDPList) {
lasso_assign_gobject(request->IDPList, IDPList);
}
request->mustUnderstand = TRUE;
request->actor = g_strdup(LASSO_SOAP_ENV_ACTOR);
return LASSO_NODE(request);
}

View File

@ -0,0 +1,75 @@
/* $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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LASSO_ECP_REQUEST_H__
#define __LASSO_ECP_REQUEST_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "../xml.h"
#include "../saml-2.0/saml2_name_id.h"
#include "../saml-2.0/samlp2_idp_list.h"
#define LASSO_TYPE_ECP_REQUEST (lasso_ecp_request_get_type())
#define LASSO_ECP_REQUEST(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_ECP_REQUEST, LassoEcpRequest))
#define LASSO_ECP_REQUEST_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_ECP_REQUEST, LassoEcpRequestClass))
#define LASSO_IS_ECP_REQUEST(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_ECP_REQUEST))
#define LASSO_IS_ECP_REQUEST_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_ECP_REQUEST))
#define LASSO_ECP_REQUEST_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_ECP_REQUEST, LassoEcpRequestClass))
typedef struct _LassoEcpRequest LassoEcpRequest;
typedef struct _LassoEcpRequestClass LassoEcpRequestClass;
struct _LassoEcpRequest {
LassoNode parent;
LassoSaml2NameID *Issuer;
LassoSamlp2IDPList *IDPList;
gboolean mustUnderstand;
gchar *actor;
gchar *ProviderName;
gboolean IsPassive;
};
struct _LassoEcpRequestClass {
LassoNodeClass parent;
};
LASSO_EXPORT int lasso_ecp_request_validate(LassoEcpRequest *request);
LASSO_EXPORT GType lasso_ecp_request_get_type(void);
LASSO_EXPORT LassoNode* lasso_ecp_request_new(const gchar *Issuer, gboolean IsPassive,
const gchar *ProviderName, LassoSamlp2IDPList *IDPList);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_ECP_REQUEST_H__ */

View File

@ -0,0 +1,194 @@
/* $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, see <http://www.gnu.org/licenses/>.
*/
#include "../private.h"
#include "ecp_response.h"
/**
* SECTION:ecp_response
* @short_description: &lt;ecp:Response&gt;
*
* <figure><title>Schema fragment for ecp:Response</title>
* <programlisting><![CDATA[
*
* <element name="Response" type="ecp:ResponseType"/>
* <complexType name="ResponseType">
* <attribute ref="S:mustUnderstand" use="required"/>
* <attribute ref="S:actor" use="required"/>
* <attribute name="AssertionConsumerServiceURL" type="anyURI" use="required"/>
* </complexType>
* ]]></programlisting>
* </figure>
*/
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
/**
* lasso_ecp_response_validate:
* @response: The #LassoEcpResponse object to validate
*
* Validates the #LassoEcpResponse object conforms to required values.
*
* <itemizedlist>
* <listitem>AssertionConsumerServiceURL must be non-NULL</listitem>
* <listitem>mustUnderstand must be TRUE</listitem>
* <listitem>actor must be equal to #LASSO_SOAP_ENV_ACTOR</listitem>
* </itemizedlist>
*
* Returns: 0 on success, error code otherwise
**/
int
lasso_ecp_response_validate(LassoEcpResponse *response)
{
g_return_val_if_fail(LASSO_IS_ECP_RESPONSE(response),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
if (response->AssertionConsumerServiceURL == NULL) {
error("%s.AssertionConsumerServiceURL missing", G_OBJECT_CLASS_NAME(response));
return LASSO_XML_ERROR_ATTR_NOT_FOUND;
}
if (!response->mustUnderstand) {
error("%s.mustUnderstand must be True", G_OBJECT_CLASS_NAME(response));
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
if (response->actor == NULL) {
error("%s.actor missing", G_OBJECT_CLASS_NAME(response));
return LASSO_XML_ERROR_ATTR_NOT_FOUND;
}
if (lasso_strisnotequal(response->actor, LASSO_SOAP_ENV_ACTOR)) {
error("%s.actor invalid, must be \"%s\" not \"%s\"",
G_OBJECT_CLASS_NAME(response), LASSO_SOAP_ENV_ACTOR, response->actor);
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
return 0;
}
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static struct XmlSnippet schema_snippets[] = {
{ "AssertionConsumerServiceURL", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoEcpResponse, AssertionConsumerServiceURL), NULL, NULL, NULL},
{ "mustUnderstand", SNIPPET_ATTRIBUTE | SNIPPET_BOOLEAN,
G_STRUCT_OFFSET(LassoEcpResponse, mustUnderstand), NULL, LASSO_SOAP_ENV_PREFIX, LASSO_SOAP_ENV_HREF},
{ "actor", SNIPPET_ATTRIBUTE,
G_STRUCT_OFFSET(LassoEcpResponse, actor), NULL, LASSO_SOAP_ENV_PREFIX, LASSO_SOAP_ENV_HREF},
{NULL, 0, 0, NULL, NULL, NULL}
};
static LassoNodeClass *parent_class = NULL;
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
lasso_error_t rc = 0;
LassoEcpResponse *response = LASSO_ECP_RESPONSE(node);
lasso_check_good_rc(parent_class->init_from_xml(node, xmlnode));
lasso_check_good_rc(lasso_ecp_response_validate(response));
cleanup:
return rc;
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
class_init(LassoEcpResponseClass *klass)
{
LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
nclass->node_data = g_new0(LassoNodeClassData, 1);
nclass->init_from_xml = init_from_xml;
lasso_node_class_set_nodename(nclass, "Response");
lasso_node_class_set_ns(nclass, LASSO_ECP_HREF, LASSO_ECP_PREFIX);
lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
lasso_ecp_response_get_type()
{
static GType ecp_response_type = 0;
if (!ecp_response_type) {
static const GTypeInfo response_info = {
sizeof (LassoEcpResponseClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoEcpResponse),
0,
NULL,
NULL
};
ecp_response_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoEcpResponse", &response_info, 0);
}
return ecp_response_type;
}
/**
* lasso_ecp_response_new:
* @AssertionConsumerServiceURL: (allow-none):
*
* Creates and initializes a new #LassoEcpResponse object.
*
* The # object is initialized as follows:
* <literallayout>
* AssertionConsumerServiceURL = @AssertionConsumerServiceURL
* mustUnderstand = TRUE
* actor = #LASSO_SOAP_ENV_ACTOR
* </literallayout>
*
* Returns: a newly created and initialized #LassoEcpResponse object
**/
LassoNode*
lasso_ecp_response_new(const gchar *AssertionConsumerServiceURL)
{
LassoEcpResponse *response;
response = g_object_new(LASSO_TYPE_ECP_RESPONSE, NULL);
if (AssertionConsumerServiceURL) {
response->AssertionConsumerServiceURL = g_strdup(AssertionConsumerServiceURL);
}
response->mustUnderstand = TRUE;
response->actor = g_strdup(LASSO_SOAP_ENV_ACTOR);
return LASSO_NODE(response);
}

View File

@ -0,0 +1,69 @@
/* $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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LASSO_ECP_RESPONSE_H__
#define __LASSO_ECP_RESPONSE_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "../xml.h"
#define LASSO_TYPE_ECP_RESPONSE (lasso_ecp_response_get_type())
#define LASSO_ECP_RESPONSE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_ECP_RESPONSE, LassoEcpResponse))
#define LASSO_ECP_RESPONSE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_ECP_RESPONSE, LassoEcpResponseClass))
#define LASSO_IS_ECP_RESPONSE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_ECP_RESPONSE))
#define LASSO_IS_ECP_RESPONSE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_ECP_RESPONSE))
#define LASSO_ECP_RESPONSE_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_ECP_RESPONSE, LassoEcpResponseClass))
typedef struct _LassoEcpResponse LassoEcpResponse;
typedef struct _LassoEcpResponseClass LassoEcpResponseClass;
struct _LassoEcpResponse {
LassoNode parent;
gboolean mustUnderstand;
gchar *actor;
gchar *AssertionConsumerServiceURL;
};
struct _LassoEcpResponseClass {
LassoNodeClass parent;
};
LASSO_EXPORT int lasso_ecp_response_validate(LassoEcpResponse *response);
LASSO_EXPORT GType lasso_ecp_response_get_type(void);
LASSO_EXPORT LassoNode* lasso_ecp_response_new(const gchar *AssertionConsumerServiceURL);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_ECP_RESPONSE_H__ */

221
lasso/xml/paos_request.c Normal file
View File

@ -0,0 +1,221 @@
/* $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, see <http://www.gnu.org/licenses/>.
*/
#include "private.h"
#include "paos_request.h"
#include <libxml/tree.h>
/**
* SECTION:paos_request
* @short_description: &lt;paos:Request&gt;
*
* <figure><title>Schema fragment for paos:Request</title>
* <programlisting><![CDATA[
*
* <xs:element name="Request" type="RequestType"/>
* <xs:complexType name="RequestType">
* <xs:attribute name="responseConsumerURL" type="xs:anyURI" use="required"/>
* <xs:attribute name="service" type="xs:anyURI" use="required"/>
* <xs:attribute name="messageID" type="IDType" use="optional"/>
* <xs:attribute ref="S:mustUnderstand" use="required"/>
* <xs:attribute ref="S:actor" use="required"/>
* </xs:complexType>
* ]]></programlisting>
* </figure>
*/
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
/**
* lasso_paos_request_validate:
* @request: The #LassoPaosRequest object to validate
*
* Validates the object conforms to required values.
*
* <itemizedlist>
* <listitem>responseConsumerURL must be non-NULL</listitem>
* <listitem>mustUnderstand must be TRUE</listitem>
* <listitem>actor must be equal to #LASSO_SOAP_ENV_ACTOR</listitem>
* <listitem>service must be equal to #LASSO_ECP_HREF</listitem>
* </itemizedlist>
*
* Returns: 0 on success, error code otherwise
**/
int
lasso_paos_request_validate(LassoPaosRequest *request)
{
g_return_val_if_fail(LASSO_IS_PAOS_REQUEST(request),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
if (request->responseConsumerURL == NULL) {
error("%s.responseConsumerURL missing", G_OBJECT_CLASS_NAME(request));
return LASSO_XML_ERROR_ATTR_NOT_FOUND;
}
if (request->service == NULL) {
error("%s.service missing", G_OBJECT_CLASS_NAME(request));
return LASSO_XML_ERROR_ATTR_NOT_FOUND;
}
if (lasso_strisnotequal(request->service, LASSO_ECP_HREF)) {
error("%s.service invalid, must be \"%s\" not \"%s\"",
G_OBJECT_CLASS_NAME(request), LASSO_ECP_HREF, request->service);
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
if (!request->mustUnderstand) {
error("%s.mustUnderstand must be True", G_OBJECT_CLASS_NAME(request));
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
if (request->actor == NULL) {
error("%s.actor missing", G_OBJECT_CLASS_NAME(request));
return LASSO_XML_ERROR_ATTR_NOT_FOUND;
}
if (lasso_strisnotequal(request->actor, LASSO_SOAP_ENV_ACTOR)) {
error("%s.actor invalid, must be \"%s\" not \"%s\"",
G_OBJECT_CLASS_NAME(request), LASSO_SOAP_ENV_ACTOR, request->actor);
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
return 0;
}
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static struct XmlSnippet schema_snippets[] = {
{ "responseConsumerURL", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoPaosRequest, responseConsumerURL), NULL, NULL, NULL},
{ "service", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoPaosRequest, service), NULL, NULL, NULL},
{ "messageID", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoPaosRequest, messageID), NULL, NULL, NULL},
{ "mustUnderstand", SNIPPET_ATTRIBUTE | SNIPPET_BOOLEAN,
G_STRUCT_OFFSET(LassoPaosRequest, mustUnderstand), NULL, LASSO_SOAP_ENV_PREFIX, LASSO_SOAP_ENV_HREF},
{ "actor", SNIPPET_ATTRIBUTE,
G_STRUCT_OFFSET(LassoPaosRequest, actor), NULL, LASSO_SOAP_ENV_PREFIX, LASSO_SOAP_ENV_HREF},
{NULL, 0, 0, NULL, NULL, NULL}
};
static LassoNodeClass *parent_class = NULL;
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
lasso_error_t rc = 0;
LassoPaosRequest *request = LASSO_PAOS_REQUEST(node);
lasso_check_good_rc(parent_class->init_from_xml(node, xmlnode));
lasso_check_good_rc(lasso_paos_request_validate(request));
cleanup:
return rc;
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
class_init(LassoPaosRequestClass *klass)
{
LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
nclass->node_data = g_new0(LassoNodeClassData, 1);
nclass->init_from_xml = init_from_xml;
lasso_node_class_set_nodename(nclass, "Request");
lasso_node_class_set_ns(nclass, LASSO_PAOS_HREF, LASSO_PAOS_PREFIX);
lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
lasso_paos_request_get_type()
{
static GType paos_request_type = 0;
if (!paos_request_type) {
static const GTypeInfo request_info = {
sizeof (LassoPaosRequestClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoPaosRequest),
0,
NULL,
NULL
};
paos_request_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoPaosRequest", &request_info, 0);
}
return paos_request_type;
}
/**
* lasso_paos_request_new:
* @responseConsumerURL: (allow-none):
* @messageID: (allow-none):
*
* The #LassoPaosRequest object is initialized as follows:
* <literallayout>
* responseConsumerURL = @responseConsumerURL (if non-NULL)
* messageID = @messageID (if non-NULL) otherwise generated unique id
* mustUnderstand = TRUE
* actor = #LASSO_SOAP_ENV_ACTOR
* service = #LASSO_ECP_HREF
* </literallayout>
*
* Returns: newly created & initialized #LassoPaosRequest object
**/
LassoNode*
lasso_paos_request_new(const gchar *responseConsumerURL, const gchar *messageID)
{
LassoPaosRequest *request;
request = g_object_new(LASSO_TYPE_PAOS_REQUEST, NULL);
if (responseConsumerURL) {
request->responseConsumerURL = g_strdup(responseConsumerURL);
}
if (messageID) {
request->messageID = g_strdup(messageID);
} else {
request->messageID = lasso_build_unique_id(32);
}
request->mustUnderstand = TRUE;
request->actor = g_strdup(LASSO_SOAP_ENV_ACTOR);
request->service = g_strdup(LASSO_ECP_HREF);
return LASSO_NODE(request);
}

69
lasso/xml/paos_request.h Normal file
View File

@ -0,0 +1,69 @@
/* $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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LASSO_PAOS_REQUEST_H__
#define __LASSO_PAOS_REQUEST_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define LASSO_TYPE_PAOS_REQUEST (lasso_paos_request_get_type())
#define LASSO_PAOS_REQUEST(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_PAOS_REQUEST, LassoPaosRequest))
#define LASSO_PAOS_REQUEST_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_PAOS_REQUEST, LassoPaosRequestClass))
#define LASSO_IS_PAOS_REQUEST(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_PAOS_REQUEST))
#define LASSO_IS_PAOS_REQUEST_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_PAOS_REQUEST))
#define LASSO_PAOS_REQUEST_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_PAOS_REQUEST, LassoPaosRequestClass))
typedef struct _LassoPaosRequest LassoPaosRequest;
typedef struct _LassoPaosRequestClass LassoPaosRequestClass;
struct _LassoPaosRequest {
LassoNode parent;
gchar *responseConsumerURL;
gchar *messageID;
gchar *service;
gboolean mustUnderstand;
gchar *actor;
};
struct _LassoPaosRequestClass {
LassoNodeClass parent;
};
LASSO_EXPORT int lasso_paos_request_validate(LassoPaosRequest *node);
LASSO_EXPORT GType lasso_paos_request_get_type(void);
LASSO_EXPORT LassoNode* lasso_paos_request_new(const gchar *responseConsumerURL, const gchar *messageID);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_PAOS_REQUEST_H__ */

190
lasso/xml/paos_response.c Normal file
View File

@ -0,0 +1,190 @@
/* $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, see <http://www.gnu.org/licenses/>.
*/
#include "private.h"
#include "paos_response.h"
#include <libxml/tree.h>
/**
* SECTION:paos_response
* @short_description: &lt;paos:Response&gt;
*
* <figure><title>Schema fragment for paos:Response</title>
* <programlisting><![CDATA[
*
* <xs:element name="Response" type="ResponseType"/>
* <xs:complexType name="ResponseType">
* <xs:attribute name="refToMessageID" type="IDType" use="optional"/>
* <xs:attribute ref="S:mustUnderstand" use="required"/>
* <xs:attribute ref="S:actor" use="required"/>
* </xs:complexType>
* ]]></programlisting>
* </figure>
*/
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
/**
* lasso_paos_response_validate:
* @response: The #LassoPaosResponse object to validate
*
* Validates the object conforms to required values.
*
* <itemizedlist>
* <listitem>mustUnderstand must be TRUE</listitem>
* <listitem>actor must be equal to #LASSO_SOAP_ENV_ACTOR</listitem>
* </itemizedlist>
*
* Returns: 0 on success, error code otherwise
**/
int
lasso_paos_response_validate(LassoPaosResponse *response)
{
g_return_val_if_fail(LASSO_IS_PAOS_RESPONSE(response),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
if (!response->mustUnderstand) {
error("%s.mustUnderstand must be True", G_OBJECT_CLASS_NAME(response));
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
if (response->actor == NULL) {
error("%s.actor missing", G_OBJECT_CLASS_NAME(response));
return LASSO_XML_ERROR_ATTR_NOT_FOUND;
}
if (lasso_strisnotequal(response->actor, LASSO_SOAP_ENV_ACTOR)) {
error("%s.actor invalid, must be \"%s\" not \"%s\"",
G_OBJECT_CLASS_NAME(response),
LASSO_SOAP_ENV_ACTOR, response->actor);
return LASSO_XML_ERROR_ATTR_VALUE_INVALID;
}
return 0;
}
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static struct XmlSnippet schema_snippets[] = {
{ "refToMessageID", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoPaosResponse, refToMessageID), NULL, NULL, NULL},
{ "mustUnderstand", SNIPPET_ATTRIBUTE | SNIPPET_BOOLEAN,
G_STRUCT_OFFSET(LassoPaosResponse, mustUnderstand), NULL, LASSO_SOAP_ENV_PREFIX, LASSO_SOAP_ENV_HREF},
{ "actor", SNIPPET_ATTRIBUTE,
G_STRUCT_OFFSET(LassoPaosResponse, actor), NULL, LASSO_SOAP_ENV_PREFIX, LASSO_SOAP_ENV_HREF},
{NULL, 0, 0, NULL, NULL, NULL}
};
static LassoNodeClass *parent_class = NULL;
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
lasso_error_t rc = 0;
LassoPaosResponse *response = LASSO_PAOS_RESPONSE(node);
lasso_check_good_rc(parent_class->init_from_xml(node, xmlnode));
lasso_check_good_rc(lasso_paos_response_validate(response));
cleanup:
return rc;
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
class_init(LassoPaosResponseClass *klass)
{
LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
nclass->node_data = g_new0(LassoNodeClassData, 1);
nclass->init_from_xml = init_from_xml;
lasso_node_class_set_nodename(nclass, "Response");
lasso_node_class_set_ns(nclass, LASSO_PAOS_HREF, LASSO_PAOS_PREFIX);
lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
lasso_paos_response_get_type()
{
static GType paos_response_type = 0;
if (!paos_response_type) {
static const GTypeInfo response_info = {
sizeof (LassoPaosResponseClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoPaosResponse),
0,
NULL,
NULL
};
paos_response_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoPaosResponse", &response_info, 0);
}
return paos_response_type;
}
/**
* lasso_paos_response_new:
* @refToMessageID: (allow-none):
*
* The #LassoPaosResponse object is initialized as follows:
* <literallayout>
* refToMessageID = @refToMessageID (if non-NULL)
* mustUnderstand = TRUE
* actor = #LASSO_SOAP_ENV_ACTOR
* </literallayout>
*
* Return value: a newly created and initialized #LassoPaosResponse object
**/
LassoNode*
lasso_paos_response_new(const char *refToMessageID)
{
LassoPaosResponse *response;
response = g_object_new(LASSO_TYPE_PAOS_RESPONSE, NULL);
if (refToMessageID) {
response->refToMessageID = g_strdup(refToMessageID);
}
response->mustUnderstand = TRUE;
response->actor = g_strdup(LASSO_SOAP_ENV_ACTOR);
return LASSO_NODE(response);
}

67
lasso/xml/paos_response.h Normal file
View File

@ -0,0 +1,67 @@
/* $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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LASSO_PAOS_RESPONSE_H__
#define __LASSO_PAOS_RESPONSE_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define LASSO_TYPE_PAOS_RESPONSE (lasso_paos_response_get_type())
#define LASSO_PAOS_RESPONSE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_PAOS_RESPONSE, LassoPaosResponse))
#define LASSO_PAOS_RESPONSE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_PAOS_RESPONSE, LassoPaosResponseClass))
#define LASSO_IS_PAOS_RESPONSE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_PAOS_RESPONSE))
#define LASSO_IS_PAOS_RESPONSE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_PAOS_RESPONSE))
#define LASSO_PAOS_RESPONSE_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_PAOS_RESPONSE, LassoPaosResponseClass))
typedef struct _LassoPaosResponse LassoPaosResponse;
typedef struct _LassoPaosResponseClass LassoPaosResponseClass;
struct _LassoPaosResponse {
LassoNode parent;
gchar *refToMessageID;
gboolean mustUnderstand;
gchar *actor;
};
struct _LassoPaosResponseClass {
LassoNodeClass parent;
};
LASSO_EXPORT int lasso_paos_response_validate(LassoPaosResponse *node);
LASSO_EXPORT GType lasso_paos_response_get_type(void);
LASSO_EXPORT LassoNode* lasso_paos_response_new(const gchar *refToMessageID);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_PAOS_RESPONSE_H__ */

View File

@ -941,13 +941,13 @@
/**
* LASSO_PAOS_PREFIX:
*
* Preferred prefix for namespace of FIXME
* URN binding name for PAOS
*
*/
#define LASSO_PAOS_PREFIX "paos"
/*****************************************************************************/
/* ECP BINDING */
/* ECP PROFILE */
/*****************************************************************************/
/**
@ -960,7 +960,7 @@
/**
* LASSO_ECP_PREFIX:
*
* Preferred prefix for namespace of FIXME
* SAML 2 URN profile name for Enhanced Client & Proxy (ECP)
*
*/
#define LASSO_ECP_PREFIX "ecp"
@ -986,4 +986,3 @@
#define LASSO_XSI_PREFIX "xsi"
#endif /* __LASSO_STRINGS_H__ */