source: examples/python_tests/payraise_rt1/query.py @ 340bd01

mei_rt2mei_rt2_fix_1
Last change on this file since 340bd01 was 2efdff5, checked in by Mei <mei@…>, 12 years ago

1) fix the missing check for 'This' rt2.y when called from creddy/prover

combo

2) patch up the stringify of abac_term that is of time type.
3) update the testing to reflect the changes to baseline output

  • Property mode set to 100755
File size: 2.1 KB
RevLine 
[7211a95]1#!/usr/bin/env python
2
3"""
[f824a9e]4Run the queries described in README
[7211a95]5
6cmd1:env keystore=`pwd` ./query.py
7cmd2: env ABAC_CN=1 keystore=`pwd` ./query.py
8
9"""
10
11import os
12import ABAC
13
14ctxt = ABAC.Context()
15
[f824a9e]16# Keystore is the directory containing the principal credentials.
17# Load existing principals and/or policy credentials
18if (os.environ.has_key("keystore")) :
19    keystore=os.environ["keystore"]
20    ctxt.load_directory(keystore)
21else:
22    print("keystore is not set...")
23    exit(1)
[7211a95]24
[f824a9e]25# retrieve principals' keyid value from local credential files
[7211a95]26alphaID=ABAC.ID("Alpha_ID.pem");
27alphaID.id_load_privkey_file("Alpha_private.pem");
28alpha=alphaID.id_keyid()
29
30bobID=ABAC.ID("Bob_ID.pem");
31bobID.id_load_privkey_file("Bob_private.pem");
32bob=bobID.id_keyid()
33
34maryannID=ABAC.ID("Maryann_ID.pem");
35maryannID.id_load_privkey_file("Maryann_private.pem");
36maryann=maryannID.id_keyid()
37
38joeID=ABAC.ID("Joe_ID.pem");
39joeID.id_load_privkey_file("Joe_private.pem");
40joe=joeID.id_keyid()
41
42##########################################################################
[f824a9e]43# dump the loaded principals/policies
44#
45out = ctxt.context_principals()
46print "\n...final principal set..."
47for x in out[1]:
48    print "%s " % x.string()
49out = ctxt.context_credentials()
50print "\n...final policy attribute set..."
51for c in out[1]:
52    print "%s <- %s" % (c.head_string(), c.tail_string())
53
54##########################################################################
55# Is Joe getting a pay raise ?
[7211a95]56# role=[keyid:alpha].role:payRaise
57# p=[keyid:Joe]
58role = ABAC.Role(alpha,"payRaise")
59p = ABAC.Role(joe)
60print "\n===bad============ alpha.payRaise <- Joe"
61out = ctxt.query(role, p)
62for c in out[1]:
63    print "%s <- %s" % (c.head_string(), c.tail_string())
64
65
66
67##########################################################################
[f824a9e]68# Is Maryann getting a pay raise ?
[7211a95]69# role=[keyid:alpha].role:payRaise
70# p=[keyid:Maryann]
71role = ABAC.Role(alpha,"payRaise")
72p = ABAC.Role(maryann)
73print "\n===good============ alpha.payRaise <- Maryann"
74out = ctxt.query(role, p)
75for c in out[1]:
76    print "%s <- %s" % (c.head_string(), c.tail_string())
77
[2efdff5]78
79##########################################################################
80#ctxt.dump_yap_db()
81
Note: See TracBrowser for help on using the repository browser.