[8bd77b5] | 1 | #ifndef __ABAC_H__ |
---|
| 2 | #define __ABAC_H__ |
---|
| 3 | |
---|
| 4 | #include <stdlib.h> |
---|
| 5 | #include <abac_common.h> |
---|
| 6 | |
---|
| 7 | typedef struct _abac_context_t abac_context_t; |
---|
| 8 | typedef struct _abac_credential_t abac_credential_t; |
---|
| 9 | typedef struct _abac_aspect_t abac_aspect_t; |
---|
| 10 | typedef struct _abac_attribute_t abac_attribute_t; |
---|
| 11 | typedef struct _abac_id_t abac_id_t; |
---|
| 12 | typedef struct _abac_id_credential_t abac_id_credential_t; |
---|
| 13 | |
---|
| 14 | typedef struct _abac_condition_t abac_condition_t; |
---|
| 15 | typedef struct _abac_term_t abac_term_t; |
---|
[440ba20] | 16 | typedef struct _abac_item_t abac_item_t; |
---|
[8bd77b5] | 17 | typedef struct _abac_param_list_t abac_param_list_t; |
---|
| 18 | |
---|
[5d06689] | 19 | /* called within abac.hh */ |
---|
| 20 | void abac_errx(int,const char*); |
---|
[8bd77b5] | 21 | abac_condition_t *abac_condition_dup(abac_condition_t *ptr); |
---|
| 22 | void abac_condition_free(abac_condition_t *ptr); |
---|
[5f551d3] | 23 | char *abac_constraint_string(abac_condition_t *ptr); |
---|
| 24 | char *abac_constraint_typed_string(abac_condition_t *ptr); |
---|
[5d06689] | 25 | |
---|
| 26 | void abac_terms_free(abac_term_t **terms); |
---|
| 27 | abac_term_t *abac_term_dup(abac_term_t *ptr); |
---|
| 28 | void abac_term_free(abac_term_t *); |
---|
| 29 | abac_term_t *abac_term_named_create(char*); |
---|
| 30 | abac_term_t *abac_term_create(char*, char*, abac_condition_t*); |
---|
[7211a95] | 31 | abac_term_t *abac_term_id_create(abac_id_t *ptr); |
---|
[5d06689] | 32 | abac_term_t *abac_term_dup(abac_term_t *ptr); |
---|
[8bd77b5] | 33 | char *abac_term_typed_string(abac_term_t *ptr); |
---|
| 34 | char *abac_term_string(abac_term_t *ptr); |
---|
[440ba20] | 35 | bool abac_term_is_time(abac_term_t *); |
---|
[5d06689] | 36 | bool abac_term_is_urn(abac_term_t *term); |
---|
| 37 | bool abac_term_is_integer(abac_term_t *term); |
---|
| 38 | bool abac_term_is_string(abac_term_t *term); |
---|
[8bd77b5] | 39 | abac_term_t *abac_term_add_constraint(abac_term_t *ptr, abac_condition_t *cond); |
---|
[5d06689] | 40 | int abac_term_type(abac_term_t *term); |
---|
[8bd77b5] | 41 | char *abac_term_name(abac_term_t *); |
---|
[5d06689] | 42 | |
---|
| 43 | void abac_aspects_free(abac_aspect_t **aspects); |
---|
| 44 | abac_aspect_t *abac_aspect_dup(abac_aspect_t *ptr); |
---|
| 45 | void abac_aspect_free(abac_aspect_t *); |
---|
| 46 | char *abac_aspect_string(abac_aspect_t *ptr); |
---|
| 47 | char *abac_aspect_typed_string(abac_aspect_t *ptr); |
---|
| 48 | |
---|
| 49 | abac_param_list_t *abac_aspect_aspect_params(abac_aspect_t *ptr); |
---|
[8bd77b5] | 50 | abac_term_t **abac_param_list_vectorize(abac_param_list_t *ptr); |
---|
[5d06689] | 51 | abac_param_list_t *abac_aspect_linked_role_params(abac_aspect_t *ptr); |
---|
[669b481] | 52 | char *abac_oset_string(abac_aspect_t *ptr); |
---|
| 53 | char *abac_oset_typed_string(abac_aspect_t *ptr); |
---|
| 54 | char *abac_role_string(abac_aspect_t *ptr); |
---|
| 55 | char *abac_role_typed_string(abac_aspect_t *ptr); |
---|
[5d06689] | 56 | |
---|
[8bd77b5] | 57 | abac_id_t *abac_id_dup(abac_id_t *id); |
---|
[5d06689] | 58 | abac_id_t *abac_id_credential_id(abac_id_credential_t *ptr); |
---|
[8bd77b5] | 59 | abac_id_t *abac_id_from_file(char *filename); |
---|
[5d06689] | 60 | int abac_id_generate(abac_id_t **ret, char *cn, int validity); |
---|
| 61 | char *abac_id_keyid(abac_id_t *id); |
---|
| 62 | char *abac_id_cn(abac_id_t *id); |
---|
| 63 | void abac_id_free(abac_id_t *id); |
---|
[8bd77b5] | 64 | int abac_id_has_privkey(abac_id_t *id); |
---|
| 65 | void abac_id_write_cert(abac_id_t *id, FILE *out); |
---|
[5d06689] | 66 | int abac_id_write_privkey(abac_id_t *id, FILE *out); |
---|
[8bd77b5] | 67 | abac_chunk_t abac_id_cert_chunk(abac_id_t *id); |
---|
[5d06689] | 68 | char *abac_id_string(abac_id_t *id); |
---|
| 69 | int abac_id_load_privkey_file(abac_id_t *id, char *filename); |
---|
[669b481] | 70 | void abac_id_write_cert_fname(abac_id_t *id, char *filename); |
---|
| 71 | void abac_id_write_privkey_fname(abac_id_t *id, char *filename); |
---|
[8bd77b5] | 72 | |
---|
[5d06689] | 73 | abac_attribute_t *abac_attribute_dup(abac_attribute_t *ptr); |
---|
| 74 | void abac_attribute_free(abac_attribute_t *ptr); |
---|
| 75 | abac_attribute_t *abac_credential_attribute(abac_credential_t *cred); |
---|
| 76 | int abac_attribute_create(abac_attribute_t **ret,abac_aspect_t *head, abac_aspect_t *tail,int validity); |
---|
| 77 | abac_attribute_t *abac_attribute_add_tail(abac_attribute_t *ptr, abac_aspect_t *); |
---|
| 78 | char *abac_attribute_string(abac_attribute_t *ptr); |
---|
| 79 | char *abac_attribute_typed_string(abac_attribute_t *ptr); |
---|
| 80 | abac_aspect_t *abac_attribute_head(abac_attribute_t *ptr); |
---|
| 81 | abac_aspect_t *abac_attribute_tail(abac_attribute_t *ptr); |
---|
[8bd77b5] | 82 | |
---|
[5d06689] | 83 | bool abac_attribute_is_role(abac_attribute_t *ptr); |
---|
| 84 | abac_aspect_t **abac_attribute_tail_vectorized(abac_attribute_t *ptr); |
---|
| 85 | int abac_attribute_bake(abac_attribute_t *ptr); |
---|
| 86 | int abac_attribute_baked(abac_attribute_t *ptr); |
---|
| 87 | int abac_attribute_write_cert(abac_attribute_t *ptr, FILE *out); |
---|
| 88 | abac_chunk_t abac_attribute_cert_chunk(abac_attribute_t *ptr); |
---|
[669b481] | 89 | void abac_attribute_write_cert_fname(abac_attribute_t *,char*); |
---|
[5d06689] | 90 | |
---|
| 91 | void abac_context_principals_free(abac_id_credential_t **principals); |
---|
| 92 | abac_context_t *abac_context_new(void); |
---|
| 93 | abac_context_t *abac_context_dup(abac_context_t *ctx); |
---|
| 94 | void abac_context_free(abac_context_t *ctx); |
---|
[440ba20] | 95 | void show_yap_db(const char *msg); |
---|
| 96 | |
---|
[5d06689] | 97 | abac_credential_t **abac_context_query(abac_context_t *ctx, char *role, char *principal, int *success); |
---|
| 98 | abac_credential_t **abac_context_query_with_structure(abac_context_t *, abac_aspect_t*, abac_aspect_t*, int*); |
---|
| 99 | void abac_context_credentials_free(abac_credential_t **); |
---|
| 100 | abac_credential_t **abac_context_credentials(abac_context_t *); |
---|
| 101 | abac_id_credential_t **abac_context_principals(abac_context_t *); |
---|
| 102 | |
---|
[8bd77b5] | 103 | /* |
---|
| 104 | * Error codes for loading certificates. |
---|
| 105 | */ |
---|
| 106 | #define ABAC_CERT_SUCCESS 0 // certificate loaded, all is well |
---|
| 107 | #define ABAC_CERT_INVALID -1 // invalid format; also file not found |
---|
| 108 | #define ABAC_CERT_BAD_SIG -2 // invalid signature |
---|
| 109 | #define ABAC_CERT_MISSING_ISSUER -3 // missing ID cert that issued the attribute cert |
---|
| 110 | #define ABAC_CERT_BAD_CN -4 // ID cert is not matching CN=principal format |
---|
| 111 | #define ABAC_CERT_BAD_YAP -5 // failed to insert into prolog engine |
---|
[440ba20] | 112 | #define ABAC_CERT_EXISTS 1 // ID already exists (does not default to a failure) |
---|
[8bd77b5] | 113 | |
---|
| 114 | #define ABAC_ID_SUCCESS 0 |
---|
| 115 | #define ABAC_ID_GENERATE_INVALID_CN -1 |
---|
| 116 | #define ABAC_ID_GENERATE_INVALID_VALIDITY -2 |
---|
| 117 | |
---|
| 118 | #define ABAC_ATTRIBUTE_SUCCESS 0 |
---|
| 119 | #define ABAC_ATTRIBUTE_INVALID_ROLE -1 |
---|
| 120 | #define ABAC_ATTRIBUTE_INVALID_VALIDITY -2 |
---|
| 121 | #define ABAC_ATTRIBUTE_ISSUER_NOKEY -3 |
---|
[440ba20] | 122 | #define ABAC_ATTRIBUTE_FAIL -4 |
---|
| 123 | |
---|
| 124 | #define ABAC_TERM_SUCCESS 0 |
---|
| 125 | #define ABAC_TERM_FAIL -1 |
---|
[8bd77b5] | 126 | |
---|
| 127 | #define USE(evalue) ((getenv(evalue)!=NULL)?1:0) |
---|
| 128 | |
---|
[5d06689] | 129 | /* from abac_c.c, the c interface */ |
---|
| 130 | void abac_constraint_add_integer_max(abac_condition_t *cond,int val); |
---|
| 131 | void abac_constraint_add_integer_min(abac_condition_t *cond,int val); |
---|
| 132 | void abac_constraint_add_integer_target(abac_condition_t *cond,int val); |
---|
| 133 | void abac_constraint_add_float_max(abac_condition_t *cond,float val); |
---|
| 134 | void abac_constraint_add_float_min(abac_condition_t *cond,float val); |
---|
| 135 | void abac_constraint_add_float_target(abac_condition_t *cond,float val); |
---|
| 136 | void abac_constraint_add_time_max(abac_condition_t *cond,char* val); |
---|
| 137 | void abac_constraint_add_time_min(abac_condition_t *cond,char* val); |
---|
| 138 | void abac_constraint_add_time_target(abac_condition_t *cond,char* val); |
---|
| 139 | void abac_constraint_add_urn_target(abac_condition_t *cond,char* val); |
---|
| 140 | void abac_constraint_add_string_target(abac_condition_t *cond,char* val); |
---|
| 141 | void abac_constraint_add_boolean_target(abac_condition_t *cond, char* val); |
---|
| 142 | abac_condition_t *abac_constraint_from_role(abac_aspect_t *ptr); |
---|
| 143 | abac_condition_t *abac_constraint_from_oset(abac_aspect_t *ptr); |
---|
[669b481] | 144 | abac_condition_t *abac_constraint_create(char *vtype); |
---|
| 145 | |
---|
[5d06689] | 146 | abac_aspect_t *abac_role_principal_create(char *principal_name); |
---|
| 147 | abac_aspect_t *abac_oset_principal_create(char *principal_name); |
---|
| 148 | abac_aspect_t *abac_oset_create(char *principal_name, char *oset_name); |
---|
| 149 | abac_aspect_t *abac_role_create(char *principal_name, char *role_name); |
---|
[7211a95] | 150 | abac_aspect_t *abac_oset_linked_create(char *principal_name, char* linked_role_name, char *oset_name); |
---|
| 151 | abac_aspect_t *abac_role_linked_create(char *principal_name, char* linked_role_name, char *role_name); |
---|
[5d06689] | 152 | abac_aspect_t *abac_oset_object_create(abac_term_t *object); |
---|
| 153 | abac_aspect_t *abac_oset_create(char *principal_name, char *oset_name); |
---|
| 154 | bool abac_oset_is_object(abac_aspect_t *ptr); |
---|
| 155 | bool abac_oset_is_principal(abac_aspect_t *ptr); |
---|
| 156 | bool abac_role_is_principal(abac_aspect_t *ptr); |
---|
| 157 | bool abac_oset_is_linking(abac_aspect_t *ptr); |
---|
| 158 | bool abac_role_is_linking(abac_aspect_t *ptr); |
---|
| 159 | char *abac_role_linked_role(abac_aspect_t *ptr); |
---|
| 160 | char *abac_oset_linked_role(abac_aspect_t *ptr); |
---|
| 161 | char *abac_role_name(abac_aspect_t *ptr); |
---|
| 162 | char *abac_oset_name(abac_aspect_t *ptr); |
---|
| 163 | char *abac_role_principal(abac_aspect_t *ptr); |
---|
| 164 | char *abac_oset_principal(abac_aspect_t *ptr); |
---|
| 165 | void abac_role_add_data_term(abac_aspect_t *ptr, abac_term_t *param); |
---|
| 166 | void abac_oset_add_data_term(abac_aspect_t *ptr, abac_term_t *param); |
---|
| 167 | void abac_role_add_linked_data_term(abac_aspect_t *ptr, abac_term_t *param); |
---|
| 168 | void abac_oset_add_linked_data_term(abac_aspect_t *ptr, abac_term_t *param); |
---|
| 169 | char *abac_oset_object(abac_aspect_t *ptr); |
---|
[669b481] | 170 | abac_term_t **abac_role_get_linked_data_terms(abac_aspect_t *ptr); |
---|
| 171 | abac_term_t **abac_role_get_data_terms(abac_aspect_t *ptr); |
---|
| 172 | abac_term_t **abac_oset_get_linked_data_terms(abac_aspect_t *ptr); |
---|
| 173 | abac_term_t **abac_oset_get_data_terms(abac_aspect_t *ptr); |
---|
| 174 | abac_aspect_t **abac_attribute_role_tails(abac_attribute_t *ptr); |
---|
| 175 | abac_aspect_t **abac_attribute_oset_tails(abac_attribute_t *ptr); |
---|
| 176 | |
---|
| 177 | |
---|
[5d06689] | 178 | char *abac_head_string(abac_attribute_t *ptr); |
---|
| 179 | char *abac_tail_string(abac_attribute_t *ptr); |
---|
| 180 | char *abac_head_typed_string(abac_attribute_t *ptr); |
---|
| 181 | char *abac_tail_typed_string(abac_attribute_t *ptr); |
---|
[669b481] | 182 | |
---|
[5d06689] | 183 | int abac_context_load_id_chunk(abac_context_t *ctx, abac_chunk_t cert); |
---|
| 184 | int abac_context_load_attribute_file(abac_context_t *ctx, char *filename); |
---|
| 185 | int abac_context_load_id(abac_context_t *ptr, abac_id_t *id); |
---|
| 186 | int abac_context_load_id_file(abac_context_t *ptr, char *filename); |
---|
| 187 | int abac_context_load_id_files(abac_context_t *ptr, char *filename, char *keyfilename); |
---|
| 188 | int abac_context_load_attribute(abac_context_t *ptr, abac_attribute_t *attr); |
---|
| 189 | void abac_context_load_directory(abac_context_t *ctx, char *path); |
---|
| 190 | int abac_context_load_attribute_chunk(abac_context_t *ctx, abac_chunk_t cert); |
---|
| 191 | |
---|
| 192 | /* exern needed for abac.hh */ |
---|
| 193 | |
---|
[8bd77b5] | 194 | #endif /* __ABAC_H__ */ |
---|