source: tests/example_scripts/wiki/ctxtQuery4.py @ bceef20

abac0-leakabac0-mei
Last change on this file since bceef20 was bceef20, checked in by Mei <mei@…>, 11 years ago

1) add the new tests

  • Property mode set to 100755
File size: 957 bytes
Line 
1#!/usr/bin/env python
2"""
3ctxtQuery4.py
4 
5shows use of mnemonic name for principals
6
7"""
8import os
9import ABAC
10
11ctx = ABAC.Context()
12
13ctx.load_attribute_file('./abac_cred.xml')
14ctx.load_attribute_file('./coyote.xml')
15
16for c in ctx.credentials():
17    print "Raw: %s -> %s" % (c.head().string(), c.tail().string())
18    print "Short: %s -> %s" % (c.head().short_string(ctx), c.tail().short_string(ctx))
19
20# Collect the identity keyids into ids
21ids = []
22for c in ctx.credentials():
23    i = ABAC.ID_chunk(c.issuer_cert())
24    if i.keyid() not in ids:
25        ids.append(i.keyid())
26
27# Change all the nicknames
28for n, i in enumerate(ids):
29    print ctx.set_nickname(i, "identity%d" % n)
30
31# Print the credentials with the new nicknames
32print ""
33print "After modifications"
34print ""
35for c in ctx.credentials():
36    print "Raw: %s -> %s" % (c.head().string(), c.tail().string())
37    print "Short: %s -> %s" % (c.head().short_string(ctx), c.tail().short_string(ctx))
38
Note: See TracBrowser for help on using the repository browser.