source: swig/python/abac_prover.py @ 0cdea0b

abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2tvf-new-xml
Last change on this file since 0cdea0b 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.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"
49
50for credential in credentials:
51    print "credential %s <- %s" % (credential.head().string(), credential.tail().string())
52    # pp.pprint(credential)
Note: See TracBrowser for help on using the repository browser.