source: libabac/abac_pl.h @ 10e1588

mei_rt2mei_rt2_fix_1meiyap-rt1rt2 rt2-01
Last change on this file since 10e1588 was 202a7f9, checked in by Mei <mei@…>, 12 years ago

commited modified files for rt1

  • Property mode set to 100644
File size: 4.2 KB
Line 
1#ifndef __ABAC_H__
2#define __ABAC_H__
3
4#include <abac_common.h>
5#include <abac_list.h>
6#include <abac_stack.h>
7
8typedef struct _abac_context_t abac_context_t;
9typedef struct _abac_credential_t abac_credential_t;
10typedef struct _abac_role_t abac_role_t;
11typedef struct _abac_id_cert_t abac_id_cert_t;
12
13typedef struct _abac_condition_t abac_condition_t;
14typedef struct _abac_param_t abac_param_t;
15typedef struct _abac_param_list_t abac_param_list_t;
16
17/*
18 * ABAC functions, operating on an ABAC context.
19 */
20abac_context_t *abac_context_new(void);
21abac_context_t *abac_context_dup(abac_context_t *ctx);
22void abac_context_free(abac_context_t *ctx);
23
24/* see the bottom of the file for possible return codes */
25int abac_context_load_id_file(abac_context_t *ctx, char *filename);
26int abac_context_load_id_chunk(abac_context_t *ctx, abac_chunk_t cert);
27int abac_context_load_attribute_file(abac_context_t *ctx, char *filename);
28int abac_context_load_attribute_chunk(abac_context_t *ctx, abac_chunk_t cert);
29
30/* load an entire directory full of certs */
31void abac_context_load_directory(abac_context_t *ctx, char *path);
32
33/* abac query, returns a NULL-terminated array of credentials on success, NULL on fail */
34abac_credential_t **abac_context_query(abac_context_t *ctx, char *role, char *principal, int *success);
35
36/* get all the credentials from the context, returns a NULL-terminated array of credentials */
37abac_credential_t **abac_context_credentials(abac_context_t *ctx);
38
39/* use this to free the results of either of the previous two functions */
40void abac_context_credentials_free(abac_credential_t **credentials);
41
42/*
43 * Operations on credentials
44 */
45abac_role_t *abac_credential_head(abac_credential_t *cred);
46abac_role_t *abac_credential_tail(abac_credential_t *cred);
47abac_chunk_t abac_credential_attribute_cert(abac_credential_t *cred);
48abac_chunk_t abac_credential_issuer_cert(abac_credential_t *cred);
49abac_credential_t *abac_credential_lookup(char *cred_string);
50char* abac_credential_clause(abac_credential_t *cred);
51
52abac_credential_t *abac_credential_dup(abac_credential_t *cred);
53void abac_credential_free(abac_credential_t *cred);
54
55/*
56 * Operations on roles.
57 */
58abac_role_t *abac_role_principal_new(char *principal);
59abac_role_t *abac_role_role_new(char *principal, char *abac_role_name);
60abac_role_t *abac_role_linking_new(char *principal, char *linked_role, char *abac_role_name);
61abac_role_t *abac_role_intersection_new(char *name, abac_list_t *prereqs);
62
63int abac_verify_roletype(char *type);
64void abac_role_free(abac_role_t *role);
65
66abac_role_t *abac_role_from_string(char *string);
67abac_role_t *abac_role_dup(abac_role_t *role);
68
69int abac_role_is_principal(abac_role_t *role);
70int abac_role_is_role(abac_role_t *role);
71int abac_role_is_linking(abac_role_t *role);
72int abac_role_is_intersection(abac_role_t *role);
73
74char *abac_role_string(abac_role_t *role);
75char *abac_role_linked_role(abac_role_t *role);
76char *abac_role_role_name(abac_role_t *role);
77char *abac_role_principal(abac_role_t *role);
78abac_list_t *abac_role_prereqs(abac_role_t *role);
79
80abac_param_list_t *abac_role_linked_role_params(abac_role_t *role);
81abac_param_list_t *abac_role_role_params(abac_role_t *role);
82
83char *abac_role_attr_key(abac_role_t *head_role, abac_role_t *tail_role);
84
85/*
86 * Operations on params.
87 */
88abac_param_t *abac_param_new(int type, char *name, char *cond);
89void abac_param_free(abac_param_t *ptr);
90abac_param_list_t *abac_param_list_new(abac_param_t *param);
91abac_param_list_t *abac_param_list_free(abac_param_list_t *ptr);
92abac_param_list_t *abac_param_list_add_param(abac_param_list_t *, abac_param_t *param);
93char* abac_param_list_string(abac_param_list_t *ptr);
94char* abac_param_list_string_with_condition(abac_param_list_t *ptr);
95
96/*
97 * Error codes for loading certificates.
98 */
99#define ABAC_CERT_SUCCESS           0   // certificate loaded, all is well
100#define ABAC_CERT_INVALID           -1  // invalid format; also file not found
101#define ABAC_CERT_BAD_SIG           -2  // invalid signature
102#define ABAC_CERT_MISSING_ISSUER    -3  // missing ID cert that issued the attribute cert
103#define ABAC_CERT_BAD_CN            -4  // ID cert is not matching CN=principal format
104#define ABAC_CERT_BAD_YAP           -5  // failed to insert into prolog engine
105
106#endif /* __ABAC_H__ */
Note: See TracBrowser for help on using the repository browser.