Commit 8cb05e32 authored by Leigh B Stoller's avatar Leigh B Stoller

Add option to create a speaksfor credential, where the speaker

is the SA instead of another user.
parent ae3ea197
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2008-2013 University of Utah and the Flux Group. # Copyright (c) 2008-2014 University of Utah and the Flux Group.
# #
# {{{GENIPUBLIC-LICENSE # {{{GENIPUBLIC-LICENSE
# #
...@@ -38,7 +38,7 @@ use Data::Dumper; ...@@ -38,7 +38,7 @@ use Data::Dumper;
# #
sub usage() sub usage()
{ {
print STDERR "Usage: $0 [-a] <user-urn> <speaker-urn>"; print STDERR "Usage: $0 [-a] <user-urn> [<speaker-urn>]\n";
exit(1); exit(1);
} }
my $optlist = "a"; my $optlist = "a";
...@@ -46,6 +46,7 @@ my $doabac = 0; ...@@ -46,6 +46,7 @@ my $doabac = 0;
# Configure ... # Configure ...
my $TB = "@prefix@"; my $TB = "@prefix@";
my $SACERT = "$TB/etc/genisa.pem";
# Do this early so that we talk to the right DB. # Do this early so that we talk to the right DB.
use vars qw($GENI_DBNAME); use vars qw($GENI_DBNAME);
...@@ -80,9 +81,28 @@ if (defined($options{"a"})) { ...@@ -80,9 +81,28 @@ if (defined($options{"a"})) {
$doabac = 1; $doabac = 1;
} }
usage() usage()
if (@ARGV < 2); if (@ARGV < 1);
my $user_urn = shift(); my $user_urn = shift();
my $speaker_urn = shift(); my $speaker;
if (@ARGV) {
my $speaker_urn = shift();
if (! (GeniHRN::IsValid($speaker_urn))) {
fatal("Malformed speaker urn");
}
$speaker = GeniUser->Lookup($speaker_urn, 1);
if (!defined($speaker)) {
fatal("No such speaker in the DB");
}
}
else {
$speaker = GeniCertificate->LoadFromFile($SACERT);
if (!defined($speaker)) {
fatal("Could not load certificate from $SACERT\n");
}
$speaker->LoadKeyFromFile($SACERT);
}
# #
# Must be an emulab user. # Must be an emulab user.
...@@ -94,13 +114,6 @@ my $geniuser = GeniUser->Lookup($user_urn, 1); ...@@ -94,13 +114,6 @@ my $geniuser = GeniUser->Lookup($user_urn, 1);
if (!defined($geniuser)) { if (!defined($geniuser)) {
fatal("No such user in the DB"); fatal("No such user in the DB");
} }
if (! (GeniHRN::IsValid($speaker_urn))) {
fatal("Malformed speaker urn");
}
my $speaker = GeniUser->Lookup($speaker_urn, 1);
if (!defined($speaker)) {
fatal("No such speaker in the DB");
}
if ($doabac) { if ($doabac) {
require ABAC; require ABAC;
...@@ -141,7 +154,7 @@ if ($doabac) { ...@@ -141,7 +154,7 @@ if ($doabac) {
print $xml; print $xml;
} }
} }
else { Else {
my $credential = GeniCredential->Create($geniuser, $speaker); my $credential = GeniCredential->Create($geniuser, $speaker);
fatal("Could not create credential") fatal("Could not create credential")
if (!defined($credential)); if (!defined($credential));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment