source: libabac/abac.h @ 55c272b

abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2tvf-new-xml
Last change on this file since 55c272b was 55c272b, checked in by Mike Ryan <mikeryan@…>, 14 years ago

remove libabac_init and libabac_deinit

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#ifndef __ABAC_H__
2#define __ABAC_H__
3
4typedef struct _abac_context_t abac_context_t;
5typedef struct _abac_credential_t abac_credential_t;
6typedef struct _abac_role_t abac_role_t;
7
8typedef struct _abac_chunk_t {
9    unsigned char *ptr;
10    int len;
11} abac_chunk_t;
12
13/*
14 * ABAC functions, operating on an ABAC context.
15 */
16abac_context_t *abac_context_new(void);
17abac_context_t *abac_context_dup(abac_context_t *ctx);
18void abac_context_free(abac_context_t *ctx);
19
20/* see the bottom of the file for possible return codes */
21int abac_context_load_id_file(abac_context_t *ctx, char *filename);
22int abac_context_load_id_chunk(abac_context_t *ctx, abac_chunk_t cert);
23int abac_context_load_attribute_file(abac_context_t *ctx, char *filename);
24int abac_context_load_attribute_chunk(abac_context_t *ctx, abac_chunk_t cert);
25
26/* load an entire directory full of certs */
27void abac_context_load_directory(abac_context_t *ctx, char *path);
28
29/* abac query, returns a NULL-terminated array of credentials on success, NULL on fail */
30abac_credential_t **abac_context_query(abac_context_t *ctx, char *role, char *principal, int *success);
31
32/* get all the credentials from the context, returns a NULL-terminated array of credentials */
33abac_credential_t **abac_context_credentials(abac_context_t *ctx);
34
35/* use this to free the results of either of the previous two functions */
36void abac_context_credentials_free(abac_credential_t **credentials);
37
38/*
39 * Operations on credentials
40 */
41abac_role_t *abac_credential_head(abac_credential_t *cred);
42abac_role_t *abac_credential_tail(abac_credential_t *cred);
43abac_chunk_t abac_credential_attribute_cert(abac_credential_t *cred);
44abac_chunk_t abac_credential_issuer_cert(abac_credential_t *cred);
45
46abac_credential_t *abac_credential_dup(abac_credential_t *cred);
47void abac_credential_free(abac_credential_t *cred);
48
49/*
50 * Operations on roles.
51 */
52abac_role_t *abac_role_principal_new(char *principal);
53abac_role_t *abac_role_role_new(char *principal, char *abac_role_name);
54abac_role_t *abac_role_linking_new(char *principal, char *linked_role, char *abac_role_name);
55
56void abac_role_free(abac_role_t *role);
57
58abac_role_t *abac_role_from_string(char *string);
59abac_role_t *abac_role_dup(abac_role_t *role);
60
61int abac_role_is_principal(abac_role_t *role);
62int abac_role_is_role(abac_role_t *role);
63int abac_role_is_linking(abac_role_t *role);
64int abac_role_is_intersection(abac_role_t *role);
65
66char *abac_role_string(abac_role_t *role);
67char *abac_role_linked_role(abac_role_t *role);
68char *abac_role_role_name(abac_role_t *role);
69char *abac_role_principal(abac_role_t *role);
70
71char *abac_role_attr_key(abac_role_t *head_role, abac_role_t *tail_role);
72
73/*
74 * Error codes for loading certificates.
75 */
76#define ABAC_CERT_SUCCESS           0   // certificate loaded, all is well
77#define ABAC_CERT_INVALID           -1  // invalid format; also file not found
78#define ABAC_CERT_BAD_SIG           -2  // invalid signature
79#define ABAC_CERT_MISSING_ISSUER    -3  // missing ID cert that issued the attribute cert
80
81#endif /* __ABAC_H__ */
Note: See TracBrowser for help on using the repository browser.