~ubuntu-branches/ubuntu/hardy/lasso/hardy

« back to all changes in this revision

Viewing changes to lasso/xml/saml-2.0/samlp2_response.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2007-07-31 21:35:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070731213526-oc6jw5mprcd5tjyy
Tags: 2.0.0-1ubuntu1
* Merge from debian unstable. Remaining changes:
  + debian/control:
    - Modify Maintainer value to match DebianMaintainerField spec.
* debian/rules:
  + Add CC=gcc-4.2 to the configure call else configure won't find jni.h
    from libgcj8-dev.
* configure{,.ac}:
  + Add missing quotes around the value for PHP[45]_LIBS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: samlp2_response.c,v 1.2 2005/11/21 18:51:52 fpeters Exp $ 
 
1
/* $Id: samlp2_response.c,v 1.13 2006/12/28 14:44:56 fpeters Exp $ 
2
2
 *
3
3
 * Lasso - A free implementation of the Liberty Alliance specifications.
4
4
 *
23
23
 */
24
24
 
25
25
#include "samlp2_response.h"
 
26
#include "saml2_assertion.h"
 
27
#include "saml2_encrypted_element.h"
26
28
 
27
29
/*
28
30
 * Schema fragment (saml-schema-protocol-2.0.xsd):
39
41
 * </complexType>
40
42
 */
41
43
 
 
44
extern LassoNode* lasso_assertion_encrypt(LassoSaml2Assertion *assertion);
 
45
 
42
46
/*****************************************************************************/
43
47
/* private methods                                                           */
44
48
/*****************************************************************************/
61
65
        char *ret, *deflated_message;
62
66
 
63
67
        deflated_message = lasso_node_build_deflated_query(node);
 
68
        if (deflated_message == NULL) {
 
69
                return NULL;
 
70
        }
64
71
        ret = g_strdup_printf("SAMLResponse=%s", deflated_message);
65
72
        /* XXX: must support RelayState (which profiles?) */
66
73
        g_free(deflated_message);
80
87
        return rc;
81
88
}
82
89
 
 
90
static xmlNode*
 
91
get_xmlNode(LassoNode *node, gboolean lasso_dump)
 
92
{
 
93
        LassoSamlp2Response *response = LASSO_SAMLP2_RESPONSE(node);
 
94
        GList *assertions, *assertions_copy;
 
95
        LassoNode *encrypted_element = NULL;
 
96
        xmlNode *result;
 
97
 
 
98
 
 
99
        /* Encrypt Assertions for messages but not for dumps */
 
100
        if (lasso_dump == FALSE) {
 
101
                assertions_copy = g_list_copy(response->Assertion);
 
102
                for (assertions = response->Assertion;
 
103
                                assertions != NULL; assertions = g_list_next(assertions)) {
 
104
                        encrypted_element = lasso_assertion_encrypt(assertions->data);
 
105
                        if (encrypted_element != NULL) {
 
106
                                /* use EncryptedAssertion */
 
107
                                response->EncryptedAssertion = g_list_append(
 
108
                                        response->EncryptedAssertion, encrypted_element);
 
109
                                /* and remove original unencrypted from Assertion */
 
110
                                response->Assertion = g_list_remove(response->Assertion,
 
111
                                        assertions->data);
 
112
                        }
 
113
                }
 
114
        }
 
115
 
 
116
        result = parent_class->get_xmlNode(node, lasso_dump);
 
117
 
 
118
        if (lasso_dump == FALSE) {
 
119
                g_list_free(response->Assertion);
 
120
                response->Assertion = assertions_copy;
 
121
                for (assertions = response->EncryptedAssertion; assertions != NULL;
 
122
                                assertions = g_list_next(assertions)) {
 
123
                        lasso_node_destroy(assertions->data);
 
124
                }
 
125
                g_list_free(response->EncryptedAssertion);
 
126
                response->EncryptedAssertion = NULL;
 
127
        }
 
128
 
 
129
        return result;
 
130
}
83
131
 
84
132
/*****************************************************************************/
85
133
/* instance and class init functions                                         */
100
148
        parent_class = g_type_class_peek_parent(klass);
101
149
        nclass->build_query = build_query;
102
150
        nclass->init_from_query = init_from_query;
 
151
        nclass->get_xmlNode = get_xmlNode;
103
152
        nclass->node_data = g_new0(LassoNodeClassData, 1);
104
153
        lasso_node_class_set_nodename(nclass, "Response"); 
105
154
        lasso_node_class_set_ns(nclass, LASSO_SAML2_PROTOCOL_HREF, LASSO_SAML2_PROTOCOL_PREFIX);