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

Add methods to return an authority's api level and api (AM, CM).

parent ee9f9a2e
...@@ -95,6 +95,8 @@ sub Lookup($$) ...@@ -95,6 +95,8 @@ sub Lookup($$)
my $self = {}; my $self = {};
$self->{'AUTHORITY'} = $query_result->fetchrow_hashref(); $self->{'AUTHORITY'} = $query_result->fetchrow_hashref();
$self->{'version'} = undef; $self->{'version'} = undef;
$self->{'apilevel'} = undef;
$self->{'api'} = undef;
bless($self, $class); bless($self, $class);
# #
...@@ -178,7 +180,9 @@ sub url($) { return field($_[0], "url"); } ...@@ -178,7 +180,9 @@ sub url($) { return field($_[0], "url"); }
sub hrn($) { return field($_[0], "hrn"); } sub hrn($) { return field($_[0], "hrn"); }
sub type($) { return field($_[0], "type"); } sub type($) { return field($_[0], "type"); }
sub disabled($) { return field($_[0], "disabled"); } sub disabled($) { return field($_[0], "disabled"); }
sub version($) { return field($_[0], "version"); } sub version($) { return $_[0]->{"version"}; }
sub apilevel($) { return $_[0]->{"apilevel"}; }
sub api($) { return $_[0]->{"api"}; }
sub cert($) { return $_[0]->{'CERT'}->cert(); } sub cert($) { return $_[0]->{'CERT'}->cert(); }
sub GetCertificate($) { return $_[0]->{'CERT'}; } sub GetCertificate($) { return $_[0]->{'CERT'}; }
...@@ -329,13 +333,53 @@ sub Version($) ...@@ -329,13 +333,53 @@ sub Version($)
return undef; return undef;
} }
if (ref($response->value())) { if (ref($response->value())) {
$self->{'version'} = $response->value()->{'api'}; # Look for the AM interface.
if (exists($response->value()->{'geni_api'})) {
$self->{'version'} = $response->value()->{'geni_api'};
# This was wrong; it should be 2.0 not 1.0
$self->{'version'} = 2.0 if ($self->{'version'} == 1.0);
$self->{'apilevel'} = 0;
$self->{'api'} = "AM";
}
else {
$self->{'version'} = $response->value()->{'api'};
$self->{'apilevel'} = $response->value()->{'level'};
$self->{'apilevel'} = 0;
$self->{'api'} = "CM";
}
} }
else { else {
$self->{'version'} = $response->value(); $self->{'version'} = $response->value();
$self->{'apilevel'} = 1;
$self->{'api'} = "CM";
} }
return $self->{'version'}; return $self->{'version'};
} }
# Ditto for the API level
sub ApiLevel($)
{
my ($self) = @_;
return $self->apilevel()
if (defined($self->apilevel()));
return undef
if (!defined($self->Version()));
return $self->apilevel();
}
sub Api($)
{
my ($self) = @_;
return $self->api()
if (defined($self->api()));
return undef
if (!defined($self->Version()));
return $self->api();
}
# #
# Check that the authority is the issuer of the given certificate. # Check that the authority is the issuer of the given certificate.
......
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