source: libabac/prover_yap.c @ e88c95b

mei_rt2mei_rt2_fix_1meiyap-rt1rt2
Last change on this file since e88c95b was da5afdf, checked in by Mei <mei@…>, 12 years ago

1) add static contraint

(limited to integer at this time)

  • Property mode set to 100644
File size: 1.9 KB
Line 
1
2#include <err.h>
3#include <stdio.h>
4#include <assert.h>
5
6
7#include <abac_pl.h>
8
9#include "options.h"
10
11extern void abac_print_cred_info(abac_credential_t*, FILE*);
12
13int main(int argc, char **argv) {
14    int i, success=0;
15    abac_credential_t *cred=NULL;
16    abac_credential_t **credentials=NULL;
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);
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);
58    if (success)
59        puts("prover success!!");
60        else puts("prover failed!!");
61
62    if (credentials != NULL && success) {
63        puts("credentials needed :");
64        for (i = 0; credentials[i] != NULL; ++i) {
65           cred = credentials[i];
66           abac_print_cred_info(cred,NULL);
67        }
68    }
69    if(credentials)
70        abac_context_credentials_free(credentials);
71    abac_context_free(ctx);
72   
73    return 0;
74}
Note: See TracBrowser for help on using the repository browser.