Example #1
0
   To demonstrate how to use ABAC's api in python to access keyid of a 
principal credential

   pre-condition: generate IceCream_ID.pem and IceCream_private.pem with
           creddy --generate --cn IceCream

   keyid of the loaded principal credential is printed

"""

from sys import argv, exit
from ABAC import ID

if len(argv) < 2:
    print "Usage: abac_keyid.py <cert.pem>"
    exit(1)

id = None
try:
    print argv[1]
    id = ID(argv[1])
    id.load_privkey(argv[2])
except Exception, e:
    print "Problem loading cert: %s" % e
    exit(1)

print id.keyid()
print 'okay'

Example #2
0
from ABAC import Context
from ABAC import ID, Attribute, Role

debug=0

## initial context
ctxt = Context()

if len(argv) != 6:
    print "Usage: abac_attr.py <cert.pem> <key.pem> <attr.xml> <pfile> <c_cert.pem>"
    exit(1)

# load the ID and its key
id = None
try:
    id = ID(argv[1])
    id.load_privkey(argv[2])
    cream_id = ID(argv[5])
except Exception, e:
    print "Problem loading ID cert: %s" % e
    exit(1)

# load the id into the context
ctxt.load_id_chunk(id.cert_chunk())
# another way to load the id into the context
# ctxt.load_id(cream_id), not implemented
ctxt.load_id_chunk(cream_id.cert_chunk())

# create an attribute cert
attr = Attribute(id, "delicious", 1000)
attr.principal(cream_id.keyid())
Example #3
0
  abac_keyid.py

   To demonstrate how to use ABAC's api in python to access keyid of a 
principal credential

   pre-condition: generate IceCream_ID.pem and IceCream_private.pem with
           creddy --generate --cn IceCream

   keyid of the loaded principal credential is printed

"""

from sys import argv, exit
from ABAC import ID

if len(argv) < 2:
    print "Usage: abac_keyid.py <cert.pem>"
    exit(1)

id = None
try:
    print argv[1]
    id = ID(argv[1])
except Exception, e:
    print "Problem loading cert: %s" % e
    exit(1)

print id.keyid()
print "okay"