source: tests/example_scripts/wiki/id5.py @ bceef20

abac0-leakabac0-mei
Last change on this file since bceef20 was bec30b5, checked in by Mei <mei@…>, 11 years ago

1) change abac_context_load_directory to check on every regular files

and try to extract id id/privkey and then attribute in turn.

2) move id_certs to be context based instead of shared globally

  • Property mode set to 100755
File size: 1.1 KB
Line 
1#!/usr/bin/env python
2"""
3id4.py
4"""
5import os
6import ABAC
7
8id = ABAC.ID("newGuy", 5*365*3600*24)
9oid = ABAC.ID("oldGuy", 5*365*3600*24)
10
11oid.write_cert_file("./oldGuy.pem")
12
13id.write_cert_file("./newGuy.pem")
14id.write_privkey_file("./newGuy.pem")
15
16id1 = ABAC.ID("./newGuy.pem")
17id1.load_privkey("./newGuy.pem")
18
19id2 = ABAC.ID("./newGuy.pem")
20
21try:
22    f = open("./newGuy.pem")
23    id3 = ABAC.ID_chunk(f.read())
24    f.close()
25except:
26    pass
27
28try:
29    f = open("./newGuy.pem")
30    id4 = ABAC.ID_chunk(f.read())
31    f.seek(0,0) 
32    id4.load_privkey_chunk(f.read())
33    f.close()
34except:
35    pass
36
37id5 = ABAC.ID("./oldGuy.pem")
38
39## can not test out this,
40#id6 = ABAC.ID("./oldGuy.pem")
41#id6.load_privkey("./newGuy.pem")
42#id7 = ABAC.ID("./oldGuy.pem")
43#id7.load_privkey("./oldGuy.pem")
44
45print "id has privkey %d" % id.has_privkey()
46print "id1 has privkey %d" % id1.has_privkey()
47print "id2 has privkey %d" % id2.has_privkey()
48print "id3 has privkey %d" % id3.has_privkey()
49print "id4 has privkey %d" % id4.has_privkey()
50
51print "id5 has privkey %d" % id5.has_privkey()
52#print "id6 has privkey %d" % id6.has_privkey()
53#print "id7 has privkey %d" % id7.has_privkey()
Note: See TracBrowser for help on using the repository browser.