#!/usr/bin/env python from sys import argv, exit from ABAC import Context from Creddy import ID, Attribute if len(argv) < 3: print "Usage: creddy_abac.py " exit(1) # load the ID and its key id = None try: id = ID(argv[1]) id.load_privkey(argv[2]) except Exception, e: print "Problem loading cert: %s" % e exit(1) # create an attribute cert attr = Attribute(id, "delicious", 10) attr.principal(id.keyid()) attr.bake() # load it into libabac ctx = Context() ctx.load_id_chunk(id.cert_chunk()) ctx.load_attribute_chunk(attr.cert_chunk()) # run the proof (success, credentials) = ctx.query("%s.delicious" % id.keyid(), id.keyid()) if success: print "success!"