abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2tvf-new-xml
Last change
on this file since 0cdea0b was
d61911e,
checked in by Mike Ryan <mikeryan@…>, 14 years ago
|
example code for integrating creddy and libabac
|
-
Property mode set to
100755
|
File size:
710 bytes
|
Line | |
---|
1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | from sys import argv, exit |
---|
4 | from ABAC import Context |
---|
5 | from Creddy import ID, Attribute |
---|
6 | |
---|
7 | if len(argv) < 3: |
---|
8 | print "Usage: creddy_abac.py <cert.pem> <key.pem>" |
---|
9 | exit(1) |
---|
10 | |
---|
11 | # load the ID and its key |
---|
12 | id = None |
---|
13 | try: |
---|
14 | id = ID(argv[1]) |
---|
15 | id.load_privkey(argv[2]) |
---|
16 | except Exception, e: |
---|
17 | print "Problem loading cert: %s" % e |
---|
18 | exit(1) |
---|
19 | |
---|
20 | # create an attribute cert |
---|
21 | attr = Attribute(id, "delicious", 10) |
---|
22 | attr.principal(id.keyid()) |
---|
23 | attr.bake() |
---|
24 | |
---|
25 | # load it into libabac |
---|
26 | ctx = Context() |
---|
27 | ctx.load_id_chunk(id.cert_chunk()) |
---|
28 | ctx.load_attribute_chunk(attr.cert_chunk()) |
---|
29 | |
---|
30 | # run the proof |
---|
31 | (success, credentials) = ctx.query("%s.delicious" % id.keyid(), id.keyid()) |
---|
32 | if success: |
---|
33 | print "success!" |
---|
Note: See
TracBrowser
for help on using the repository browser.