source: swig/perl/abac_prover.pl @ 605ee1d

abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0tvf-new-xml
Last change on this file since 605ee1d was 605ee1d, checked in by Mike Ryan <mikeryan@…>, 12 years ago

be clear when a proof has failed

  • Property mode set to 100755
File size: 973 bytes
Line 
1#!/usr/bin/perl
2
3use strict;
4use ABAC;
5use Getopt::Long;
6use Data::Dumper;
7$Data::Dumper::Indent = 1;
8
9my ($keystore, $role, $principal);
10GetOptions(
11    'keystore=s'    => \$keystore,
12    'role=s'        => \$role,
13    'principal=s'   => \$principal,
14) || usage();
15
16usage() unless defined $keystore && defined $role && defined $principal;
17
18# code starts here
19
20my $ctx = ABAC::Context->new;
21$ctx->load_directory($keystore);
22
23my ($success, $credentials) = $ctx->query($role, $principal);
24
25if ($success) {
26    print "Success\n";
27}
28else {
29    print "Fail, here's a partial proof\n";
30}
31
32foreach my $credential (@$credentials) {
33    printf "credential %s <- %s\n",
34        $credential->head->string,
35        $credential->tail->string;
36}
37
38sub usage {
39    print "Usage: $0 \\\n";
40    print "        --keystore <keystore> \\\n";
41    print "        --role <role> --principal <principal>\n";
42    print "    loads the keystore and runs the query role <-?- principal\n";
43    exit 1;
44}
Note: See TracBrowser for help on using the repository browser.