diff options
| author | Nicolas Clapies <nclapies@entrouvert.com> | 2004-07-12 10:03:38 +0000 |
|---|---|---|
| committer | Nicolas Clapies <nclapies@entrouvert.com> | 2004-07-12 10:03:38 +0000 |
| commit | 7175b7c6937d9f5a4e6e94094f8e0ffbb1e0054c (patch) | |
| tree | 0bc21abae6e851c3e3437fe2af66cbe5002ad49c | |
| parent | f8b363262daaa664446c382b88b4cdb1de2ac08c (diff) | |
| download | lasso-7175b7c6937d9f5a4e6e94094f8e0ffbb1e0054c.tar.gz lasso-7175b7c6937d9f5a4e6e94094f8e0ffbb1e0054c.tar.xz lasso-7175b7c6937d9f5a4e6e94094f8e0ffbb1e0054c.zip | |
register name identifier profile
| -rw-r--r-- | lasso/Attic/protocols/provider.c | 12 | ||||
| -rw-r--r-- | lasso/Attic/protocols/provider.h | 42 | ||||
| -rw-r--r-- | lasso/id-ff/Makefile.am | 2 | ||||
| -rw-r--r-- | lasso/id-ff/register_name_identifier.c | 291 | ||||
| -rw-r--r-- | lasso/id-ff/register_name_identifier.h | 85 |
5 files changed, 415 insertions, 17 deletions
diff --git a/lasso/Attic/protocols/provider.c b/lasso/Attic/protocols/provider.c index c906552a..a1f96541 100644 --- a/lasso/Attic/protocols/provider.c +++ b/lasso/Attic/protocols/provider.c @@ -73,6 +73,18 @@ lasso_provider_get_providerID(LassoProvider *provider) } xmlChar * +lasso_provider_get_registerNameIdentifierProtocolProfile(LassoProvider *provider) +{ + return(lasso_node_get_child_content(provider->metadata, "RegisterNameIdentifierProtocolProfile", NULL)); +} + +xmlChar * +lasso_provider_get_registerNameIdentifierServiceURL(LassoProvider *provider) +{ + return(lasso_node_get_child_content(provider->metadata, "RegisterNameIdentifierServiceURL", NULL)); +} + +xmlChar * lasso_provider_get_singleSignOnProtocolProfile(LassoProvider *provider) { return(lasso_node_get_child_content(provider->metadata, "SingleSignOnProtocolProfile", NULL)); diff --git a/lasso/Attic/protocols/provider.h b/lasso/Attic/protocols/provider.h index cd5a9946..bf58c332 100644 --- a/lasso/Attic/protocols/provider.h +++ b/lasso/Attic/protocols/provider.h @@ -60,33 +60,41 @@ struct _LassoProviderClass { GObjectClass parent; }; -LASSO_EXPORT GType lasso_provider_get_type (void); +LASSO_EXPORT GType lasso_provider_get_type (void); -LASSO_EXPORT LassoProvider *lasso_provider_new (gchar *metadata_filename, - gchar *public_key_filename, - gchar *certificate_filename); +LASSO_EXPORT LassoProvider *lasso_provider_new (gchar *metadata_filename, + gchar *public_key_filename, + gchar *certificate_filename); -LASSO_EXPORT LassoProvider *lasso_provider_new_metadata_xmlNode (xmlNodePtr metadata_xmlNode); -LASSO_EXPORT LassoProvider *lasso_provider_new_metadata_filename (xmlChar *metadata_filename); +LASSO_EXPORT LassoProvider *lasso_provider_new_metadata_xmlNode (xmlNodePtr metadata_xmlNode); -LASSO_EXPORT xmlChar *lasso_provider_get_assertionConsumerServiceURL (LassoProvider *provider); +LASSO_EXPORT LassoProvider *lasso_provider_new_metadata_filename (xmlChar *metadata_filename); -LASSO_EXPORT xmlChar *lasso_provider_get_federationTerminationNotificationProtocolProfile(LassoProvider *provider); +LASSO_EXPORT xmlChar *lasso_provider_get_assertionConsumerServiceURL (LassoProvider *provider); -LASSO_EXPORT xmlChar *lasso_provider_get_federationTerminationNotificationServiceURL(LassoProvider *provider); +LASSO_EXPORT xmlChar *lasso_provider_get_federationTerminationNotificationProtocolProfile (LassoProvider *provider); -LASSO_EXPORT xmlChar *lasso_provider_dump (LassoProvider *provider); +LASSO_EXPORT xmlChar *lasso_provider_get_federationTerminationNotificationServiceURL (LassoProvider *provider); -LASSO_EXPORT xmlChar *lasso_provider_get_providerID (LassoProvider *provider); +LASSO_EXPORT xmlChar *lasso_provider_dump (LassoProvider *provider); -LASSO_EXPORT xmlChar *lasso_provider_get_singleSignOnProtocolProfile (LassoProvider *provider); -LASSO_EXPORT xmlChar *lasso_provider_get_singleSignOnServiceURL (LassoProvider *provider); +LASSO_EXPORT xmlChar *lasso_provider_get_providerID (LassoProvider *provider); -LASSO_EXPORT xmlChar *lasso_provider_get_singleLogoutProtocolProfile (LassoProvider *provider); -LASSO_EXPORT xmlChar *lasso_provider_get_singleLogoutServiceURL (LassoProvider *provider); -LASSO_EXPORT xmlChar *lasso_provider_get_singleLogoutServiceReturnURL (LassoProvider *provider); +LASSO_EXPORT xmlChar *lasso_provider_get_registerNameIdentifierProtocolProfile (LassoProvider *provider); -LASSO_EXPORT xmlChar* lasso_provider_get_soapEndpoint (LassoProvider *provider); +LASSO_EXPORT xmlChar *lasso_provider_get_registerNameIdentifierServiceURL (LassoProvider *provider); + +LASSO_EXPORT xmlChar *lasso_provider_get_singleSignOnProtocolProfile (LassoProvider *provider); + +LASSO_EXPORT xmlChar *lasso_provider_get_singleSignOnServiceURL (LassoProvider *provider); + +LASSO_EXPORT xmlChar *lasso_provider_get_singleLogoutProtocolProfile (LassoProvider *provider); + +LASSO_EXPORT xmlChar *lasso_provider_get_singleLogoutServiceURL (LassoProvider *provider); + +LASSO_EXPORT xmlChar *lasso_provider_get_singleLogoutServiceReturnURL (LassoProvider *provider); + +LASSO_EXPORT xmlChar* lasso_provider_get_soapEndpoint (LassoProvider *provider); #ifdef __cplusplus } diff --git a/lasso/id-ff/Makefile.am b/lasso/id-ff/Makefile.am index b0a17ed7..3d67ef02 100644 --- a/lasso/id-ff/Makefile.am +++ b/lasso/id-ff/Makefile.am @@ -19,6 +19,7 @@ liblasso_environs_la_SOURCES = \ login.c \ logout.c \ profile_context.c \ + register_name_identifier.c \ server.c \ user.c @@ -27,5 +28,6 @@ liblassoinclude_HEADERS = \ login.h \ logout.h \ profile_context.h \ + register_name_identifier.h \ server.h \ user.h diff --git a/lasso/id-ff/register_name_identifier.c b/lasso/id-ff/register_name_identifier.c new file mode 100644 index 00000000..aae154e0 --- /dev/null +++ b/lasso/id-ff/register_name_identifier.c @@ -0,0 +1,291 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Author: 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/environs/register_name_identifier.h> + +/*****************************************************************************/ +/* public methods */ +/*****************************************************************************/ + +gchar * +lasso_register_name_identifier_dump(LassoRegisterNameIdentifier *register_name_identifier) +{ + LassoProfileContext *profileContext; + gchar *dump; + + g_return_val_if_fail(LASSO_IS_REGISTER_NAME_IDENTIFIER(register_name_identifier), NULL); + + return(dump); +} + +gint +lasso_register_name_identifier_build_request_msg(LassoRegisterNameIdentifier *register_name_identifier) +{ + LassoProfileContext *profileContext; + LassoProvider *provider; + xmlChar *protocolProfile; + + g_return_val_if_fail(LASSO_IS_REGISTER_NAME_IDENTIFIER(register_name_identifier), -1); + + profileContext = LASSO_PROFILE_CONTEXT(register_name_identifier); + + /* get the prototocol profile of the register_name_identifier */ + provider = lasso_server_get_provider(profileContext->server, profileContext->remote_providerID); + if(provider==NULL){ + debug(ERROR, "Provider %s not found\n", profileContext->remote_providerID); + return(-2); + } + + protocolProfile = lasso_provider_get_registerNameIdentifierProtocolProfile(provider); + if(protocolProfile==NULL){ + debug(ERROR, "Register name identifier protocol profile not found\n"); + return(-3); + } + + if(xmlStrEqual(protocolProfile, lassoLibProtocolProfileRniSpSoap) || xmlStrEqual(protocolProfile, lassoLibProtocolProfileRniIdpSoap)){ + debug(DEBUG, "building a soap request message\n"); + profileContext->request_type = lassoHttpMethodSoap; + profileContext->msg_url = lasso_provider_get_singleRegisterNameIdentifierServiceURL(provider); + profileContext->msg_body = lasso_node_export_to_soap(profileContext->request); + } + else if(xmlStrEqual(protocolProfile,lassoLibProtocolProfileRniSpHttp)||xmlStrEqual(protocolProfile,lassoLibProtocolProfileRniIdpHttp)){ + debug(DEBUG, "building a http get request message\n"); + profileContext->request_type = lassoHttpMethodRedirect; + profileContext->msg_url = lasso_node_export_to_query(profileContext->request, + profileContext->server->signature_method, + profileContext->server->private_key); + profileContext->msg_body = NULL; + } + + return(0); +} + +gint +lasso_register_name_identifier_build_response_msg(LassoRegisterNameIdentifier *register_name_identifier) +{ + LassoProfileContext *profileContext; + LassoProvider *provider; + xmlChar *protocolProfile; + + g_return_val_if_fail(LASSO_IS_REGISTER_NAME_IDENTIFIER(register_name_identifier), -1); + + profileContext = LASSO_PROFILE_CONTEXT(register_name_identifier); + + provider = lasso_server_get_provider(profileContext->server, profileContext->remote_providerID); + if(provider==NULL){ + debug(ERROR, "Provider %s not found\n", profileContext->remote_providerID); + return(-2); + } + + protocolProfile = lasso_provider_get_registerNameIdentifierProtocolProfile(provider); + if(protocolProfile==NULL){ + debug(ERROR, "Single Register_Name_Identifier Protocol profile not found\n"); + return(-3); + } + + if(xmlStrEqual(protocolProfile, lassoLibProtocolProfileRniSpSoap) || xmlStrEqual(protocolProfile, lassoLibProtocolProfileRniIdpSoap)){ + debug(DEBUG, "building a soap response message\n"); + profileContext->msg_url = lasso_provider_get_singleRegisterNameIdentifierServiceURL(provider); + profileContext->msg_body = lasso_node_export_to_soap(profileContext->response); + } + else if(xmlStrEqual(protocolProfile,lassoLibProtocolProfileRniSpHttp)||xmlStrEqual(protocolProfile,lassoLibProtocolProfileRniIdpHttp)){ + debug(DEBUG, "building a http get response message\n"); + profileContext->response_type = lassoHttpMethodRedirect; + profileContext->msg_url = lasso_node_export_to_query(profileContext->response, + profileContext->server->signature_method, + profileContext->server->private_key); + profileContext->msg_body = NULL; + } + + return(0); +} + +gint +lasso_register_name_identifier_init_request(LassoRegisterNameIdentifier *register_name_identifier, + gchar *remote_providerID) +{ + LassoProfileContext *profileContext; + LassoNode *nameIdentifier; + LassoIdentity *identity; + LassoRegisterNameIdentifierRequest *request; + + xmlChar *content, *nameQualifier, *format; + + g_return_val_if_fail(LASSO_IS_REGISTER_NAME_IDENTIFIER(register_name_identifier), -1); + + profileContext = LASSO_PROFILE_CONTEXT(register_name_identifier); + + profileContext->remote_providerID = remote_providerID; + + /* get identity */ + identity = lasso_user_get_identity(profileContext->user, profileContext->remote_providerID); + if(identity==NULL){ + debug(ERROR, "error, identity not found\n"); + return(-2); + } + + /* TODO : implement the setting of the request */ + + return(0); +} + +gint +lasso_register_name_identifier_handle_request_msg(LassoRegisterNameIdentifier *register_name_identifier, + gchar *request_msg, + lassoHttpMethods request_method) +{ + LassoProfileContext *profileContext; + LassoIdentity *identity; + LassoNode *nameIdentifier, *assertion; + LassoNode *statusCode; + LassoNodeClass *statusCode_class; + xmlChar *remote_providerID; + + profileContext = LASSO_PROFILE_CONTEXT(register_name_identifier); + + switch(request_method){ + case lassoHttpMethodSoap: + debug(DEBUG, "build a register_name_identifier request from soap msg\n"); + profileContext->request = lasso_register_name_identifier_request_new_from_soap(request_msg); + break; + case lassoHttpMethodRedirect: + debug(DEBUG, "build a register_name_identifier request from query msg\n"); + profileContext->request = lasso_register_name_identifier_request_new_from_query(request_msg); + break; + case lassoHttpMethodGet: + debug(WARNING, "TODO, implement the get method\n"); + break; + default: + debug(ERROR, "Unknown request method\n"); + return(-1); + } + + /* set the remote provider id from the request */ + remote_providerID = lasso_node_get_child_content(profileContext->request, "ProviderID", NULL); + profileContext->remote_providerID = remote_providerID; + + /* set RegisterNameIdentifierResponse */ + profileContext->response = lasso_register_name_identifier_response_new( + lasso_provider_get_providerID(LASSO_PROVIDER(profileContext->server)), + lassoSamlStatusCodeSuccess, + profileContext->request); + + statusCode = lasso_node_get_child(profileContext->response, "StatusCode", NULL); + statusCode_class = LASSO_NODE_GET_CLASS(statusCode); + + nameIdentifier = lasso_node_get_child(profileContext->request, "NameIdentifier", NULL); + if(nameIdentifier==NULL){ + statusCode_class->set_prop(statusCode, "Value", lassoLibStatusCodeFederationDoesNotExist); + return(-2); + } + + remote_providerID = lasso_node_get_child_content(profileContext->request, "ProviderID", NULL); + + + return(0); +} + +gint +lasso_register_name_identifier_handle_response_msg(LassoRegisterNameIdentifier *register_name_identifier, + gchar *response_msg, + lassoHttpMethods response_method) +{ + LassoProfileContext *profileContext; + xmlChar *statusCodeValue; + LassoNode *statusCode; + + profileContext = LASSO_PROFILE_CONTEXT(register_name_identifier); + + /* parse RegisterNameIdentifierResponse */ + switch(response_method){ + case lassoHttpMethodSoap: + profileContext->response = lasso_register_name_identifier_response_new_from_soap(response_msg); + } + + statusCode = lasso_node_get_child(profileContext->response, "StatusCode", NULL); + statusCodeValue = lasso_node_get_attr_value(statusCode, "Value"); + if(!xmlStrEqual(statusCodeValue, lassoSamlStatusCodeSuccess)){ + return(-1); + } + + return(0); +} + +/*****************************************************************************/ +/* instance and class init functions */ +/*****************************************************************************/ + +static void +lasso_register_name_identifier_instance_init(LassoRegisterNameIdentifier *register_name_identifier){ +} + +static void +lasso_register_name_identifier_class_init(LassoRegisterNameIdentifierClass *klass) { +} + +GType lasso_register_name_identifier_get_type() { + static GType this_type = 0; + + if (!this_type) { + static const GTypeInfo this_info = { + sizeof (LassoRegisterNameIdentifierClass), + NULL, + NULL, + (GClassInitFunc) lasso_register_name_identifier_class_init, + NULL, + NULL, + sizeof(LassoRegisterNameIdentifier), + 0, + (GInstanceInitFunc) lasso_register_name_identifier_instance_init, + }; + + this_type = g_type_register_static(LASSO_TYPE_PROFILE_CONTEXT, + "LassoRegisterNameIdentifier", + &this_info, 0); + } + return this_type; +} + +LassoRegisterNameIdentifier * +lasso_register_name_identifier_new(LassoServer *server, + LassoUser *user, + gint provider_type) +{ + LassoRegisterNameIdentifier *register_name_identifier; + LassoProfileContext *profileContext; + + g_return_val_if_fail(LASSO_IS_SERVER(server), NULL); + g_return_val_if_fail(LASSO_IS_USER(user), NULL); + + /* set the register_name_identifier object */ + register_name_identifier = g_object_new(LASSO_TYPE_REGISTER_NAME_IDENTIFIER, NULL); + register_name_identifier->provider_type = provider_type; + + /* set the properties */ + profileContext = LASSO_PROFILE_CONTEXT(register_name_identifier); + profileContext->user = user; + profileContext->server = server; + + return(register_name_identifier); +} diff --git a/lasso/id-ff/register_name_identifier.h b/lasso/id-ff/register_name_identifier.h new file mode 100644 index 00000000..5b2a3548 --- /dev/null +++ b/lasso/id-ff/register_name_identifier.h @@ -0,0 +1,85 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: Valery Febvre <vfebvre@easter-eggs.com> + * Nicolas Clapies <nclapies@entrouvert.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_REGISTER_NAME_IDENTIFIER_H__ +#define __LASSO_REGISTER_NAME_IDENTIFIER_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <lasso/environs/profile_context.h> + +#include <lasso/protocols/register_name_identifier_request.h> +#include <lasso/protocols/register_name_identifier_response.h> + +#define LASSO_TYPE_REGISTER_NAME_IDENTIFIER (lasso_register_name_identifier_get_type()) +#define LASSO_REGISTER_NAME_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_REGISTER_NAME_IDENTIFIER, LassoRegisterNameIdentifier)) +#define LASSO_REGISTER_NAME_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_REGISTER_NAME_IDENTIFIER, LassoRegisterNameIdentifierClass)) +#define LASSO_IS_REGISTER_NAME_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_REGISTER_NAME_IDENTIFIER)) +#define LASSP_IS_REGISTER_NAME_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_REGISTER_NAME_IDENTIFIER)) +#define LASSO_REGISTER_NAME_IDENTIFIER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_REGISTER_NAME_IDENTIFIER, LassoRegisterNameIdentifierClass)) + +typedef struct _LassoRegisterNameIdentifier LassoRegisterNameIdentifier; +typedef struct _LassoRegisterNameIdentifierClass LassoRegisterNameIdentifierClass; + +struct _LassoRegisterNameIdentifier { + LassoProfileContext parent; + int provider_type; + + /*< private >*/ +}; + +struct _LassoRegisterNameIdentifierClass { + LassoNodeClass parent; + +}; + +LASSO_EXPORT GType lasso_register_name_identifier_get_type (void); + +LASSO_EXPORT LassoRegisterNameIdentifier *lasso_register_name_identifier_new (LassoServer *server, + LassoUser *user, + gint provider_type); + +LASSO_EXPORT gint lasso_register_name_identifier_build_request_msg (LassoRegisterNameIdentifier *register_name_identifier); + +LASSO_EXPORT gint lasso_register_name_identifier_build_response_msg (LassoRegisterNameIdentifier *register_name_identifier); + +LASSO_EXPORT gint lasso_register_name_identifier_init_request (LassoRegisterNameIdentifier *register_name_identifier, + gchar *remote_providerID); + +LASSO_EXPORT gint lasso_register_name_identifier_handle_request (LassoRegisterNameIdentifier *register_name_identifier, + gchar *request_msg, + gint request_method); + +LASSO_EXPORT gint lasso_register_name_identifier_handle_response (LassoRegisterNameIdentifier *register_name_identifier, + gchar *response_msg, + gint response_method); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LASSO_REGISTER_NAME_IDENTIFIER_H__ */ |
