source: examples/scaling_tests/daisychain/likes_python/base/QUERY.py @ b92a620

mei_rt2mei_rt2_fix_1
Last change on this file since b92a620 was 373bf68, checked in by Mei <mei@…>, 12 years ago

1) add the scaling test suite

  • Property mode set to 100755
File size: 1.3 KB
Line 
1#!/usr/bin/env python
2
3"""
4Run the queries described in README
5
6cmd2: env ABAC_CN=1 keystore=`pwd` ./query.py
7
8"""
9
10import os
11import ABAC
12
13ctxt = ABAC.Context()
14
15# Keystore is the directory containing the principal credentials.
16# Load existing principals and/or policy credentials
17if (os.environ.has_key("keystore")) :
18    keystore=os.environ["keystore"]
19    ctxt.load_directory(keystore)
20else:
21    print("keystore is not set...")
22    exit(1)
23
24##########################################################################
25# dump the loaded principals/policies
26#
27
28fd=os.open("creds_dump",os.O_WRONLY|os.O_CREAT)
29out = ctxt.context_principals()
30for x in out[1]:
31    os.write(fd, x.string())
32    os.write(fd,"\n")
33out = ctxt.context_credentials()
34for c in out[1]:
35    string="%s <- %s" % (c.head_string(), c.tail_string())
36    os.write(fd,string) 
37    os.write(fd,"\n")
38os.close(fd)
39
40##########################################################################
41# Does JohnX likes John0 ?
42# role = [keyid:JohnX].role:after
43# p [Keyid:john0]
44aid="John%s_ID.pem"% #VAL#
45aID=ABAC.ID(aid)
46a=aID.id_keyid()
47
48bID=ABAC.ID("John0_ID.pem")
49b=bID.id_keyid()
50
51role = ABAC.Role(a,"likes")
52p = ABAC.Role(b)
53
54print "\n===good============ johnN.likes <- john0 "
55out = ctxt.query(role, p)
56for c in out[1]:
57    print "%s <- %s" % (c.head_string(), c.tail_string())
58
Note: See TracBrowser for help on using the repository browser.