mei_rt2mei_rt2_fix_1meiyap-rt1rt2
Last change
on this file since e79018b was
da5afdf,
checked in by Mei <mei@…>, 13 years ago
|
1) add static contraint
(limited to integer at this time)
|
-
Property mode set to
100644
|
File size:
1.9 KB
|
Rev | Line | |
---|
[e95d652] | 1 | |
---|
| 2 | #include <err.h> |
---|
| 3 | #include <stdio.h> |
---|
[da5afdf] | 4 | #include <assert.h> |
---|
[e95d652] | 5 | |
---|
[202a7f9] | 6 | |
---|
[e95d652] | 7 | #include <abac_pl.h> |
---|
| 8 | |
---|
| 9 | #include "options.h" |
---|
| 10 | |
---|
[da5afdf] | 11 | extern void abac_print_cred_info(abac_credential_t*, FILE*); |
---|
[202a7f9] | 12 | |
---|
[e95d652] | 13 | int main(int argc, char **argv) { |
---|
[da5afdf] | 14 | int i, success=0; |
---|
| 15 | abac_credential_t *cred=NULL; |
---|
| 16 | abac_credential_t **credentials=NULL; |
---|
[e95d652] | 17 | |
---|
| 18 | options_t opts = { 0, }; |
---|
| 19 | get_options(argc, argv, &opts); |
---|
| 20 | abac_context_t *ctx = abac_context_new(); |
---|
| 21 | abac_context_load_directory(ctx, opts.keystore); |
---|
[da5afdf] | 22 | |
---|
| 23 | if(opts.filename) { |
---|
| 24 | credentials = abac_context_credentials(ctx); |
---|
| 25 | FILE *fp=fopen(opts.filename,"w+"); |
---|
| 26 | |
---|
| 27 | if (credentials != NULL) { |
---|
| 28 | for (i = 0; credentials[i] != NULL; ++i) { |
---|
| 29 | cred = credentials[i]; |
---|
| 30 | abac_print_cred_info(cred,fp); |
---|
| 31 | } |
---|
| 32 | abac_context_credentials_free(credentials); |
---|
| 33 | } |
---|
| 34 | fclose(fp); |
---|
| 35 | return 0; |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | char *query=NULL; |
---|
| 39 | char *with=NULL; |
---|
| 40 | if(opts.role && opts.principal) { |
---|
| 41 | query=opts.role; |
---|
| 42 | with=opts.principal; |
---|
| 43 | } else { |
---|
| 44 | if(opts.oset) { |
---|
| 45 | query=opts.oset; |
---|
| 46 | } else if(opts.principal) { |
---|
| 47 | with=opts.principal; |
---|
| 48 | } else if(opts.object) { |
---|
| 49 | with=opts.object; |
---|
| 50 | } else { |
---|
| 51 | puts("XXXX eeekkk \n"); |
---|
| 52 | assert(0); |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | credentials = abac_context_query(ctx, |
---|
| 56 | query, with, |
---|
| 57 | &success); |
---|
[e95d652] | 58 | if (success) |
---|
| 59 | puts("prover success!!"); |
---|
[da5afdf] | 60 | else puts("prover failed!!"); |
---|
[e95d652] | 61 | |
---|
[da5afdf] | 62 | if (credentials != NULL && success) { |
---|
[e95d652] | 63 | puts("credentials needed :"); |
---|
| 64 | for (i = 0; credentials[i] != NULL; ++i) { |
---|
[da5afdf] | 65 | cred = credentials[i]; |
---|
| 66 | abac_print_cred_info(cred,NULL); |
---|
[e95d652] | 67 | } |
---|
[da5afdf] | 68 | } |
---|
| 69 | if(credentials) |
---|
| 70 | abac_context_credentials_free(credentials); |
---|
[e95d652] | 71 | abac_context_free(ctx); |
---|
[da5afdf] | 72 | |
---|
[e95d652] | 73 | return 0; |
---|
| 74 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.