source: swig/python/creddy_abac.py @ df3fe37

abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2tvf-new-xml
Last change on this file since df3fe37 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
3from sys import argv, exit
4from ABAC import Context
5from Creddy import ID, Attribute
6
7if len(argv) < 3:
8    print "Usage: creddy_abac.py <cert.pem> <key.pem>"
9    exit(1)
10
11# load the ID and its key
12id = None
13try:
14    id = ID(argv[1])
15    id.load_privkey(argv[2])
16except Exception, e:
17    print "Problem loading cert: %s" % e
18    exit(1)
19
20# create an attribute cert
21attr = Attribute(id, "delicious", 10)
22attr.principal(id.keyid())
23attr.bake()
24
25# load it into libabac
26ctx = Context()
27ctx.load_id_chunk(id.cert_chunk())
28ctx.load_attribute_chunk(attr.cert_chunk())
29
30# run the proof
31(success, credentials) = ctx.query("%s.delicious" % id.keyid(), id.keyid())
32if success:
33    print "success!"
Note: See TracBrowser for help on using the repository browser.