source: swig/perl/partial_proof.pl @ fbb591e

abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2tvf-new-xml
Last change on this file since fbb591e was c987819, checked in by Mike Ryan <mikeryan@…>, 14 years ago

partial proof tester

  • Property mode set to 100755
File size: 1.3 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use ABAC;
5use Data::Dumper;
6$Data::Dumper::Indent = 1;
7
8use constant {
9    ROLE        => '3f1aca4c5911b345d81c5f1a77675dce13249d0c.fed_create',
10    PRINCIPAL   => '5839d714b16bbe108642c5eb586c2173420bed19',
11};
12
13my $keystore = shift || die "Usage: prover.pl <keystore> [-v]\n";
14my $verbose = shift;
15
16ABAC::libabac_init();
17
18my $ctx = ABAC::Context->new;
19$ctx->load_directory("$keystore/1");
20
21my $ctx_add = ABAC::Context->new($ctx);
22
23my ($success, $credentials) = $ctx_add->query(ROLE, PRINCIPAL);
24my $result = $success ? 'FAIL' : 'PASS';
25printf "%-60s %s\n", 'Unsuccessful query:', $result;
26dump_creds($credentials) if $verbose;
27
28$ctx_add->load_directory("$keystore/2");
29my ($success, $credentials) = $ctx_add->query(ROLE, PRINCIPAL);
30my $result = $success ? 'PASS' : 'FAIL';
31printf "%-60s %s\n", 'Added credentials, successful query:', $result;
32dump_creds($credentials) if $verbose;
33
34my ($success, $credentials) = $ctx->query(ROLE, PRINCIPAL);
35my $result = $success ? 'FAIL' : 'PASS';
36printf "%-60s %s\n", 'Original context, failed query:', $result;
37dump_creds($credentials) if $verbose;
38
39ABAC::libabac_deinit();
40
41sub dump_creds {
42    my $credentials = shift;
43    foreach my $credential (@$credentials) {
44        printf "%s <- %s\n",
45            $credential->head->string,
46            $credential->tail->string;
47    }
48}
Note: See TracBrowser for help on using the repository browser.