コード例 #1
0
ファイル: abac_e_attr.py プロジェクト: nbsdx/abac
    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())
attr.bake()

# load attribute cert into the context
ctxt.load_attribute_chunk(attr.cert_chunk())

# another way to load the attribute cert into the context,
# ctxt.load_attribute(attr)

# yet another way to load the attribute cert into the context,
attr.write_file(argv[3])
# ctxt.load_attribute_file(argv[3])

print '---------'
(credentials) = ctxt.credentials()
for credential in credentials:
コード例 #2
0
ファイル: abac_keyid2.py プロジェクト: nbsdx/abac
   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'