Commit b8a9c13f authored by Leigh B Stoller's avatar Leigh B Stoller

Do a better job of trying to figure the caller context so that we can

look for an existing credential in the table.
parent 2fafb77e
......@@ -909,14 +909,31 @@ sub GetCredential($;$$)
{
my ($class, $context, $certfile) = @_;
$context = Genixmlrpc->GetContext()
if (!defined($context));
#
# If there is no UUID in the environment, then try to figure it
# out from the context.
#
my $myuuid = (exists($ENV{'MYUUID'}) ? $ENV{'MYUUID'} : undef);
if (!defined($myuuid) && defined($context)) {
$myuuid = $context->certificate()->uuid();
}
if (!defined($myuuid)) {
print STDERR "*** GeniRegistry::ClearingHouse::GetCredential: ".
"No context or MYUUID for RPC\n";
return undef;
}
my $clearinghousecert = GeniRegistry::ClearingHouse->GetCertificate();
if (!defined($clearinghousecert)) {
return undef;
}
my $clearinghousecred =
GeniCredential->Lookup($clearinghousecert->uuid(), $ENV{'MYUUID'});
GeniCredential->Lookup($clearinghousecert->uuid(), $myuuid);
#print "$clearinghousecred\n";
#print "$clearinghousecred\n" if (defined($clearinghousecred));
if (defined($clearinghousecred) &&
defined($clearinghousecred->expires())) {
......@@ -931,9 +948,6 @@ sub GetCredential($;$$)
}
#print STDERR "Getting new clearinghouse credential\n";
$context = Genixmlrpc->GetContext()
if (!defined($context));
my $url = $clearinghousecert->URL();
if (!defined($url)) {
print STDERR "No URI extension in $clearinghousecert\n";
......@@ -957,8 +971,11 @@ sub GetCredential($;$$)
print STDERR "Could not parse credential from clearinghouse\n";
return undef;
}
$clearinghousecred->Store();
if ($clearinghousecred->Store()) {
print STDERR "*** GeniRegistry::ClearingHouse::GetCredential: ".
"Could not store credential for clearinghouse\n";
return undef;
}
return $clearinghousecred;
}
......
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