source: swig/python/abac_prover.py @ 55c272b

abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2tvf-new-xml
Last change on this file since 55c272b 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
RevLine 
[06e2fc5]1#!/usr/bin/python
2
[7af34ed]3import getopt
[06e2fc5]4import sys
5from ABAC import *
6import pprint
7
[7af34ed]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
[06e2fc5]15pp = pprint.PrettyPrinter(indent=4)
16
[7af34ed]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"
[06e2fc5]36
[7af34ed]37if keystore == '' or role == '' or principal == '':
38    usage()
39
40# code begins here! sorry about that
[06e2fc5]41
42ctx = Context()
43ctx.load_directory(keystore)
44
[7af34ed]45(success, credentials) = ctx.query(role, principal)
46
47if success:
48    print "success"
[06e2fc5]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.