updated Doxyfile
[strongswan.git] / src / libstrongswan / credentials / credential_factory.h
1 /*
2 * Copyright (C) 2008 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 /**
17 * @defgroup credential_factory credential_factory
18 * @{ @ingroup credentials
19 */
20
21 #ifndef CREDENTIAL_FACTORY_H_
22 #define CREDENTIAL_FACTORY_H_
23
24 typedef struct credential_factory_t credential_factory_t;
25 typedef enum credential_type_t credential_type_t;
26
27 #include <credentials/keys/private_key.h>
28 #include <credentials/keys/public_key.h>
29 #include <credentials/certificates/certificate.h>
30 #include <credentials/builder.h>
31
32 /**
33 * Kind of credential.
34 */
35 enum credential_type_t {
36 /** private key, implemented in private_key_t */
37 CRED_PRIVATE_KEY,
38 /** public key, implemented in public_key_t */
39 CRED_PUBLIC_KEY,
40 /** certificates, implemented in certificate_t */
41 CRED_CERTIFICATE,
42 };
43
44 /**
45 * enum names for credential_type_t
46 */
47 extern enum_name_t *credential_type_names;
48
49 /**
50 * Manages credential construction functions and creates instances.
51 */
52 struct credential_factory_t {
53
54 /**
55 * Create a credential using a list of builder_part_t's.
56 *
57 * The variable argument list takes builder_part_t types followed
58 * by the type specific value. The list must be terminated using BUILD_END.
59 * All passed parts get cloned/refcounted by the builder implementations,
60 * so free up allocated ressources after successful and unsuccessful
61 * invocations.
62 *
63 * @param type credential type to build
64 * @param subtype subtype specific for type of the credential
65 * @param ... build_part_t arguments, BUILD_END terminated.
66 * @return type specific credential, NULL if failed
67 */
68 void* (*create)(credential_factory_t *this, credential_type_t type,
69 int subtype, ...);
70
71 /**
72 * Create an enumerator for a builder type.
73 *
74 * The build() method has to be called on each enumerated builder to
75 * cleanup associated ressources.
76 *
77 * @param type type of credentials the builder creates
78 * @param subtype type specific subtype, such as certificate_type_t
79 * @return enumerator over builder_t
80 */
81 enumerator_t* (*create_builder_enumerator)(credential_factory_t *this,
82 credential_type_t type, int subtype);
83
84 /**
85 * Register a builder_t constructor function.
86 *
87 * @param type type of credential the builder creates
88 * @param constructor builder constructor function to register
89 */
90 void (*add_builder)(credential_factory_t *this,
91 credential_type_t type, int subtype,
92 builder_constructor_t constructor);
93 /**
94 * Unregister a builder_t constructor function.
95 *
96 * @param constructor constructor function to unregister.
97 */
98 void (*remove_builder)(credential_factory_t *this,
99 builder_constructor_t constructor);
100
101 /**
102 * Destroy a credential_factory instance.
103 */
104 void (*destroy)(credential_factory_t *this);
105 };
106
107 /**
108 * Create a credential_factory instance.
109 */
110 credential_factory_t *credential_factory_create();
111
112 #endif /** CREDENTIAL_FACTORY_H_ @}*/