abac0-leakabac0-meimei-idmei-rt0-nmei_rt0tvf-new-xml
Last change
on this file since 02036f4 was
4721618,
checked in by Mei <mei@…>, 12 years ago
|
1) tested out python and perl test scripts along with
abac_chunk_t calls in libabac's abac.hh
|
-
Property mode set to
100755
|
File size:
1.3 KB
|
Rev | Line | |
---|
[4721618] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use ABAC; |
---|
| 5 | use Getopt::Long; |
---|
| 6 | use Data::Dumper; |
---|
| 7 | $Data::Dumper::Indent = 1; |
---|
| 8 | |
---|
| 9 | my ($idfile, $keyfile, $id2file, $attrxml); |
---|
| 10 | GetOptions( |
---|
| 11 | 'id=s' => \$idfile, |
---|
| 12 | 'key=s' => \$keyfile, |
---|
| 13 | 'id2=s' => \$id2file, |
---|
| 14 | 'attr=s' => \$attrxml, |
---|
| 15 | ) || usage(); |
---|
| 16 | |
---|
| 17 | usage() unless defined $idfile && defined $keyfile && $id2file && defined $attrxml; |
---|
| 18 | |
---|
| 19 | my $ctx = ABAC::Context->new; |
---|
| 20 | |
---|
| 21 | my $ice; |
---|
| 22 | my $choco; |
---|
| 23 | eval { |
---|
| 24 | # will throw a RuntimeException if it can't load the cert |
---|
| 25 | $ice = ABAC::ID->new($idfile); |
---|
| 26 | $ice->load_privkey($keyfile); |
---|
| 27 | $choco = ABAC::ID->new($id2file); |
---|
| 28 | }; |
---|
| 29 | if ($@) { |
---|
| 30 | print "ERROR, Problem loading cert: $@"; |
---|
| 31 | exit; |
---|
| 32 | } |
---|
| 33 | print $ice->keyid, " , ice cream\n"; |
---|
| 34 | print $choco->keyid, " , chocolate\n"; |
---|
| 35 | |
---|
| 36 | my $attr; |
---|
| 37 | eval { |
---|
| 38 | $attr = ABAC::Attribute->new($ice,"delicious",1000); |
---|
| 39 | $attr->principal($choco->keyid()); |
---|
| 40 | $attr->bake(); |
---|
| 41 | }; |
---|
| 42 | |
---|
| 43 | if ($@) { |
---|
| 44 | print "ERROR, Problem baking attribute: $@"; |
---|
| 45 | exit; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | eval { |
---|
| 49 | $attr->write_file($attrxml); |
---|
| 50 | }; |
---|
| 51 | if ($@) { |
---|
| 52 | print "ERROR, Problem writing attribute's xml file: $@"; |
---|
| 53 | exit; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | sub usage { |
---|
| 57 | print "Usage: $0 \\\n"; |
---|
| 58 | print " --id <idfile> --key <keyfile> \n"; |
---|
| 59 | print " --id2 <id2file> --attr <attrxml>\n"; |
---|
| 60 | print " loads id/key, id2, and makes attr\n"; |
---|
| 61 | exit 1; |
---|
| 62 | } |
---|
| 63 | |
---|
Note: See
TracBrowser
for help on using the repository browser.