Wed, 20 Jun 2007 01:47:55 +0000
- Add chunks of the certificate scheme registration interface
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
1 | /** |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
2 | * @file certificate.h Public-Key Certificate API |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
3 | * @ingroup core |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
4 | */ |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
5 | |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
6 | /* |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
7 | * |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
8 | * purple |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
9 | * |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
10 | * Purple is the legal property of its developers, whose names are too numerous |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
11 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
12 | * source distribution. |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
13 | * |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
14 | * This program is free software; you can redistribute it and/or modify |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
15 | * it under the terms of the GNU General Public License as published by |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
16 | * the Free Software Foundation; either version 2 of the License, or |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
17 | * (at your option) any later version. |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
18 | * |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
19 | * This program is distributed in the hope that it will be useful, |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
22 | * GNU General Public License for more details. |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
23 | * |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
24 | * You should have received a copy of the GNU General Public License |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
25 | * along with this program; if not, write to the Free Software |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
27 | */ |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
28 | |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
29 | #include <glib.h> |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
30 | |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
31 | #include "certificate.h" |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
32 | #include "debug.h" |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
33 | |
|
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
34 | /** List holding pointers to all registered certificate schemes */ |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
35 | static GList *cert_schemes = NULL; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
36 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
37 | PurpleCertificateScheme * |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
38 | purple_certificate_find_scheme(const gchar *name) |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
39 | { |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
40 | PurpleCertificateScheme *scheme = NULL; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
41 | GList *l; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
42 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
43 | g_return_val_if_fail(name, NULL); |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
44 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
45 | /* Traverse the list of registered schemes and locate the |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
46 | one whose name matches */ |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
47 | for(l = cert_schemes; l; l = l->next) { |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
48 | scheme = (PurpleCertificateScheme *)(l->data); |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
49 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
50 | /* Name matches? that's our man */ |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
51 | if(!g_ascii_strcasecmp(scheme->name, name)) |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
52 | return scheme; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
53 | } |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
54 | |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
55 | purple_debug_warning("certificate", |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
56 | "CertificateScheme %s requested but not found.\n", |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
57 | name); |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
58 | |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
59 | /* TODO: Signalling and such? */ |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
60 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
61 | return NULL; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
62 | } |
|
17506
eff6bdd382f3
- Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff
changeset
|
63 | |
|
18251
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
64 | gboolean |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
65 | purple_certificate_register_scheme(PurpleCertificateScheme *scheme) |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
66 | { |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
67 | g_return_val_if_fail(scheme != NULL, FALSE); |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
68 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
69 | /* Make sure no scheme is registered with the same name */ |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
70 | if (purple_certificate_find_scheme(scheme->name) != NULL) { |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
71 | return FALSE; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
72 | } |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
73 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
74 | /* Okay, we're golden. Register it. */ |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
75 | cert_schemes = g_list_append(cert_schemes, scheme); |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
76 | |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
77 | /* TODO: Signalling and such? */ |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
78 | return TRUE; |
|
41e00264c49d
- Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents:
17509
diff
changeset
|
79 | } |