diff options
author | Emmanuel Raviart <eraviart@entrouvert.com> | 2005-01-27 23:41:05 +0000 |
---|---|---|
committer | Emmanuel Raviart <eraviart@entrouvert.com> | 2005-01-27 23:41:05 +0000 |
commit | 472aded71ad91451e94d3c2449b8258779a0d692 (patch) | |
tree | 760fb8f001a3eb207c49cf8ba7bd3abefba32ca8 | |
parent | 6f41ce7a3c71e3cff675432d54b13630bd4868fd (diff) | |
download | lasso-472aded71ad91451e94d3c2449b8258779a0d692.tar.gz lasso-472aded71ad91451e94d3c2449b8258779a0d692.tar.xz lasso-472aded71ad91451e94d3c2449b8258779a0d692.zip |
Merged wsf-api-change-not-for-0-6 branch with trunk.
-rw-r--r-- | lasso/id-ff/login.c | 65 | ||||
-rw-r--r-- | lasso/id-ff/login.h | 16 | ||||
-rw-r--r-- | lasso/id-ff/profile.c | 26 | ||||
-rw-r--r-- | lasso/id-ff/profile.h | 6 | ||||
-rw-r--r-- | lasso/id-ff/server.c | 75 | ||||
-rw-r--r-- | lasso/id-ff/server.h | 11 | ||||
-rw-r--r-- | lasso/id-wsf/discovery.c | 60 | ||||
-rw-r--r-- | lasso/id-wsf/profile_service.c | 24 | ||||
-rw-r--r-- | lasso/id-wsf/profile_service.h | 2 | ||||
-rw-r--r-- | lasso/xml/Makefile.am | 2 | ||||
-rw-r--r-- | lasso/xml/disco_resource_offering.c | 3 | ||||
-rw-r--r-- | lasso/xml/disco_service_instance.c | 10 | ||||
-rw-r--r-- | lasso/xml/disco_service_instance.h | 5 | ||||
-rw-r--r-- | lasso/xml/dst_data.c | 3 | ||||
-rw-r--r-- | lasso/xml/dst_data.h | 2 | ||||
-rw-r--r-- | lasso/xml/saml_attribute.c | 2 | ||||
-rw-r--r-- | lasso/xml/saml_attribute.h | 2 | ||||
-rw-r--r-- | lasso/xml/saml_attribute_statement.c | 2 | ||||
-rw-r--r-- | lasso/xml/saml_attribute_statement.h | 2 | ||||
-rw-r--r-- | lasso/xml/saml_attribute_value.c | 92 | ||||
-rw-r--r-- | lasso/xml/saml_attribute_value.h | 71 | ||||
-rw-r--r-- | swig/Lasso-wsf.i | 26 | ||||
-rw-r--r-- | swig/Lasso.i | 35 |
23 files changed, 443 insertions, 99 deletions
diff --git a/lasso/id-ff/login.c b/lasso/id-ff/login.c index c4761776..8ab92e88 100644 --- a/lasso/id-ff/login.c +++ b/lasso/id-ff/login.c @@ -24,8 +24,13 @@ #include <xmlsec/base64.h> +#include <lasso/xml/disco_description.h> +#include <lasso/xml/disco_resource_offering.h> +#include <lasso/xml/disco_service_instance.h> #include <lasso/xml/lib_authentication_statement.h> #include <lasso/xml/lib_subject.h> +#include <lasso/xml/saml_attribute.h> +#include <lasso/xml/saml_attribute_value.h> #include <lasso/xml/samlp_response.h> #include <lasso/id-ff/login.h> @@ -40,6 +45,8 @@ struct _LassoLoginPrivate { char *soap_request_msg; + LassoDiscoResourceID *resourceId; + LassoDiscoEncryptedResourceID *encryptedResourceId; }; /*****************************************************************************/ @@ -129,6 +136,39 @@ lasso_login_build_assertion(LassoLogin *login, LASSO_SAMLP_RESPONSE(profile->response)->Assertion = g_list_append(NULL, LASSO_SAML_ASSERTION(assertion)); } + + /* Bootstrapping : if server has a discovery service and if login->resourceId is set, + then add a AttributeStatement / ResourceOffering */ + { + LassoDiscoResourceOffering *resourceOffering; + LassoDiscoServiceInstance *serviceInstance; + + LassoSamlAttributeStatement *attributeStatement; + LassoSamlAttribute *attribute; + LassoSamlAttributeValue *attributeValue; + + serviceInstance = lasso_server_get_service(profile->server, LASSO_DISCO_HREF); + if (LASSO_IS_DISCO_SERVICE_INSTANCE(serviceInstance) == TRUE) { + + resourceOffering = lasso_disco_resource_offering_new(serviceInstance); + resourceOffering->ResourceID = g_object_ref( + login->private_data->resourceId); + + attributeValue = lasso_saml_attribute_value_new(); + attributeValue->any = g_list_append(attributeValue->any, resourceOffering); + + attribute = lasso_saml_attribute_new(); + attribute->AttributeValue = g_list_append(attribute->AttributeValue, + attributeValue); + + attributeStatement = lasso_saml_attribute_statement_new(); + attributeStatement->Attribute = g_list_append( + attributeStatement->Attribute, attribute); + + assertion->AttributeStatement = attributeStatement; + } + } + /* store assertion in session object */ if (profile->session == NULL) { profile->session = lasso_session_new(); @@ -1273,6 +1313,31 @@ lasso_login_process_response_msg(LassoLogin *login, gchar *response_msg) return lasso_login_process_response_status_and_assertion(login); } +int +lasso_login_set_encryptedResourceId(LassoLogin *login, + LassoDiscoEncryptedResourceID *encryptedResourceId) +{ + g_return_val_if_fail(LASSO_IS_LOGIN(login), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(LASSO_IS_DISCO_ENCRYPTED_RESOURCE_ID(encryptedResourceId), + LASSO_PARAM_ERROR_INVALID_VALUE); + + g_object_ref(encryptedResourceId); + login->private_data->encryptedResourceId = encryptedResourceId; + + return 0; +} + +int +lasso_login_set_resourceId(LassoLogin *login, const char *content) +{ + g_return_val_if_fail(LASSO_IS_LOGIN(login), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(content != NULL, LASSO_PARAM_ERROR_INVALID_VALUE); + + login->private_data->resourceId = lasso_disco_resource_id_new(content); + + return 0; +} + /*****************************************************************************/ /* private methods */ /*****************************************************************************/ diff --git a/lasso/id-ff/login.h b/lasso/id-ff/login.h index 2d80c0bf..347b2c0a 100644 --- a/lasso/id-ff/login.h +++ b/lasso/id-ff/login.h @@ -30,6 +30,8 @@ extern "C" { #endif /* __cplusplus */ +#include <lasso/xml/disco_encrypted_resource_id.h> +#include <lasso/xml/disco_resource_id.h> #include <lasso/xml/lib_authn_request.h> #include <lasso/xml/lib_authn_response.h> #include <lasso/xml/samlp_request.h> @@ -81,6 +83,11 @@ LASSO_EXPORT gint lasso_login_accept_sso(LassoLogin *login); LASSO_EXPORT gint lasso_login_build_artifact_msg(LassoLogin *login, LassoHttpMethod http_method); +LASSO_EXPORT int lasso_login_build_assertion(LassoLogin *login, + const char *authenticationMethod, const char *authenticationInstant, + const char *reauthenticateOnOrAfter, + const char *notBefore, const char *notOnOrAfter); + LASSO_EXPORT gint lasso_login_build_authn_request_msg(LassoLogin *login); LASSO_EXPORT gint lasso_login_build_authn_response_msg(LassoLogin *login); @@ -110,13 +117,14 @@ LASSO_EXPORT gint lasso_login_process_authn_response_msg(LassoLogin *login, LASSO_EXPORT gint lasso_login_process_request_msg(LassoLogin *login, gchar *request_msg); LASSO_EXPORT gint lasso_login_process_response_msg(LassoLogin *login, gchar *response_msg); +LASSO_EXPORT int lasso_login_set_encryptedResourceId( + LassoLogin *login, LassoDiscoEncryptedResourceID *encryptedResourceId); + +LASSO_EXPORT int lasso_login_set_resourceId(LassoLogin *login, const char *resourceId); + LASSO_EXPORT int lasso_login_validate_request_msg(LassoLogin *login, gboolean authentication_result, gboolean is_consent_obtained); -LASSO_EXPORT int lasso_login_build_assertion(LassoLogin *login, - const char *authenticationMethod, const char *authenticationInstant, - const char *reauthenticateOnOrAfter, - const char *notBefore, const char *notOnOrAfter); #ifdef __cplusplus } diff --git a/lasso/id-ff/profile.c b/lasso/id-ff/profile.c index a88eec39..9719d3f6 100644 --- a/lasso/id-ff/profile.c +++ b/lasso/id-ff/profile.c @@ -103,6 +103,7 @@ LassoRequestType lasso_profile_get_request_type_from_soap_msg(const gchar *soap) { xmlDoc *doc; + xmlNode *xmlnode; xmlXPathContext *xpathCtx; xmlXPathObject *xpathObj; LassoRequestType type = LASSO_REQUEST_TYPE_INVALID; @@ -131,7 +132,30 @@ lasso_profile_get_request_type_from_soap_msg(const gchar *soap) } else if (strcmp(name, "AuthnRequest") == 0) { type = LASSO_REQUEST_TYPE_LECP; } else { - message(G_LOG_LEVEL_WARNING, "Unkown node name : %s", name); + /* try to get type of wsf request */ + xmlnode = xpathObj->nodesetval->nodeTab[0]; + if (xmlnode->ns == NULL) { + return LASSO_REQUEST_TYPE_INVALID; + } + if ( strcmp(name, "Query") == 0 ) { + if ( strcmp(xmlnode->ns->href, LASSO_DISCO_HREF) == 0 ) { + type = LASSO_REQUEST_TYPE_DISCO_QUERY; + } + else { + type = LASSO_REQUEST_TYPE_DST_QUERY; + } + } + else if ( strcmp(name, "Modify") == 0 ) { + if ( strcmp(xmlnode->ns->href, LASSO_DISCO_HREF) == 0 ) { + type = LASSO_REQUEST_TYPE_DISCO_MODIFY; + } + else { + type = LASSO_REQUEST_TYPE_DST_MODIFY; + } + } + else { + message(G_LOG_LEVEL_WARNING, "Unkown node name : %s", name); + } } xmlFreeDoc(doc); diff --git a/lasso/id-ff/profile.h b/lasso/id-ff/profile.h index b20e64e8..102e1f73 100644 --- a/lasso/id-ff/profile.h +++ b/lasso/id-ff/profile.h @@ -58,7 +58,11 @@ typedef enum { LASSO_REQUEST_TYPE_DEFEDERATION = 3, LASSO_REQUEST_TYPE_NAME_REGISTRATION = 4, LASSO_REQUEST_TYPE_NAME_IDENTIFIER_MAPPING = 5, - LASSO_REQUEST_TYPE_LECP = 6 + LASSO_REQUEST_TYPE_LECP = 6, + LASSO_REQUEST_TYPE_DISCO_QUERY = 7, + LASSO_REQUEST_TYPE_DISCO_MODIFY = 8, + LASSO_REQUEST_TYPE_DST_QUERY = 9, + LASSO_REQUEST_TYPE_DST_MODIFY = 10, } LassoRequestType; typedef enum { diff --git a/lasso/id-ff/server.c b/lasso/id-ff/server.c index a7b1196c..ffe1a73e 100644 --- a/lasso/id-ff/server.c +++ b/lasso/id-ff/server.c @@ -68,6 +68,21 @@ lasso_server_add_provider(LassoServer *server, LassoProviderRole role, return 0; } +gint +lasso_server_add_service(LassoServer *server, LassoDiscoServiceInstance *service) +{ + g_return_val_if_fail(LASSO_IS_SERVER(server), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + g_return_val_if_fail(LASSO_IS_DISCO_SERVICE_INSTANCE(service), + LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); + + /* append new service */ + g_hash_table_insert(server->services, + g_strdup(service->ServiceType), + g_object_ref(service)); + + return 0; +} + /** * lasso_server_destroy: * @server: a #LassoServer @@ -100,6 +115,12 @@ add_provider_childnode(gchar *key, LassoProvider *value, xmlNode *xmlnode) xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(value), TRUE)); } +static void +add_service_childnode(gchar *key, LassoNode *value, xmlNode *xmlnode) +{ + xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(value), TRUE)); +} + static xmlNode* get_xmlNode(LassoNode *node, gboolean lasso_dump) { @@ -119,6 +140,14 @@ get_xmlNode(LassoNode *node, gboolean lasso_dump) (GHFunc)add_provider_childnode, t); } + /* Services */ + if (g_hash_table_size(server->services)) { + xmlNode *t; + t = xmlNewTextChild(xmlnode, NULL, "Services", NULL); + g_hash_table_foreach(server->services, + (GHFunc)add_service_childnode, t); + } + xmlCleanNs(xmlnode); return xmlnode; @@ -149,21 +178,41 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode) while (t) { xmlNode *t2 = t->children; LassoProvider *p; + LassoDiscoServiceInstance *s; - if (t->type != XML_ELEMENT_NODE || strcmp(t->name, "Providers") != 0) { + if (t->type != XML_ELEMENT_NODE) { t = t->next; continue; } - while (t2) { - if (t2->type != XML_ELEMENT_NODE) { + + /* Providers part */ + if (strcmp(t->name, "Providers") == 0) { + while (t2) { + if (t2->type != XML_ELEMENT_NODE) { + t2 = t2->next; + continue; + } + p = g_object_new(LASSO_TYPE_PROVIDER, NULL); + LASSO_NODE_GET_CLASS(p)->init_from_xml(LASSO_NODE(p), t2); + g_hash_table_insert(server->providers, g_strdup(p->ProviderID), p); + t2 = t2->next; + } + } + + /* Services part */ + else if (strcmp(t->name, "Services") == 0) { + while (t2) { + if (t2->type != XML_ELEMENT_NODE) { + t2 = t2->next; + continue; + } + s = g_object_new(LASSO_TYPE_DISCO_SERVICE_INSTANCE, NULL); + LASSO_NODE_GET_CLASS(s)->init_from_xml(LASSO_NODE(s), t2); + g_hash_table_insert(server->services, g_strdup(s->ServiceType), s); t2 = t2->next; - continue; } - p = g_object_new(LASSO_TYPE_PROVIDER, NULL); - LASSO_NODE_GET_CLASS(p)->init_from_xml(LASSO_NODE(p), t2); - g_hash_table_insert(server->providers, g_strdup(p->ProviderID), p); - t2 = t2->next; } + t = t->next; } return 0; @@ -212,6 +261,11 @@ lasso_server_get_provider(LassoServer *server, gchar *providerID) return g_hash_table_lookup(server->providers, providerID); } +LassoDiscoServiceInstance* +lasso_server_get_service(LassoServer *server, gchar *serviceType) +{ + return g_hash_table_lookup(server->services, serviceType); +} static gboolean get_providerID_with_hash(gchar *key, gpointer value, char **providerID) @@ -300,10 +354,15 @@ instance_init(LassoServer *server) server->providers = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, (GDestroyNotify)lasso_node_destroy); + server->private_key = NULL; server->secret_key = NULL; server->certificate = NULL; server->signature_method = LASSO_SIGNATURE_METHOD_RSA_SHA1; + + /* FIXME: set the value_destroy_func */ + server->services = g_hash_table_new_full(g_str_hash, g_str_equal, + (GDestroyNotify)g_free, NULL); } static void diff --git a/lasso/id-ff/server.h b/lasso/id-ff/server.h index 74b674c4..85d28718 100644 --- a/lasso/id-ff/server.h +++ b/lasso/id-ff/server.h @@ -29,8 +29,10 @@ extern "C" { #endif /* __cplusplus */ +#include <lasso/xml/disco_service_instance.h> #include <lasso/id-ff/provider.h> + #define LASSO_TYPE_SERVER (lasso_server_get_type()) #define LASSO_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_SERVER, LassoServer)) #define LASSO_SERVER_CLASS(klass) \ @@ -77,10 +79,17 @@ LASSO_EXPORT gint lasso_server_add_provider (LassoServer *server, LassoProviderRole role, const gchar *metadata, const gchar *public_key, const gchar *ca_cert_chain); +LASSO_EXPORT gint lasso_server_add_service(LassoServer *server, LassoDiscoServiceInstance *service); + LASSO_EXPORT void lasso_server_destroy(LassoServer *server); -LASSO_EXPORT LassoProvider* lasso_server_get_provider(LassoServer *server, gchar *providerID); + LASSO_EXPORT gchar* lasso_server_dump(LassoServer *server); +LASSO_EXPORT LassoProvider* lasso_server_get_provider(LassoServer *server, gchar *providerID); + +LASSO_EXPORT LassoDiscoServiceInstance* lasso_server_get_service(LassoServer *server, + gchar *serviceType); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lasso/id-wsf/discovery.c b/lasso/id-wsf/discovery.c index 8b4b06b4..3c1ba045 100644 --- a/lasso/id-wsf/discovery.c +++ b/lasso/id-wsf/discovery.c @@ -63,7 +63,10 @@ lasso_discovery_init_request(LassoDiscovery *discovery, message(G_LOG_LEVEL_CRITICAL, lasso_strerror(LASSO_PARAM_ERROR_INVALID_VALUE)); } /* get ResourceID/EncryptedResourceID in description */ + /* ResourceID and EncryptedResourceID are owned by resourceOffering, + so increment reference count */ if (resourceOffering->ResourceID != NULL) { + g_object_ref(resourceOffering->ResourceID); if (LASSO_IS_DISCO_MODIFY(profile->request)) { LASSO_DISCO_MODIFY(profile->request)->ResourceID = \ resourceOffering->ResourceID; @@ -74,6 +77,7 @@ lasso_discovery_init_request(LassoDiscovery *discovery, } } else if (resourceOffering->EncryptedResourceID != NULL) { + g_object_ref(resourceOffering->EncryptedResourceID); if (LASSO_IS_DISCO_MODIFY(profile->request)) { LASSO_DISCO_MODIFY(profile->request)->EncryptedResourceID = \ resourceOffering->EncryptedResourceID; @@ -84,7 +88,7 @@ lasso_discovery_init_request(LassoDiscovery *discovery, } } if (description->Endpoint != NULL) { - profile->msg_url = description->Endpoint; + profile->msg_url = g_strdup(description->Endpoint); } else if (description->WsdlURI != NULL) { /* TODO: get Endpoint at WsdlURI */ @@ -101,14 +105,11 @@ LassoDiscoInsertEntry* lasso_discovery_add_insert_entry(LassoDiscovery *discovery, const gchar *serviceType, const gchar *providerID, -/* GList *descriptions, */ LassoDiscoDescription *description, LassoDiscoResourceID *resourceID, LassoDiscoEncryptedResourceID *encryptedResourceID, -/* GList *options) */ const char *option) { - GList *descriptions = NULL; LassoDiscoInsertEntry *entry; LassoDiscoModify *modify; LassoDiscoOptions *opts; @@ -118,43 +119,29 @@ lasso_discovery_add_insert_entry(LassoDiscovery *discovery, g_return_val_if_fail(LASSO_IS_DISCOVERY(discovery), NULL); g_return_val_if_fail(serviceType!= NULL, NULL); g_return_val_if_fail(providerID != NULL, NULL); - /* only one description is required */ -/* g_return_val_if_fail(g_list_length(descriptions) >= 1, NULL); */ - /* resourceID/encryptedResourceID and options are optionals */ + /* resourceID/encryptedResourceID and option are optional */ g_return_val_if_fail((resourceID == NULL && encryptedResourceID == NULL) || \ (LASSO_IS_DISCO_RESOURCE_ID(resourceID) ^ \ LASSO_IS_DISCO_ENCRYPTED_RESOURCE_ID(encryptedResourceID)), NULL); modify = LASSO_DISCO_MODIFY(LASSO_WSF_PROFILE(discovery)->request); - /* create InsertEntry */ - entry = lasso_disco_insert_entry_new(); - /* create ServiceInstance */ - descriptions = g_list_append(descriptions, (gpointer)description); - service = lasso_disco_service_instance_new(serviceType, providerID, descriptions); - /* create ResourceOffering */ - resource = lasso_disco_resource_offering_new(service); - resource->ResourceID = resourceID; - resource->EncryptedResourceID = encryptedResourceID; + service = lasso_disco_service_instance_new(serviceType, providerID, description); + resource = lasso_disco_resource_offering_new(service); + /* ResourceID and EncryptedResourceID are owned by the method caller, + so increment reference count */ + resource->ResourceID = g_object_ref(resourceID); + resource->EncryptedResourceID = g_object_ref(encryptedResourceID); /* optional data */ - /* create Options */ -/* if (options != NULL) { */ -/* opts = lasso_disco_options_new(); */ -/* while (options != NULL) { */ -/* opts->Option = g_list_append(opts->Option, options->data); */ -/* options = g_list_next(options); */ -/* } */ -/* resource->Options = opts; */ -/* } */ if (option != NULL) { opts = lasso_disco_options_new(); - opts->Option = g_list_append(opts->Option, (gpointer)option); + opts->Option = g_list_append(opts->Option, g_strdup(option)); + resource->Options = opts; } + entry = lasso_disco_insert_entry_new(); entry->ResourceOffering = resource; - - /* add InsertEntry */ modify->InsertEntry = g_list_append(modify->InsertEntry, (gpointer)entry); return entry; @@ -170,9 +157,10 @@ lasso_discovery_add_remove_entry(LassoDiscovery *discovery, g_return_val_if_fail(entryID != NULL, LASSO_PARAM_ERROR_INVALID_VALUE); modify = LASSO_DISCO_MODIFY(LASSO_WSF_PROFILE(discovery)->request); + /* add RemoveEntry */ modify->RemoveEntry = g_list_append(modify->RemoveEntry, - (gpointer)lasso_disco_remove_entry_new(entryID)); + lasso_disco_remove_entry_new(entryID)); return 0; } @@ -180,7 +168,6 @@ lasso_discovery_add_remove_entry(LassoDiscovery *discovery, LassoDiscoRequestedServiceType* lasso_discovery_add_requested_service_type(LassoDiscovery *discovery, const gchar *serviceType, -/* GList *options) */ const char *option) { LassoDiscoQuery *query; @@ -189,23 +176,17 @@ lasso_discovery_add_requested_service_type(LassoDiscovery *discovery, g_return_val_if_fail(LASSO_IS_DISCOVERY(discovery), NULL); g_return_val_if_fail(serviceType != NULL, NULL); - /* options is optional */ + /* option is optional */ query = LASSO_DISCO_QUERY(LASSO_WSF_PROFILE(discovery)->request); rst = lasso_disco_requested_service_type_new(serviceType); /* optionals data */ - /* create Options */ if (option != NULL) { + opts = lasso_disco_options_new(); opts->Option = g_list_append(opts->Option, (gpointer)option); rst->Options = opts; -/* opts = lasso_disco_options_new(); */ -/* while (options != NULL) { */ -/* opts->Option = g_list_append(opts->Option, options->data); */ -/* options = g_list_next(options); */ -/* } */ -/* rst->Options = opts; */ } /* add RequestedServiceType */ @@ -356,7 +337,6 @@ static xmlNode* get_xmlNode(LassoNode *node, gboolean lasso_dump) { xmlNode *xmlnode; - LassoDiscovery *discovery = LASSO_DISCOVERY(node); xmlnode = parent_class->get_xmlNode(node, lasso_dump); xmlNodeSetName(xmlnode, "Discovery"); @@ -368,8 +348,6 @@ get_xmlNode(LassoNode *node, gboolean lasso_dump) static int init_from_xml(LassoNode *node, xmlNode *xmlnode) { - LassoDiscovery *discovery = LASSO_DISCOVERY(node); - xmlNode *t; int rc; rc = parent_class->init_from_xml(node, xmlnode); diff --git a/lasso/id-wsf/profile_service.c b/lasso/id-wsf/profile_service.c index d5c83a29..78e4268f 100644 --- a/lasso/id-wsf/profile_service.c +++ b/lasso/id-wsf/profile_service.c @@ -33,18 +33,25 @@ /*****************************************************************************/ gint -lasso_profile_service_add_data(LassoProfileService *service, LassoNode *requested_data) +lasso_profile_service_add_data(LassoProfileService *service, const char *xmlNodeBuffer) { LassoWsfProfile *profile; LassoDstData *data; - + xmlNode *root, *xmlnode; + xmlDoc *doc; + g_return_val_if_fail(LASSO_IS_PROFILE_SERVICE(service) == TRUE, -1); - g_return_val_if_fail(LASSO_IS_NODE(requested_data) == TRUE, -1); + g_return_val_if_fail(xmlNodeBuffer != NULL, -1); profile = LASSO_WSF_PROFILE(service); + /* xmlBuffer must be parsed and set in LassoDstData */ + doc = xmlParseMemory(xmlNodeBuffer, strlen(xmlNodeBuffer)); + root = xmlDocGetRootElement(doc); + xmlnode = xmlCopyNode(root, 1); + data = lasso_dst_data_new(); - data->any = g_list_append(data->any, requested_data); + data->any = g_list_append(data->any, xmlnode); LASSO_DST_QUERY_RESPONSE(profile->response)->Data = \ g_list_append(LASSO_DST_QUERY_RESPONSE(profile->response)->Data, data); @@ -137,7 +144,6 @@ lasso_profile_service_init_query(LassoProfileService *service, LassoDiscoDescription *description, const char *select) { - GList *l_desc; LassoDstQueryItem *query_item; LassoWsfProfile *profile; @@ -179,8 +185,6 @@ lasso_profile_service_process_modify_msg(LassoProfileService *service, const char *modify_soap_msg) { LassoDstModify *modify; - LassoDstModification *modification; - LassoDstModifyResponse *modification_response; LassoWsfProfile *profile; LassoUtilityStatus *status; @@ -212,8 +216,6 @@ lasso_profile_service_process_query_msg(LassoProfileService *service, const char *query_soap_msg) { LassoDstQuery *query; - LassoDstQueryItem *query_item; - LassoDstQueryResponse *query_response; LassoWsfProfile *profile; LassoUtilityStatus *status; @@ -243,7 +245,6 @@ lasso_profile_service_process_query_response_msg(LassoProfileService *service, const char *query_response_soap_msg) { LassoDstQueryResponse *query_response; - GList *Data; g_return_val_if_fail(LASSO_IS_PROFILE_SERVICE(service), -1); g_return_val_if_fail(query_response_soap_msg != NULL, -1); @@ -263,7 +264,6 @@ lasso_profile_service_process_modify_response_msg(LassoProfileService *service, const char *modify_response_soap_msg) { LassoDstModifyResponse *modify_response; - GList *Data; g_return_val_if_fail(LASSO_IS_PROFILE_SERVICE(service), -1); g_return_val_if_fail(modify_response_soap_msg != NULL, -1); @@ -281,8 +281,6 @@ lasso_profile_service_process_modify_response_msg(LassoProfileService *service, /* private methods */ /*****************************************************************************/ -static LassoProfileServiceClass *parent_class = NULL; - /*****************************************************************************/ /* instance and class init functions */ /*****************************************************************************/ diff --git a/lasso/id-wsf/profile_service.h b/lasso/id-wsf/profile_service.h index b31eea73..3af99dcd 100644 --- a/lasso/id-wsf/profile_service.h +++ b/lasso/id-wsf/profile_service.h @@ -74,7 +74,7 @@ LASSO_EXPORT LassoProfileService* lasso_profile_service_new(LassoServer *server) LASSO_EXPORT gint lasso_profile_service_add_data(LassoProfileService *service, - LassoNode *requested_data); + const char *xmlNodeBuffer); LASSO_EXPORT LassoDstModification* lasso_profile_service_add_modification( LassoProfileService *service, diff --git a/lasso/xml/Makefile.am b/lasso/xml/Makefile.am index 8b29dace..6aec6d05 100644 --- a/lasso/xml/Makefile.am +++ b/lasso/xml/Makefile.am @@ -71,6 +71,7 @@ liblasso_xml_la_SOURCES = \ saml_attribute.c \ saml_attribute_designator.c \ saml_attribute_statement.c \ + saml_attribute_value.c \ saml_audience_restriction_condition.c \ saml_authentication_statement.c \ saml_authority_binding.c \ @@ -154,6 +155,7 @@ liblassoinclude_HEADERS = \ saml_attribute.h \ saml_attribute_designator.h \ saml_attribute_statement.h \ + saml_attribute_value.h \ saml_audience_restriction_condition.h \ saml_authentication_statement.h \ saml_authority_binding.h \ diff --git a/lasso/xml/disco_resource_offering.c b/lasso/xml/disco_resource_offering.c index e9f0a7cb..5e1c4c8f 100644 --- a/lasso/xml/disco_resource_offering.c +++ b/lasso/xml/disco_resource_offering.c @@ -122,9 +122,10 @@ lasso_disco_resource_offering_new(LassoDiscoServiceInstance *serviceInstance) g_return_val_if_fail(LASSO_IS_DISCO_SERVICE_INSTANCE(serviceInstance), NULL); + g_object_ref(serviceInstance); + resource = g_object_new(LASSO_TYPE_DISCO_RESOURCE_OFFERING, NULL); - /* FIXME: Should ServiceInstance be copy ? */ resource->ServiceInstance = serviceInstance; return resource; diff --git a/lasso/xml/disco_service_instance.c b/lasso/xml/disco_service_instance.c index 808b31e2..87efd635 100644 --- a/lasso/xml/disco_service_instance.c +++ b/lasso/xml/disco_service_instance.c @@ -102,21 +102,23 @@ lasso_disco_service_instance_get_type() LassoDiscoServiceInstance* lasso_disco_service_instance_new(const gchar *serviceType, const gchar *providerID, - GList *descriptions) + LassoDiscoDescription *description) { LassoDiscoServiceInstance *service_instance; g_return_val_if_fail (serviceType != NULL, NULL); g_return_val_if_fail (providerID != NULL, NULL); - g_return_val_if_fail(g_list_length(descriptions) >= 1, NULL); + g_return_val_if_fail(LASSO_IS_DISCO_DESCRIPTION(description) == TRUE, NULL); + + g_object_ref(description); service_instance = g_object_new(LASSO_TYPE_DISCO_SERVICE_INSTANCE, NULL); service_instance->ServiceType = g_strdup(serviceType); service_instance->ProviderID = g_strdup(providerID); - /* FIXME: should Description be a copy ??*/ - service_instance->Description = descriptions; + service_instance->Description = g_list_append(service_instance->Description, + description); return service_instance; } diff --git a/lasso/xml/disco_service_instance.h b/lasso/xml/disco_service_instance.h index cb9a27a8..b188f8a5 100644 --- a/lasso/xml/disco_service_instance.h +++ b/lasso/xml/disco_service_instance.h @@ -64,9 +64,8 @@ struct _LassoDiscoServiceInstanceClass { LASSO_EXPORT GType lasso_disco_service_instance_get_type(void); -LASSO_EXPORT LassoDiscoServiceInstance* lasso_disco_service_instance_new(const gchar *serviceType, - const gchar *providerID, - GList *descriptions); +LASSO_EXPORT LassoDiscoServiceInstance* lasso_disco_service_instance_new( + const gchar *serviceType, const gchar *providerID, LassoDiscoDescription *description); #ifdef __cplusplus } diff --git a/lasso/xml/dst_data.c b/lasso/xml/dst_data.c index 5f09240c..522329df 100644 --- a/lasso/xml/dst_data.c +++ b/lasso/xml/dst_data.c @@ -53,12 +53,13 @@ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { - { "any", SNIPPET_LIST_NODES, G_STRUCT_OFFSET(LassoDstData, any) }, + { "", SNIPPET_LIST_XMLNODES, G_STRUCT_OFFSET(LassoDstData, any) }, { "id", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoDstData, id) }, { "itemIDRef", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoDstData, itemIDRef) }, { NULL, 0, 0} }; + /*****************************************************************************/ /* instance and class init functions */ /*****************************************************************************/ diff --git a/lasso/xml/dst_data.h b/lasso/xml/dst_data.h index e027187f..576759e5 100644 --- a/lasso/xml/dst_data.h +++ b/lasso/xml/dst_data.h @@ -46,7 +46,7 @@ typedef struct _LassoDstDataClass LassoDstDataClass; struct _LassoDstData { LassoNode parent; - GList *any; + GList *any; /* list of xmlNodes */ char *id; char *itemIDRef; diff --git a/lasso/xml/saml_attribute.c b/lasso/xml/saml_attribute.c index 2fef5484..fabbed6f 100644 --- a/lasso/xml/saml_attribute.c +++ b/lasso/xml/saml_attribute.c @@ -115,7 +115,7 @@ lasso_saml_attribute_get_type() * * Return value: a newly created #LassoSamlAttribute object **/ -LassoNode* +LassoSamlAttribute* lasso_saml_attribute_new() { return g_object_new(LASSO_TYPE_SAML_ATTRIBUTE, NULL); diff --git a/lasso/xml/saml_attribute.h b/lasso/xml/saml_attribute.h index 910992fb..82ba2fc2 100644 --- a/lasso/xml/saml_attribute.h +++ b/lasso/xml/saml_attribute.h @@ -58,7 +58,7 @@ struct _LassoSamlAttributeClass { }; LASSO_EXPORT GType lasso_saml_attribute_get_type(void); -LASSO_EXPORT LassoNode* lasso_saml_attribute_new(void); +LASSO_EXPORT LassoSamlAttribute* lasso_saml_attribute_new(void); #ifdef __cplusplus } diff --git a/lasso/xml/saml_attribute_statement.c b/lasso/xml/saml_attribute_statement.c index dbd078d9..55e0b0cd 100644 --- a/lasso/xml/saml_attribute_statement.c +++ b/lasso/xml/saml_attribute_statement.c @@ -102,7 +102,7 @@ lasso_saml_attribute_statement_get_type() * * Return value: a newly created #LassoSamlAttributeStatement object **/ -LassoNode* +LassoSamlAttributeStatement* lasso_saml_attribute_statement_new() { return g_object_new(LASSO_TYPE_SAML_ATTRIBUTE_STATEMENT, NULL); diff --git a/lasso/xml/saml_attribute_statement.h b/lasso/xml/saml_attribute_statement.h index b56889e5..6fbe2ebc 100644 --- a/lasso/xml/saml_attribute_statement.h +++ b/lasso/xml/saml_attribute_statement.h @@ -62,7 +62,7 @@ struct _LassoSamlAttributeStatementClass { }; LASSO_EXPORT GType lasso_saml_attribute_statement_get_type(void); -LASSO_EXPORT LassoNode* lasso_saml_attribute_statement_new(void); +LASSO_EXPORT LassoSamlAttributeStatement* lasso_saml_attribute_statement_new(void); #ifdef __cplusplus } diff --git a/lasso/xml/saml_attribute_value.c b/lasso/xml/saml_attribute_value.c new file mode 100644 index 00000000..c7a61e32 --- /dev/null +++ b/lasso/xml/saml_attribute_value.c @@ -0,0 +1,92 @@ +/* $Id$ + * + * Lasso - A free implementation of the Samlerty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: Nicolas Clapies <nclapies@entrouvert.com> + * Valery Febvre <vfebvre@easter-eggs.com> + * + * 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/saml_attribute_value.h> + +/* + * The schema fragment (oasis-sstc-saml-schema-assertion-1.1.xsd): + * + */ + +/*****************************************************************************/ +/* private methods */ +/*****************************************************************************/ + +static struct XmlSnippet schema_snippets[] = { + { "", SNIPPET_LIST_NODES, G_STRUCT_OFFSET(LassoSamlAttributeValue, any) }, + { NULL, 0, 0 } +}; + +/*****************************************************************************/ +/* instance and class init functions */ +/*****************************************************************************/ + +static void +instance_init(LassoSamlAttributeValue *node) +{ + node->any = NULL; +} + +static void +class_init(LassoSamlAttributeValueClass *klass) +{ + LassoNodeClass *nclass = LASSO_NODE_CLASS(klass); + + nclass->node_data = g_new0(LassoNodeClassData, 1); + lasso_node_class_set_nodename(nclass, "AttributeValue"); + lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX); + lasso_node_class_add_snippets(nclass, schema_snippets); +} + +GType +lasso_saml_attribute_value_get_type() +{ + static GType this_type = 0; + + if (!this_type) { + static const GTypeInfo this_info = { + sizeof (LassoSamlAttributeValueClass), + NULL, + NULL, + (GClassInitFunc) class_init, + NULL, + NULL, + sizeof(LassoSamlAttributeValue), + 0, + (GInstanceInitFunc) instance_init, + }; + + this_type = g_type_register_static(LASSO_TYPE_NODE, + "LassoSamlAttributeValue", + &this_info, 0); + } + return this_type; +} + +LassoSamlAttributeValue* +lasso_saml_attribute_value_new() +{ + return g_object_new(LASSO_TYPE_SAML_ATTRIBUTE_VALUE, NULL); +} diff --git a/lasso/xml/saml_attribute_value.h b/lasso/xml/saml_attribute_value.h new file mode 100644 index 00000000..c20aecc8 --- /dev/null +++ b/lasso/xml/saml_attribute_value.h @@ -0,0 +1,71 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: Nicolas Clapies <nclapies@entrouvert.com> + * Valery Febvre <vfebvre@easter-eggs.com> + * + * 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_SAML_ATTRIBUTE_VALUE_H__ +#define __LASSO_SAML_ATTRIBUTE_VALUE_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <lasso/xml/xml.h> + +#define LASSO_TYPE_SAML_ATTRIBUTE_VALUE (lasso_saml_attribute_value_get_type()) +#define LASSO_SAML_ATTRIBUTE_VALUE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_SAML_ATTRIBUTE_VALUE, \ + LassoSamlAttributeValue)) +#define LASSO_SAML_ATTRIBUTE_VALUE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_SAML_ATTRIBUTE_VALUE, \ + LassoSamlAttributeValueClass)) +#define LASSO_IS_SAML_ATTRIBUTE_VALUE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_SAML_ATTRIBUTE_VALUE)) +#define LASSO_IS_SAML_ATTRIBUTE_VALUE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_SAML_ATTRIBUTE_VALUE)) +#define LASSO_SAML_ATTRIBUTE_VALUE_GET_CLASS(o) \ + (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_SAML_ATTRIBUTE_VALUE, \ + LassoSamlAttributeValueClass)) + +typedef struct _LassoSamlAttributeValue LassoSamlAttributeValue; +typedef struct _LassoSamlAttributeValueClass LassoSamlAttributeValueClass; + +struct _LassoSamlAttributeValue { + LassoNode parent; + + /*< public >*/ + GList *any; +}; + +struct _LassoSamlAttributeValueClass { + LassoNodeClass parent; +}; + +LASSO_EXPORT GType lasso_saml_attribute_value_get_type(void); +LASSO_EXPORT LassoSamlAttributeValue* lasso_saml_attribute_value_new(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LASSO_SAML_ATTRIBUTE_VALUE_H__ */ diff --git a/swig/Lasso-wsf.i b/swig/Lasso-wsf.i index 5a9f1fc9..55697746 100644 --- a/swig/Lasso-wsf.i +++ b/swig/Lasso-wsf.i @@ -1033,8 +1033,8 @@ typedef struct { /* Constructor, Destructor & Static Methods */ - /* FIXME: Add typemap for LassoNodeList *description. */ - LassoDiscoServiceInstance(char *serviceType, char *providerID, void *description = NULL); + LassoDiscoServiceInstance(char *serviceType, char *providerID, + LassoDiscoDescription *description); ~LassoDiscoServiceInstance(); @@ -1095,7 +1095,7 @@ typedef struct { /* Attributes */ %newobject any_get; - LassoNodeList *any; + LassoStringList *any; /* Constructor, Destructor & Static Methods */ @@ -1114,10 +1114,10 @@ typedef struct { /* Attributes Implementations */ /* any */ -#define LassoDstData_get_any(self) get_node_list((self)->any) -#define LassoDstData_any_get(self) get_node_list((self)->any) -#define LassoDstData_set_any(self, value) set_node_list(&(self)->any, (value)) -#define LassoDstData_any_set(self, value) set_node_list(&(self)->any, (value)) +#define LassoDstData_get_any(self) get_xml_list((self)->any) +#define LassoDstData_any_get(self) get_xml_list((self)->any) +#define LassoDstData_set_any(self, value) set_xml_list(&(self)->any, (value)) +#define LassoDstData_any_set(self, value) set_xml_list(&(self)->any, (value)) /* Constructors, destructors & static methods implementations */ @@ -1382,7 +1382,7 @@ typedef struct { /* Attributes */ %newobject any_get; - LassoNodeList *any; + LassoStringList *any; /* Constructor, Destructor & Static Methods */ @@ -1401,10 +1401,10 @@ typedef struct { /* Attributes Implementations */ /* any */ -#define LassoDstNewData_get_any(self) get_node_list((self)->any) -#define LassoDstNewData_any_get(self) get_node_list((self)->any) -#define LassoDstNewData_set_any(self, value) set_node_list(&(self)->any, (value)) -#define LassoDstNewData_any_set(self, value) set_node_list(&(self)->any, (value)) +#define LassoDstNewData_get_any(self) get_xml_list((self)->any) +#define LassoDstNewData_any_get(self) get_xml_list((self)->any) +#define LassoDstNewData_set_any(self, value) set_xml_list(&(self)->any, (value)) +#define LassoDstNewData_any_set(self, value) set_xml_list(&(self)->any, (value)) /* Constructors, destructors & static methods implementations */ @@ -2813,7 +2813,7 @@ typedef struct { /* Methods */ THROW_ERROR - int addData(LassoNode *data); + int addData(char *xmlNodeBuffer); END_THROW_ERROR LassoDstModification *addModification(char *select); diff --git a/swig/Lasso.i b/swig/Lasso.i index 49e75d17..bf99356a 100644 --- a/swig/Lasso.i +++ b/swig/Lasso.i @@ -47,6 +47,9 @@ #include <lasso/lasso.h> #include <lasso/xml/lib_assertion.h> +#include <lasso/xml/disco_resource_id.h> +#include <lasso/xml/disco_encrypted_resource_id.h> + %} /* GLib types */ @@ -820,6 +823,10 @@ typedef enum { %rename(REQUEST_TYPE_NAME_REGISTRATION) LASSO_REQUEST_TYPE_NAME_REGISTRATION; %rename(REQUEST_TYPE_NAME_IDENTIFIER_MAPPING) LASSO_REQUEST_TYPE_NAME_IDENTIFIER_MAPPING; %rename(REQUEST_TYPE_LECP) LASSO_REQUEST_TYPE_LECP; +%rename(REQUEST_TYPE_DISCO_QUERY) LASSO_REQUEST_TYPE_DISCO_QUERY; +%rename(REQUEST_TYPE_DISCO_MODIFY) LASSO_REQUEST_TYPE_DISCO_MODIFY; +%rename(REQUEST_TYPE_DST_QUERY) LASSO_REQUEST_TYPE_DST_QUERY; +%rename(REQUEST_TYPE_DST_MODIFY) LASSO_REQUEST_TYPE_DST_MODIFY; %rename(RequestType) LassoRequestType; #endif typedef enum { @@ -829,7 +836,11 @@ typedef enum { LASSO_REQUEST_TYPE_DEFEDERATION = 3, LASSO_REQUEST_TYPE_NAME_REGISTRATION = 4, LASSO_REQUEST_TYPE_NAME_IDENTIFIER_MAPPING = 5, - LASSO_REQUEST_TYPE_LECP = 6 + LASSO_REQUEST_TYPE_LECP = 6, + LASSO_REQUEST_TYPE_DISCO_QUERY = 7, + LASSO_REQUEST_TYPE_DISCO_MODIFY = 8, + LASSO_REQUEST_TYPE_DST_QUERY = 9, + LASSO_REQUEST_TYPE_DST_MODIFY = 10, } LassoRequestType; /* lib:AuthnContextClassRef */ @@ -4777,6 +4788,8 @@ typedef struct { %rename(Server) LassoServer; #endif typedef struct { + /* Attributes */ + char *certificate; #ifndef SWIGPHP4 @@ -4857,15 +4870,21 @@ typedef struct { /* Methods */ - THROW_ERROR + THROW_ERROR int addProvider(LassoProviderRole role, char *metadata, char *publicKey = NULL, char *caCertChain = NULL); END_THROW_ERROR + THROW_ERROR + int addService(LassoDiscoServiceInstance *service); + END_THROW_ERROR + %newobject dump; char *dump(); LassoProvider *getProvider(char *providerId); + + LassoDiscoServiceInstance *getService(char *serviceType); } %{ @@ -4928,8 +4947,10 @@ LassoStringList *LassoServer_providerIds_get(LassoServer *self) { /* Methods implementations */ #define LassoServer_addProvider lasso_server_add_provider +#define LassoServer_addService lasso_server_add_service #define LassoServer_dump lasso_server_dump #define LassoServer_getProvider lasso_server_get_provider +#define LassoServer_getService lasso_server_get_service %} @@ -5513,6 +5534,14 @@ typedef struct { END_THROW_ERROR THROW_ERROR + int setEncryptedResourceId(LassoDiscoEncryptedResourceID *encryptedResourceId); + END_THROW_ERROR + + THROW_ERROR + int setResourceId(char *content); + END_THROW_ERROR + + THROW_ERROR int validateRequestMsg(gboolean authenticationResult, gboolean isConsentObtained); END_THROW_ERROR } @@ -5622,6 +5651,8 @@ int LassoLogin_setSessionFromDump(LassoLogin *self, char *dump) { #define LassoLogin_processAuthnResponseMsg lasso_login_process_authn_response_msg #define LassoLogin_processRequestMsg lasso_login_process_request_msg #define LassoLogin_processResponseMsg lasso_login_process_response_msg +#define LassoLogin_setEncryptedResourceId lasso_login_set_encryptedResourceId +#define LassoLogin_setResourceId lasso_login_set_resourceId #define LassoLogin_validateRequestMsg lasso_login_validate_request_msg %} |