~ubuntu-branches/ubuntu/intrepid/lasso/intrepid-security

« back to all changes in this revision

Viewing changes to lasso/id-ff/server.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: server.c,v 1.108 2006/03/04 12:35:37 fpeters Exp $
 
1
/* $Id: server.c,v 1.124 2007/01/05 11:40:10 fpeters Exp $
2
2
 *
3
3
 * Lasso - A free implementation of the Liberty Alliance specifications.
4
4
 *
30
30
#include <lasso/id-ff/providerprivate.h>
31
31
#include <lasso/id-ff/serverprivate.h>
32
32
 
33
 
struct _LassoServerPrivate
34
 
{
35
 
        gboolean dispose_has_run;
36
 
};
 
33
#include <lasso/saml-2.0/serverprivate.h>
 
34
 
37
35
 
38
36
/*****************************************************************************/
39
37
/* public methods                                                            */
64
62
        if (provider == NULL) {
65
63
                return critical_error(LASSO_SERVER_ERROR_ADD_PROVIDER_FAILED);
66
64
        }
 
65
        provider->role = role;
67
66
 
68
67
        if (LASSO_PROVIDER(server)->private_data->conformance == LASSO_PROTOCOL_SAML_2_0 &&
69
68
                        provider->private_data->conformance != LASSO_PROTOCOL_SAML_2_0) {
121
120
}
122
121
 
123
122
 
 
123
/**
 
124
 * lasso_server_set_encryption_private_key:
 
125
 * @server: a #LassoServer
 
126
 * @filename: file name of the encryption key to load
 
127
 *
 
128
 * Load an encryption private key from a file and set it in the server object
 
129
 *
 
130
 * Return value: 0 on success; another value if an error occured.
 
131
 **/
 
132
int
 
133
lasso_server_set_encryption_private_key(LassoServer *server, const gchar *filename)
 
134
{
 
135
        LassoPemFileType file_type;
 
136
 
 
137
        if (server->private_data->encryption_private_key != NULL) {
 
138
                xmlSecKeyDestroy(server->private_data->encryption_private_key);
 
139
                server->private_data->encryption_private_key = NULL;
 
140
        }
 
141
        file_type = lasso_get_pem_file_type(filename);
 
142
        if (file_type == LASSO_PEM_FILE_TYPE_PRIVATE_KEY) {
 
143
                server->private_data->encryption_private_key = xmlSecCryptoAppKeyLoad(filename,
 
144
                        xmlSecKeyDataFormatPem, NULL, NULL, NULL);
 
145
        }
 
146
 
 
147
        if (server->private_data->encryption_private_key == NULL)
 
148
                return LASSO_SERVER_ERROR_SET_ENCRYPTION_PRIVATE_KEY_FAILED;
 
149
 
 
150
        return 0;
 
151
}
 
152
 
 
153
 
 
154
/**
 
155
 * lasso_server_load_affiliation:
 
156
 * @server: a #LassoServer
 
157
 * @filename: file name of the affiliation metadata to load
 
158
 *
 
159
 * Load an affiliation metadata file into @server; this must be called after
 
160
 * providers have been added to @server.
 
161
 *
 
162
 * Return value: 0 on success; another value if an error occured.
 
163
 **/
 
164
int
 
165
lasso_server_load_affiliation(LassoServer *server, const gchar *filename)
 
166
{
 
167
        LassoProvider *provider = LASSO_PROVIDER(server);
 
168
        xmlDoc *doc;
 
169
        xmlNode *node;
 
170
        int rc;
 
171
 
 
172
        doc = xmlParseFile(filename);
 
173
        if (doc == NULL) {
 
174
                return LASSO_XML_ERROR_INVALID_FILE;
 
175
        }
 
176
 
 
177
        node = xmlDocGetRootElement(doc);
 
178
        if (node == NULL || node->ns == NULL) {
 
179
                xmlFreeDoc(doc);
 
180
                return LASSO_XML_ERROR_NODE_NOT_FOUND;
 
181
        }
 
182
 
 
183
        if (provider->private_data->conformance == LASSO_PROTOCOL_SAML_2_0) {
 
184
                rc = lasso_saml20_server_load_affiliation(server, doc, node);
 
185
        } else {
 
186
                /* affiliations are not supported in ID-FF 1.2 mode */
 
187
                rc = LASSO_ERROR_UNIMPLEMENTED;
 
188
        }
 
189
 
 
190
        xmlFreeDoc(doc);
 
191
 
 
192
        return rc;
 
193
}
 
194
 
124
195
/*****************************************************************************/
125
196
/* private methods                                                           */
126
197
/*****************************************************************************/
219
290
                                }
220
291
                                p = g_object_new(LASSO_TYPE_PROVIDER, NULL);
221
292
                                LASSO_NODE_GET_CLASS(p)->init_from_xml(LASSO_NODE(p), t2);
222
 
                                if (lasso_provider_load_public_key(p) == TRUE) {
 
293
                                if (lasso_provider_load_public_key(p, LASSO_PUBLIC_KEY_SIGNING)) {
223
294
                                        g_hash_table_insert(server->providers,
224
295
                                                        g_strdup(p->ProviderID), p);
225
296
                                } else {
226
297
                                        message(G_LOG_LEVEL_CRITICAL,
227
 
                                                        "Failed to load public key for %s.",
 
298
                                                        "Failed to load signing public key for %s.",
228
299
                                                        p->ProviderID);
229
300
                                }
230
301
                                t2 = t2->next;
291
362
 *     #LassoProvider is owned by Lasso and should not be freed.
292
363
 **/
293
364
LassoProvider*
294
 
lasso_server_get_provider(LassoServer *server, gchar *providerID)
 
365
lasso_server_get_provider(LassoServer *server, const gchar *providerID)
295
366
{
296
367
        return g_hash_table_lookup(server->providers, providerID);
297
368
}
309
380
 *     freed.
310
381
 **/
311
382
LassoDiscoServiceInstance*
312
 
lasso_server_get_service(LassoServer *server, gchar *serviceType)
 
383
lasso_server_get_service(LassoServer *server, const gchar *serviceType)
313
384
{
314
385
        return g_hash_table_lookup(server->services, serviceType);
315
386
}
407
478
{
408
479
        server->private_data = g_new(LassoServerPrivate, 1);
409
480
        server->private_data->dispose_has_run = FALSE;
 
481
        server->private_data->encryption_private_key = NULL;
410
482
 
411
483
        server->providers = g_hash_table_new_full(
412
484
                        g_str_hash, g_str_equal, g_free,
417
489
        server->certificate = NULL;
418
490
        server->signature_method = LASSO_SIGNATURE_METHOD_RSA_SHA1;
419
491
 
420
 
        /* FIXME: set the value_destroy_func */
421
492
        server->services = g_hash_table_new_full(g_str_hash, g_str_equal,
422
 
                                                 (GDestroyNotify)g_free, NULL);
 
493
                        (GDestroyNotify)g_free,
 
494
                        (GDestroyNotify)lasso_node_destroy);
423
495
}
424
496
 
425
497
static void