abac0-leakabac0-mei
Last change
on this file since 2be12d2 was
bceef20,
checked in by Mei <mei@…>, 11 years ago
|
1) add the new tests
|
-
Property mode set to
100755
|
File size:
1.2 KB
|
Rev | Line | |
---|
[bceef20] | 1 | #!/usr/bin/env python |
---|
| 2 | """ |
---|
| 3 | attr4.py |
---|
| 4 | |
---|
| 5 | generate an attribute with principal initialized |
---|
| 6 | with nickname |
---|
| 7 | |
---|
| 8 | """ |
---|
| 9 | import os |
---|
| 10 | import sys |
---|
| 11 | import ABAC |
---|
| 12 | |
---|
| 13 | ctx = ABAC.Context() |
---|
| 14 | |
---|
| 15 | ## this would replace |
---|
| 16 | ctx.load_id_file('./issuer.pem') |
---|
| 17 | i = ABAC.ID('./issuer.pem') |
---|
| 18 | ctx.set_nickname(i.keyid(), "Ted") |
---|
| 19 | a = ABAC.Attribute(i, 'ABAC_Guy', 20 * 365 * 24 * 3600) |
---|
| 20 | a.principal(i.keyid()) |
---|
| 21 | a.bake(ctx) |
---|
| 22 | a.write_file("Ted_attr.xml") |
---|
| 23 | a.write(sys.stdout) |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | ## this would not replace |
---|
| 27 | ctx.load_id_file('./issuer2.pem') |
---|
| 28 | i2 = ABAC.ID('./issuer2.pem') |
---|
| 29 | ctx.set_nickname(i2.keyid(), "AnotherTed") |
---|
| 30 | a2 = ABAC.Attribute(i2, 'ABAC_Guy', 20 * 365 * 24 * 3600) |
---|
| 31 | a2.principal(i.keyid()) |
---|
| 32 | a2.bake() |
---|
| 33 | a2.write_file("AnotherTed_attr.xml") |
---|
| 34 | a2.write(sys.stdout) |
---|
| 35 | |
---|
| 36 | ## this would be mixed ? |
---|
| 37 | ctx.set_nickname(i.keyid(), "OtherTed") |
---|
| 38 | a3 = ABAC.Attribute(i, 'ABAC_Guy', 20 * 365 * 24 * 3600) |
---|
| 39 | a3.principal(i2.keyid()) |
---|
| 40 | a3.bake(ctx) |
---|
| 41 | a3.write_file("OtherTed_attr.xml") |
---|
| 42 | a3.write(sys.stdout) |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | ## this would replace with original common name.. |
---|
| 46 | ctx.load_id_file('./issuer3.pem') |
---|
| 47 | i3 = ABAC.ID('./issuer3.pem') |
---|
| 48 | a3 = ABAC.Attribute(i3, 'ABAC_Guy', 20 * 365 * 24 * 3600) |
---|
| 49 | a3.principal(i3.keyid()) |
---|
| 50 | a3.bake(ctx) |
---|
| 51 | a3.write_file("NotTed_attr.xml") |
---|
| 52 | a3.write(sys.stdout) |
---|
| 53 | |
---|
Note: See
TracBrowser
for help on using the repository browser.