diff options
author | Damien Laniel <dlaniel@entrouvert.com> | 2007-04-24 15:25:08 +0000 |
---|---|---|
committer | Damien Laniel <dlaniel@entrouvert.com> | 2007-04-24 15:25:08 +0000 |
commit | 5c99d2ea80d0aade07462a8d3ee7e329a76e2c7a (patch) | |
tree | 8e7a08e805c17fbdf72b53b1bfd2cd08064b015a | |
parent | fce9becb19dcf6501c760c952416654fb3920fad (diff) | |
download | lasso-5c99d2ea80d0aade07462a8d3ee7e329a76e2c7a.tar.gz lasso-5c99d2ea80d0aade07462a8d3ee7e329a76e2c7a.tar.xz lasso-5c99d2ea80d0aade07462a8d3ee7e329a76e2c7a.zip |
implemented discovery query
-rw-r--r-- | lasso/id-ff/identity.c | 64 | ||||
-rw-r--r-- | lasso/id-ff/login.c | 1 | ||||
-rw-r--r-- | lasso/id-ff/server.c | 2 | ||||
-rw-r--r-- | lasso/id-wsf-2.0/discovery.c | 241 | ||||
-rw-r--r-- | lasso/id-wsf-2.0/discovery.h | 8 | ||||
-rw-r--r-- | lasso/id-wsf-2.0/identity.h | 8 | ||||
-rw-r--r-- | lasso/saml-2.0/login.c | 42 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/Makefile.am | 2 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/disco_query.c | 78 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/disco_query.h | 45 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/disco_query_response.c | 113 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/disco_query_response.h | 55 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/disco_requested_service.c | 153 | ||||
-rw-r--r-- | lasso/xml/id-wsf-2.0/disco_requested_service.h | 91 | ||||
-rw-r--r-- | lasso/xml/strings.h | 6 | ||||
-rw-r--r-- | lasso/xml/ws/wsa_endpoint_reference.c | 10 | ||||
-rw-r--r-- | lasso/xml/ws/wsa_endpoint_reference.h | 4 | ||||
-rw-r--r-- | lasso/xml/xml.c | 10 | ||||
-rw-r--r-- | swig/Lasso-wsf2-disco.i | 82 | ||||
-rw-r--r-- | swig/Lasso-wsf2.i | 26 |
20 files changed, 762 insertions, 279 deletions
diff --git a/lasso/id-ff/identity.c b/lasso/id-ff/identity.c index c9234d47..cf1f703a 100644 --- a/lasso/id-ff/identity.c +++ b/lasso/id-ff/identity.c @@ -37,6 +37,7 @@ struct _LassoIdentityPrivate GList *resource_offerings; gboolean dispose_has_run; GList *svcMD; + GHashTable *eprs; }; /*****************************************************************************/ @@ -250,6 +251,30 @@ lasso_identity_get_svc_metadatas(LassoIdentity *identity, const char *service_ty return result; } +gint +lasso_identity_add_endpoint_reference(LassoIdentity *identity, LassoWsAddrEndpointReference *epr) +{ + GList *i; + + for (i = g_list_first(epr->Metadata->any); i != NULL; i = g_list_next(i)) { + if (LASSO_IS_IDWSF2_DISCO_SERVICE_TYPE(i->data)) { + g_hash_table_insert(identity->private_data->eprs, + g_strdup(LASSO_IDWSF2_DISCO_SERVICE_TYPE(i->data)->content), + g_object_ref(epr)); + identity->is_dirty = TRUE; + break; + } + } + + return 0; +} + +LassoWsAddrEndpointReference * +lasso_identity_get_endpoint_reference(LassoIdentity *identity, gchar *service_type) { + return LASSO_WSA_ENDPOINT_REFERENCE(g_hash_table_lookup( + identity->private_data->eprs, service_type)); +} + #endif @@ -278,6 +303,9 @@ get_xmlNode(LassoNode *node, gboolean lasso_dump) { xmlNode *xmlnode; LassoIdentity *identity = LASSO_IDENTITY(node); +#ifdef LASSO_WSF_ENABLED + xmlNode *t; +#endif xmlnode = xmlNewNode(NULL, (xmlChar*)"Identity"); xmlSetNs(xmlnode, xmlNewNs(xmlnode, (xmlChar*)LASSO_LASSO_HREF, NULL)); @@ -294,12 +322,18 @@ get_xmlNode(LassoNode *node, gboolean lasso_dump) /* Service Metadatas (SvcMD) */ if (identity->private_data->svcMD != NULL) { - xmlNode *t; t = xmlNewTextChild(xmlnode, NULL, (xmlChar*)"SvcMDs", NULL); g_list_foreach(identity->private_data->svcMD, (GFunc)add_childnode_from_list, t); } + /* Endpoint References */ + if (identity->private_data->eprs != NULL + && g_hash_table_size(identity->private_data->eprs)) + t = xmlNewTextChild(xmlnode, NULL, (xmlChar*)"EndpointReferences", NULL); + g_hash_table_foreach(identity->private_data->eprs, + (GHFunc)add_childnode_from_hashtable, t); + /* Simpler version which has the drawback of not working. */ /* Kept here in case it can work and be a nicer solution */ /* g_list_foreach(identity->private_data->svcMD, */ @@ -314,7 +348,9 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode) { LassoIdentity *identity = LASSO_IDENTITY(node); xmlNode *t; +#ifdef LASSO_WSF_ENABLED xmlNode *t2; +#endif t = xmlnode->children; while (t) { @@ -358,6 +394,23 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode) } } + /* Endpoint References */ + if (strcmp((char*)t->name, "EndpointReferences") == 0) { + t2 = t->children; + while (t2) { + LassoWsAddrEndpointReference *epr; + if (t2->type != XML_ELEMENT_NODE) { + t2 = t2->next; + continue; + } + epr = LASSO_WSA_ENDPOINT_REFERENCE( + lasso_wsa_endpoint_reference_new()); + LASSO_NODE_GET_CLASS(epr)->init_from_xml(LASSO_NODE(epr), t2); + lasso_identity_add_endpoint_reference(identity, epr); + t2 = t2->next; + } + } + /* Simpler version which has the drawback of not working. */ /* Kept here in case it can work and be a nicer solution */ /* if (strcmp((char*)t->name, "SvcMD") == 0) { */ @@ -403,6 +456,9 @@ dispose(GObject *object) g_hash_table_destroy(identity->federations); identity->federations = NULL; + g_hash_table_destroy(identity->private_data->eprs); + identity->private_data->eprs = NULL; + G_OBJECT_CLASS(parent_class)->dispose(object); } @@ -426,7 +482,11 @@ instance_init(LassoIdentity *identity) identity->private_data->resource_offerings = NULL; identity->private_data->dispose_has_run = FALSE; identity->private_data->svcMD = NULL; - +#ifdef LASSO_WSF_ENABLED + identity->private_data->eprs = g_hash_table_new_full(g_str_hash, g_str_equal, + (GDestroyNotify)g_free, + (GDestroyNotify)lasso_wsa_endpoint_reference_destroy); +#endif identity->federations = g_hash_table_new_full(g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)lasso_federation_destroy); diff --git a/lasso/id-ff/login.c b/lasso/id-ff/login.c index ef7e56ea..7e2d7490 100644 --- a/lasso/id-ff/login.c +++ b/lasso/id-ff/login.c @@ -1834,7 +1834,6 @@ lasso_login_set_resourceId(LassoLogin *login, const char *content) return 0; } - /*****************************************************************************/ /* private methods */ /*****************************************************************************/ diff --git a/lasso/id-ff/server.c b/lasso/id-ff/server.c index ab447bfd..1133d3b4 100644 --- a/lasso/id-ff/server.c +++ b/lasso/id-ff/server.c @@ -239,13 +239,13 @@ add_provider_childnode(gchar *key, LassoProvider *value, xmlNode *xmlnode) xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(value), TRUE)); } +#ifdef LASSO_WSF_ENABLED static void add_service_childnode(gchar *key, LassoNode *value, xmlNode *xmlnode) { xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(value), TRUE)); } -#ifdef LASSO_WSF_ENABLED static void add_childnode_from_list(LassoNode *value, xmlNode *xmlnode) { diff --git a/lasso/id-wsf-2.0/discovery.c b/lasso/id-wsf-2.0/discovery.c index 430bb500..883dc328 100644 --- a/lasso/id-wsf-2.0/discovery.c +++ b/lasso/id-wsf-2.0/discovery.c @@ -30,10 +30,18 @@ #include <lasso/xml/saml_assertion.h> #include <lasso/xml/saml_attribute_value.h> +#include <lasso/xml/id-wsf-2.0/disco_query.h> +#include <lasso/xml/id-wsf-2.0/disco_requested_service.h> #include <lasso/xml/id-wsf-2.0/disco_svc_md_register.h> #include <lasso/xml/id-wsf-2.0/disco_svc_md_register_response.h> #include <lasso/xml/id-wsf-2.0/disco_svc_md_association_add.h> #include <lasso/xml/id-wsf-2.0/disco_svc_md_association_add_response.h> +#include <lasso/xml/id-wsf-2.0/disco_svc_md_association_add_response.h> +#include <lasso/xml/id-wsf-2.0/disco_abstract.h> +#include <lasso/xml/id-wsf-2.0/disco_providerid.h> +#include <lasso/xml/id-wsf-2.0/disco_service_type.h> + +#include <lasso/xml/ws/wsa_endpoint_reference.h> #include <lasso/id-ff/server.h> #include <lasso/id-ff/provider.h> @@ -69,48 +77,32 @@ lasso_idwsf2_discovery_destroy(LassoIdWsf2Discovery *discovery) g_object_unref(G_OBJECT(discovery)); } -/** - * lasso_discovery_init_query - * @discovery: a #LassoDiscovery - * - * Initializes a disco:Query message. - * - * Return value: 0 on success; or a negative value otherwise. - **/ -gint -lasso_idwsf2_discovery_init_query(LassoIdWsf2Discovery *discovery, const gchar *security_mech_id) -{ - LassoIdWsf2DiscoQuery *query; - - query = lasso_idwsf2_disco_query_new(); - lasso_wsf2_profile_init_soap_request(LASSO_WSF2_PROFILE(discovery), LASSO_NODE(query)); - - return 0; -} - - gint lasso_idwsf2_discovery_init_metadata_register(LassoIdWsf2Discovery *discovery, gchar *service_type, gchar *abstract, gchar *disco_provider_id) { LassoIdWsf2DiscoSvcMDRegister *metadata_register; + LassoWsf2Profile *profile = LASSO_WSF2_PROFILE(discovery); + LassoProvider *provider; + gchar *sp_provider_id; + + g_return_val_if_fail(LASSO_IS_IDWSF2_DISCOVERY(discovery), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); /* Get the providerId of this SP */ - LassoProvider *provider = LASSO_PROVIDER(LASSO_WSF2_PROFILE(discovery)->server); - gchar *sp_provider_id = provider->ProviderID; + provider = LASSO_PROVIDER(profile->server); + sp_provider_id = provider->ProviderID; /* Get a MetadataRegister node */ metadata_register = lasso_idwsf2_disco_svc_md_register_new( service_type, abstract, sp_provider_id); /* Create request with this xml node */ - lasso_wsf2_profile_init_soap_request(LASSO_WSF2_PROFILE(discovery), - LASSO_NODE(metadata_register)); + lasso_wsf2_profile_init_soap_request(profile, LASSO_NODE(metadata_register)); /* FIXME : Get the url of the disco service where we must send the soap request */ - /* LASSO_WSF2_PROFILE(discovery)->msg_url = g_strdup(disco_provider_id); */ + /* profile->msg_url = g_strdup(disco_provider_id); */ -/* printf(lasso_node_dump(LASSO_NODE(metadata_register))); */ return 0; } @@ -205,6 +197,9 @@ lasso_idwsf2_discovery_init_metadata_association_add(LassoIdWsf2Discovery *disco { LassoIdWsf2DiscoSvcMDAssociationAdd *md_association_add; + g_return_val_if_fail(LASSO_IS_IDWSF2_DISCOVERY(discovery), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + /* Get a MetadataRegister node */ md_association_add = LASSO_IDWSF2_DISCO_SVC_MD_ASSOCIATION_ADD( lasso_idwsf2_disco_svc_md_association_add_new()); @@ -304,6 +299,200 @@ lasso_idwsf2_discovery_process_metadata_association_add_response_msg( return res; } +/** + * lasso_idwsf2_discovery_init_query + * @discovery: a #LassoIdWsf2Discovery + * + * Initializes a disco:Query message. + * + * Return value: 0 on success; or a negative value otherwise. + **/ +gint +lasso_idwsf2_discovery_init_query(LassoIdWsf2Discovery *discovery, const gchar *security_mech_id) +{ + LassoWsf2Profile *profile = LASSO_WSF2_PROFILE(discovery); + LassoIdentity *identity = profile->identity; + LassoWsAddrEndpointReference *epr; + + g_return_val_if_fail(LASSO_IS_IDWSF2_DISCOVERY(discovery), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(LASSO_IS_IDENTITY(identity), LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND); + + if (profile->request) + lasso_node_destroy(LASSO_NODE(profile->request)); + + profile->request = LASSO_NODE(lasso_idwsf2_disco_query_new()); + lasso_wsf2_profile_init_soap_request(profile, profile->request); + + epr = lasso_identity_get_endpoint_reference(identity, LASSO_IDWSF2_DISCO_HREF); + if (epr != NULL) { + profile->msg_url = g_strdup(epr->Address->content); + } + + return 0; +} + +gint +lasso_idwsf2_discovery_add_requested_service_type(LassoIdWsf2Discovery *discovery, + const gchar *service_type) +{ + LassoIdWsf2DiscoQuery *query; + LassoWsf2Profile *profile = LASSO_WSF2_PROFILE(discovery); + LassoIdWsf2DiscoRequestedService *service; + + g_return_val_if_fail(LASSO_IS_IDWSF2_DISCOVERY(discovery), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + + query = LASSO_IDWSF2_DISCO_QUERY(profile->request); + service = LASSO_IDWSF2_DISCO_REQUESTED_SERVICE(lasso_idwsf2_disco_requested_service_new()); + service->ServiceType = g_list_append(service->ServiceType, g_strdup(service_type)); + query->RequestedService = g_list_append(query->RequestedService, service); + + return 0; +} + +static LassoWsAddrEndpointReference * +lasso_idwsf2_discovery_build_query_response_epr(LassoIdWsf2DiscoRequestedService *service, + LassoIdentity *identity) +{ + gchar * service_type = NULL; + GList *svcMDs; + LassoIdWsf2DiscoSvcMetadata *svcMD; + LassoWsAddrEndpointReference *epr; + LassoWsAddrMetadata *metadata; + + g_return_val_if_fail(LASSO_IS_IDENTITY(identity), NULL); + + if (service != NULL && service->ServiceType != NULL) { + service_type = (gchar *)service->ServiceType->data; + } + + svcMDs = lasso_identity_get_svc_metadatas(identity, service_type); + if (svcMDs == NULL) { + return NULL; + } + + /* FIXME : foreach on the whole list and build on epr for each svcMD */ + svcMD = svcMDs->data; + + if (svcMD == NULL || svcMD->ServiceContext == NULL + || svcMD->ServiceContext->EndpointContext == NULL) { + return NULL; + } + + /* Build EndpointReference */ + + epr = LASSO_WSA_ENDPOINT_REFERENCE(lasso_wsa_endpoint_reference_new()); + + epr->Address = LASSO_WSA_ATTRIBUTED_URI(lasso_wsa_attributed_uri_new_with_string( + svcMD->ServiceContext->EndpointContext->Address)); + + metadata = LASSO_WSA_METADATA(lasso_wsa_metadata_new()); + + /* Abstract */ + metadata->any = g_list_append(metadata->any, + lasso_idwsf2_disco_abstract_new_with_content(svcMD->Abstract)); + /* ProviderID */ + metadata->any = g_list_append(metadata->any, + lasso_idwsf2_disco_providerid_new_with_content(svcMD->ProviderID)); + /* ServiceType */ + metadata->any = g_list_append(metadata->any, + lasso_idwsf2_disco_service_type_new_with_content( + svcMD->ServiceContext->ServiceType)); + /* Framework */ + metadata->any = g_list_append(metadata->any, + g_object_ref(svcMD->ServiceContext->EndpointContext->Framework)); + + epr->Metadata = metadata; + + return epr; +} + +gint +lasso_idwsf2_discovery_process_query_msg(LassoIdWsf2Discovery *discovery, const gchar *message) +{ + LassoWsf2Profile *profile = LASSO_WSF2_PROFILE(discovery); + LassoIdentity *identity = profile->identity; + LassoIdWsf2DiscoQuery* request; + LassoIdWsf2DiscoQueryResponse *response; + LassoSoapEnvelope *envelope; + LassoIdWsf2DiscoRequestedService *service = NULL; + LassoWsAddrEndpointReference *epr; + int res = 0; + + g_return_val_if_fail(LASSO_IS_IDWSF2_DISCOVERY(discovery), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(message != NULL, LASSO_PARAM_ERROR_INVALID_VALUE); + + /* Process request */ + res = lasso_wsf2_profile_process_soap_request_msg(profile, message); + + /* If the request has been correctly processed, */ + /* put interesting data into the discovery object */ + if (res == 0) { + request = LASSO_IDWSF2_DISCO_QUERY(profile->request); + /* FIXME : foreach on the list instead */ + if (request->RequestedService != NULL) { + service = LASSO_IDWSF2_DISCO_REQUESTED_SERVICE( + request->RequestedService->data); + } + } + + /* Build response */ + response = LASSO_IDWSF2_DISCO_QUERY_RESPONSE( + lasso_idwsf2_disco_query_response_new()); + + /* FIXME : Replace status codes with a constant ? */ + if (res == 0) { + response->Status = lasso_util_status_new("OK"); + /* FIXME : foreach here as well */ + epr = lasso_idwsf2_discovery_build_query_response_epr(service, identity); + if (epr != NULL) { + response->EndpointReference = + g_list_append(response->EndpointReference, epr); + } + } else { + response->Status = lasso_util_status_new("Failed"); + /* XXX : May add secondary status codes here */ + } + + envelope = profile->soap_envelope_response; + envelope->Body->any = g_list_append(envelope->Body->any, response); + + return res; +} + +gint +lasso_idwsf2_discovery_process_query_response_msg(LassoIdWsf2Discovery *discovery, + const gchar *message) +{ + LassoWsf2Profile *profile = LASSO_WSF2_PROFILE(discovery); + LassoIdentity *identity = profile->identity; + LassoIdWsf2DiscoQueryResponse *response; + int res = 0; + + g_return_val_if_fail(LASSO_IS_IDWSF2_DISCOVERY(discovery), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(message != NULL, LASSO_PARAM_ERROR_INVALID_VALUE); + g_return_val_if_fail(LASSO_IS_IDENTITY(identity), LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND); + + /* Process request */ + res = lasso_wsf2_profile_process_soap_response_msg(profile, message); + + /* If the response has been correctly processed, */ + /* put interesting data into the discovery object */ + if (res == 0) { + response = LASSO_IDWSF2_DISCO_QUERY_RESPONSE(profile->response); + /* FIXME : foreach on the list instead */ + if (response->EndpointReference != NULL) { + lasso_identity_add_endpoint_reference(identity, + response->EndpointReference->data); + } + } + + return res; +} + /*****************************************************************************/ /* private methods */ /*****************************************************************************/ diff --git a/lasso/id-wsf-2.0/discovery.h b/lasso/id-wsf-2.0/discovery.h index a8187c95..3269e96b 100644 --- a/lasso/id-wsf-2.0/discovery.h +++ b/lasso/id-wsf-2.0/discovery.h @@ -94,6 +94,14 @@ LASSO_EXPORT gint lasso_idwsf2_discovery_process_metadata_association_add_respon LASSO_EXPORT gint lasso_idwsf2_discovery_init_query(LassoIdWsf2Discovery *discovery, const gchar *security_mech_id); +LASSO_EXPORT gint lasso_idwsf2_discovery_add_requested_service_type(LassoIdWsf2Discovery *discovery, + const gchar *service_type); + +LASSO_EXPORT gint lasso_idwsf2_discovery_process_query_msg(LassoIdWsf2Discovery *discovery, + const gchar *message); + +LASSO_EXPORT gint lasso_idwsf2_discovery_process_query_response_msg(LassoIdWsf2Discovery *discovery, + const gchar *message); #ifdef __cplusplus } diff --git a/lasso/id-wsf-2.0/identity.h b/lasso/id-wsf-2.0/identity.h index 80186958..930ec487 100644 --- a/lasso/id-wsf-2.0/identity.h +++ b/lasso/id-wsf-2.0/identity.h @@ -30,6 +30,8 @@ extern "C" { #endif /* __cplusplus */ #include <lasso/xml/id-wsf-2.0/disco_svc_metadata.h> +#include <lasso/xml/id-wsf-2.0/disco_service_type.h> +#include <lasso/xml/ws/wsa_endpoint_reference.h> LASSO_EXPORT gint lasso_identity_add_svc_metadata(LassoIdentity *identity, LassoIdWsf2DiscoSvcMetadata *metadata); @@ -37,6 +39,12 @@ LASSO_EXPORT gint lasso_identity_add_svc_metadata(LassoIdentity *identity, LASSO_EXPORT GList* lasso_identity_get_svc_metadatas(LassoIdentity *identity, const char *service_type); +LASSO_EXPORT gint lasso_identity_add_endpoint_reference(LassoIdentity *identity, + LassoWsAddrEndpointReference *epr); + +LASSO_EXPORT LassoWsAddrEndpointReference *lasso_identity_get_endpoint_reference( + LassoIdentity *identity, gchar *service_type); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lasso/saml-2.0/login.c b/lasso/saml-2.0/login.c index 33ae164c..6b37833f 100644 --- a/lasso/saml-2.0/login.c +++ b/lasso/saml-2.0/login.c @@ -814,7 +814,6 @@ lasso_saml20_login_build_assertion(LassoLogin *login, return 0; } - gint lasso_saml20_login_build_artifact_msg(LassoLogin *login, LassoHttpMethod http_method) { @@ -1208,6 +1207,45 @@ lasso_saml20_login_process_response_status_and_assertion(LassoLogin *login) return ret; } +static gint +lasso_saml20_login_copy_assertion_epr(LassoLogin *login) +{ +#ifdef LASSO_WSF_ENABLED + LassoProfile *profile = LASSO_PROFILE(login); + LassoIdentity *identity = profile->identity; + LassoSaml2Assertion *assertion; + GList *attribute_statement_item; + LassoSaml2AttributeStatement *attribute_statement; + LassoSaml2Attribute *attribute; + LassoSaml2AttributeValue *attribute_value; + GList *attribute_value_item; + GList *i; + LassoWsAddrEndpointReference *epr; + + g_return_val_if_fail(LASSO_IS_IDENTITY(identity), LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND); + + assertion = LASSO_SAMLP2_RESPONSE(profile->response)->Assertion->data; + + attribute_statement_item = assertion->AttributeStatement; + if (attribute_statement_item == NULL || g_list_length(attribute_statement_item) == 0) { + return 0; + } + + attribute_statement = LASSO_SAML2_ATTRIBUTE_STATEMENT(attribute_statement_item->data); + attribute = LASSO_SAML2_ATTRIBUTE(attribute_statement->Attribute->data); + attribute_value = LASSO_SAML2_ATTRIBUTE_VALUE(attribute->AttributeValue->data); + attribute_value_item = attribute_value->any; + for (i = g_list_first(attribute_value_item); i != NULL; i = g_list_next(i)) { + if (LASSO_IS_WSA_ENDPOINT_REFERENCE(attribute_value_item->data)) { + epr = LASSO_WSA_ENDPOINT_REFERENCE(attribute_value_item->data); + lasso_identity_add_endpoint_reference(identity, epr); + } + } +#endif + + return 0; +} + gint lasso_saml20_login_accept_sso(LassoLogin *login) { @@ -1265,6 +1303,8 @@ lasso_saml20_login_accept_sso(LassoLogin *login) lasso_identity_add_federation(LASSO_PROFILE(login)->identity, federation); } + lasso_saml20_login_copy_assertion_epr(login); + return 0; } diff --git a/lasso/xml/id-wsf-2.0/Makefile.am b/lasso/xml/id-wsf-2.0/Makefile.am index 679f331e..9e53299d 100644 --- a/lasso/xml/id-wsf-2.0/Makefile.am +++ b/lasso/xml/id-wsf-2.0/Makefile.am @@ -13,6 +13,7 @@ liblasso_xml_id_wsf2_la_SOURCES = \ disco_options.c \ disco_query.c \ disco_query_response.c \ + disco_requested_service.c \ disco_service_context.c \ disco_svc_metadata.c \ disco_svc_md_association_add.c \ @@ -30,6 +31,7 @@ liblassoinclude_HEADERS = \ disco_options.h \ disco_query.h \ disco_query_response.h \ + disco_requested_service.c \ disco_service_context.h \ disco_svc_metadata.h \ disco_svc_md_association_add.h \ diff --git a/lasso/xml/id-wsf-2.0/disco_query.c b/lasso/xml/id-wsf-2.0/disco_query.c index bf5c8955..caf5c524 100644 --- a/lasso/xml/id-wsf-2.0/disco_query.c +++ b/lasso/xml/id-wsf-2.0/disco_query.c @@ -1,8 +1,8 @@ -/* $Id: disco_query.c,v 1.7 2005/01/22 15:57:55 $ +/* $Id: disco_query.c,v 1.0 2005/10/14 15:17:55 fpeters Exp $ * * Lasso - A free implementation of the Liberty Alliance specifications. * - * Copyright (C) 2007 Entr'ouvert + * Copyright (C) 2004-2007 Entr'ouvert * http://lasso.entrouvert.org * * Authors: See AUTHORS file in top-level directory. @@ -22,38 +22,40 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <lasso/xml/id-wsf-2.0/disco_query.h> +#include "disco_query.h" /* - * Schema fragments (liberty-idwsf-disco-svc-v2.0.xsd) : - * - * <xs:element name="Query" type="QueryType"/> + * Schema fragment (liberty-idwsf-disco-svc-v2.0.xsd): * * <xs:complexType name="QueryType"> * <xs:sequence> * <xs:element name="RequestedService" - * type="RequestedServiceType" - * minOccurs="0" - * maxOccurs="unbounded"/> - * </xs:sequence> - * <xs:anyAttribute namespace="##other" processContents="lax"/> - * </xs:complexType> - */ + * type="RequestedServiceType" + * minOccurs="0" + * maxOccurs="unbounded"/> + * </xs:sequence> + * + * <xs:anyAttribute namespace="##other" processContents="lax"/> + * </xs:complexType> + */ /*****************************************************************************/ /* private methods */ /*****************************************************************************/ + static struct XmlSnippet schema_snippets[] = { -// { "ResourceID", SNIPPET_NODE, G_STRUCT_OFFSET(LassoIdWsf2DiscoQuery, ResourceID) }, -// { "EncryptedResourceID", -// SNIPPET_NODE, G_STRUCT_OFFSET(LassoIdWsf2DiscoQuery, EncryptedResourceID) }, -// { "RequestedServiceType", SNIPPET_LIST_NODES, -// G_STRUCT_OFFSET(LassoIdWsf2DiscoQuery, RequestedServiceType) }, - { "id", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoIdWsf2DiscoQuery, id) }, - { NULL, 0, 0} + { "RequestedService", SNIPPET_LIST_NODES, + G_STRUCT_OFFSET(LassoIdWsf2DiscoQuery, RequestedService), + "LassoIdWsf2DiscoRequestedService" }, + { "any", SNIPPET_ATTRIBUTE | SNIPPET_ANY, + G_STRUCT_OFFSET(LassoIdWsf2DiscoQuery, attributes) }, + {NULL, 0, 0} }; +static LassoNodeClass *parent_class = NULL; + + /*****************************************************************************/ /* instance and class init functions */ /*****************************************************************************/ @@ -61,10 +63,9 @@ static struct XmlSnippet schema_snippets[] = { static void instance_init(LassoIdWsf2DiscoQuery *node) { -// node->ResourceID = NULL; -// node->EncryptedResourceID = NULL; -// node->RequestedServiceType = NULL; - node->id = NULL; + node->RequestedService = NULL; + node->attributes = g_hash_table_new_full( + g_str_hash, g_str_equal, g_free, g_free); } static void @@ -72,6 +73,7 @@ class_init(LassoIdWsf2DiscoQueryClass *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, "Query"); lasso_node_class_set_ns(nclass, LASSO_IDWSF2_DISCO_HREF, LASSO_IDWSF2_DISCO_PREFIX); @@ -102,25 +104,15 @@ lasso_idwsf2_disco_query_get_type() return this_type; } -LassoIdWsf2DiscoQuery* +/** + * lasso_idwsf2_disco_query_new: + * + * Creates a new #LassoIdWsf2DiscoQuery object. + * + * Return value: a newly created #LassoIdWsf2DiscoQuery object + **/ +LassoNode* lasso_idwsf2_disco_query_new() { - LassoIdWsf2DiscoQuery *node; - - node = g_object_new(LASSO_TYPE_IDWSF2_DISCO_QUERY, NULL); - - return node; -} - -LassoIdWsf2DiscoQuery* -lasso_idwsf2_disco_query_new_from_message(const gchar *message) -{ - LassoIdWsf2DiscoQuery *node; - - g_return_val_if_fail(message != NULL, NULL); - - node = g_object_new(LASSO_TYPE_IDWSF2_DISCO_QUERY, NULL); - lasso_node_init_from_message(LASSO_NODE(node), message); - - return node; + return g_object_new(LASSO_TYPE_IDWSF2_DISCO_QUERY, NULL); } diff --git a/lasso/xml/id-wsf-2.0/disco_query.h b/lasso/xml/id-wsf-2.0/disco_query.h index df6a6ac5..2285d5ee 100644 --- a/lasso/xml/id-wsf-2.0/disco_query.h +++ b/lasso/xml/id-wsf-2.0/disco_query.h @@ -1,8 +1,8 @@ -/* $Id: disco_query.h,v 1.8 2005/01/22 15:57:55 $ +/* $Id: disco_query.h,v 1.0 2005/10/14 15:17:55 fpeters Exp $ * * Lasso - A free implementation of the Liberty Alliance specifications. * - * Copyright (C) 2007 Entr'ouvert + * Copyright (C) 2004-2007 Entr'ouvert * http://lasso.entrouvert.org * * Authors: See AUTHORS file in top-level directory. @@ -27,43 +27,54 @@ #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ #include <lasso/xml/xml.h> -//#include <lasso/xml/disco_resource_id.h> -//#include <lasso/xml/disco_encrypted_resource_id.h> -//#include <lasso/xml/disco_requested_service_type.h> #define LASSO_TYPE_IDWSF2_DISCO_QUERY (lasso_idwsf2_disco_query_get_type()) -#define LASSO_IDWSF2_DISCO_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \ - LASSO_TYPE_IDWSF2_DISCO_QUERY, LassoIdWsf2DiscoQuery)) -#define LASSO_IDWSF2_DISCO_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \ - LASSO_TYPE_IDWSF2_DISCO_QUERY, LassoIdWsf2DiscoQueryClass)) -#define LASSO_IS_IDWSF2_DISCO_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_IDWSF2_DISCO_QUERY)) +#define LASSO_IDWSF2_DISCO_QUERY(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + LASSO_TYPE_IDWSF2_DISCO_QUERY, \ + LassoIdWsf2DiscoQuery)) +#define LASSO_IDWSF2_DISCO_QUERY_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + LASSO_TYPE_IDWSF2_DISCO_QUERY, \ + LassoIdWsf2DiscoQueryClass)) +#define LASSO_IS_IDWSF2_DISCO_QUERY(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + LASSO_TYPE_IDWSF2_DISCO_QUERY)) #define LASSO_IS_IDWSF2_DISCO_QUERY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass),LASSO_TYPE_IDWSF2_DISCO_QUERY)) + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + LASSO_TYPE_IDWSF2_DISCO_QUERY)) #define LASSO_IDWSF2_DISCO_QUERY_GET_CLASS(o) \ - (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_IDWSF2_DISCO_QUERY, LassoIdWsf2DiscoQueryClass)) + (G_TYPE_INSTANCE_GET_CLASS ((o), \ + LASSO_TYPE_IDWSF2_DISCO_QUERY, \ + LassoIdWsf2DiscoQueryClass)) + typedef struct _LassoIdWsf2DiscoQuery LassoIdWsf2DiscoQuery; typedef struct _LassoIdWsf2DiscoQueryClass LassoIdWsf2DiscoQueryClass; + struct _LassoIdWsf2DiscoQuery { LassoNode parent; -// GList *RequestedService; - gchar *id; + /*< public >*/ + /* elements */ + GList *RequestedService; /* of LassoIdWsf2DiscoRequestedService */ + /* attributes */ + GHashTable *attributes; }; + struct _LassoIdWsf2DiscoQueryClass { LassoNodeClass parent; }; LASSO_EXPORT GType lasso_idwsf2_disco_query_get_type(void); +LASSO_EXPORT LassoNode* lasso_idwsf2_disco_query_new(void); -LASSO_EXPORT LassoIdWsf2DiscoQuery* lasso_idwsf2_disco_query_new(void); -LASSO_EXPORT LassoIdWsf2DiscoQuery* lasso_idwsf2_disco_query_new_from_message(const gchar *message); #ifdef __cplusplus } diff --git a/lasso/xml/id-wsf-2.0/disco_query_response.c b/lasso/xml/id-wsf-2.0/disco_query_response.c index 7bda0c3e..49d4e2d8 100644 --- a/lasso/xml/id-wsf-2.0/disco_query_response.c +++ b/lasso/xml/id-wsf-2.0/disco_query_response.c @@ -1,8 +1,8 @@ -/* $Id: disco_query_response.c,v 1.9 2005/08/12 09:08:44$ +/* $Id: disco_query_response.c,v 1.0 2005/10/14 15:17:55 fpeters Exp $ * * Lasso - A free implementation of the Liberty Alliance specifications. * - * Copyright (C) 2007 Entr'ouvert + * Copyright (C) 2004-2007 Entr'ouvert * http://lasso.entrouvert.org * * Authors: See AUTHORS file in top-level directory. @@ -22,67 +22,42 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <lasso/xml/id-wsf-2.0/disco_query_response.h> +#include "disco_query_response.h" /* * Schema fragment (liberty-idwsf-disco-svc-v2.0.xsd): * - * <xs:element name="QueryResponse" type="QueryResponseType"/> - * * <xs:complexType name="QueryResponseType"> * <xs:sequence> * <xs:element ref="lu:Status"/> - * <xs:element ref="wsa:EndpointReference" - * minOccurs="0" - * maxOccurs="unbounded"/> - * </xs:sequence> - * <xs:anyAttribute namespace="##other" processContents="lax"/> - * </xs:complexType> + * + * <xs:element ref="wsa:EndpointReference" + * minOccurs="0" + * maxOccurs="unbounded"/> + * </xs:sequence> + * <xs:anyAttribute namespace="##other" processContents="lax"/> + * </xs:complexType> */ /*****************************************************************************/ /* private methods */ /*****************************************************************************/ + static struct XmlSnippet schema_snippets[] = { -// { "Status", SNIPPET_NODE, -// G_STRUCT_OFFSET(LassoIdWsf2DiscoQueryResponse, Status) }, -// { "ResourceOffering", SNIPPET_LIST_NODES, -// G_STRUCT_OFFSET(LassoIdWsf2DiscoQueryResponse, ResourceOffering) }, -// { "Credentials", SNIPPET_NODE, -// G_STRUCT_OFFSET(LassoIdWsf2DiscoQueryResponse, Credentials) }, - { "id", SNIPPET_ATTRIBUTE, - G_STRUCT_OFFSET(LassoIdWsf2DiscoQueryResponse, id) }, - { NULL, 0, 0} + { "Status", SNIPPET_NODE, + G_STRUCT_OFFSET(LassoIdWsf2DiscoQueryResponse, Status), + "LassoIdWsf2UtilStatus" }, + { "EndpointReference", SNIPPET_LIST_NODES, + G_STRUCT_OFFSET(LassoIdWsf2DiscoQueryResponse, EndpointReference), + "LassoWsAddrEndpointReference" }, + { "any", SNIPPET_ATTRIBUTE | SNIPPET_ANY, + G_STRUCT_OFFSET(LassoIdWsf2DiscoQueryResponse, attributes) }, + {NULL, 0, 0} }; static LassoNodeClass *parent_class = NULL; -static void -insure_namespace(xmlNode *xmlnode, xmlNs *ns) -{ - xmlNode *t = xmlnode->children; - - xmlSetNs(xmlnode, ns); - while (t) { - if (t->type == XML_ELEMENT_NODE && t->ns == NULL) - insure_namespace(t, ns); - t = t->next; - } -} - -static xmlNode* -get_xmlNode(LassoNode *node, gboolean lasso_dump) -{ - xmlNode *xmlnode; - xmlNs *ns; - - xmlnode = parent_class->get_xmlNode(node, lasso_dump); - ns = xmlNewNs(NULL, (xmlChar*)LASSO_IDWSF2_DISCO_HREF, (xmlChar*)LASSO_IDWSF2_DISCO_PREFIX); - insure_namespace(xmlnode, ns); - - return xmlnode; -} /*****************************************************************************/ /* instance and class init functions */ @@ -92,19 +67,17 @@ static void instance_init(LassoIdWsf2DiscoQueryResponse *node) { node->Status = NULL; -// node->ResourceOffering = NULL; -// node->Credentials = NULL; - - node->id = NULL; + node->EndpointReference = NULL; + node->attributes = g_hash_table_new_full( + g_str_hash, g_str_equal, g_free, g_free); } static void -class_init(LassoIdWsf2DiscoQueryResponseClass *class) +class_init(LassoIdWsf2DiscoQueryResponseClass *klass) { - LassoNodeClass *nclass = LASSO_NODE_CLASS(class); + LassoNodeClass *nclass = LASSO_NODE_CLASS(klass); - parent_class = g_type_class_peek_parent(class); - nclass->get_xmlNode = get_xmlNode; + parent_class = g_type_class_peek_parent(klass); nclass->node_data = g_new0(LassoNodeClassData, 1); lasso_node_class_set_nodename(nclass, "QueryResponse"); lasso_node_class_set_ns(nclass, LASSO_IDWSF2_DISCO_HREF, LASSO_IDWSF2_DISCO_PREFIX); @@ -135,29 +108,15 @@ lasso_idwsf2_disco_query_response_get_type() return this_type; } -LassoIdWsf2DiscoQueryResponse* -lasso_idwsf2_disco_query_response_new(LassoUtilityStatus *status) -{ - LassoIdWsf2DiscoQueryResponse *node; - - g_return_val_if_fail(LASSO_IS_UTILITY_STATUS(status), NULL); - - node = g_object_new(LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE, NULL); - - node->Status = status; - - return node; -} - -LassoIdWsf2DiscoQueryResponse* -lasso_idwsf2_disco_query_response_new_from_message(const gchar *message) +/** + * lasso_idwsf2_disco_query_response_new: + * + * Creates a new #LassoIdWsf2DiscoQueryResponse object. + * + * Return value: a newly created #LassoIdWsf2DiscoQueryResponse object + **/ +LassoNode* +lasso_idwsf2_disco_query_response_new() { - LassoIdWsf2DiscoQueryResponse *response; - - g_return_val_if_fail(message != NULL, NULL); - - response = g_object_new(LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE, NULL); - lasso_node_init_from_message(LASSO_NODE(response), message); - - return response; + return g_object_new(LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE, NULL); } diff --git a/lasso/xml/id-wsf-2.0/disco_query_response.h b/lasso/xml/id-wsf-2.0/disco_query_response.h index d26c97dc..15de70e2 100644 --- a/lasso/xml/id-wsf-2.0/disco_query_response.h +++ b/lasso/xml/id-wsf-2.0/disco_query_response.h @@ -1,8 +1,8 @@ -/* $Id: disco_query_response.h,v 1.5 2005/01/22 15:57:55 $ +/* $Id: disco_query_response.h,v 1.0 2005/10/14 15:17:55 fpeters Exp $ * * Lasso - A free implementation of the Liberty Alliance specifications. * - * Copyright (C) 2007 Entr'ouvert + * Copyright (C) 2004-2007 Entr'ouvert * http://lasso.entrouvert.org * * Authors: See AUTHORS file in top-level directory. @@ -27,48 +27,57 @@ #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ #include <lasso/xml/xml.h> -//#include <lasso/xml/disco_credentials.h> -#include <lasso/xml/utility_status.h> - -#define LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE (lasso_idwsf2_disco_query_response_get_type()) -#define LASSO_IDWSF2_DISCO_QUERY_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \ - LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE, LassoIdWsf2DiscoQueryResponse)) -#define LASSO_IDWSF2_DISCO_QUERY_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \ - LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE, LassoIdWsf2DiscoQueryResponseClass)) +#include "util_status.h" + +#define LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE \ + (lasso_idwsf2_disco_query_response_get_type()) +#define LASSO_IDWSF2_DISCO_QUERY_RESPONSE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE, \ + LassoIdWsf2DiscoQueryResponse)) +#define LASSO_IDWSF2_DISCO_QUERY_RESPONSE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE, \ + LassoIdWsf2DiscoQueryResponseClass)) #define LASSO_IS_IDWSF2_DISCO_QUERY_RESPONSE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE)) + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE)) #define LASSO_IS_IDWSF2_DISCO_QUERY_RESPONSE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE)) + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE)) #define LASSO_IDWSF2_DISCO_QUERY_RESPONSE_GET_CLASS(o) \ - (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE, \ - LassoIdWsf2DiscoQueryResponseClass)) + (G_TYPE_INSTANCE_GET_CLASS ((o), \ + LASSO_TYPE_IDWSF2_DISCO_QUERY_RESPONSE, \ + LassoIdWsf2DiscoQueryResponseClass)) + typedef struct _LassoIdWsf2DiscoQueryResponse LassoIdWsf2DiscoQueryResponse; typedef struct _LassoIdWsf2DiscoQueryResponseClass LassoIdWsf2DiscoQueryResponseClass; + struct _LassoIdWsf2DiscoQueryResponse { LassoNode parent; - LassoUtilityStatus *Status; -// GList *ResourceOffering; -// LassoIdWsf2DiscoCredentials *Credentials; - - char *id; + /*< public >*/ + /* elements */ + LassoIdWsf2UtilStatus *Status; + GList *EndpointReference; /* of LassoWsAddrEndpointReference */ + /* attributes */ + GHashTable *attributes; }; + struct _LassoIdWsf2DiscoQueryResponseClass { LassoNodeClass parent; }; LASSO_EXPORT GType lasso_idwsf2_disco_query_response_get_type(void); +LASSO_EXPORT LassoNode* lasso_idwsf2_disco_query_response_new(void); -LASSO_EXPORT LassoIdWsf2DiscoQueryResponse* lasso_idwsf2_disco_query_response_new(LassoUtilityStatus *status); -LASSO_EXPORT LassoIdWsf2DiscoQueryResponse* lasso_idwsf2_disco_query_response_new_from_message( - const gchar *message); #ifdef __cplusplus } diff --git a/lasso/xml/id-wsf-2.0/disco_requested_service.c b/lasso/xml/id-wsf-2.0/disco_requested_service.c new file mode 100644 index 00000000..bcf03a47 --- /dev/null +++ b/lasso/xml/id-wsf-2.0/disco_requested_service.c @@ -0,0 +1,153 @@ +/* $Id: disco_requested_service.c,v 1.0 2005/10/14 15:17:55 fpeters Exp $ + * + * 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 "disco_requested_service.h" + +/* + * Schema fragment (liberty-idwsf-disco-svc-v2.0.xsd): + * + * <xs:complexType name="RequestedServiceType"> + * <xs:sequence> + * <xs:element ref="ServiceType" minOccurs="0" maxOccurs="unbounded" /> + * + * <xs:element ref="ProviderID" minOccurs="0" maxOccurs="unbounded" /> + * + * <xs:element ref="Options" minOccurs="0" maxOccurs="unbounded"/> + * + * <xs:element ref="SecurityMechID" minOccurs="0" maxOccurs="unbounded"/> + * + * <xs:element ref="Framework" minOccurs="0" maxOccurs="unbounded"/> + * + * <xs:element ref="Action" minOccurs="0" maxOccurs="unbounded"/> + * + * <xs:any namespace="##other" + * processContents="lax" + * minOccurs="0" + * maxOccurs="unbounded"/> + * + * </xs:sequence> + * + * <xs:attribute name="reqID" type="xs:string" use="optional" /> + * <xs:attribute name="resultsType" type="xs:string" use="optional" /> + * + * </xs:complexType> + */ + +/*****************************************************************************/ +/* private methods */ +/*****************************************************************************/ + + +static struct XmlSnippet schema_snippets[] = { + { "ServiceType", SNIPPET_LIST_CONTENT, + G_STRUCT_OFFSET(LassoIdWsf2DiscoRequestedService, ServiceType) }, + { "ProviderID", SNIPPET_LIST_CONTENT, + G_STRUCT_OFFSET(LassoIdWsf2DiscoRequestedService, ProviderID) }, + { "Options", SNIPPET_LIST_NODES, + G_STRUCT_OFFSET(LassoIdWsf2DiscoRequestedService, Options), + "LassoIdWsf2DiscoOptions" }, + { "SecurityMechID", SNIPPET_LIST_CONTENT, + G_STRUCT_OFFSET(LassoIdWsf2DiscoRequestedService, SecurityMechID) }, + { "Framework", SNIPPET_LIST_NODES, + G_STRUCT_OFFSET(LassoIdWsf2DiscoRequestedService, Framework) }, + { "Action", SNIPPET_LIST_CONTENT, + G_STRUCT_OFFSET(LassoIdWsf2DiscoRequestedService, Action) }, + { "any", SNIPPET_NODE | SNIPPET_ANY, + G_STRUCT_OFFSET(LassoIdWsf2DiscoRequestedService, any) }, + { "reqID", SNIPPET_ATTRIBUTE, + G_STRUCT_OFFSET(LassoIdWsf2DiscoRequestedService, reqID) }, + { "resultsType", SNIPPET_ATTRIBUTE, + G_STRUCT_OFFSET(LassoIdWsf2DiscoRequestedService, resultsType) }, + {NULL, 0, 0} +}; + +static LassoNodeClass *parent_class = NULL; + + +/*****************************************************************************/ +/* instance and class init functions */ +/*****************************************************************************/ + +static void +instance_init(LassoIdWsf2DiscoRequestedService *node) +{ + node->ServiceType = NULL; + node->ProviderID = NULL; + node->Options = NULL; + node->SecurityMechID = NULL; + node->Framework = NULL; + node->Action = NULL; + node->any = NULL; + node->reqID = NULL; + node->resultsType = NULL; +} + +static void +class_init(LassoIdWsf2DiscoRequestedServiceClass *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, "RequestedService"); + lasso_node_class_set_ns(nclass, LASSO_IDWSF2_DISCO_HREF, LASSO_IDWSF2_DISCO_PREFIX); + lasso_node_class_add_snippets(nclass, schema_snippets); +} + +GType +lasso_idwsf2_disco_requested_service_get_type() +{ + static GType this_type = 0; + + if (!this_type) { + static const GTypeInfo this_info = { + sizeof (LassoIdWsf2DiscoRequestedServiceClass), + NULL, + NULL, + (GClassInitFunc) class_init, + NULL, + NULL, + sizeof(LassoIdWsf2DiscoRequestedService), + 0, + (GInstanceInitFunc) instance_init, + }; + + this_type = g_type_register_static(LASSO_TYPE_NODE, + "LassoIdWsf2DiscoRequestedService", &this_info, 0); + } + return this_type; +} + +/** + * lasso_idwsf2_disco_requested_service_new: + * + * Creates a new #LassoIdWsf2DiscoRequestedService object. + * + * Return value: a newly created #LassoIdWsf2DiscoRequestedService object + **/ +LassoNode* +lasso_idwsf2_disco_requested_service_new() +{ + return g_object_new(LASSO_TYPE_IDWSF2_DISCO_REQUESTED_SERVICE, NULL); +} diff --git a/lasso/xml/id-wsf-2.0/disco_requested_service.h b/lasso/xml/id-wsf-2.0/disco_requested_service.h new file mode 100644 index 00000000..098dffee --- /dev/null +++ b/lasso/xml/id-wsf-2.0/disco_requested_service.h @@ -0,0 +1,91 @@ +/* $Id: disco_requested_service.h,v 1.0 2005/10/14 15:17:55 fpeters Exp $ + * + * 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_IDWSF2_DISCO_REQUESTED_SERVICE_H__ +#define __LASSO_IDWSF2_DISCO_REQUESTED_SERVICE_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <lasso/xml/xml.h> + +#define LASSO_TYPE_IDWSF2_DISCO_REQUESTED_SERVICE \ + (lasso_idwsf2_disco_requested_service_get_type()) +#define LASSO_IDWSF2_DISCO_REQUESTED_SERVICE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + LASSO_TYPE_IDWSF2_DISCO_REQUESTED_SERVICE, \ + LassoIdWsf2DiscoRequestedService)) +#define LASSO_IDWSF2_DISCO_REQUESTED_SERVICE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + LASSO_TYPE_IDWSF2_DISCO_REQUESTED_SERVICE, \ + LassoIdWsf2DiscoRequestedServiceClass)) +#define LASSO_IS_IDWSF2_DISCO_REQUESTED_SERVICE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + LASSO_TYPE_IDWSF2_DISCO_REQUESTED_SERVICE)) +#define LASSO_IS_IDWSF2_DISCO_REQUESTED_SERVICE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + LASSO_TYPE_IDWSF2_DISCO_REQUESTED_SERVICE)) +#define LASSO_IDWSF2_DISCO_REQUESTED_SERVICE_GET_CLASS(o) \ + (G_TYPE_INSTANCE_GET_CLASS ((o), \ + LASSO_TYPE_IDWSF2_DISCO_REQUESTED_SERVICE, \ + LassoIdWsf2DiscoRequestedServiceClass)) + + +typedef struct _LassoIdWsf2DiscoRequestedService LassoIdWsf2DiscoRequestedService; +typedef struct _LassoIdWsf2DiscoRequestedServiceClass LassoIdWsf2DiscoRequestedServiceClass; + + +struct _LassoIdWsf2DiscoRequestedService { + LassoNode parent; + + /*< public >*/ + /* elements */ + GList *ServiceType; + GList *ProviderID; + GList *Options; /* of LassoIdWsf2DiscoOptions */ + GList *SecurityMechID; + GList *Framework; + GList *Action; + LassoNode *any; + /* attributes */ + char *reqID; + char *resultsType; +}; + + +struct _LassoIdWsf2DiscoRequestedServiceClass { + LassoNodeClass parent; +}; + +LASSO_EXPORT GType lasso_idwsf2_disco_requested_service_get_type(void); +LASSO_EXPORT LassoNode* lasso_idwsf2_disco_requested_service_new(void); + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LASSO_IDWSF2_DISCO_REQUESTED_SERVICE_H__ */ diff --git a/lasso/xml/strings.h b/lasso/xml/strings.h index 5bab31f6..4aeaf5db 100644 --- a/lasso/xml/strings.h +++ b/lasso/xml/strings.h @@ -474,6 +474,12 @@ #define LASSO_IDWSF2_DISCO_HREF "urn:liberty:disco:2006-08" #define LASSO_IDWSF2_DISCO_PREFIX "disco" +#define LASSO_EP_HREF "urn:liberty:id-sis-ep:2003-08" +#define LASSO_EP_PREFIX "ep" + +#define LASSO_PP_HREF "urn:liberty:id-sis-pp:2003-08" +#define LASSO_PP_PREFIX "pp" + #define LASSO_IDWSF2_DST_HREF "urn:liberty:dst:2006-08" #define LASSO_IDWSF2_DST_PREFIX "dst" diff --git a/lasso/xml/ws/wsa_endpoint_reference.c b/lasso/xml/ws/wsa_endpoint_reference.c index 9c91cd19..1474661e 100644 --- a/lasso/xml/ws/wsa_endpoint_reference.c +++ b/lasso/xml/ws/wsa_endpoint_reference.c @@ -39,6 +39,16 @@ */ /*****************************************************************************/ +/* public methods */ +/*****************************************************************************/ + +void +lasso_wsa_endpoint_reference_destroy(LassoWsAddrEndpointReference *epr) +{ + lasso_node_destroy(LASSO_NODE(epr)); +} + +/*****************************************************************************/ /* private methods */ /*****************************************************************************/ diff --git a/lasso/xml/ws/wsa_endpoint_reference.h b/lasso/xml/ws/wsa_endpoint_reference.h index bf2eb8fa..6bc6e1bf 100644 --- a/lasso/xml/ws/wsa_endpoint_reference.h +++ b/lasso/xml/ws/wsa_endpoint_reference.h @@ -70,11 +70,11 @@ struct _LassoWsAddrEndpointReferenceClass { LassoNodeClass parent; }; +void lasso_wsa_endpoint_reference_destroy(LassoWsAddrEndpointReference *epr); + LASSO_EXPORT GType lasso_wsa_endpoint_reference_get_type(void); LASSO_EXPORT LassoNode* lasso_wsa_endpoint_reference_new(void); - - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index 0caa83f4..edc9b2a8 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -2197,7 +2197,8 @@ static void xmlUseNsDef(xmlNs *ns, xmlNode *node) { xmlNode *t; - xmlNs *ns2, *ns3; + xmlNs *ns2; + xmlNs *ns3 = NULL; if (sameNs(ns, node->ns)) { node->ns = ns; @@ -2215,11 +2216,14 @@ xmlUseNsDef(xmlNs *ns, xmlNode *node) } else if (node->nsDef) { for (ns2 = node->nsDef; ns2->next; ns2 = ns2->next) { if (sameNs(ns2->next, ns)) { - ns3 = ns2; ns2->next = ns2->next->next; - xmlFreeNs(ns3); + if (ns3 != NULL) { + xmlFreeNs(ns3); + } + ns3 = ns2; } } + /* FIXME : memory leak : ns3 should be freed here */ } } diff --git a/swig/Lasso-wsf2-disco.i b/swig/Lasso-wsf2-disco.i deleted file mode 100644 index 5e6569d7..00000000 --- a/swig/Lasso-wsf2-disco.i +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: c; c-basic-offset: 8 -*- - * - * $Id: Lasso-wsf-disco.i,v 1.7 2006/12/20 23:41:44 fpeters Exp $ - * - * SWIG bindings for Lasso Library - * - * 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 - */ - - -/* WSF prefix & href */ -#ifndef SWIGPHP4 -%rename(IDWSF2_DISCO_HREF) LASSO_IDWSF2_DISCO_HREF; -%rename(IDWSF2_DISCO_PREFIX) LASSO_IDWSF2_DISCO_PREFIX; -#endif -#define LASSO_IDWSF2_DISCO_HREF "urn:liberty:disco:2006-08" -#define LASSO_IDWSF2_DISCO_PREFIX "disco" - - -/*********************************************************************** - *********************************************************************** - * XML Elements in Discovery Namespace - *********************************************************************** - ***********************************************************************/ - - -/*********************************************************************** - * disco:Query - ***********************************************************************/ - - -#ifndef SWIGPHP4 -%rename(IdWsf2DiscoQuery) LassoIdWsf2DiscoQuery; -#endif -typedef struct { - /* Attributes */ - - char *id; -} LassoIdWsf2DiscoQuery; -%extend LassoIdWsf2DiscoQuery { - - /* Constructor, Destructor & Static Methods */ - - LassoIdWsf2DiscoQuery(); - - ~LassoIdWsf2DiscoQuery(); - - /* Methods inherited from LassoNode */ - - %newobject dump; - char *dump(); -} - -%{ - -/* Constructors, destructors & static methods implementations */ - -#define new_LassoIdWsf2DiscoQuery lasso_idwsf2_disco_query_new -#define delete_LassoIdWsf2DiscoQuery(self) lasso_node_destroy(LASSO_NODE(self)) - -/* Implementations of methods inherited from LassoNode */ - -#define LassoIdWsf2DiscoQuery_dump(self) lasso_node_dump(LASSO_NODE(self)) - -%} diff --git a/swig/Lasso-wsf2.i b/swig/Lasso-wsf2.i index 08de555f..9b4ae2a0 100644 --- a/swig/Lasso-wsf2.i +++ b/swig/Lasso-wsf2.i @@ -24,7 +24,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -%include Lasso-wsf2-disco.i +/* %include Lasso-wsf2-disco.i */ %include Lasso-wsf-soap.i %{ @@ -32,6 +32,15 @@ %} +/* WSF prefix & href */ +#ifndef SWIGPHP4 +%rename(IDWSF2_DISCO_HREF) LASSO_IDWSF2_DISCO_HREF; +%rename(IDWSF2_DISCO_PREFIX) LASSO_IDWSF2_DISCO_PREFIX; +#endif +#define LASSO_IDWSF2_DISCO_HREF "urn:liberty:disco:2006-08" +#define LASSO_IDWSF2_DISCO_PREFIX "disco" + + /*********************************************************************** *********************************************************************** * ID-WSF @@ -147,6 +156,18 @@ typedef struct { THROW_ERROR() int initQuery(const char *security_mech_id = NULL); END_THROW_ERROR() + + THROW_ERROR() + int addRequestedServiceType(const gchar *service_type); + END_THROW_ERROR() + + THROW_ERROR() + int processQueryMsg(const gchar *message); + END_THROW_ERROR() + + THROW_ERROR() + int processQueryResponseMsg(const gchar *message); + END_THROW_ERROR() } %{ @@ -245,5 +266,8 @@ typedef struct { #define LassoIdWsf2Discovery_processMetadataAssociationAddMsg lasso_idwsf2_discovery_process_metadata_association_add_msg #define LassoIdWsf2Discovery_processMetadataAssociationAddResponseMsg lasso_idwsf2_discovery_process_metadata_association_add_response_msg #define LassoIdWsf2Discovery_initQuery lasso_idwsf2_discovery_init_query +#define LassoIdWsf2Discovery_addRequestedServiceType lasso_idwsf2_discovery_add_requested_service_type +#define LassoIdWsf2Discovery_processQueryMsg lasso_idwsf2_discovery_process_query_msg +#define LassoIdWsf2Discovery_processQueryResponseMsg lasso_idwsf2_discovery_process_query_response_msg %} |