diff options
| author | Nicolas Clapies <nclapies@entrouvert.com> | 2005-03-02 17:10:22 +0000 |
|---|---|---|
| committer | Nicolas Clapies <nclapies@entrouvert.com> | 2005-03-02 17:10:22 +0000 |
| commit | 5cfcd1f9058c29d4e14c40499fb159f1fca6b553 (patch) | |
| tree | 715a3dce1e0a0db7aad4c93fc8d130f031a33181 | |
| parent | a2ba7e940e7ce9538ebb083136c06dcc2b52ab65 (diff) | |
| download | lasso-5cfcd1f9058c29d4e14c40499fb159f1fca6b553.tar.gz lasso-5cfcd1f9058c29d4e14c40499fb159f1fca6b553.tar.xz lasso-5cfcd1f9058c29d4e14c40499fb159f1fca6b553.zip | |
Added credentials and resource offerings if authentication is OK.
| -rw-r--r-- | lasso/xml/Makefile.am | 2 | ||||
| -rw-r--r-- | lasso/xml/sa_credentials.c | 128 | ||||
| -rw-r--r-- | lasso/xml/sa_credentials.h | 73 | ||||
| -rw-r--r-- | lasso/xml/sa_sasl_response.c | 33 | ||||
| -rw-r--r-- | lasso/xml/sa_sasl_response.h | 11 | ||||
| -rw-r--r-- | swig/Lasso-wsf.i | 92 | ||||
| -rw-r--r-- | swig/inheritance.h | 1 |
7 files changed, 334 insertions, 6 deletions
diff --git a/lasso/xml/Makefile.am b/lasso/xml/Makefile.am index 35faf6de..e1a79a47 100644 --- a/lasso/xml/Makefile.am +++ b/lasso/xml/Makefile.am @@ -66,6 +66,7 @@ liblasso_xml_la_SOURCES = \ lib_scoping.c \ lib_status_response.c \ lib_subject.c \ + sa_credentials.c \ sa_parameter.c \ sa_password_transforms.c \ sa_transform.c \ @@ -159,6 +160,7 @@ liblassoinclude_HEADERS = \ lib_scoping.h \ lib_status_response.h \ lib_subject.h \ + sa_credentials.h \ sa_parameter.h \ sa_password_transforms.h \ sa_transform.h \ diff --git a/lasso/xml/sa_credentials.c b/lasso/xml/sa_credentials.c new file mode 100644 index 00000000..2b8475b0 --- /dev/null +++ b/lasso/xml/sa_credentials.c @@ -0,0 +1,128 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004, 2005 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 <lasso/xml/sa_credentials.h> + +/* + * Schema fragments (liberty-idwsf-authn-svc-v1.0.xsd): + * + * <xs:element name="Credentials" minOccurs="0"> + * <xs:complexType> + * <xs:sequence> + * <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + * </xs:sequence> + * </xs:complexType> + * </xs:element> + */ + +/*****************************************************************************/ +/* private methods */ +/*****************************************************************************/ + +static struct XmlSnippet schema_snippets[] = { + { "", SNIPPET_LIST_NODES, G_STRUCT_OFFSET(LassoSaCredentials, any) }, + { NULL, 0, 0} +}; + +/*****************************************************************************/ +/* instance and class init functions */ +/*****************************************************************************/ + +static void +instance_init(LassoSaCredentials *node) +{ + node->any = NULL; +} + +static void +class_init(LassoSaCredentialsClass *klass) +{ + LassoNodeClass *nclass = LASSO_NODE_CLASS(klass); + + nclass->node_data = g_new0(LassoNodeClassData, 1); + lasso_node_class_set_nodename(nclass, "Credentials"); + lasso_node_class_add_snippets(nclass, schema_snippets); +} + +GType +lasso_sa_credentials_get_type() +{ + static GType this_type = 0; + + if (!this_type) { + static const GTypeInfo this_info = { + sizeof (LassoSaCredentialsClass), + NULL, + NULL, + (GClassInitFunc) class_init, + NULL, + NULL, + sizeof(LassoSaCredentials), + 0, + (GInstanceInitFunc) instance_init, + }; + + this_type = g_type_register_static(LASSO_TYPE_NODE, + "LassoSaCredentials", &this_info, 0); + } + return this_type; +} + +LassoSaCredentials* +lasso_sa_credentials_new() +{ + LassoSaCredentials *node; + + node = g_object_new(LASSO_TYPE_SA_CREDENTIALS, NULL); + + return node; +} + +LassoSaCredentials* +lasso_sa_credentials_new_from_message(const gchar *message) +{ + LassoSaCredentials *node; + + g_return_val_if_fail(message != NULL, NULL); + + node = g_object_new(LASSO_TYPE_SA_CREDENTIALS, NULL); + lasso_node_init_from_message(LASSO_NODE(node), message); + + return node; +} + +gint +lasso_sa_credentials_add_assertion(LassoSaCredentials *credentials, + LassoSamlAssertion *assertion) +{ + g_return_val_if_fail(LASSO_IS_SA_CREDENTIALS(credentials), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(LASSO_IS_SAML_ASSERTION(assertion), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + + g_object_ref(assertion); + credentials->any = g_list_append(credentials->any, assertion); + + return 0; +} diff --git a/lasso/xml/sa_credentials.h b/lasso/xml/sa_credentials.h new file mode 100644 index 00000000..6444b4c1 --- /dev/null +++ b/lasso/xml/sa_credentials.h @@ -0,0 +1,73 @@ +/* $Id$$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004, 2005 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_SA_CREDENTIALS_H__ +#define __LASSO_SA_CREDENTIALS_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <lasso/xml/xml.h> +#include <lasso/xml/saml_assertion.h> + +#define LASSO_TYPE_SA_CREDENTIALS (lasso_sa_credentials_get_type()) +#define LASSO_SA_CREDENTIALS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + LASSO_TYPE_SA_CREDENTIALS, LassoSaCredentials)) +#define LASSO_SA_CREDENTIALS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \ + LASSO_TYPE_SA_CREDENTIALS, LassoSaCredentialsClass)) +#define LASSO_IS_SA_CREDENTIALS(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_SA_CREDENTIALS)) +#define LASSO_IS_SA_CREDENTIALS_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass),LASSO_TYPE_SA_CREDENTIALS)) +#define LASSO_SA_CREDENTIALS_GET_CLASS(o) \ + (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_SA_CREDENTIALS, LassoSaCredentialsClass)) + +typedef struct _LassoSaCredentials LassoSaCredentials; +typedef struct _LassoSaCredentialsClass LassoSaCredentialsClass; + +struct _LassoSaCredentials { + LassoNode parent; + + GList *any; +}; + +struct _LassoSaCredentialsClass { + LassoNodeClass parent; +}; + +LASSO_EXPORT GType lasso_sa_credentials_get_type(void); + +LASSO_EXPORT LassoSaCredentials* lasso_sa_credentials_new(); + +LASSO_EXPORT LassoSaCredentials* lasso_sa_credentials_new_from_message(const gchar *message); + +LASSO_EXPORT gint lasso_sa_credentials_add_assertion(LassoSaCredentials *credentials, + LassoSamlAssertion *assertion); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LASSO_SA_CREDENTIALS_H__ */ diff --git a/lasso/xml/sa_sasl_response.c b/lasso/xml/sa_sasl_response.c index 9e0fb4a4..30c88795 100644 --- a/lasso/xml/sa_sasl_response.c +++ b/lasso/xml/sa_sasl_response.c @@ -67,7 +67,7 @@ static struct XmlSnippet schema_snippets[] = { G_STRUCT_OFFSET(LassoSaSASLResponse, Data) }, { "ResourceOffering", SNIPPET_LIST_NODES, G_STRUCT_OFFSET(LassoSaSASLResponse, ResourceOffering) }, - /* TODO : Credentials */ + { "Credentials", SNIPPET_LIST_NODES, G_STRUCT_OFFSET(LassoSaSASLResponse, Credentials) }, { "serverMechanism", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoSaSASLResponse, serverMechanism) }, { "id", SNIPPET_ATTRIBUTE, @@ -163,6 +163,7 @@ lasso_sa_sasl_response_new(LassoUtilityStatus *status) node = g_object_new(LASSO_TYPE_SA_SASL_RESPONSE, NULL); + g_object_ref(status); node->Status = status; return node; @@ -180,3 +181,33 @@ lasso_sa_sasl_response_new_from_message(const gchar *message) return node; } + +gint +lasso_sa_sasl_response_add_credentials(LassoSaSASLResponse *response, + LassoSaCredentials *credentials) +{ + g_return_val_if_fail(LASSO_IS_SA_SASL_RESPONSE(response), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(LASSO_IS_SA_CREDENTIALS(credentials), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + + g_object_ref(credentials); + response->Credentials = g_list_append(response->Credentials, credentials); + + return 0; +} + +gint +lasso_sa_sasl_response_add_resource_offering(LassoSaSASLResponse *response, + LassoDiscoResourceOffering *resourceOffering) +{ + g_return_val_if_fail(LASSO_IS_SA_SASL_RESPONSE(response), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(LASSO_IS_DISCO_RESOURCE_OFFERING(resourceOffering), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + + g_object_ref(resourceOffering); + response->ResourceOffering = g_list_append(response->ResourceOffering, resourceOffering); + + return 0; +} diff --git a/lasso/xml/sa_sasl_response.h b/lasso/xml/sa_sasl_response.h index 21129c04..978bb5b2 100644 --- a/lasso/xml/sa_sasl_response.h +++ b/lasso/xml/sa_sasl_response.h @@ -29,7 +29,9 @@ extern "C" { #endif /* __cplusplus */ +#include <lasso/xml/disco_resource_offering.h> #include <lasso/xml/utility_status.h> +#include <lasso/xml/sa_credentials.h> #include <lasso/xml/sa_password_transforms.h> #include <lasso/xml/xml.h> @@ -43,7 +45,7 @@ extern "C" { #define LASSO_IS_SA_SASL_RESPONSE_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_SA_SASL_RESPONSE)) #define LASSO_SA_SASL_RESPONSE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \ - LASSO_TYPE_SA_SASL_RESPONSE, LassoSaSASLResponseClass)) + LASSO_TYPE_SA_SASL_RESPONSE, LassoSaSASLResponseClass)) typedef struct _LassoSaSASLResponse LassoSaSASLResponse; typedef struct _LassoSaSASLResponseClass LassoSaSASLResponseClass; @@ -73,6 +75,13 @@ LASSO_EXPORT LassoSaSASLResponse* lasso_sa_sasl_response_new(LassoUtilityStatus LASSO_EXPORT LassoSaSASLResponse* lasso_sa_sasl_response_new_from_message(const gchar *message); +LASSO_EXPORT gint lasso_sa_sasl_response_add_credentials(LassoSaSASLResponse *response, + LassoSaCredentials *credentials); + +LASSO_EXPORT gint lasso_sa_sasl_response_add_resource_offering( + LassoSaSASLResponse *response, + LassoDiscoResourceOffering *resourceOffering); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/swig/Lasso-wsf.i b/swig/Lasso-wsf.i index 8f429dc5..74ba18c8 100644 --- a/swig/Lasso-wsf.i +++ b/swig/Lasso-wsf.i @@ -46,6 +46,7 @@ #include <lasso/xml/is_select.h> #include <lasso/xml/is_text.h> #include <lasso/xml/is_user_interaction.h> +#include <lasso/xml/sa_credentials.h> #include <lasso/xml/sa_sasl_request.h> #include <lasso/xml/sa_sasl_response.h> #include <lasso/xml/soap_body.h> @@ -2433,9 +2434,65 @@ typedef struct { ***********************************************************************/ /*********************************************************************** - * sa:SaSASLRequest + * sa:SaCredentials ***********************************************************************/ +#ifndef SWIGPHP4 +%rename(SaCredentials) LassoSaCredentials; +#endif +typedef struct { + /* Attributes */ + +} LassoSaCredentials; +%extend LassoSaCredentials { + /* Attributes */ +#ifndef SWIGPHP4 + %rename(any) any; +#endif + %newobject any_get; + LassoNodeList *any; + + /* Constructor, Destructor & Static Methods */ + + LassoSaCredentials(); + + ~LassoSaCredentials(); + + int addAssertion(LassoSamlAssertion *assertion); + + /* Methods inherited from LassoNode */ + + %newobject dump; + char *dump(); +} + +%{ + +/* Attributes Implementations */ +/* any */ +#define LassoSaCredentials_get_any(self) get_node_list((self)->any) +#define LassoSaCredentials_any_get(self) get_node_list((self)->any) +#define LassoSaCredentials_set_any(self, value) set_node_list(&(self)->any, (value)) +#define LassoSaCredentials_any_set(self, value) set_node_list(&(self)->any, (value)) + +/* Constructors, destructors & static methods implementations */ + +#define new_LassoSaCredentials lasso_sa_credentials_new +#define delete_LassoSaCredentials(self) lasso_node_destroy(LASSO_NODE(self)) + +/* Implementations of methods inherited from LassoNode */ + +#define LassoSaCredentials_dump(self) lasso_node_dump(LASSO_NODE(self)) + +/* Implementation of methods */ +#define LassoSaCredentials_addAssertion lasso_sa_credentials_add_assertion + +%} + + +/*********************************************************************** + * sa:SaSASLRequest + ***********************************************************************/ #ifndef SWIGPHP4 %rename(SaSASLRequest) LassoSaSASLRequest; @@ -2529,10 +2586,10 @@ typedef struct { LassoNodeList *Data; #ifndef SWIGPHP4 - %rename(passwordTransforms) PasswordTransforms; + %rename(credentials) Credentials; #endif - %newobject PasswordTransforms_get; - LassoNodeList *PasswordTransforms; + %newobject Credentials_get; + LassoNodeList *Credentials; #ifndef SWIGPHP4 %rename(resourceOffering) ResourceOffering; @@ -2541,6 +2598,12 @@ typedef struct { LassoNodeList *ResourceOffering; #ifndef SWIGPHP4 + %rename(passwordTransforms) PasswordTransforms; +#endif + %newobject PasswordTransforms_get; + LassoNodeList *PasswordTransforms; + +#ifndef SWIGPHP4 %rename(status) Status; #endif %newobject Status_get; @@ -2552,10 +2615,15 @@ typedef struct { ~LassoSaSASLResponse(); + int addCredentials(LassoSaCredentials *credentials); + + int addResourceOffering(LassoDiscoResourceOffering *resourceOffering); + /* Methods inherited from LassoNode */ %newobject dump; char *dump(); + } %{ @@ -2567,6 +2635,18 @@ typedef struct { #define LassoSaSASLResponse_set_Data(self, value) set_node_list(&(self)->Data, (value)) #define LassoSaSASLResponse_Data_set(self, value) set_node_list(&(self)->Data, (value)) +/* Credentials */ +#define LassoSaSASLResponse_get_Credentials(self) get_node_list((self)->Credentials) +#define LassoSaSASLResponse_Credentials_get(self) get_node_list((self)->Credentials) +#define LassoSaSASLResponse_set_Credentials(self, value) set_node_list(&(self)->Credentials, (value)) +#define LassoSaSASLResponse_Credentials_set(self, value) set_node_list(&(self)->Credentials, (value)) + +/* ResourceOffering */ +#define LassoSaSASLResponse_get_ResourceOffering(self) get_node_list((self)->ResourceOffering) +#define LassoSaSASLResponse_ResourceOffering_get(self) get_node_list((self)->ResourceOffering) +#define LassoSaSASLResponse_set_ResourceOffering(self, value) set_node_list(&(self)->ResourceOffering, (value)) +#define LassoSaSASLResponse_ResourceOffering_set(self, value) set_node_list(&(self)->ResourceOffering, (value)) + /* PasswordTransforms */ #define LassoSaSASLResponse_get_PasswordTransforms(self) get_node_list((self)->PasswordTransforms) #define LassoSaSASLResponse_PasswordTransforms_get(self) get_node_list((self)->PasswordTransforms) @@ -2594,6 +2674,10 @@ typedef struct { #define LassoSaSASLResponse_dump(self) lasso_node_dump(LASSO_NODE(self)) +/* Implementations of methods */ +#define LassoSaSASLResponse_addCredentials lasso_sa_sasl_response_add_credentials +#define LassoSaSASLResponse_addResourceOffering lasso_sa_sasl_response_add_resource_offering + %} /*********************************************************************** diff --git a/swig/inheritance.h b/swig/inheritance.h index 6ac71ec1..e70a13c5 100644 --- a/swig/inheritance.h +++ b/swig/inheritance.h @@ -131,6 +131,7 @@ SET_NODE_INFO(IsUserInteraction, Node) /* sa prefix */ SET_NODE_INFO(SaSASLRequest, Node) SET_NODE_INFO(SaSASLResponse, Node) +SET_NODE_INFO(SaCredentials, Node) /* soap prefix */ |
