diff options
| author | Valery Febvre <vfebvre at easter-eggs.com> | 2004-06-25 13:12:50 +0000 |
|---|---|---|
| committer | Valery Febvre <vfebvre at easter-eggs.com> | 2004-06-25 13:12:50 +0000 |
| commit | eef1d1971c940056d9321a545d11aa2004508d3c (patch) | |
| tree | b0e4e2acbd571205cf0282bf20f1287cfd9a9dff | |
| parent | 7958874b946b035e9faa2cf7c336fb99fc68bb29 (diff) | |
*** empty log message ***
| -rw-r--r-- | lasso/id-ff/authn_environ.c | 161 | ||||
| -rw-r--r-- | lasso/id-ff/authn_environ.h | 69 | ||||
| -rw-r--r-- | lasso/id-ff/server_environ.c | 116 | ||||
| -rw-r--r-- | lasso/id-ff/server_environ.h | 75 | ||||
| -rw-r--r-- | lasso/id-ff/session_environ.c | 383 | ||||
| -rw-r--r-- | lasso/id-ff/session_environ.h | 119 | ||||
| -rw-r--r-- | lasso/id-ff/user_environ.c | 102 | ||||
| -rw-r--r-- | lasso/id-ff/user_environ.h | 70 |
8 files changed, 0 insertions, 1095 deletions
diff --git a/lasso/id-ff/authn_environ.c b/lasso/id-ff/authn_environ.c deleted file mode 100644 index 4205bf86..00000000 --- a/lasso/id-ff/authn_environ.c +++ /dev/null @@ -1,161 +0,0 @@ -/* $Id$ - * - * Lasso - A free implementation of the Samlerty 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/authn_environ.h> - -/*****************************************************************************/ -/* public methods */ -/*****************************************************************************/ - -char* -lasso_authn_environ_build_request(LassoAuthnEnviron *env, char *authnRequestProtocolProfile){ - LassoEnviron *e = LASSO_ENVIRON(env); - LassoNode *node = LASSO_NODE(e->local_provider); - char *url, *query, *protocolProfile; - - e->request = lasso_authn_request_new(lasso_node_get_attr_value(node, "ProviderID")); - if(authnRequestProtocolProfile){ - lasso_lib_authn_request_set_protocolProfile(e->request, authnRequestProtocolProfile); - } - - /* get the url and protocol profile */ - url = lasso_node_get_child_content(node, "SingleSignOnServiceUrl", NULL); - g_return_val_if_fail (url, NULL); - protocolProfile = lasso_node_get_child_content(node, "SingleSignOnProtocolProfile", NULL); - g_return_val_if_fail (protocolProfile, NULL); - - /* get or post ? */ - if(strcmp(protocolProfile, lassoLibProtocolProfileSSOGet)==0){ - printf("AuthnRequest Redirect method ...\n"); - return build_request_url(e, url, query, lassoLibProtocolProfileSSOGet); - } - else if(strcmp(protocolProfile, lassoLibProtocolProfileSSOPost)==0){ - printf("AuthnRequest POST method ...\n"); - return build_request_url(e, url, lassoLibProtocolProfileSSOPost); - } - else - printf("No method ...\n"); - - return(NULL); -} - -gboolean lasso_authn_environ_process_request_from_query(LassoAuthnEnviron *env, - char *query, - int isAuthenticated){ - LassoEnviron *e = LASSO_ENVIRON(env); - LassoNode *node = LASSO_NODE(e->local_provider); - char *protocolProfile, *providerId; - - protocolProfile = lasso_authn_request_get_protocolProfile(query); - if(strcmp(protocolProfile, lassoLibProtocolProfileArtifact)==0){ - printf("artifact ...\n"); - } - else if(strcmp(protocolProfile, lassoLibProtocolProfilePost)==0){ - printf("post ...\n"); - providerId = lasso_node_get_attr_value(node, "ProviderID"); - e->response = lasso_authn_response_new_from_request_query(query, providerId); - return lasso_authn_response_must_authenticate(e->response, isAuthenticated); - } -} - -char *lasso_authn_environ_dump_response(LassoAuthnEnviron *env){ - LassoEnviron *e = LASSO_ENVIRON(env); - char *dump; - - dump = lasso_node_dump(e->response, "utf-8", 1); - - return(dump); -} - -char *lasso_environ_process_authentication(LassoAuthnEnviron *env, gboolean isAuthenticated){ - LassoEnviron *e = LASSO_ENVIRON(env); - LassoNode *response, *assertion, *statement; - - response = e->response; - - -} - - -/*****************************************************************************/ -/* instance and class init functions */ -/*****************************************************************************/ - -static void -lasso_authn_environ_instance_init(LassoAuthnEnviron *env) -{ -} - -static void -lasso_authn_environ_class_init(LassoAuthnEnvironClass *klass) -{ -} - -GType lasso_authn_environ_get_type() -{ - static GType this_type = 0; - - if (!this_type) { - static const GTypeInfo this_info = { - sizeof (LassoAuthnEnvironClass), - NULL, - NULL, - (GClassInitFunc) lasso_authn_environ_class_init, - NULL, - NULL, - sizeof(LassoAuthnEnviron), - 0, - (GInstanceInitFunc) lasso_authn_environ_instance_init, - }; - - this_type = g_type_register_static(LASSO_TYPE_ENVIRON, - "LassoAuthnEnviron", - &this_info, 0); - } - return this_type; -} - -LassoAuthnEnviron* lasso_authn_environ_new(gchar *metadata, - gchar *public_key, - gchar *private_key, - gchar *certificate) -{ - LassoAuthnEnviron *authn; - LassoEnviron *e; - LassoNode *local_provider; - - authn = g_object_new(LASSO_TYPE_AUTHN_ENVIRON, NULL); - e = LASSO_ENVIRON(authn); - - local_provider = lasso_provider_new(metadata); - if(public_key) - lasso_provider_set_public_key(LASSO_PROVIDER(local_provider), public_key); - if(private_key) - lasso_provider_set_private_key(LASSO_PROVIDER(local_provider), private_key); - if(certificate) - lasso_provider_set_certificate(LASSO_PROVIDER(local_provider), certificate); - e->local_provider = local_provider; - - return(authn); -} diff --git a/lasso/id-ff/authn_environ.h b/lasso/id-ff/authn_environ.h deleted file mode 100644 index 254b3e47..00000000 --- a/lasso/id-ff/authn_environ.h +++ /dev/null @@ -1,69 +0,0 @@ -/* $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 - */ - -#ifndef __LASSO_AUTHN_ENVIRON_H__ -#define __LASSO_AUTHN_ENVIRON_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include <lasso/environs/environ.h> - -#define LASSO_TYPE_AUTHN_ENVIRON (lasso_authn_environ_get_type()) -#define LASSO_AUTHN_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_AUTHN_ENVIRON, LassoAuthnEnviron)) -#define LASSO_AUTHN_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_AUTHN_ENVIRON, LassoAuthnEnvironClass)) -#define LASSO_IS_AUTHN_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_AUTHN_ENVIRON)) -#define LASSO_IS_AUTHN_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_AUTHN_ENVIRON)) -#define LASSO_AUTHN_ENVIRON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_AUTHN_ENVIRON, LassoAuthnEnvironClass)) - -typedef struct _LassoAuthnEnviron LassoAuthnEnviron; -typedef struct _LassoAuthnEnvironClass LassoAuthnEnvironClass; - -struct _LassoAuthnEnviron { - LassoEnviron parent; - /*< private >*/ -}; - -struct _LassoAuthnEnvironClass { - LassoEnvironClass parent; -}; - -LASSO_EXPORT GType lasso_authn_environ_get_type(void); -LASSO_EXPORT LassoAuthnEnviron *lasso_authn_environ_new(gchar *metadata, - gchar *public_key, - gchar *private_key, - gchar *certificate); - -LASSO_EXPORT char *lasso_authn_environ_build_request(LassoAuthnEnviron *env, char *authnRequestProtocolProfile); - -LASSO_EXPORT gboolean lasso_authn_environ_process_request_from_query(LassoAuthnEnviron *env, - char *query, - int isAuthenticated); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __LASSO_AUTHN_ENVIRON_H__ */ diff --git a/lasso/id-ff/server_environ.c b/lasso/id-ff/server_environ.c deleted file mode 100644 index b9d3200a..00000000 --- a/lasso/id-ff/server_environ.c +++ /dev/null @@ -1,116 +0,0 @@ -/* $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/server_environ.h> - -/*****************************************************************************/ -/* public methods */ -/*****************************************************************************/ - -int lasso_server_environ_add_provider_from_file(LassoServerEnviron *server, char *filename){ - LassoProvider *provider, *p; - - provider = lasso_provider_new_from_filename(filename); - g_ptr_array_add(server->providers, provider); - - return(1); -} - -LassoProvider *lasso_server_environ_get_provider(LassoServerEnviron *server, char *providerID){ - LassoProvider *provider; - char *id; - int index, len; - - len = server->providers->len; - for(index = 0; index<len; index++){ - provider = g_ptr_array_index(server->providers, index); - - id = lasso_provider_get_providerID(provider); - if(!strcmp(providerID, id)){ - return(provider); - } - } - - return(NULL); -} - -int lasso_server_environ_set_security(char *private_key, char *public_key, char *certificate){ - g_return_if_fail(private_key); - g_return_if_fail(public_key); - g_return_if_fail(certificate); - - - -} - -/*****************************************************************************/ -/* instance and class init functions */ -/*****************************************************************************/ - -static void -lasso_server_environ_instance_init(LassoServerEnviron *server) -{ - server->providers = g_ptr_array_new(); - - server->private_key = NULL; - server->public_key = NULL; - server->certificate = NULL; -} - -static void -lasso_server_environ_class_init(LassoServerEnvironClass *klass){ -} - -GType lasso_server_environ_get_type() { - static GType this_type = 0; - - if (!this_type) { - static const GTypeInfo this_info = { - sizeof (LassoServerEnvironClass), - NULL, - NULL, - (GClassInitFunc) lasso_server_environ_class_init, - NULL, - NULL, - sizeof(LassoServerEnviron), - 0, - (GInstanceInitFunc) lasso_server_environ_instance_init, - }; - - this_type = g_type_register_static(G_TYPE_OBJECT, - "LassoServerEnviron", - &this_info, 0); - } - return this_type; -} - -LassoServerEnviron *lasso_server_environ_new() -{ - LassoServerEnviron *server; - - server = g_object_new(LASSO_TYPE_SERVER_ENVIRON, NULL); - - return(server); - -} diff --git a/lasso/id-ff/server_environ.h b/lasso/id-ff/server_environ.h deleted file mode 100644 index 6007118f..00000000 --- a/lasso/id-ff/server_environ.h +++ /dev/null @@ -1,75 +0,0 @@ -/* $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_SERVER_ENVIRON_H__ -#define __LASSO_SERVER_ENVIRON_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include <lasso/xml/xml.h> -#include <lasso/environs/provider.h> - -#define LASSO_TYPE_SERVER_ENVIRON (lasso_server_environ_get_type()) -#define LASSO_SERVER_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_SERVER_ENVIRON, LassoServerEnviron)) -#define LASSO_SERVER_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_SERVER_ENVIRON, LassoServerEnvironClass)) -#define LASSO_IS_SERVER_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_SERVER_ENVIRON)) -#define LASSP_IS_SERVER_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_SERVER_ENVIRON)) -#define LASSO_SERVER_ENVIRON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_SERVER_ENVIRON, LassoServerEnvironClass)) - -typedef struct _LassoServerEnviron LassoServerEnviron; -typedef struct _LassoServerEnvironClass LassoServerEnvironClass; - -struct _LassoServerEnviron { - GObject parent; - - GPtrArray *providers; - - char *private_key; - char *public_key; - char *certificate; - - /*< private >*/ -}; - -struct _LassoServerEnvironClass { - GObjectClass parent; -}; - -LASSO_EXPORT GType lasso_server_environ_get_type (void); -LASSO_EXPORT LassoServerEnviron *lasso_server_environ_new (void); - -LASSO_EXPORT int lasso_server_environ_add_provider_from_file (LassoServerEnviron *server, char *filename); -LASSO_EXPORT LassoProvider *lasso_server_environ_get_provider (LassoServerEnviron *server, char *providerID); - -LASSO_EXPORT int lasso_server_environ_set_security (char *private_key, char *public_key, char *certificate); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __LASSO_SERVER_ENVIRON_H__ */ diff --git a/lasso/id-ff/session_environ.c b/lasso/id-ff/session_environ.c deleted file mode 100644 index 9d76ead1..00000000 --- a/lasso/id-ff/session_environ.c +++ /dev/null @@ -1,383 +0,0 @@ -/* $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/xml/samlp_response.h> -#include <lasso/protocols/request.h> -#include <lasso/protocols/response.h> -#include <lasso/protocols/authn_response.h> -#include <lasso/environs/session_environ.h> - -/*****************************************************************************/ -/* functions */ -/*****************************************************************************/ - -static void -set_response_status(LassoNode *response, - const xmlChar *statusCodeValue) -{ - LassoNode *status, *status_code; - - status = lasso_samlp_status_new(); - - status_code = lasso_samlp_status_code_new(); - lasso_samlp_status_code_set_value(LASSO_SAMLP_STATUS_CODE(status_code), - statusCodeValue); - - lasso_samlp_status_set_statusCode(LASSO_SAMLP_STATUS(status), - LASSO_SAMLP_STATUS_CODE(status_code)); - - lasso_samlp_response_set_status(LASSO_SAMLP_RESPONSE(response), - LASSO_SAMLP_STATUS(status)); - lasso_node_destroy(status_code); - lasso_node_destroy(status); -} - -/*****************************************************************************/ -/* public methods */ -/*****************************************************************************/ - -gchar * -lasso_session_environ_build_authn_request(LassoSessionEnviron *session, - const gchar *protocolProfile, - gboolean isPassive, - gboolean forceAuthn, - const gchar *nameIDPolicy) -{ - LassoProvider *provider; - xmlChar *request_protocolProfile, *url, *query; - gchar *str; - - provider = lasso_server_environ_get_provider(session->server, - session->local_providerID); - if (provider == NULL) { - return (NULL); - } - - /* build the request object */ - session->request = LASSO_NODE(lasso_authn_request_new(session->local_providerID)); - /* optional values */ - if (protocolProfile != NULL) { - lasso_lib_authn_request_set_protocolProfile(LASSO_LIB_AUTHN_REQUEST(session->request), - protocolProfile); - } - if (nameIDPolicy != NULL) { - lasso_lib_authn_request_set_nameIDPolicy(LASSO_LIB_AUTHN_REQUEST(session->request), - nameIDPolicy); - } - lasso_lib_authn_request_set_isPassive(LASSO_LIB_AUTHN_REQUEST(session->request), isPassive); - lasso_lib_authn_request_set_forceAuthn(LASSO_LIB_AUTHN_REQUEST(session->request), forceAuthn); - - /* export request depending on the request protocol profile */ - request_protocolProfile = lasso_provider_get_singleSignOnProtocolProfile(provider); - if (xmlStrEqual(request_protocolProfile, lassoLibProtocolProfileSSOGet)) { - url = lasso_provider_get_singleSignOnServiceUrl(provider); - query = lasso_node_export_to_query(session->request, 1, NULL); - str = (gchar *) malloc(strlen(url) + strlen(query) + 2); // +2 for the ? character and the end line character - sprintf(str, "%s?%s", url, query); - - session->request_protocol_method = lasso_protocol_method_get; - } - else if (xmlStrEqual(request_protocolProfile, lassoLibProtocolProfileSSOPost)) { - printf("TODO - export the AuthnRequest in a formular\n"); - } - - return (str); -} - -xmlChar* -lasso_session_environ_process_artifact(LassoSessionEnviron *session, - gchar *artifact) -{ - session->request = lasso_request_new(artifact); - return (lasso_node_export_to_soap(session->request)); -} - -gboolean -lasso_session_environ_process_authn_response(LassoSessionEnviron *session, - xmlChar *response) -{ - LassoNode *statusCode, *assertion; - LassoNode *nameIdentifier, *idpProvidedNameIdentifier; - char *artifact, *statusCodeValue; - - printf("DEBUG - POST response, process the authnResponse\n"); - session->response = LASSO_NODE(lasso_authn_response_new_from_export(response, 0)); - - /* process the status code value */ - statusCode = lasso_node_get_child(session->response, "StatusCode", NULL); - statusCodeValue = lasso_node_get_attr_value(statusCode, "Value"); - if(strcmp(statusCodeValue, lassoSamlStatusCodeSuccess)) - return(FALSE); - - /* process the assertion */ - assertion = lasso_node_get_child(session->response, "Assertion", NULL); - if(!assertion) - return(FALSE); - - /* set the name identifiers */ - nameIdentifier = lasso_node_get_child(assertion, "NameIdentifier", NULL); - printf("name identifier %s(%s)\n", lasso_node_get_content(nameIdentifier), lasso_node_export(nameIdentifier)); - - idpProvidedNameIdentifier = lasso_node_get_child(assertion, "IDPProvidedNameIdentifier", NULL); - - return(TRUE); -} - -gboolean -lasso_session_environ_process_authn_request(LassoSessionEnviron *session, - gchar *request, - gint request_method, - gboolean is_authenticated) -{ - LassoProvider *provider; - xmlChar *protocolProfile; - gboolean must_authenticate = TRUE; - gboolean isPassive = TRUE; - gboolean forceAuthn = FALSE; - gboolean signature_status; - - switch (request_method) { - case lasso_protocol_method_get: - session->request = LASSO_NODE(lasso_authn_request_new_from_query(request)); - session->peer_providerID = lasso_node_get_child_content(session->request, "ProviderID", NULL); - - protocolProfile = lasso_node_get_child_content(session->request, "ProtocolProfile", NULL); - if (xmlStrEqual(protocolProfile, lassoLibProtocolProfilePost)) { - session->response = lasso_authn_response_new(session->local_providerID, session->request); - } - else { - session->response = lasso_response_new(); - } - - provider = lasso_server_environ_get_provider(session->server, session->peer_providerID); - if (xmlStrEqual(lasso_node_get_child_content(provider->metadata, "AuthnRequestsSigned", NULL), "true")) { - signature_status = lasso_query_verify_signature(request, - provider->public_key, - session->server->private_key); - /* Status & StatusCode */ - if (signature_status == 0 || signature_status == 2) { - switch (signature_status) { - case 0: - set_response_status(session->response, lassoLibStatusCodeInvalidSignature); - break; - case 2: - set_response_status(session->response, lassoLibStatusCodeUnsignedAuthnRequest); - break; - } - } - } - break; - case lasso_protocol_method_post: - printf("TODO - lasso_session_environ_process_authnRequest() - implement the parsing of the post request\n"); - break; - default: - printf("ERROR - lasso_session_environ_process_authnRequest() - Unknown protocol method\n"); - } - - /* verify if the user must be authenticated or not */ - if (xmlStrEqual(lasso_node_get_child_content(session->request, "IsPassive", NULL), "false")) { - isPassive = FALSE; - } - - if (xmlStrEqual(lasso_node_get_child_content(session->request, "ForceAuthn", NULL), "true")) { - forceAuthn = TRUE; - } - - /* complex test to authentication process */ - if ((forceAuthn == TRUE || is_authenticated == FALSE) && isPassive == FALSE) { - must_authenticate = TRUE; - } - else if (is_authenticated == FALSE && isPassive == TRUE) { - set_response_status(session->response, lassoLibStatusCodeNoPassive); - must_authenticate = FALSE; - } - - return (must_authenticate); -} - -gchar * -lasso_session_environ_process_authentication(LassoSessionEnviron *session, - gint authentication_result, - const gchar *authentication_method) -{ - LassoUserEnviron *user; - xmlChar *str, *nameIDPolicy, *protocolProfile; - LassoNode *assertion, *authentication_statement, *idpProvidedNameIdentifier; - - LassoIdentity *identity; - - /* process the federation policy */ - /* TODO : implement a get identity */ - - printf("process authentication\n"); - /* verify if a user environ exists */ - if (session->user == NULL) { - session->user = lasso_user_environ_new(); - } - - identity = lasso_user_environ_find_identity(session->user, session->peer_providerID); - nameIDPolicy = lasso_node_get_child_content(session->request, "NameIDPolicy", NULL); - printf("NameIDPolicy %s\n", nameIDPolicy); - if (xmlStrEqual(nameIDPolicy, lassoLibNameIDPolicyTypeNone)) { - if (identity == NULL) { - set_response_status(session->response, lassoLibStatusCodeFederationDoesNotExist); - } - } - else if (!strcmp(nameIDPolicy, lassoLibNameIDPolicyTypeFederated)) { - printf("DEBUG - NameIDPolicy is federated\n"); - if (identity == NULL) { - identity = lasso_identity_new(session->peer_providerID); - idpProvidedNameIdentifier = LASSO_NODE(lasso_lib_idp_provided_name_identifier_new(lasso_build_unique_id(32))); - lasso_identity_set_local_name_identifier(identity, idpProvidedNameIdentifier); - } - } - else if (xmlStrEqual(nameIDPolicy, lassoLibNameIDPolicyTypeOneTime)) { - - } - - /* fill the response with the assertion */ - if (identity) { - printf("DEBUG - an identity found, so build an assertion\n"); - //assertion = lasso_assertion_new(session->local_providerID, lasso_node_get_attr_value(LASSO_NODE(session->request), - // "RequestID")); - //authentication_statement = lasso_authentication_statement_new(authentication_method, - // "TODO", - // nameIdentifier, - // "TODO", - // "TODO", - // idpProvidedNameIdentifier, - // "TODO", - // "TODO"); - //lasso_saml_assertion_add_authenticationStatement(assertion, - // authentication_statement); - //lasso_samlp_response_add_assertion(session->response, assertion); - } - - /* return a response message */ - protocolProfile = lasso_node_get_child_content(session->request, "ProtocolProfile", NULL); - if (xmlStrEqual(protocolProfile, lassoLibProtocolProfilePost)) { - str = lasso_node_export_to_base64(session->response); - } - else { - printf("DEBUG - return a artifact message\n"); - } - - return(str); -} - -gint -lasso_session_environ_set_local_providerID(LassoSessionEnviron *session, - gchar *providerID) -{ - if (session->local_providerID) { - free(session->local_providerID); - } - session->local_providerID = (char *)malloc(strlen(providerID)+1); - strcpy(session->local_providerID, providerID); - - return (1); -} - -gint -lasso_session_environ_set_peer_providerID(LassoSessionEnviron *session, - gchar *providerID) -{ - if (session->peer_providerID) { - free(session->peer_providerID); - } - session->peer_providerID = (char *)malloc(strlen(providerID)+1); - strcpy(session->peer_providerID, providerID); - - return (1); -} - -/*****************************************************************************/ -/* instance and class init functions */ -/*****************************************************************************/ - -static void -lasso_session_environ_instance_init(LassoSessionEnviron *session) -{ - session->user = NULL; - session->message = NULL; - session->request = NULL; - session->response = NULL; - session->local_providerID = NULL; - session->peer_providerID = NULL; - session->request_protocol_method = 0; -} - -static void -lasso_session_environ_class_init(LassoSessionEnvironClass *class) -{ -} - -GType lasso_session_environ_get_type() { - static GType this_type = 0; - - if (!this_type) { - static const GTypeInfo this_info = { - sizeof (LassoSessionEnvironClass), - NULL, - NULL, - (GClassInitFunc) lasso_session_environ_class_init, - NULL, - NULL, - sizeof(LassoSessionEnviron), - 0, - (GInstanceInitFunc) lasso_session_environ_instance_init, - }; - - this_type = g_type_register_static(G_TYPE_OBJECT, - "LassoSessionEnviron", - &this_info, 0); - } - return this_type; -} - -LassoSessionEnviron* -lasso_session_environ_new(LassoServerEnviron *server, - LassoUserEnviron *user, - gchar *local_providerID, - gchar *peer_providerID) -{ - /* load the ProviderID name or a reference to the provider ? */ - g_return_val_if_fail(local_providerID != NULL, NULL); - g_return_val_if_fail(peer_providerID != NULL, NULL); - - LassoSessionEnviron *session; - - session = g_object_new(LASSO_TYPE_SESSION_ENVIRON, NULL); - - session->server = server; - - if (user != NULL) { - session->user = user; - } - - lasso_session_environ_set_local_providerID(session, local_providerID); - lasso_session_environ_set_peer_providerID(session, peer_providerID); - - return (session); -} diff --git a/lasso/id-ff/session_environ.h b/lasso/id-ff/session_environ.h deleted file mode 100644 index b75c834b..00000000 --- a/lasso/id-ff/session_environ.h +++ /dev/null @@ -1,119 +0,0 @@ -/* $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_SESSION_ENVIRON_H__ -#define __LASSO_SESSION_ENVIRON_H__ - -#ifdef __cplusplus -extern "C" { - -#endif /* __cplusplus */ - -#include <lasso/xml/xml.h> -#include <lasso/environs/provider.h> -#include <lasso/environs/server_environ.h> -#include <lasso/environs/user_environ.h> - -#define LASSO_TYPE_SESSION_ENVIRON (lasso_session_environ_get_type()) -#define LASSO_SESSION_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_SESSION_ENVIRON, LassoSessionEnviron)) -#define LASSO_SESSION_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_SESSION_ENVIRON, LassoSessionEnvironClass)) -#define LASSO_IS_SESSION_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_SESSION_ENVIRON)) -#define LASSP_IS_SESSION_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_SESSION_ENVIRON)) -#define LASSO_SESSION_ENVIRON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_SESSION_ENVIRON, LassoSessionEnvironClass)) - -typedef struct _LassoSessionEnviron LassoSessionEnviron; -typedef struct _LassoSessionEnvironClass LassoSessionEnvironClass; - -typedef enum { - lasso_protocol_method_get = 1, - lasso_protocol_method_redirect, - lasso_protocol_method_post, - lasso_protocol_method_soap, - lasso_protocol_method_artifact, -} lasso_protocol_methods; - -struct _LassoSessionEnviron { - GObject parent; - - /*< public >*/ - LassoServerEnviron *server; - LassoUserEnviron *user; - - gchar *message; - - LassoNode *request; - LassoNode *response; - - gchar *local_providerID; - gchar *peer_providerID; - - gint request_protocol_method; - - /*< private >*/ -}; - -struct _LassoSessionEnvironClass { - GObjectClass parent; -}; - -LASSO_EXPORT GType lasso_session_environ_get_type (void); - -LASSO_EXPORT LassoSessionEnviron* lasso_session_environ_new (LassoServerEnviron *server, - LassoUserEnviron *user, - gchar *local_providerID, - gchar *peer_providerID); - -LASSO_EXPORT gchar* lasso_session_environ_build_authn_request (LassoSessionEnviron *session, - const gchar *responseProtocolProfile, - gboolean isPassive, - gboolean forceAuthn, - const gchar *nameIDPolicy); - -LASSO_EXPORT xmlChar* lasso_session_environ_process_artifact (LassoSessionEnviron *session, - gchar *artifact); - -LASSO_EXPORT gboolean lasso_session_environ_process_authn_response (LassoSessionEnviron *session, - xmlChar *response); - -LASSO_EXPORT gboolean lasso_session_environ_process_authn_request (LassoSessionEnviron *session, - gchar *request, - gint request_method, - gboolean is_authenticated); - -LASSO_EXPORT gchar* lasso_session_environ_process_authentication (LassoSessionEnviron *session, - gint authentication_result, - const char *authentication_method); - -LASSO_EXPORT gint lasso_session_environ_set_local_providerID (LassoSessionEnviron *session, - gchar *providerID); - -LASSO_EXPORT gint lasso_session_environ_set_peer_providerID (LassoSessionEnviron *session, - gchar *providerID); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __LASSO_SESSION_ENVIRON_H__ */ diff --git a/lasso/id-ff/user_environ.c b/lasso/id-ff/user_environ.c deleted file mode 100644 index 843121b8..00000000 --- a/lasso/id-ff/user_environ.c +++ /dev/null @@ -1,102 +0,0 @@ -/* $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/user_environ.h> - -/*****************************************************************************/ -/* public methods */ -/*****************************************************************************/ - -LassoIdentity *lasso_user_environ_find_identity(LassoUserEnviron *user, char *peer_providerID){ - LassoIdentity *identity; - int index; - - printf("nb identity %d\n", user->identities->len); - for(index = 0; index<user->identities->len; index++){ - identity = g_ptr_array_index(user->identities, index); - printf("provider id : %s\n", identity->peer_providerID); - if(!strcmp(identity->peer_providerID, peer_providerID)){ - return(identity); - } - } - - return(NULL); -} - -int lasso_user_environ_add_assertion(){ - -} - -int lasso_user_environ_add_identity(LassoUserEnviron *user, LassoIdentity *identity){ - g_ptr_array_add(user->identities, identity); - - return(1); -} - -/*****************************************************************************/ -/* instance and class init functions */ -/*****************************************************************************/ - -static void -lasso_user_environ_instance_init(LassoUserEnviron *user){ - user->identities = g_ptr_array_new(); - user->assertions = g_ptr_array_new(); -} - -static void -lasso_user_environ_class_init(LassoUserEnvironClass *klass) { -} - -GType lasso_user_environ_get_type() { - static GType this_type = 0; - - if (!this_type) { - static const GTypeInfo this_info = { - sizeof (LassoUserEnvironClass), - NULL, - NULL, - (GClassInitFunc) lasso_user_environ_class_init, - NULL, - NULL, - sizeof(LassoUserEnviron), - 0, - (GInstanceInitFunc) lasso_user_environ_instance_init, - }; - - this_type = g_type_register_static(G_TYPE_OBJECT, - "LassoUserEnviron", - &this_info, 0); - } - return this_type; -} - -LassoUserEnviron* -lasso_user_environ_new() -{ - LassoUserEnviron *user; - - user = LASSO_USER_ENVIRON(g_object_new(LASSO_TYPE_USER_ENVIRON, NULL)); - - return(user); -} diff --git a/lasso/id-ff/user_environ.h b/lasso/id-ff/user_environ.h deleted file mode 100644 index f9075f14..00000000 --- a/lasso/id-ff/user_environ.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $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_USER_ENVIRON_H__ -#define __LASSO_USER_ENVIRON_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include <lasso/xml/xml.h> -#include <lasso/environs/identity.h> - -#define LASSO_TYPE_USER_ENVIRON (lasso_user_environ_get_type()) -#define LASSO_USER_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_USER_ENVIRON, LassoUserEnviron)) -#define LASSO_USER_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_USER_ENVIRON, LassoUserEnvironClass)) -#define LASSO_IS_USER_ENVIRON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_USER_ENVIRON)) -#define LASSP_IS_USER_ENVIRON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_USER_ENVIRON)) -#define LASSO_USER_ENVIRON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_USER_ENVIRON, LassoUserEnvironClass)) - -typedef struct _LassoUserEnviron LassoUserEnviron; -typedef struct _LassoUserEnvironClass LassoUserEnvironClass; - -struct _LassoUserEnviron { - GObject parent; - - /*< public >*/ - GPtrArray *assertions; - GPtrArray *identities; - - /*< private >*/ -}; - -struct _LassoUserEnvironClass { - GObjectClass parent; -}; - -LASSO_EXPORT GType lasso_user_environ_get_type (void); -LASSO_EXPORT LassoUserEnviron *lasso_user_environ_new (void); - -LASSO_EXPORT LassoIdentity *lasso_user_environ_find_identity (LassoUserEnviron *user, - gchar *peer_providerID); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __LASSO_USER_ENVIRON_H__ */ |
