15cae4fcdaf61dabd8fd1f759854d45309b6e2e2
[strongswan.git] / src / charon / credentials / auth_info.h
1 /*
2 * Copyright (C) 2007 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 auth_info auth_info
18 * @{ @ingroup ccredentials
19 */
20
21 #ifndef AUTH_INFO_H_
22 #define AUTH_INFO_H_
23
24 #include <utils/enumerator.h>
25
26 typedef struct auth_info_t auth_info_t;
27 typedef enum auth_item_t auth_item_t;
28
29 /**
30 * Authentication/Authorization process helper item.
31 *
32 * For the authentication process, further information may be needed. These
33 * items are defined as auth_item_t and have a AUTHN prefix.
34 * The authentication process returns important data for the authorization
35 * process, these items are defined with a AUTHZ prefix.
36 * Authentication uses AUTHN items and creates AUTHZ items during authentication,
37 * authorization reads AUTHZ values to give out privileges.
38 *
39 * +---+ +---------------------+
40 * | A | | A |
41 * | u | | u +-----------+ |
42 * | t | | t | Required | |
43 * | h | | h | auth_info | |
44 * | e | | o +-----------+ |
45 * | n | | r | |
46 * +-----------+ | t | | i | |
47 * | Provided | | i | | z V |
48 * | auth_info |--| c |-------------| a ----> match? ----|------->
49 * +-----------+ | a | | t |
50 * | t | | i |
51 * | i | | o |
52 * | o | | n |
53 * | n | | |
54 * +---+ +---------------------+
55 */
56 enum auth_item_t {
57
58 /*
59 * items provided to authentication process
60 */
61
62 /** CA certificate to use for authentication, value is certificate_t* */
63 AUTHN_CA_CERT,
64 /** Keyid of a CA certificate to use, value is identification_t* */
65 AUTHN_CA_CERT_KEYID,
66 /** intermediate certificate, value is certificate_t* */
67 AUTHN_IM_CERT,
68 /** certificate for trustchain verification, value is certificate_t* */
69 AUTHN_SUBJECT_CERT,
70
71 /*
72 * item provided to authorization process
73 */
74
75 /** subject has been authenticated by public key, value is public_key_t* */
76 AUTHZ_PUBKEY,
77 /** subject has ben authenticated using preshared secrets, value is shared_key_t* */
78 AUTHZ_PSK,
79 /** subject has been authenticated using EAP, value is eap_method_t */
80 AUTHZ_EAP,
81 /** certificate authority, value is certificate_t* */
82 AUTHZ_CA_CERT,
83 /** intermediate certificate in trustchain, value is certificate_t* */
84 AUTHZ_IM_CERT,
85 /** subject certificate, value is certificate_t* */
86 AUTHZ_SUBJECT_CERT,
87 /** result of a CRL validation, value is cert_validation_t */
88 AUTHZ_CRL_VALIDATION,
89 /** result of a OCSP validation, value is cert_validation_t */
90 AUTHZ_OCSP_VALIDATION,
91 /** subject is in attribute certificate group, value is identification_t* */
92 AUTHZ_AC_GROUP,
93 };
94
95
96 /**
97 * enum name for auth_item_t.
98 */
99 extern enum_name_t *auth_item_names;
100
101 /**
102 * The auth_info class contains auth_item_t's used for AA.
103 *
104 * A auth_info allows the separation of authentication and authorization.
105 */
106 struct auth_info_t {
107
108 /**
109 * Add an item to the set.
110 *
111 * @param type auth_info type
112 * @param value associated value to auth_info type, if any
113 */
114 void (*add_item)(auth_info_t *this, auth_item_t type, void *value);
115
116 /**
117 * Get an item.
118 *
119 * @param type auth_info type to get
120 * @param value pointer to a pointer receiving item
121 * @return bool if item has been found
122 */
123 bool (*get_item)(auth_info_t *this, auth_item_t type, void **value);
124
125 /**
126 * Create an enumerator over all items.
127 *
128 * @return enumerator over (auth_item_t type, void *value)
129 */
130 enumerator_t* (*create_item_enumerator)(auth_info_t *this);
131
132 /**
133 * Check if this fulfills a set of required constraints.
134 *
135 * @param constraints required authorization infos
136 * @return TRUE if this complies with constraints
137 */
138 bool (*complies)(auth_info_t *this, auth_info_t *constraints);
139
140 /**
141 * Merge items from other into this.
142 *
143 * Items do not get cloned, but moved from other to this.
144 *
145 * @param other items to read for merge
146 */
147 void (*merge)(auth_info_t *this, auth_info_t *other);
148
149 /**
150 * Destroy a auth_info instance with all associated values.
151 */
152 void (*destroy)(auth_info_t *this);
153 };
154
155 /**
156 * Create a auth_info instance.
157 */
158 auth_info_t *auth_info_create();
159
160 #endif /* AUTH_INFO_H_ @}*/