source: swig/perl/partial_proof.pl @ df3fe37

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

remove libabac_init and libabac_deinit

  • 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
16my $ctx = ABAC::Context->new;
17$ctx->load_directory("$keystore/1");
18
19my $ctx_add = ABAC::Context->new($ctx);
20
21my ($success, $credentials) = $ctx_add->query(ROLE, PRINCIPAL);
22my $result = $success ? 'FAIL' : 'PASS';
23printf "%-60s %s\n", 'Unsuccessful query:', $result;
24dump_creds($credentials) if $verbose;
25
26$ctx_add->load_directory("$keystore/2");
27my ($success, $credentials) = $ctx_add->query(ROLE, PRINCIPAL);
28my $result = $success ? 'PASS' : 'FAIL';
29printf "%-60s %s\n", 'Added credentials, successful query:', $result;
30dump_creds($credentials) if $verbose;
31
32my ($success, $credentials) = $ctx->query(ROLE, PRINCIPAL);
33my $result = $success ? 'FAIL' : 'PASS';
34printf "%-60s %s\n", 'Original context, failed query:', $result;
35dump_creds($credentials) if $verbose;
36
37sub dump_creds {
38    my $credentials = shift;
39    foreach my $credential (@$credentials) {
40        printf "%s <- %s\n",
41            $credential->head->string,
42            $credential->tail->string;
43    }
44}
Note: See TracBrowser for help on using the repository browser.