summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Laniel <dlaniel@entrouvert.com>2006-11-23 17:44:26 +0000
committerDamien Laniel <dlaniel@entrouvert.com>2006-11-23 17:44:26 +0000
commit0a391478bec7bb5afcb3f8a708d1abda9605e3f1 (patch)
treef2b93ece7b5d8554ae1ded531744779a22d7b355
parent03aa90b8b79681e1e9f6195767cb116047775caf (diff)
Added an original node to encrypted elements, only in dumps, for the dump to be readable
-rw-r--r--lasso/id-ff/profile.c7
-rw-r--r--lasso/saml-2.0/profile.c36
-rw-r--r--lasso/saml-2.0/profileprivate.h1
-rw-r--r--lasso/xml/saml-2.0/saml2_encrypted_element.c3
-rw-r--r--lasso/xml/saml-2.0/saml2_encrypted_element.h1
-rw-r--r--lasso/xml/xml.c4
6 files changed, 50 insertions, 2 deletions
diff --git a/lasso/id-ff/profile.c b/lasso/id-ff/profile.c
index 39b5a942..64e199e1 100644
--- a/lasso/id-ff/profile.c
+++ b/lasso/id-ff/profile.c
@@ -334,13 +334,18 @@ lasso_profile_set_identity_from_dump(LassoProfile *profile, const gchar *dump)
* Return value: 0 on success; or a negative value otherwise.
**/
gint
-lasso_profile_set_session_from_dump(LassoProfile *profile, const gchar *dump)
+lasso_profile_set_session_from_dump(LassoProfile *profile, const gchar *dump)
{
g_return_val_if_fail(dump != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
profile->session = lasso_session_new_from_dump(dump);
if (profile->session == NULL)
return critical_error(LASSO_PROFILE_ERROR_BAD_SESSION_DUMP);
+
+ IF_SAML2(profile) {
+ lasso_saml20_profile_set_session_from_dump(profile);
+ }
+
profile->session->is_dirty = FALSE;
return 0;
diff --git a/lasso/saml-2.0/profile.c b/lasso/saml-2.0/profile.c
index 81e262a4..29a4ba85 100644
--- a/lasso/saml-2.0/profile.c
+++ b/lasso/saml-2.0/profile.c
@@ -38,7 +38,7 @@
#include <lasso/xml/saml-2.0/samlp2_name_id_mapping_response.h>
#include <lasso/xml/saml-2.0/samlp2_status_response.h>
#include <lasso/xml/saml-2.0/samlp2_response.h>
-
+#include <lasso/xml/saml-2.0/saml2_assertion.h>
static char* lasso_saml20_profile_build_artifact(LassoProvider *provider);
@@ -302,3 +302,37 @@ lasso_profile_is_saml_query(const gchar *query)
return FALSE;
}
+
+static void
+add_value_to_array(gpointer key, gpointer value, GPtrArray *array)
+{
+ g_ptr_array_add(array, value);
+}
+
+gint
+lasso_saml20_profile_set_session_from_dump(LassoProfile *profile)
+{
+ GPtrArray *assertions = NULL;
+ LassoSaml2Assertion *assertion = NULL;
+ int i;
+
+ if (profile->session->assertions != NULL) {
+ assertions = g_ptr_array_sized_new(g_hash_table_size(profile->session->assertions));
+ g_hash_table_foreach(profile->session->assertions, (GHFunc) add_value_to_array,
+ assertions);
+ }
+
+ if (assertions == NULL)
+ return -1;
+
+ for (i = 0; i < assertions->len; ++i) {
+ assertion = g_ptr_array_index(assertions, i);
+ if (assertion != NULL && assertion->Subject->EncryptedID != NULL) {
+ assertion->Subject->NameID = LASSO_SAML2_NAME_ID(
+ assertion->Subject->EncryptedID->original_data);
+ assertion->Subject->EncryptedID = NULL;
+ }
+ }
+
+ return 0;
+}
diff --git a/lasso/saml-2.0/profileprivate.h b/lasso/saml-2.0/profileprivate.h
index f43c88ef..0cbd6deb 100644
--- a/lasso/saml-2.0/profileprivate.h
+++ b/lasso/saml-2.0/profileprivate.h
@@ -38,6 +38,7 @@ int lasso_saml20_profile_init_artifact_resolve(LassoProfile *profile,
int lasso_saml20_profile_process_artifact_resolve(LassoProfile *profile, const char *msg);
int lasso_saml20_profile_build_artifact_response(LassoProfile *profile);
int lasso_saml20_profile_process_artifact_response(LassoProfile *profile, const char *msg);
+gint lasso_saml20_profile_set_session_from_dump(LassoProfile *profile);
#ifdef __cplusplus
}
diff --git a/lasso/xml/saml-2.0/saml2_encrypted_element.c b/lasso/xml/saml-2.0/saml2_encrypted_element.c
index 3757401c..89f0c347 100644
--- a/lasso/xml/saml-2.0/saml2_encrypted_element.c
+++ b/lasso/xml/saml-2.0/saml2_encrypted_element.c
@@ -45,6 +45,8 @@ static struct XmlSnippet schema_snippets[] = {
G_STRUCT_OFFSET(LassoSaml2EncryptedElement, EncryptedData) },
{ "EncryptedKey", SNIPPET_LIST_XMLNODES,
G_STRUCT_OFFSET(LassoSaml2EncryptedElement, EncryptedKey) },
+ { "NameID", SNIPPET_NODE | SNIPPET_LASSO_DUMP,
+ G_STRUCT_OFFSET(LassoSaml2EncryptedElement, original_data) },
{NULL, 0, 0}
};
@@ -60,6 +62,7 @@ instance_init(LassoSaml2EncryptedElement *node)
{
node->EncryptedData = NULL;
node->EncryptedKey = NULL;
+ node->original_data = NULL;
}
static void
diff --git a/lasso/xml/saml-2.0/saml2_encrypted_element.h b/lasso/xml/saml-2.0/saml2_encrypted_element.h
index c0f47760..3aa41108 100644
--- a/lasso/xml/saml-2.0/saml2_encrypted_element.h
+++ b/lasso/xml/saml-2.0/saml2_encrypted_element.h
@@ -59,6 +59,7 @@ struct _LassoSaml2EncryptedElement {
/* elements */
xmlNode *EncryptedData;
GList *EncryptedKey;
+ LassoNode *original_data;
};
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index 141fffa5..4f40cccb 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -420,8 +420,12 @@ lasso_node_encrypt(LassoNode *lasso_node, xmlSecKey *encryption_public_key)
xmlNodePtr key_info_node2 = NULL;
xmlSecEncCtxPtr enc_ctx = NULL;
+ /* Create a new EncryptedElement */
encrypted_element = LASSO_SAML2_ENCRYPTED_ELEMENT(lasso_saml2_encrypted_element_new());
+ /* Save the original data for dumps */
+ encrypted_element->original_data = lasso_node;
+
/* Create a document to contain the node to encrypt */
doc = xmlNewDoc((xmlChar*)"1.0");
orig_node = lasso_node_get_xmlNode(lasso_node, 1);