summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2006-11-30 16:26:06 +0000
committerFrederic Peters <fpeters@entrouvert.com>2006-11-30 16:26:06 +0000
commit01fda42b98b0fb793613f55d7966ea150975a879 (patch)
treebe49ecbf2f8fc284a234e1887fb24111fdc86384
parent2552b72458e153b21a7677bbcfc6d56250dae3fd (diff)
downloadlasso-01fda42b98b0fb793613f55d7966ea150975a879.tar.gz
lasso-01fda42b98b0fb793613f55d7966ea150975a879.tar.xz
lasso-01fda42b98b0fb793613f55d7966ea150975a879.zip
removed side effects in samlp2_response/get_xmlNode
-rw-r--r--lasso/xml/saml-2.0/samlp2_response.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/lasso/xml/saml-2.0/samlp2_response.c b/lasso/xml/saml-2.0/samlp2_response.c
index 4cfb4491..2c6fb00a 100644
--- a/lasso/xml/saml-2.0/samlp2_response.c
+++ b/lasso/xml/saml-2.0/samlp2_response.c
@@ -88,29 +88,39 @@ static xmlNode*
get_xmlNode(LassoNode *node, gboolean lasso_dump)
{
LassoSamlp2Response *response = LASSO_SAMLP2_RESPONSE(node);
- GList *assertions;
+ GList *assertions, *assertions_copy;
LassoNode *encrypted_element = NULL;
xmlNode *result;
- assertions = response->Assertion;
+
/* Encrypt Assertions for messages but not for dumps */
- if (lasso_dump == FALSE && response->Assertion != NULL) {
+ if (lasso_dump == FALSE) {
+ assertions_copy = g_list_copy(response->Assertion);
for (assertions = response->Assertion;
assertions != NULL; assertions = g_list_next(assertions)) {
encrypted_element = lasso_assertion_encrypt(assertions->data);
if (encrypted_element != NULL) {
+ /* use EncryptedAssertion */
response->EncryptedAssertion = g_list_append(
response->EncryptedAssertion, encrypted_element);
- /* if there is at least one encrypted
- * assertion; consider all of them to be
- * encrypted */
- response->Assertion = NULL;
+ /* and remove original unencrypted from Assertion */
+ response->Assertion = g_list_remove(response->Assertion,
+ assertions->data);
}
}
}
result = parent_class->get_xmlNode(node, lasso_dump);
- response->Assertion = assertions;
+
+ if (lasso_dump == FALSE) {
+ g_list_free(response->Assertion);
+ response->Assertion = assertions_copy;
+ for (assertions = response->EncryptedAssertion; assertions != NULL;
+ assertions = g_list_next(assertions)) {
+ lasso_node_destroy(assertions->data);
+ }
+ g_list_free(response->EncryptedAssertion);
+ }
return result;
}