2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
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>.
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
17 * @defgroup credential_factory credential_factory
18 * @{ @ingroup credentials
21 #ifndef CREDENTIAL_FACTORY_H_
22 #define CREDENTIAL_FACTORY_H_
24 typedef struct credential_factory_t credential_factory_t
;
25 typedef enum credential_type_t credential_type_t
;
27 #include <credentials/builder.h>
32 enum credential_type_t
{
33 /** private key, implemented in private_key_t */
35 /** public key, implemented in public_key_t */
37 /** certificates, implemented in certificate_t */
42 * enum names for credential_type_t
44 extern enum_name_t
*credential_type_names
;
47 * Manages credential construction functions and creates instances.
49 struct credential_factory_t
{
52 * Create a credential using a list of builder_part_t's.
54 * The variable argument list takes builder_part_t types followed
55 * by the type specific value. The list must be terminated using BUILD_END.
56 * All passed parts get cloned/refcounted by the builder functions,
57 * so free up allocated resources after successful and unsuccessful
60 * @param type credential type to build
61 * @param subtype subtype specific for type of the credential
62 * @param ... build_part_t arguments, BUILD_END terminated.
63 * @return type specific credential, NULL if failed
65 void* (*create
)(credential_factory_t
*this, credential_type_t type
,
69 * Register a credential builder function.
71 * The final flag indicates if the registered builder can build such
72 * a credential itself the most common encoding, without the need
73 * for an additional builder.
75 * @param type type of credential the builder creates
76 * @param subtype subtype of the credential, type specific
77 * @param final TRUE if this build does not invoke other builders
78 * @param constructor builder constructor function to register
80 void (*add_builder
)(credential_factory_t
*this,
81 credential_type_t type
, int subtype
, bool final
,
82 builder_function_t constructor
);
84 * Unregister a credential builder function.
86 * @param constructor constructor function to unregister.
88 void (*remove_builder
)(credential_factory_t
*this,
89 builder_function_t constructor
);
92 * Create an enumerator over registered builder types.
94 * The enumerator returns only builder types registered with the final
97 * @return enumerator (credential_type_t, int subtype)
99 enumerator_t
* (*create_builder_enumerator
)(credential_factory_t
*this);
102 * Destroy a credential_factory instance.
104 void (*destroy
)(credential_factory_t
*this);
108 * Create a credential_factory instance.
110 credential_factory_t
*credential_factory_create();
112 #endif /** CREDENTIAL_FACTORY_H_ @}*/