diff options
author | Valery Febvre <vfebvre at easter-eggs.com> | 2004-06-25 16:44:26 +0000 |
---|---|---|
committer | Valery Febvre <vfebvre at easter-eggs.com> | 2004-06-25 16:44:26 +0000 |
commit | 5202492aebef2b51cc6c33d7f49d57d0875e1444 (patch) | |
tree | c8ea2e4f558d8957dc45bc43571eced88dec54f7 | |
parent | df4e8f993c29a17e329fff0b3723a91ee3095bd1 (diff) | |
download | lasso-5202492aebef2b51cc6c33d7f49d57d0875e1444.tar.gz lasso-5202492aebef2b51cc6c33d7f49d57d0875e1444.tar.xz lasso-5202492aebef2b51cc6c33d7f49d57d0875e1444.zip |
*** empty log message ***
-rw-r--r-- | lasso/Attic/protocols/Makefile.am | 4 | ||||
-rw-r--r-- | lasso/Attic/protocols/authn_response.c | 30 | ||||
-rw-r--r-- | lasso/id-ff/Makefile.am | 18 | ||||
-rw-r--r-- | lasso/id-ff/authentication.c | 190 | ||||
-rw-r--r-- | lasso/id-ff/authentication.h | 31 | ||||
-rw-r--r-- | lasso/id-ff/profile_context.c | 133 | ||||
-rw-r--r-- | lasso/id-ff/profile_context.h | 9 |
7 files changed, 247 insertions, 168 deletions
diff --git a/lasso/Attic/protocols/Makefile.am b/lasso/Attic/protocols/Makefile.am index 814185da..b81eccbe 100644 --- a/lasso/Attic/protocols/Makefile.am +++ b/lasso/Attic/protocols/Makefile.am @@ -26,10 +26,12 @@ liblasso_protocols_la_SOURCES = \ authn_request.c \ authn_response.c \ federation_termination_notification.c \ + identity.c \ logout_request.c \ logout_response.c \ name_identifier_mapping_request.c \ name_identifier_mapping_response.c \ + provider.c \ register_name_identifier_request.c \ register_name_identifier_response.c \ request.c \ @@ -40,10 +42,12 @@ liblassoinclude_HEADERS = \ authn_request.h \ authn_response.h \ federation_termination_notification.h \ + identity.h \ logout_request.h \ logout_response.h \ name_identifier_mapping_request.h \ name_identifier_mapping_response.h \ + provider.h \ register_name_identifier_request.h \ register_name_identifier_response.h \ request.h \ diff --git a/lasso/Attic/protocols/authn_response.c b/lasso/Attic/protocols/authn_response.c index d8b1ade9..d938df6a 100644 --- a/lasso/Attic/protocols/authn_response.c +++ b/lasso/Attic/protocols/authn_response.c @@ -28,25 +28,25 @@ //static GObjectClass *parent_class = NULL; -/* static void */ -/* lasso_authn_response_set_status(LassoAuthnResponse *response, */ -/* const xmlChar *statusCodeValue) { */ -/* LassoNode *status, *status_code; */ +static void +lasso_authn_response_set_status(LassoAuthnResponse *response, + const xmlChar *statusCodeValue) { + LassoNode *status, *status_code; -/* status = lasso_samlp_status_new(); */ + 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); */ + 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_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); */ -/* } */ + lasso_samlp_response_set_status(LASSO_SAMLP_RESPONSE(response), + LASSO_SAMLP_STATUS(status)); + lasso_node_destroy(status_code); + lasso_node_destroy(status); +} /*****************************************************************************/ /* public methods */ diff --git a/lasso/id-ff/Makefile.am b/lasso/id-ff/Makefile.am index 6232ba56..11a7e578 100644 --- a/lasso/id-ff/Makefile.am +++ b/lasso/id-ff/Makefile.am @@ -15,15 +15,13 @@ INCLUDES = \ noinst_LTLIBRARIES = liblasso-environs.la liblasso_environs_la_SOURCES = \ - identity.c \ - provider.c \ - server_environ.c \ - session_environ.c \ - user_environ.c + authentication.c \ + profile_context.c \ + server.c \ + user.c liblassoinclude_HEADERS = \ - identity.h \ - provider.h \ - server_environ.h \ - session_environ.h \ - user_environ.h + authentication.h \ + profile_context.h \ + server.h \ + user.h diff --git a/lasso/id-ff/authentication.c b/lasso/id-ff/authentication.c index 581f9aa6..bc4aa46e 100644 --- a/lasso/id-ff/authentication.c +++ b/lasso/id-ff/authentication.c @@ -26,7 +26,7 @@ #include <lasso/protocols/request.h> #include <lasso/protocols/response.h> #include <lasso/protocols/authn_response.h> -#include <lasso/environs/context.h> +#include <lasso/environs/authentication.h> /*****************************************************************************/ /* functions */ @@ -37,45 +37,42 @@ /*****************************************************************************/ gchar * -lasso_authentication_build_request(LassoAuthentication *authn, - const gchar *protocolProfile, - gboolean isPassive, - gboolean forceAuthn, - const gchar *nameIDPolicy) +lasso_authentication_build_request(LassoAuthentication *authn) { LassoProvider *provider; xmlChar *request_protocolProfile, *url, *query; gchar *str; - provider = lasso_server_get_provider(authn->server, - authn->local_providerID); + provider = lasso_server_get_provider(LASSO_PROFILE_CONTEXT(authn)->server, + LASSO_PROFILE_CONTEXT(authn)->local_providerID); if (provider == NULL) { return (NULL); } /* build the request object */ - authn->request = LASSO_NODE(lasso_authn_request_new(authn->local_providerID)); + LASSO_PROFILE_CONTEXT(authn)->request = lasso_authn_request_new(LASSO_PROFILE_CONTEXT(authn)->local_providerID); + /* optional values */ - if (protocolProfile != NULL) { - lasso_lib_authn_request_set_protocolProfile(LASSO_LIB_AUTHN_REQUEST(authn->request), - protocolProfile); - } - if (nameIDPolicy != NULL) { - lasso_lib_authn_request_set_nameIDPolicy(LASSO_LIB_AUTHN_REQUEST(authn->request), - nameIDPolicy); - } - lasso_lib_authn_request_set_isPassive(LASSO_LIB_AUTHN_REQUEST(authn->request), isPassive); - lasso_lib_authn_request_set_forceAuthn(LASSO_LIB_AUTHN_REQUEST(authn->request), forceAuthn); +/* if (protocolProfile != NULL) { */ +/* lasso_lib_authn_request_set_protocolProfile(LASSO_LIB_AUTHN_REQUEST(LASSO_PROFILE_CONTEXT(authn)->request), */ +/* protocolProfile); */ +/* } */ +/* if (nameIDPolicy != NULL) { */ +/* lasso_lib_authn_request_set_nameIDPolicy(LASSO_LIB_AUTHN_REQUEST(LASSO_PROFILE_CONTEXT(authn)->request), */ +/* nameIDPolicy); */ +/* } */ +/* lasso_lib_authn_request_set_isPassive(LASSO_LIB_AUTHN_REQUEST(LASSO_PROFILE_CONTEXT(authn)->request), isPassive); */ +/* lasso_lib_authn_request_set_forceAuthn(LASSO_LIB_AUTHN_REQUEST(LASSO_PROFILE_CONTEXT(authn)->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(authn->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); + query = lasso_node_export_to_query(LASSO_PROFILE_CONTEXT(authn)->request, 1, NULL); + str = (gchar *) g_new(gchar, strlen(url) + strlen(query) + 2); // +2 for the ? character and the end line character + g_sprintf(str, "%s?%s", url, query); - authn->request_protocol_method = lassoProfileContextMethodGet; + LASSO_PROFILE_CONTEXT(authn)->request_protocol_method = lassoProfileContextMethodGet; } else if (xmlStrEqual(request_protocolProfile, lassoLibProtocolProfileSSOPost)) { printf("TODO - export the AuthnRequest in a formular\n"); @@ -88,8 +85,8 @@ xmlChar* lasso_authentication_process_artifact(LassoAuthentication *authn, gchar *artifact) { - authn->request = lasso_request_new(artifact); - return (lasso_node_export_to_soap(authn->request)); + LASSO_PROFILE_CONTEXT(authn)->request = lasso_request_new(artifact); + return (lasso_node_export_to_soap(LASSO_PROFILE_CONTEXT(authn)->request)); } gboolean @@ -101,16 +98,16 @@ lasso_authentication_process_response(LassoAuthentication *authn, char *artifact, *statusCodeValue; printf("DEBUG - POST response, process the authnResponse\n"); - authn->response = LASSO_NODE(lasso_authn_response_new_from_export(response, 0)); + LASSO_PROFILE_CONTEXT(authn)->response = LASSO_NODE(lasso_authn_response_new_from_export(response, 0)); /* process the status code value */ - statusCode = lasso_node_get_child(authn->response, "StatusCode", NULL); + statusCode = lasso_node_get_child(LASSO_PROFILE_CONTEXT(authn)->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(authn->response, "Assertion", NULL); + assertion = lasso_node_get_child(LASSO_PROFILE_CONTEXT(authn)->response, "Assertion", NULL); if(!assertion) return(FALSE); @@ -137,37 +134,42 @@ lasso_authentication_process_request(LassoAuthentication *authn, gboolean signature_status; switch (request_method) { - case lasso_protocol_method_get: - authn->request = LASSO_NODE(lasso_authn_request_new_from_query(request)); - authn->peer_providerID = lasso_node_get_child_content(authn->request, "ProviderID", NULL); + case lassoProfileContextMethodGet: + LASSO_PROFILE_CONTEXT(authn)->request = LASSO_NODE(lasso_authn_request_new_from_query(request)); + LASSO_PROFILE_CONTEXT(authn)->remote_providerID = lasso_node_get_child_content(LASSO_PROFILE_CONTEXT(authn)->request, + "ProviderID", NULL); - protocolProfile = lasso_node_get_child_content(->request, "ProtocolProfile", NULL); + protocolProfile = lasso_node_get_child_content(LASSO_PROFILE_CONTEXT(authn)->request, "ProtocolProfile", NULL); if (xmlStrEqual(protocolProfile, lassoLibProtocolProfilePost)) { - authn->response = lasso_authn_response_new(->local_providerID, ->request); + LASSO_PROFILE_CONTEXT(authn)->response = lasso_authn_response_new(LASSO_PROFILE_CONTEXT(authn)->local_providerID, + LASSO_PROFILE_CONTEXT(authn)->request); } else { - authn->response = lasso_response_new(); + LASSO_PROFILE_CONTEXT(authn)->response = lasso_response_new(); } - provider = lasso_server_authentication_get_provider(authn->server, authn->peer_providerID); + provider = lasso_server_get_provider(LASSO_PROFILE_CONTEXT(authn)->server, + LASSO_PROFILE_CONTEXT(authn)->remote_providerID); if (xmlStrEqual(lasso_node_get_child_content(provider->metadata, "AuthnRequestsSigned", NULL), "true")) { signature_status = lasso_query_verify_signature(request, provider->public_key, - authn->server->private_key); + LASSO_PROFILE_CONTEXT(authn)->server->private_key); /* Status & StatusCode */ if (signature_status == 0 || signature_status == 2) { switch (signature_status) { - case 0: - set_response_status(authn->response, lassoLibStatusCodeInvalidSignature); + case 0: // Invalid Signature + lasso_profile_context_set_response_status(LASSO_PROFILE_CONTEXT(authn), + lassoLibStatusCodeInvalidSignature); break; - case 2: - set_response_status(authn->response, lassoLibStatusCodeUnsignedAuthnRequest); + case 2: // Unsigned AuthnRequest + lasso_profile_context_set_response_status(LASSO_PROFILE_CONTEXT(authn), + lassoLibStatusCodeUnsignedAuthnRequest); break; } } } break; - case lasso_protocol_method_post: + case lassoProfileContextMethodPost: printf("TODO - lasso_authentication_process_authnRequest() - implement the parsing of the post request\n"); break; default: @@ -175,11 +177,11 @@ lasso_authentication_process_request(LassoAuthentication *authn, } /* verify if the user must be authenticated or not */ - if (xmlStrEqual(lasso_node_get_child_content(authn->request, "IsPassive", NULL), "false")) { + if (xmlStrEqual(lasso_node_get_child_content(LASSO_PROFILE_CONTEXT(authn)->request, "IsPassive", NULL), "false")) { isPassive = FALSE; } - if (xmlStrEqual(lasso_node_get_child_content(authn->request, "ForceAuthn", NULL), "true")) { + if (xmlStrEqual(lasso_node_get_child_content(LASSO_PROFILE_CONTEXT(authn)->request, "ForceAuthn", NULL), "true")) { forceAuthn = TRUE; } @@ -188,7 +190,8 @@ lasso_authentication_process_request(LassoAuthentication *authn, must_authenticate = TRUE; } else if (is_authenticated == FALSE && isPassive == TRUE) { - set_response_status(authn->response, lassoLibStatusCodeNoPassive); + lasso_profile_context_set_response_status(LASSO_PROFILE_CONTEXT(authn), + lassoLibStatusCodeNoPassive); must_authenticate = FALSE; } @@ -211,22 +214,25 @@ lasso_authentication_process_authentication_result(LassoAuthentication *authn, printf("process authentication\n"); /* verify if a user context exists */ - if (authn->user == NULL) { - authn->user = lasso_user_authentication_new(); + if (LASSO_PROFILE_CONTEXT(authn)->user == NULL) { + LASSO_PROFILE_CONTEXT(authn)->user = lasso_user_new(); } - identity = lasso_user_find_identity(authn->user, authn->peer_providerID); - nameIDPolicy = lasso_node_get_child_content(authn->request, "NameIDPolicy", NULL); + identity = lasso_user_find_identity(LASSO_PROFILE_CONTEXT(authn)->user, + LASSO_PROFILE_CONTEXT(authn)->remote_providerID); + nameIDPolicy = lasso_node_get_child_content(LASSO_PROFILE_CONTEXT(authn)->request, + "NameIDPolicy", NULL); printf("NameIDPolicy %s\n", nameIDPolicy); if (xmlStrEqual(nameIDPolicy, lassoLibNameIDPolicyTypeNone)) { if (identity == NULL) { - set_response_status(authn->response, lassoLibStatusCodeFederationDoesNotExist); + lasso_profile_context_set_response_status(LASSO_PROFILE_CONTEXT(authn), + lassoLibStatusCodeFederationDoesNotExist); } } - else if (!strcmp(nameIDPolicy, lassoLibNameIDPolicyTypeFederated)) { + else if (xmlStrEqual(nameIDPolicy, lassoLibNameIDPolicyTypeFederated)) { printf("DEBUG - NameIDPolicy is federated\n"); if (identity == NULL) { - identity = lasso_identity_new(authn->peer_providerID); + identity = lasso_identity_new(LASSO_PROFILE_CONTEXT(authn)->remote_providerID); idpProvidedNameIdentifier = LASSO_NODE(lasso_lib_idp_provided_name_identifier_new(lasso_build_unique_id(32))); lasso_identity_set_local_name_identifier(identity, idpProvidedNameIdentifier); } @@ -254,9 +260,10 @@ lasso_authentication_process_authentication_result(LassoAuthentication *authn, } /* return a response message */ - protocolProfile = lasso_node_get_child_content(authn->request, "ProtocolProfile", NULL); + protocolProfile = lasso_node_get_child_content(LASSO_PROFILE_CONTEXT(authn)->request, + "ProtocolProfile", NULL); if (xmlStrEqual(protocolProfile, lassoLibProtocolProfilePost)) { - str = lasso_node_export_to_base64(authn->response); + str = lasso_node_export_to_base64(LASSO_PROFILE_CONTEXT(authn)->response); } else { printf("DEBUG - return a artifact message\n"); @@ -265,6 +272,38 @@ lasso_authentication_process_authentication_result(LassoAuthentication *authn, return(str); } +void +lasso_authentication_set_forceAuthn(LassoAuthentication *authn, + const xmlChar *forceAuthn) +{ + lasso_lib_authn_request_set_forceAuthn(LASSO_LIB_AUTHN_REQUEST(LASSO_PROFILE_CONTEXT(authn)->request), + forceAuthn); +} + +void +lasso_authentication_set_isPassive(LassoAuthentication *authn, + gboolean *isPassive) +{ + lasso_lib_authn_request_set_isPassive(LASSO_LIB_AUTHN_REQUEST(LASSO_PROFILE_CONTEXT(authn)->request), + isPassive); +} + +void +lasso_authentication_set_nameIDPolicy(LassoAuthentication *authn, + const xmlChar *nameIDPolicy) +{ + lasso_lib_authn_request_set_nameIDPolicy(LASSO_LIB_AUTHN_REQUEST(LASSO_PROFILE_CONTEXT(authn)->request), + nameIDPolicy); +} + +void +lasso_authentication_set_protocolProfile(LassoAuthentication *authn, + const xmlChar *protocolProfile) +{ + lasso_lib_authn_request_set_protocolProfile(LASSO_LIB_AUTHN_REQUEST(LASSO_PROFILE_CONTEXT(authn)->request), + protocolProfile); +} + /*****************************************************************************/ /* instance and class init functions */ /*****************************************************************************/ @@ -272,13 +311,6 @@ lasso_authentication_process_authentication_result(LassoAuthentication *authn, static void lasso_authentication_instance_init(LassoAuthentication *authn) { - authn->user = NULL; - authn->message = NULL; - authn->request = NULL; - authn->response = NULL; - authn->local_providerID = NULL; - authn->peer_providerID = NULL; - authn->request_protocol_method = 0; } static void @@ -294,12 +326,14 @@ GType lasso_authentication_get_type() { sizeof (LassoAuthenticationClass), NULL, NULL, - (GClassInitFunc) lasso_authentication_class_init, +/* (GClassInitFunc) lasso_authentication_class_init, */ + NULL, NULL, NULL, sizeof(LassoAuthentication), 0, - (GInstanceInitFunc) lasso_authentication_instance_init, +/* (GInstanceInitFunc) lasso_authentication_instance_init, */ + NULL, }; this_type = g_type_register_static(LASSO_TYPE_PROFILE_CONTEXT, @@ -309,28 +343,24 @@ GType lasso_authentication_get_type() { return this_type; } -LassoAuthentication* -lasso_authentication_new(LassoServerAuthentication *server, - LassoUserAuthentication *user, - gchar *local_providerID, - gchar *peer_providerID) +LassoProfileContext* +lasso_authentication_new(LassoServer *server, + LassoUser *user, + gchar *local_providerID, + gchar *remote_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); - - LassoAuthentication *authn; - - authn = g_object_new(LASSO_TYPE_AUTHENTICATION, NULL); + g_return_val_if_fail(remote_providerID != NULL, NULL); - ->server = server; - - if (user != NULL) { - authn->user = user; - } + LassoProfileContext *authn; - lasso_authentication_set_local_providerID(authn, local_providerID); - lasso_authentication_set_peer_providerID(authn, peer_providerID); + authn = LASSO_PROFILE_CONTEXT(g_object_new(LASSO_TYPE_AUTHENTICATION, + "server", server, + "user", user, + "local_providerID", local_providerID, + "remote_providerID", remote_providerID, + NULL)); - return (); + return (authn); } diff --git a/lasso/id-ff/authentication.h b/lasso/id-ff/authentication.h index 31215cff..c7275b04 100644 --- a/lasso/id-ff/authentication.h +++ b/lasso/id-ff/authentication.h @@ -32,10 +32,10 @@ extern "C" { #endif /* __cplusplus */ #include <lasso/xml/xml.h> +#include <lasso/protocols/provider.h> #include <lasso/environs/profile_context.h> -#include <lasso/environs/provider.h> -#include <lasso/environs/server_context.h> -#include <lasso/environs/user_context.h> +#include <lasso/environs/server.h> +#include <lasso/environs/user.h> #define LASSO_TYPE_AUTHENTICATION (lasso_authentication_get_type()) #define LASSO_AUTHENTICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_AUTHENTICATION, LassoAuthentication)) @@ -59,16 +59,12 @@ struct _LassoAuthenticationClass { LASSO_EXPORT GType lasso_authentication_get_type (void); -LASSO_EXPORT LassoAuthentication* lasso_authentication_new (LassoServerAuthentication *server, - LassoUserAuthentication *user, - gchar *local_providerID, - gchar *peer_providerID); +LASSO_EXPORT LassoProfileContext* lasso_authentication_new (LassoServer *server, + LassoUser *user, + gchar *local_providerID, + gchar *remote_providerID); -LASSO_EXPORT gchar* lasso_authentication_build_request (LassoAuthentication *authn, - const gchar *responseProtocolProfile, - gboolean isPassive, - gboolean forceAuthn, - const gchar *nameIDPolicy); +LASSO_EXPORT gchar* lasso_authentication_build_request (LassoAuthentication *authn); LASSO_EXPORT xmlChar* lasso_authentication_process_artifact (LassoAuthentication *authn, gchar *artifact); @@ -85,6 +81,17 @@ LASSO_EXPORT gchar* lasso_authentication_process_authentication_re gint authentication_result, const char *authentication_method); +LASSO_EXPORT void lasso_authentication_set_forceAuthn (LassoAuthentication *authn, + const xmlChar *forceAuthn); + +LASSO_EXPORT void lasso_authentication_set_isPassive (LassoAuthentication *authn, + gboolean *isPassive); + +LASSO_EXPORT void lasso_authentication_set_nameIDPolicy (LassoAuthentication *authn, + const xmlChar *nameIDPolicy); + +LASSO_EXPORT void lasso_authentication_set_protocolProfile (LassoAuthentication *authn, + const xmlChar *protocolProfile); #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lasso/id-ff/profile_context.c b/lasso/id-ff/profile_context.c index 0ba84434..eecfdae6 100644 --- a/lasso/id-ff/profile_context.c +++ b/lasso/id-ff/profile_context.c @@ -26,33 +26,12 @@ #include <lasso/protocols/request.h> #include <lasso/protocols/response.h> #include <lasso/protocols/authn_response.h> -#include <lasso/environs/context.h> +#include <lasso/environs/profile_context.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 */ /*****************************************************************************/ @@ -71,25 +50,49 @@ lasso_profile_context_set_local_providerID(LassoProfileContext *ctx, } gint -lasso_profile_context_set_peer_providerID(LassoProfileContext *ctx, - gchar *providerID) +lasso_profile_context_set_remote_providerID(LassoProfileContext *ctx, + gchar *providerID) { - if (ctx->peer_providerID) { - free(ctx->peer_providerID); + if (ctx->remote_providerID) { + free(ctx->remote_providerID); } - ctx->peer_providerID = (char *)malloc(strlen(providerID)+1); - strcpy(ctx->peer_providerID, providerID); + ctx->remote_providerID = (char *)malloc(strlen(providerID)+1); + strcpy(ctx->remote_providerID, providerID); return (1); } +void +lasso_profile_context_set_response_status(LassoProfileContext *ctx, + 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(ctx->response), + LASSO_SAMLP_STATUS(status)); + lasso_node_destroy(status_code); + lasso_node_destroy(status); +} + + /*****************************************************************************/ /* instance and class init functions */ /*****************************************************************************/ enum { LASSO_PROFILE_CONTEXT_SERVER = 1, - LASSO_PROFILE_CONTEXT_USER = 2, + LASSO_PROFILE_CONTEXT_USER, + LASSO_PROFILE_CONTEXT_LOCAL_PROVIDERID, + LASSO_PROFILE_CONTEXT_REMOTE_PROVIDERID, }; static void @@ -102,7 +105,7 @@ lasso_profile_context_instance_init(GTypeInstance *instance, ctx->request = NULL; ctx->response = NULL; ctx->local_providerID = NULL; - ctx->peer_providerID = NULL; + ctx->remote_providerID = NULL; ctx->request_protocol_method = 0; } @@ -122,7 +125,17 @@ lasso_profile_context_set_property (GObject *object, break; case LASSO_PROFILE_CONTEXT_USER: { g_object_unref(self->user); - self->user = g_value_get_pointer (user); + self->user = g_value_get_pointer (value); + } + break; + case LASSO_PROFILE_CONTEXT_LOCAL_PROVIDERID: { + g_free (self->local_providerID); + self->local_providerID = g_value_dup_string (value); + } + break; + case LASSO_PROFILE_CONTEXT_REMOTE_PROVIDERID: { + g_free (self->remote_providerID); + self->remote_providerID = g_value_dup_string (value); } break; default: @@ -133,6 +146,14 @@ lasso_profile_context_set_property (GObject *object, } static void +lasso_profile_context_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ +} + +static void lasso_profile_context_class_init(gpointer g_class, gpointer g_class_data) { @@ -141,11 +162,11 @@ lasso_profile_context_class_init(gpointer g_class, GParamSpec *pspec; gobject_class->set_property = lasso_profile_context_set_property; + gobject_class->get_property = lasso_profile_context_get_property; pspec = g_param_spec_pointer ("server", - "servers metadata and keys/cert", + "server metadata and keys/certs", "Set datas of server", - NULL /* default value */, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); g_object_class_install_property (gobject_class, LASSO_PROFILE_CONTEXT_SERVER, @@ -154,11 +175,28 @@ lasso_profile_context_class_init(gpointer g_class, pspec = g_param_spec_pointer ("user", "user assertion and identities", "Set user's datas", - NULL /* default value */, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); g_object_class_install_property (gobject_class, LASSO_PROFILE_CONTEXT_USER, pspec); + + pspec = g_param_spec_string ("local_providerID", + "local ProviderID", + "Set local ProviderID", + NULL, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + LASSO_PROFILE_CONTEXT_LOCAL_PROVIDERID, + pspec); + + pspec = g_param_spec_string ("remote_providerID", + "remote ProviderID", + "Set remote ProviderID", + NULL, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + LASSO_PROFILE_CONTEXT_REMOTE_PROVIDERID, + pspec); } GType lasso_profile_context_get_type() { @@ -185,27 +223,26 @@ GType lasso_profile_context_get_type() { } LassoProfileContext* -lasso_profile_context_new(LassoServerProfileContext *server, - LassoUserProfileContext *user, - gchar *local_providerID, - gchar *peer_providerID) +lasso_profile_context_new(LassoServer *server, + LassoUser *user, + gchar *local_providerID, + gchar *remote_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); + g_return_val_if_fail(remote_providerID != NULL, NULL); LassoProfileContext *ctx; - ctx = g_object_new(LASSO_TYPE_PROFILE_CONTEXT, NULL); - - ctx->server = server; - - if (user != NULL) { - ctx->user = user; - } + ctx = g_object_new(LASSO_TYPE_PROFILE_CONTEXT, + "server", server, + "user", user, + "local_providerID", local_providerID, + "remote_providerID", remote_providerID, + NULL); - lasso_profile_context_set_local_providerID(ctx, local_providerID); - lasso_profile_context_set_peer_providerID(ctx, peer_providerID); +/* lasso_profile_context_set_local_providerID(ctx, local_providerID); */ +/* lasso_profile_context_set_remote_providerID(ctx, remote_providerID); */ return (ctx); } diff --git a/lasso/id-ff/profile_context.h b/lasso/id-ff/profile_context.h index 7cbca139..10acfb59 100644 --- a/lasso/id-ff/profile_context.h +++ b/lasso/id-ff/profile_context.h @@ -64,7 +64,7 @@ struct _LassoProfileContext { LassoNode *response; gchar *local_providerID; - gchar *peer_providerID; + gchar *remote_providerID; gint request_protocol_method; @@ -80,14 +80,17 @@ LASSO_EXPORT GType lasso_profile_context_get_type (vo LASSO_EXPORT LassoProfileContext* lasso_profile_context_new (LassoServer *server, LassoUser *user, gchar *local_providerID, - gchar *peer_providerID); + gchar *remote_providerID); LASSO_EXPORT gint lasso_profile_context_set_local_providerID (LassoProfileContext *ctx, gchar *providerID); -LASSO_EXPORT gint lasso_profile_context_set_peer_providerID (LassoProfileContext *ctx, +LASSO_EXPORT gint lasso_profile_context_set_remote_providerID(LassoProfileContext *ctx, gchar *providerID); +LASSO_EXPORT void lasso_profile_context_set_response_status (LassoProfileContext *ctx, + const xmlChar *statusCodeValue); + #ifdef __cplusplus } #endif /* __cplusplus */ |