diff options
| author | Nicolas Clapies <nclapies@entrouvert.com> | 2004-07-30 13:39:30 +0000 |
|---|---|---|
| committer | Nicolas Clapies <nclapies@entrouvert.com> | 2004-07-30 13:39:30 +0000 |
| commit | e4b04efa9cb9adf01464d28dbea28ef03d92d1c3 (patch) | |
| tree | f0093daf90f5dc76f5d95d05c4b036443f67fa86 | |
| parent | 2f28f2508d942c9ee82c9afcdca43bbdc82d1e58 (diff) | |
| download | lasso-e4b04efa9cb9adf01464d28dbea28ef03d92d1c3.tar.gz lasso-e4b04efa9cb9adf01464d28dbea28ef03d92d1c3.tar.xz lasso-e4b04efa9cb9adf01464d28dbea28ef03d92d1c3.zip | |
lecp in environs is complete
| -rw-r--r-- | lasso/Attic/protocols/authn_request_envelope.c | 12 | ||||
| -rw-r--r-- | lasso/Attic/protocols/authn_request_envelope.h | 8 | ||||
| -rw-r--r-- | lasso/Attic/protocols/authn_response_envelope.c | 46 | ||||
| -rw-r--r-- | lasso/Attic/protocols/authn_response_envelope.h | 5 | ||||
| -rw-r--r-- | lasso/id-ff/lecp.c | 59 | ||||
| -rw-r--r-- | lasso/id-ff/lecp.h | 1 |
6 files changed, 98 insertions, 33 deletions
diff --git a/lasso/Attic/protocols/authn_request_envelope.c b/lasso/Attic/protocols/authn_request_envelope.c index 17edaefa..0058637f 100644 --- a/lasso/Attic/protocols/authn_request_envelope.c +++ b/lasso/Attic/protocols/authn_request_envelope.c @@ -79,19 +79,19 @@ GType lasso_authn_request_envelope_get_type() { } LassoNode* -lasso_authn_request_envelope_new(LassoLibAuthnRequest *authnRequest, - const xmlChar *providerID, - const xmlChar *assertionConsumerServiceURL) +lasso_authn_request_envelope_new(LassoAuthnRequest *authnRequest, + xmlChar *providerID, + xmlChar *assertionConsumerServiceURL) { LassoNode *request; - g_return_val_if_fail(LASSO_IS_LIB_AUTHN_REQUEST(authnRequest), NULL); + g_return_val_if_fail(LASSO_IS_AUTHN_REQUEST(authnRequest), NULL); g_return_val_if_fail(providerID!=NULL, NULL); g_return_val_if_fail(assertionConsumerServiceURL!=NULL, NULL); request = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_REQUEST_ENVELOPE, NULL)); - lasso_lib_authn_request_envelope_set_authnRequest(LASSO_LIB_AUTHN_REQUEST_ENVELOPE(request), authnRequest); + lasso_lib_authn_request_envelope_set_authnRequest(LASSO_LIB_AUTHN_REQUEST_ENVELOPE(request), LASSO_LIB_AUTHN_REQUEST(authnRequest)); lasso_lib_authn_request_envelope_set_providerID(LASSO_LIB_AUTHN_REQUEST_ENVELOPE(request), providerID); lasso_lib_authn_request_envelope_set_assertionConsumerServiceURL(LASSO_LIB_AUTHN_REQUEST_ENVELOPE(request), assertionConsumerServiceURL); @@ -116,7 +116,9 @@ lasso_authn_request_envelope_new_from_export(gchar *buffer, xmlSecBase64Decode(buffer, buffer_decoded, strlen(buffer)); lasso_node_import(request, buffer_decoded); xmlFree(buffer_decoded); + break; default: + message(G_LOG_LEVEL_ERROR, "Invalid export type : %d\n", export_type); break; } diff --git a/lasso/Attic/protocols/authn_request_envelope.h b/lasso/Attic/protocols/authn_request_envelope.h index 7440ac81..86e507ba 100644 --- a/lasso/Attic/protocols/authn_request_envelope.h +++ b/lasso/Attic/protocols/authn_request_envelope.h @@ -31,6 +31,8 @@ extern "C" { #endif /* __cplusplus */ #include <lasso/xml/lib_authn_request_envelope.h> +#include <lasso/protocols/authn_request.h> + #define LASSO_TYPE_AUTHN_REQUEST_ENVELOPE (lasso_authn_request_envelope_get_type()) #define LASSO_AUTHN_REQUEST_ENVELOPE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_AUTHN_REQUEST_ENVELOPE, LassoAuthnRequestEnvelope)) @@ -54,9 +56,9 @@ struct _LassoAuthnRequestEnvelopeClass { LASSO_EXPORT GType lasso_authn_request_envelope_get_type (void); -LASSO_EXPORT LassoNode* lasso_authn_request_envelope_new (LassoLibAuthnRequest *authnRequest, - const xmlChar *providerID, - const xmlChar *assertionConsumerServiceURL); +LASSO_EXPORT LassoNode* lasso_authn_request_envelope_new (LassoAuthnRequest *authnRequest, + xmlChar *providerID, + xmlChar *assertionConsumerServiceURL); LASSO_EXPORT LassoNode* lasso_authn_request_envelope_get_authnRequest (LassoAuthnRequestEnvelope *request); diff --git a/lasso/Attic/protocols/authn_response_envelope.c b/lasso/Attic/protocols/authn_response_envelope.c index 53dcc4fd..db4d3154 100644 --- a/lasso/Attic/protocols/authn_response_envelope.c +++ b/lasso/Attic/protocols/authn_response_envelope.c @@ -34,7 +34,7 @@ /* public methods */ /*****************************************************************************/ -xmlChar *lasso_authn_response_envelope_get_assertionConsumerServiceURL (LassoAuthnResponseEnvelope *response) +xmlChar *lasso_authn_response_envelope_get_assertionConsumerServiceURL(LassoAuthnResponseEnvelope *response) { g_return_val_if_fail(LASSO_IS_AUTHN_RESPONSE_ENVELOPE(response), NULL); @@ -86,41 +86,71 @@ GType lasso_authn_response_envelope_get_type() { } LassoNode* -lasso_authn_response_envelope_new(LassoLibAuthnResponse *authnResponse, - const xmlChar *assertionConsumerServiceURL) +lasso_authn_response_envelope_new(LassoAuthnResponse *authnResponse, + xmlChar *assertionConsumerServiceURL) { LassoNode *response; - g_return_val_if_fail(LASSO_IS_LIB_AUTHN_RESPONSE(authnResponse), NULL); + g_return_val_if_fail(LASSO_IS_AUTHN_RESPONSE(authnResponse), NULL); g_return_val_if_fail(assertionConsumerServiceURL!=NULL, NULL); response = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_RESPONSE_ENVELOPE, NULL)); - lasso_lib_authn_response_envelope_set_authnResponse(LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(response), authnResponse); + lasso_lib_authn_response_envelope_set_authnResponse(LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(response), + LASSO_LIB_AUTHN_RESPONSE(authnResponse)); lasso_lib_authn_response_envelope_set_assertionConsumerServiceURL(LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(response), assertionConsumerServiceURL); return(response); } +static LassoNode * +lasso_authn_response_envelope_new_from_soap(gchar *buffer) +{ + LassoNode *response; + LassoNode *envelope, *lassoNode_response; + xmlNodePtr xmlNode_response; + LassoNodeClass *class; + + response = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_RESPONSE_ENVELOPE, NULL)); + + envelope = lasso_node_new_from_dump(buffer); + lassoNode_response = lasso_node_get_child(envelope, "AuthnResponseEnvelope", NULL); + + class = LASSO_NODE_GET_CLASS(lassoNode_response); + xmlNode_response = xmlCopyNode(class->get_xmlNode(LASSO_NODE(lassoNode_response)), 1); + lasso_node_destroy(lassoNode_response); + + class = LASSO_NODE_GET_CLASS(response); + class->set_xmlNode(LASSO_NODE(response), xmlNode_response); + lasso_node_destroy(envelope); + + return(response); +} + LassoNode* lasso_authn_response_envelope_new_from_export(gchar *buffer, lassoNodeExportTypes export_type) { - LassoNode *response; + LassoNode *response = NULL; xmlChar *buffer_decoded; g_return_val_if_fail(buffer != NULL, NULL); - response = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_RESPONSE_ENVELOPE, NULL)); - switch(export_type){ case lassoNodeExportTypeBase64: + response = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_RESPONSE_ENVELOPE, NULL)); buffer_decoded = xmlMalloc(strlen(buffer)); xmlSecBase64Decode(buffer, buffer_decoded, strlen(buffer)); lasso_node_import(response, buffer_decoded); xmlFree(buffer_decoded); + break; + case lassoNodeExportTypeSoap: + response = lasso_authn_response_envelope_new_from_soap(buffer); + break; default: + message(G_LOG_LEVEL_CRITICAL, "Invalid export type\n"); + return(NULL); break; } diff --git a/lasso/Attic/protocols/authn_response_envelope.h b/lasso/Attic/protocols/authn_response_envelope.h index 146bac37..5cbaaa60 100644 --- a/lasso/Attic/protocols/authn_response_envelope.h +++ b/lasso/Attic/protocols/authn_response_envelope.h @@ -31,6 +31,7 @@ extern "C" { #endif /* __cplusplus */ #include <lasso/xml/lib_authn_response_envelope.h> +#include <lasso/protocols/authn_response.h> #define LASSO_TYPE_AUTHN_RESPONSE_ENVELOPE (lasso_authn_response_envelope_get_type()) #define LASSO_AUTHN_RESPONSE_ENVELOPE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_AUTHN_RESPONSE_ENVELOPE, LassoAuthnResponseEnvelope)) @@ -54,8 +55,8 @@ struct _LassoAuthnResponseEnvelopeClass { LASSO_EXPORT GType lasso_authn_response_envelope_get_type (void); -LASSO_EXPORT LassoNode* lasso_authn_response_envelope_new (LassoLibAuthnResponse *authnResponse, - const xmlChar *assertionConsumerServiceURL); +LASSO_EXPORT LassoNode* lasso_authn_response_envelope_new (LassoAuthnResponse *authnResponse, + xmlChar *assertionConsumerServiceURL); LASSO_EXPORT xmlChar* lasso_authn_response_envelope_get_assertionConsumerServiceURL (LassoAuthnResponseEnvelope *response); diff --git a/lasso/id-ff/lecp.c b/lasso/id-ff/lecp.c index 90649e07..97a267d7 100644 --- a/lasso/id-ff/lecp.c +++ b/lasso/id-ff/lecp.c @@ -65,7 +65,7 @@ lasso_lecp_build_authn_response_msg(LassoLecp *lecp) { g_return_val_if_fail(LASSO_IS_LECP(lecp), -1); - lecp->msg_body = lasso_node_export_to_soap(lecp->authnResponse); + lecp->msg_body = lasso_node_export_to_base64(lecp->authnResponse); if(lecp->msg_body==NULL){ message(G_LOG_LEVEL_ERROR, "Error while exporting the AuthnResponse to soap msg\n"); return(-2); @@ -94,34 +94,60 @@ lasso_lecp_destroy(LassoLecp *lecp) g_object_unref(G_OBJECT(lecp)); } + gint -lasso_lecp_init_authn_request(LassoLecp *lecp, - LassoServer *server) +lasso_lecp_init_authn_request_envelope(LassoLecp *lecp, + LassoServer *server, + LassoAuthnRequest *authnRequest) { + gchar *assertionConsumerServiceURL; + g_return_val_if_fail(LASSO_IS_LECP(lecp), -1); - lecp->server = server; - lecp->authnRequest = lasso_authn_request_new(server->providerID); + assertionConsumerServiceURL = lasso_provider_get_assertionConsumerServiceURL(LASSO_PROVIDER(server)); + + lecp->request = lasso_authn_request_envelope_new(authnRequest, + server->providerID, + assertionConsumerServiceURL); + if(lecp->request==NULL){ + message(G_LOG_LEVEL_ERROR, "Error while building request\n"); + return(-1); + } + + g_free(assertionConsumerServiceURL); return(0); } gint -lasso_lecp_init_authn_request_envelope(LassoLecp *lecp) +lasso_lecp_init_authn_response_envelope(LassoLecp *lecp, + LassoServer *server, + LassoAuthnRequest *authnRequest, + LassoAuthnResponse *authnResponse) { - gchar *assertionConsumerServiceURL; + LassoProvider *provider; + gchar *providerID, *assertionConsumerServiceURL; g_return_val_if_fail(LASSO_IS_LECP(lecp), -1); + g_return_val_if_fail(LASSO_IS_AUTHN_REQUEST(authnRequest), -1); - if(lecp->authnRequest==NULL){ - message(G_LOG_LEVEL_ERROR, "AuthnRequest not found\n"); - return(-4); + lecp->server = lasso_server_copy(server); + providerID = lasso_node_get_child_content(LASSO_NODE(authnRequest), "ProviderID", NULL); + if(providerID==NULL){ + message(G_LOG_LEVEL_CRITICAL, "ProviderID not found\n"); + return(-1); } - assertionConsumerServiceURL = lasso_provider_get_assertionConsumerServiceURL(LASSO_PROVIDER(lecp->server)); - lecp->request = lasso_authn_request_envelope_new(lecp->authnRequest, - lecp->server->providerID, - assertionConsumerServiceURL); + provider = lasso_server_get_provider(lecp->server, providerID); + assertionConsumerServiceURL = lasso_provider_get_assertionConsumerServiceURL(provider); + if(providerID==NULL){ + message(G_LOG_LEVEL_CRITICAL, "AssertionConsumerServiceURL not found\n"); + return(-1); + } + + lecp->response = lasso_authn_response_envelope_new(authnResponse, + assertionConsumerServiceURL); + g_free(assertionConsumerServiceURL); return(0); @@ -156,12 +182,15 @@ lasso_lecp_process_authn_response_envelope_msg(LassoLecp *lecp, g_return_val_if_fail(LASSO_IS_LECP(lecp), -1); g_return_val_if_fail(response_msg!=NULL, -2); - lecp->response = lasso_authn_response_envelope_new_from_export(response_msg, lassoNodeExportTypeBase64); + printf("------------------- process authn response : %s\n", response_msg); + lecp->response = lasso_authn_response_envelope_new_from_export(response_msg, lassoNodeExportTypeSoap); if (lecp->response == NULL) { message(G_LOG_LEVEL_ERROR, "Error while building the authentication response envelope\n"); return(-3); } + printf("apres new_from_dump : %s\n", lasso_node_export(lecp->response)); + lecp->authnResponse = lasso_authn_response_envelope_get_authnResponse(LASSO_AUTHN_RESPONSE_ENVELOPE(lecp->response)); if (lecp->authnResponse == NULL) { message(G_LOG_LEVEL_ERROR, "AuthnResponse not found\n"); diff --git a/lasso/id-ff/lecp.h b/lasso/id-ff/lecp.h index 63cf56cd..497792a8 100644 --- a/lasso/id-ff/lecp.h +++ b/lasso/id-ff/lecp.h @@ -38,6 +38,7 @@ extern "C" { #include <lasso/protocols/authn_response.h> #include <lasso/environs/server.h> +#include <lasso/environs/profile.h> #define LASSO_TYPE_LECP (lasso_lecp_get_type()) #define LASSO_LECP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_LECP, LassoLecp)) |
