source: swig/python/abac_prover.py @ ab52de1

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

be clear when a proof has failed

  • Property mode set to 100755
File size: 1.1 KB
Line 
1#!/usr/bin/python
2
3import getopt
4import sys
5from ABAC import *
6import pprint
7
8def usage():
9    print "Usage: abac_prover.py \\"
10    print "        --keystore <keystore> \\"
11    print "        --role <role> --principal"
12    print "    loads the keystore and runs the query role <-?- principal"
13    sys.exit(1)
14
15pp = pprint.PrettyPrinter(indent=4)
16
17keystore = ''
18role = ''
19principal = ''
20
21try:
22    opts, args = getopt.getopt(sys.argv[1:], '', ['keystore=', 'role=', 'principal='])
23except getopt.GetoptError, err:
24    print str(err)
25    sys.exit(1)
26
27for o, a in opts:
28    if o == '--keystore':
29        keystore = a
30    elif o == '--role':
31        role = a
32    elif o == '--principal':
33        principal = a
34    else:
35        assert False, "WAT"
36
37if keystore == '' or role == '' or principal == '':
38    usage()
39
40# code begins here! sorry about that
41
42ctx = Context()
43ctx.load_directory(keystore)
44
45(success, credentials) = ctx.query(role, principal)
46
47if success:
48    print "success"
49else:
50    print "fail, here's a partial proof"
51
52for credential in credentials:
53    print "credential %s <- %s" % (credential.head().string(), credential.tail().string())
54    # pp.pprint(credential)
Note: See TracBrowser for help on using the repository browser.