-draft API
[oweals/gnunet.git] / src / include / gnunet_credential_service.h
1 /*
2       This file is part of GNUnet
3       Copyright (C) 2012-2014 GNUnet e.V.
4
5       GNUnet is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published
7       by the Free Software Foundation; either version 3, or (at your
8       option) any later version.
9
10       GNUnet is distributed in the hope that it will be useful, but
11       WITHOUT ANY WARRANTY; without even the implied warranty of
12       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13       General Public License for more details.
14
15       You should have received a copy of the GNU General Public License
16       along with GNUnet; see the file COPYING.  If not, write to the
17       Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18       Boston, MA 02110-1301, USA.
19  */
20
21 /**
22  * @author Martin Schanzenbach
23  *
24  * @file
25  * API to the Credential service
26  *
27  * @defgroup credential  Credential service
28  * Credentials
29  *
30  * @{
31  */
32 #ifndef GNUNET_CREDENTIAL_SERVICE_H
33 #define GNUNET_CREDENTIAL_SERVICE_H
34
35 #include "gnunet_util_lib.h"
36 #include "gnunet_gns_service.h"
37
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #if 0                           /* keep Emacsens' auto-indent happy */
42 }
43 #endif
44 #endif
45
46
47 /**
48  * Connection to the Credential service.
49  */
50 struct GNUNET_CREDENTIAL_Handle;
51
52 /**
53  * Handle to control a lookup operation.
54  */
55 struct GNUNET_CREDENTIAL_LookupRequest;
56
57
58 /**
59  * Initialize the connection with the Credential service.
60  *
61  * @param cfg configuration to use
62  * @return handle to the Credential service, or NULL on error
63  */
64 struct GNUNET_Credential_Handle *
65 GNUNET_CREDENTIAL_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
66
67
68 /**
69  * Shutdown connection with the Credentail service.
70  *
71  * @param handle connection to shut down
72  */
73 void
74 GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle);
75
76
77 /**
78  * Iterator called on obtained result for a Credential lookup.
79  *
80  * @param cls closure
81  * @param issuer the issuer chain
82  * @param issuer_len length of issuer chain
83  * @param rd the records in reply
84  */
85 typedef void (*GNUNET_CREDENTIAL_LookupResultProcessor) (void *cls,
86                                                   struct GNUNET_IDENTITY_Ego *issuer,
87               uint16_t issuer_len,
88                                                   const struct GNUNET_CREDENTIAL_Value *value);
89
90
91 /**
92  * Perform an asynchronous lookup operation for a credential.
93  *
94  * @param handle handle to the Credential service
95  * @param credential the credential to look up
96  * @param subject Ego to check the credential for
97  * @param proc function to call on result
98  * @param proc_cls closure for processor
99  * @return handle to the queued request
100  */
101 struct GNUNET_CREDENTIAL_LookupRequest *
102 GNUNET_CREDENTIAL_lookup (struct GNUNET_CREDENTIAL_Handle *handle,
103                    const char *credential,
104                    const struct GNUNET_IDENTITY_Ego *subject,
105                    GNUNET_CREDENTIAL_LookupResultProcessor proc,
106                    void *proc_cls);
107
108
109 /**
110  * Issue a credential to an identity
111  *
112  * @param handle handle to the Credential service
113  * @param issuer the identity that issues the credential
114  * @param subject the subject of the credential
115  * @param credential the name of the credential
116  * @param value the value of the credential
117  * @return handle to the queued request
118  */
119 struct GNUNET_CREDENTIAL_IssueRequest *
120 GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle,
121                          struct GNUNET_IDENTITY_Ego *issuer,
122                          struct GNUNET_IDENTITY_Ego *subject,
123                          const char *credential,
124                          struct GNUNET_CREDENTIAL_Value *value,
125                          GNUNET_CREDENTIAL_IssueResultProcessor proc,
126                          void *proc_cls);
127
128 /**
129  * Remove a credential
130  *
131  * @param handle handle to the Credential service
132  * @param issuer the identity that issued the credential
133  * @param subject the subject of the credential
134  * @param credential the name of the credential
135  * @return handle to the queued request
136  */
137 struct GNUNET_CREDENTIAL_IssueRequest *
138 GNUNET_CREDENTIAL_remove (struct GNUNET_CREDENTIAL_Handle *handle,
139                           struct GNUNET_IDENTITY_Ego *issuer,
140                           struct GNUNET_IDENTITY_Ego *subject,
141                           const char *credential,
142                           GNUNET_CREDENTIAL_IssueResultProcessor proc,
143                           void *proc_cls);
144
145
146
147 /**
148  * Cancel pending lookup request
149  *
150  * @param lr the lookup request to cancel
151  */
152 void
153 GNUNET_CREDENTIAL_lookup_cancel (struct GNUNET_CREDENTIAL_LookupRequest *lr);
154
155
156 #if 0                           /* keep Emacsens' auto-indent happy */
157 {
158 #endif
159 #ifdef __cplusplus
160 }
161 #endif
162
163 #endif
164
165 /** @} */  /* end of group */