Updated x509 plugin to the new builder API
[strongswan.git] / src / libstrongswan / plugins / x509 / x509_plugin.c
1 /*
2 * Copyright (C) 2008-2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "x509_plugin.h"
17
18 #include <library.h>
19 #include "x509_cert.h"
20 #include "x509_ac.h"
21 #include "x509_crl.h"
22 #include "x509_ocsp_request.h"
23 #include "x509_ocsp_response.h"
24
25 typedef struct private_x509_plugin_t private_x509_plugin_t;
26
27 /**
28 * private data of x509_plugin
29 */
30 struct private_x509_plugin_t {
31
32 /**
33 * public functions
34 */
35 x509_plugin_t public;
36 };
37
38 /**
39 * Implementation of x509_plugin_t.x509troy
40 */
41 static void destroy(private_x509_plugin_t *this)
42 {
43 lib->creds->remove_builder(lib->creds,
44 (builder_function_t)x509_cert_gen);
45 lib->creds->remove_builder(lib->creds,
46 (builder_function_t)x509_cert_load);
47 lib->creds->remove_builder(lib->creds,
48 (builder_function_t)x509_ac_gen);
49 lib->creds->remove_builder(lib->creds,
50 (builder_function_t)x509_ac_load);
51 lib->creds->remove_builder(lib->creds,
52 (builder_function_t)x509_crl_load);
53 lib->creds->remove_builder(lib->creds,
54 (builder_function_t)x509_ocsp_request_gen);
55 lib->creds->remove_builder(lib->creds,
56 (builder_function_t)x509_ocsp_response_load);
57 free(this);
58 }
59
60 /*
61 * see header file
62 */
63 plugin_t *plugin_create()
64 {
65 private_x509_plugin_t *this = malloc_thing(private_x509_plugin_t);
66
67 this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
68
69 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509,
70 (builder_function_t)x509_cert_gen);
71 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509,
72 (builder_function_t)x509_cert_load);
73 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509_AC,
74 (builder_function_t)x509_ac_gen);
75 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509_AC,
76 (builder_function_t)x509_ac_load);
77 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509_CRL,
78 (builder_function_t)x509_crl_load);
79 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509_OCSP_REQUEST,
80 (builder_function_t)x509_ocsp_request_gen);
81 lib->creds->add_builder(lib->creds, CRED_CERTIFICATE, CERT_X509_OCSP_RESPONSE,
82 (builder_function_t)x509_ocsp_response_load);
83
84 return &this->public.plugin;
85 }
86