diff options
| author | Damien Laniel <dlaniel@entrouvert.com> | 2007-06-04 16:20:53 +0000 |
|---|---|---|
| committer | Damien Laniel <dlaniel@entrouvert.com> | 2007-06-04 16:20:53 +0000 |
| commit | d9e89319796aa680c8f006cec7dc2cb04b8e6d64 (patch) | |
| tree | 2c2b12bcbf6072471c3302cb9c0ac72a159e9e98 | |
| parent | 41ec34ede5ea32b9643d23b05440095e34123259 (diff) | |
| download | lasso-d9e89319796aa680c8f006cec7dc2cb04b8e6d64.tar.gz lasso-d9e89319796aa680c8f006cec7dc2cb04b8e6d64.tar.xz lasso-d9e89319796aa680c8f006cec7dc2cb04b8e6d64.zip | |
moved identity token code from discovery to wsf2_profile
| -rw-r--r-- | lasso/id-wsf-2.0/discovery.c | 39 | ||||
| -rw-r--r-- | lasso/id-wsf-2.0/wsf2_profile.c | 57 |
2 files changed, 52 insertions, 44 deletions
diff --git a/lasso/id-wsf-2.0/discovery.c b/lasso/id-wsf-2.0/discovery.c index 7a00bb19..5c05738b 100644 --- a/lasso/id-wsf-2.0/discovery.c +++ b/lasso/id-wsf-2.0/discovery.c @@ -44,7 +44,6 @@ #include <lasso/xml/id-wsf-2.0/disco_service_type.h> #include <lasso/xml/ws/wsa_endpoint_reference.h> -#include <lasso/xml/ws/wsse_200401_security.h> #include <lasso/id-ff/server.h> #include <lasso/id-ff/provider.h> @@ -214,9 +213,6 @@ lasso_idwsf2_discovery_init_metadata_association_add(LassoIdWsf2Discovery *disco LassoWsf2Profile *profile = LASSO_WSF2_PROFILE(discovery); LassoSession *session = profile->session; LassoIdWsf2DiscoSvcMDAssociationAdd *md_association_add; - LassoSoapEnvelope *envelope; - LassoSaml2Assertion *assertion; - LassoWsse200401Security *wsse_security; LassoWsAddrEndpointReference *epr; g_return_val_if_fail(LASSO_IS_IDWSF2_DISCOVERY(discovery), @@ -230,17 +226,6 @@ lasso_idwsf2_discovery_init_metadata_association_add(LassoIdWsf2Discovery *disco /* Create request with this xml node */ lasso_wsf2_profile_init_soap_request(profile, LASSO_NODE(md_association_add)); - /* Identity token */ - assertion = lasso_session_get_assertion_identity_token(session); - - if (assertion != NULL) { - wsse_security = lasso_wsse_200401_security_new(); - wsse_security->any = g_list_append(wsse_security->any, assertion); - - envelope = profile->soap_envelope_request; - envelope->Header->Other = g_list_append(envelope->Header->Other, wsse_security); - } - epr = lasso_session_get_endpoint_reference(session, LASSO_IDWSF2_DISCO_HREF); if (epr != NULL) { profile->msg_url = g_strdup(epr->Address->content); @@ -256,10 +241,6 @@ lasso_idwsf2_discovery_process_metadata_association_add_msg(LassoIdWsf2Discovery LassoWsf2Profile *profile = LASSO_WSF2_PROFILE(discovery); LassoIdWsf2DiscoSvcMDAssociationAddResponse *response; LassoSoapEnvelope *envelope; - LassoWsse200401Security *wsse_security; - LassoSaml2Assertion *assertion; - GList *i; - GList *j; int res = 0; g_return_val_if_fail(LASSO_IS_IDWSF2_DISCOVERY(discovery), @@ -273,26 +254,6 @@ lasso_idwsf2_discovery_process_metadata_association_add_msg(LassoIdWsf2Discovery res = LASSO_PROFILE_ERROR_INVALID_SOAP_MSG; } - /* Get NameIdentifier (if exists) from the soap header */ - if (res == 0) { - envelope = profile->soap_envelope_request; - for (i = g_list_first(envelope->Header->Other); i != NULL; i = g_list_next(i)) { - if (LASSO_IS_WSSE_200401_SECURITY(i->data)) { - wsse_security = LASSO_WSSE_200401_SECURITY(i->data); - for (j = g_list_first(wsse_security->any); j != NULL; - j = g_list_next(j)) { - if (LASSO_IS_SAML2_ASSERTION(j->data)) { - assertion = LASSO_SAML2_ASSERTION(j->data); - profile->name_id = g_strdup( - assertion->Subject->NameID->content); - break; - } - } - break; - } - } - } - /* Build response */ response = LASSO_IDWSF2_DISCO_SVC_MD_ASSOCIATION_ADD_RESPONSE( lasso_idwsf2_disco_svc_md_association_add_response_new()); diff --git a/lasso/id-wsf-2.0/wsf2_profile.c b/lasso/id-wsf-2.0/wsf2_profile.c index 607be2d2..a1954f07 100644 --- a/lasso/id-wsf-2.0/wsf2_profile.c +++ b/lasso/id-wsf-2.0/wsf2_profile.c @@ -30,16 +30,21 @@ #include <xmlsec/templates.h> #include <xmlsec/crypto.h> +#include <lasso/id-ff/server.h> +#include <lasso/id-ff/providerprivate.h> + +#include <lasso/id-wsf-2.0/wsf2_profile.h> +#include <lasso/id-wsf-2.0/wsf2_profile_private.h> +#include <lasso/id-wsf-2.0/session.h> + #include <lasso/xml/soap_fault.h> #include <lasso/xml/soap_binding_correlation.h> #include <lasso/xml/soap_binding_provider.h> #include <lasso/xml/soap_binding_processing_context.h> -#include <lasso/id-ff/server.h> -#include <lasso/id-ff/providerprivate.h> +#include <lasso/xml/ws/wsse_200401_security.h> -#include <lasso/id-wsf-2.0/wsf2_profile.h> -#include <lasso/id-wsf-2.0/wsf2_profile_private.h> +#include <lasso/xml/saml-2.0/saml2_assertion.h> struct _LassoWsf2ProfilePrivate { @@ -49,7 +54,6 @@ struct _LassoWsf2ProfilePrivate GList *credentials; }; - /*****************************************************************************/ /* private methods */ /*****************************************************************************/ @@ -204,10 +208,27 @@ gint lasso_wsf2_profile_init_soap_request(LassoWsf2Profile *profile, LassoNode *request) { LassoSoapEnvelope *envelope; + LassoSession *session = profile->session; + LassoSaml2Assertion *assertion; + LassoWsse200401Security *wsse_security; + /* Initialise soap envelope */ envelope = lasso_wsf2_profile_build_soap_envelope(NULL, LASSO_PROVIDER(profile->server)->ProviderID); profile->soap_envelope_request = envelope; + + /* Add identity token (if it exists in the session) in soap header */ + assertion = lasso_session_get_assertion_identity_token(session); + + if (assertion != NULL) { + wsse_security = lasso_wsse_200401_security_new(); + wsse_security->any = g_list_append(wsse_security->any, assertion); + + envelope = profile->soap_envelope_request; + envelope->Header->Other = g_list_append(envelope->Header->Other, wsse_security); + } + + /* Add the given request in soap body */ envelope->Body->any = g_list_append(envelope->Body->any, request); return 0; @@ -228,6 +249,10 @@ gint lasso_wsf2_profile_process_soap_request_msg(LassoWsf2Profile *profile, const gchar *message) { LassoSoapEnvelope *envelope = NULL; + LassoSaml2Assertion *assertion; + LassoWsse200401Security *wsse_security; + GList *i; + GList *j; int res = 0; g_return_val_if_fail(LASSO_IS_WSF2_PROFILE(profile), @@ -239,6 +264,28 @@ lasso_wsf2_profile_process_soap_request_msg(LassoWsf2Profile *profile, const gch profile->soap_envelope_request = envelope; + /* Get NameIdentifier (if exists) from the soap header */ + for (i = g_list_first(envelope->Header->Other); i != NULL; i = g_list_next(i)) { + if (LASSO_IS_WSSE_200401_SECURITY(i->data)) { + wsse_security = LASSO_WSSE_200401_SECURITY(i->data); + for (j = g_list_first(wsse_security->any); j != NULL; + j = g_list_next(j)) { + if (LASSO_IS_SAML2_ASSERTION(j->data)) { + assertion = LASSO_SAML2_ASSERTION(j->data); + if (assertion->Subject == NULL + || assertion->Subject->NameID == NULL + || assertion->Subject->NameID->content == NULL) { + continue; + } + profile->name_id = g_strdup( + assertion->Subject->NameID->content); + break; + } + } + break; + } + } + if (envelope != NULL && envelope->Body != NULL && envelope->Body->any != NULL) { profile->request = LASSO_NODE(envelope->Body->any->data); } else { |
