source: examples/access_rt2_typed/query.py @ 9502c50

mei_rt2mei_rt2_fix_1meiyap-rt1rt2
Last change on this file since 9502c50 was 9502c50, checked in by Mei <mei@…>, 12 years ago

1) rename examples' rr to run_query
2) updated some doc
3) add decode to creddy --roles and creddy --display --show so it will

show more useful attribute rule string

4) stub in the python script in one of the example directory

  • Property mode set to 100755
File size: 605 bytes
Line 
1#!/usr/bin/env python
2
3"""
4  to test with python
5
6env PYTHON_PATH=/usr/local/lib/python2.7/site-packages ABAC_CN=1 keystore=`pwd` alpha=`creddy --keyid --cert Alpha_ID.pem` bob=`creddy --keyid --cert Bob_ID.pem` ./query.py
7
8"""
9
10import os
11import ABAC
12
13ctxt = ABAC.Context()
14
15keystore=os.environ["keystore"]
16alpha=os.environ["alpha"]
17bob=os.environ["bob"]
18
19ctxt.load_directory(keystore)
20
21role ="[keyid:%s].role:access([string:'Read'],[urn:'file//fileA'])" % alpha
22p = "[keyid:%s]" % bob
23
24out = ctxt.query(role, p)
25print out
26
27for c in out[1]:
28    print "%s <- %s" % (c.head().string(), c.tail().string())
29
30
Note: See TracBrowser for help on using the repository browser.