source: examples/python_tests/basic_id/id.py @ 1621520

mei_rt2mei_rt2_fix_1
Last change on this file since 1621520 was d9c3886, checked in by Mei <mei@…>, 13 years ago

1) add 2 more query calls in abac.hh that take Role and Oset instead of

strings. Add supporting code in libabac that will take abac_aspect_t
and make query term directly instead of doing stringify the structure
and do string->yyparse->abac_aspect_t again.

2) start on inline doc into abac.hh
3) tweaked some scripts in examples directory

  • Property mode set to 100755
File size: 1.5 KB
Line 
1#!/usr/bin/env python
2
3"""
4  to test with python
5
6cmd1:env keystore=`pwd` ./id.py
7cmd2:env ABAC_CN=1 keystore=`pwd` ./id.py
8
9"""
10
11import os
12import ABAC
13
14ctxt = ABAC.Context()
15
16print "ABAC version %s" % ctxt.version()
17
18keystore=os.environ["keystore"]
19
20ctxt.load_directory(keystore)
21out = ctxt.context_principals()
22print "...initial principal set..."
23for x in out[1]:
24    print "%s " % x.string()
25print "\n" 
26
27id=ABAC.ID("Mary", 0)
28print "adding -> %s(good)" % id.name()
29id.write_cert("Mary_ID.pem")
30id.write_privkey("Mary_private.pem")
31ctxt.load_id_file("Mary_ID.pem","Mary_private.pem")
32
33nid=ABAC.ID("Jack", 0)
34print "adding -> %s(good)" % nid.name()
35ctxt.load_id(nid)
36
37id=ABAC.ID("Mark", 0)
38print "adding -> %s(good)" % id.name()
39id.write_privkey("Mark_IDKEY.pem")
40id.write_cert("Mark_IDKEY.pem")
41ctxt.load_id_file("Mark_IDKEY.pem")
42
43id=ABAC.ID("John", 0)
44print "adding -> %s(good,invisible)" % id.name()
45id.write_privkey("John_other.pem")
46id.write_cert("John_other.pem")
47ctxt.load_id_file("John_other.pem")
48
49id=ABAC.ID("Lori", 0)
50print "adding -> %s(good,nokey)" % id.name()
51id.write_cert("Lori_IDKEY.pem")
52ctxt.load_id_file("Lori_IDKEY.pem")
53
54id=ABAC.ID("Tom", 0)
55print "adding -> %s(bad,nocert)" % id.name()
56id.write_privkey("Tom_IDKEY.pem")
57ctxt.load_id_file("Tom_IDKEY.pem")
58
59print "adding -> Casper(bad,unknown file)"
60ctxt.load_id_file("Casper_IDKEY.pem")
61
62print "...final principal set..."
63out = ctxt.context_principals()
64for x in out[1]:
65    print "%s " % x.string()
66print "\n"
67
68ctxt.dump_yap()
Note: See TracBrowser for help on using the repository browser.