source: examples/python_tests/basic_id/id_ctxt.py @ b4b0d0a

mei_rt2
Last change on this file since b4b0d0a was 2e9455f, checked in by Mei <mei@…>, 11 years ago

1) added namespace
2) tweak ?This,
3) allowing linking role/oset as constraining conditions
4) adding access_tests regression testing that uses GENI's access policy
5) added couple multi contexts regression tests
6) add compression/uncompression calls to abac_encode_string/abac_decode_string
(libstrongwan only allows 512 char for attribute rule storage)
7) add attribute_now option to creddy that takes a whole char string for attribute
rule

  • Property mode set to 100755
File size: 1.1 KB
Line 
1#!/usr/bin/env python
2
3"""
4  to test when an id gets loaded into the session
5vs when it gets loaded into a context
6
7cmd1:env keystore=`pwd` ./id_ctxt.py
8cmd2:env ABAC_CN=1 keystore=`pwd` ./id_ctxt.py
9
10"""
11
12import os
13import ABAC
14
15def pSZ(CTXT,msg):
16   psz= CTXT.principal_count()
17   csz= CTXT.credential_count()
18   print "context [%s] %d principals, %d credentials" % (msg,psz,csz)
19
20ctxtA = ABAC.Context()
21ctxtB = ABAC.Context()
22
23ABAC.dump_debug_info("first")
24pSZ(ctxtA, "A")
25pSZ(ctxtB, "B")
26
27## creating and writing out using libabac ID
28id=ABAC.ID("Ella", 0)
29print "adding -> %s(good) to session" % id.id_name()
30id.id_write_cert("Ella_ID.pem")
31id.id_write_privkey("Ella_private.pem")
32
33ABAC.dump_debug_info("second")
34pSZ(ctxtA, "A")
35pSZ(ctxtB, "B")
36
37## load principal with id/key file pair
38## note, with this, we do not have handle on the keyid
39## to Ella but it will be in the db
40print "loading -> %s to ctxtA" % id.id_name()
41ctxtA.load_id_files("Ella_ID.pem","Ella_private.pem")
42
43print "loading -> Bob to ctxtB"
44ctxtB.load_id_files("Bob_ID.pem","Bob_private.pem")
45
46ABAC.dump_debug_info("third")
47pSZ(ctxtA, "A")
48pSZ(ctxtB, "B")
Note: See TracBrowser for help on using the repository browser.