source: libabac/abac_pl.h @ 9806e76

mei_rt2mei_rt2_fix_1meiyap-rt1rt2
Last change on this file since 9806e76 was 7b548fa, checked in by Mei <mei@…>, 12 years ago

1) add time static constraint
2) add example balltime_rt2_typed
3) change the way that time is being kept

from 20120228T080000 to time(2012,2,28,8,0,0) and
the constraint check is via compare(op,time1,time2)

  • Property mode set to 100644
File size: 5.5 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_oset_t abac_oset_t;
12typedef struct _abac_id_cert_t abac_id_cert_t;
13
14typedef struct _abac_condition_t abac_condition_t;
15typedef struct _abac_term_t abac_term_t;
16typedef struct _abac_param_list_t abac_param_list_t;
17
18/*
19 * ABAC functions, operating on an ABAC context.
20 */
21abac_context_t *abac_context_new(void);
22abac_context_t *abac_context_dup(abac_context_t *ctx);
23void abac_context_free(abac_context_t *ctx);
24
25/* see the bottom of the file for possible return codes */
26int abac_context_load_id_file(abac_context_t *ctx, char *filename);
27int abac_context_load_id_chunk(abac_context_t *ctx, abac_chunk_t cert);
28int abac_context_load_attribute_file(abac_context_t *ctx, char *filename);
29int abac_context_load_attribute_chunk(abac_context_t *ctx, abac_chunk_t cert);
30
31/* load an entire directory full of certs */
32void abac_context_load_directory(abac_context_t *ctx, char *path);
33
34/* abac query, returns a NULL-terminated array of credentials on success, NULL on fail */
35abac_credential_t **abac_context_query(abac_context_t *ctx, char *role, char *principal, int *success);
36
37/* get all the credentials from the context, returns a NULL-terminated array of credentials */
38abac_credential_t **abac_context_credentials(abac_context_t *ctx);
39
40/* use this to free the results of either of the previous two functions */
41void abac_context_credentials_free(abac_credential_t **credentials);
42
43/*
44 * Operations on credentials
45 */
46abac_role_t *abac_credential_head(abac_credential_t *cred);
47abac_role_t *abac_credential_tail(abac_credential_t *cred);
48abac_chunk_t abac_credential_attribute_cert(abac_credential_t *cred);
49abac_chunk_t abac_credential_issuer_cert(abac_credential_t *cred);
50abac_credential_t *abac_credential_lookup(char *cred_string);
51char* abac_credential_clause(abac_credential_t *cred);
52
53abac_credential_t *abac_credential_dup(abac_credential_t *cred);
54void abac_credential_free(abac_credential_t *cred);
55
56/*
57 * Operations on roles.
58 */
59abac_role_t *abac_role_principal_new(char *principal);
60abac_role_t *abac_role_role_new(char *principal, char *abac_role_name);
61abac_role_t *abac_role_linking_new(char *principal, char *linked_role, char *abac_role_name);
62abac_role_t *abac_role_intersection_new(char *name, abac_list_t *prereqs);
63
64int abac_verify_roletype(char *type);
65void abac_role_free(abac_role_t *role);
66
67abac_role_t *abac_role_from_string(char *string);
68abac_role_t *abac_role_dup(abac_role_t *role);
69
70int abac_role_is_principal(abac_role_t *role);
71int abac_role_is_role(abac_role_t *role);
72int abac_role_is_linking(abac_role_t *role);
73int abac_role_is_intersection(abac_role_t *role);
74
75char *abac_role_string(abac_role_t *role);
76char *abac_role_linked_role(abac_role_t *role);
77char *abac_role_role_name(abac_role_t *role);
78char *abac_role_role_param_string(abac_role_t *role);
79char *abac_role_principal(abac_role_t *role);
80abac_list_t *abac_role_prereqs(abac_role_t *role);
81
82abac_param_list_t *abac_role_linked_role_params(abac_role_t *role);
83abac_param_list_t *abac_role_role_params(abac_role_t *role);
84
85char *abac_role_attr_key(abac_role_t *head_role, abac_role_t *tail_role);
86char *abac_role_principal_cn(abac_role_t *role);
87char *abac_role_string_with_condition(abac_role_t *);
88
89/*
90 * Operations on oset
91 */
92char *abac_oset_principal_cn(abac_oset_t *oset);
93char *abac_oset_oset_name(abac_oset_t *oset);
94abac_param_list_t *abac_oset_oset_params(abac_oset_t *);
95int abac_oset_is_object(abac_oset_t *);
96char *abac_oset_object_cn(abac_oset_t *);
97char *abac_oset_linked_role(abac_oset_t *);
98abac_param_list_t *abac_oset_linked_role_params(abac_oset_t *);
99abac_list_t *abac_oset_prereqs(abac_oset_t *);
100int abac_oset_is_intersection(abac_oset_t *);
101abac_oset_t *abac_oset_principal_new(char *);
102abac_oset_t *abac_oset_intersection_new(char *, abac_list_t *);
103abac_oset_t *abac_oset_oset_new(char *, char *);
104abac_oset_t *abac_oset_object_new(abac_term_t *);
105char *abac_oset_principal(abac_oset_t *);
106abac_oset_t *abac_oset_linking_new(char *, char *, char *);
107char *abac_oset_string_with_condition(abac_oset_t *);
108char *abac_oset_oset_param_string(abac_oset_t *);
109
110/*
111 * Operations on term/params.
112 */
113char *abac_term_to_time(char *string);
114char *abac_term_type(int);
115abac_term_t *abac_term_new(int, char *, char *, void *);
116void abac_term_free(abac_term_t *);
117int abac_term_is_time_type(int);
118char *abac_term_name(abac_term_t *);
119abac_condition_t *abac_term_constraint(abac_term_t *term);
120abac_param_list_t *abac_param_list_new(abac_term_t *term);
121abac_param_list_t *abac_param_list_free(abac_param_list_t *ptr);
122abac_param_list_t *abac_param_list_add_term(abac_param_list_t *, abac_term_t *term);
123char* abac_param_list_string(abac_param_list_t *ptr);
124char* abac_param_list_string_with_condition(abac_param_list_t *ptr);
125
126/* from abac_verifier */
127char *abac_cn_with_sha(char*);
128char *abac_keyid_type(int);
129
130/*
131 * Error codes for loading certificates.
132 */
133#define ABAC_CERT_SUCCESS           0   // certificate loaded, all is well
134#define ABAC_CERT_INVALID           -1  // invalid format; also file not found
135#define ABAC_CERT_BAD_SIG           -2  // invalid signature
136#define ABAC_CERT_MISSING_ISSUER    -3  // missing ID cert that issued the attribute cert
137#define ABAC_CERT_BAD_CN            -4  // ID cert is not matching CN=principal format
138#define ABAC_CERT_BAD_YAP           -5  // failed to insert into prolog engine
139
140#endif /* __ABAC_H__ */
Note: See TracBrowser for help on using the repository browser.