Commit 9ea87020 authored by Jonathon Duerig's avatar Jonathon Duerig

Various bugfixes to conform with jFed

parent ca3a2979
......@@ -52,15 +52,16 @@ my $coder = Frontier::RPC2->new('use_objects' => 1);
sub GetVersion()
{
my $blob = {
"VERSION" => $coder->string("0.1"),
"CREDENTIAL_TYPES" => ["SFA"]
"VERSION" => $coder->string("0.2"),
"CREDENTIAL_TYPES" => ["SFA"], #=> [$coder->string("3")]],
"SERVICES" => ["MEMBER"]
};
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
}
sub LookupPublic($)
{
my ($options) = @_;
my ($credential_args, $options) = @_;
my ($match, $filter) = GeniStd::GetMatchFilter($options);
......@@ -170,14 +171,14 @@ sub GetCredentials($$$)
{
my ($member_urn, $credential_args, $options) = @_;
my $credential = GeniSA::GetCredential($member_urn);
my $credential = GeniSA::GetCredential({ "urn" => $member_urn });
return $credential
if (GeniResponse::IsResponse($credential));
if (GeniResponse::IsError($credential));
my $blob = {
"geni_type" => "sfa",
"geni_type" => "geni_sfa",
"geni_version" => $coder->string("3"),
"geni_credential" => $credential->value()
"geni_value" => $credential->{"value"}
};
return GeniResponse->Create(GENIRESPONSE_SUCCESS, [$blob]);
......
......@@ -54,12 +54,14 @@ sub FilterCredentials
{
my ($credentials) = @_;
my $result = [];
foreach my $cred (@{ $credentials }) {
if (ref($cred) eq "HASH" &&
$cred->{'geni_type'} eq "geni_sfa" &&
($cred->{'geni_version'} eq 2 || $cred->{'geni_version'} eq 3)) {
push(@{ $result }, $cred->{'geni_value'});
auto_add_sa($cred->{'geni_value'});
if (defined($credentials)) {
foreach my $cred (@{ $credentials }) {
if (ref($cred) eq "HASH" &&
$cred->{'geni_type'} eq "geni_sfa" &&
($cred->{'geni_version'} eq 2 || $cred->{'geni_version'} eq 3)) {
push(@{ $result }, $cred->{'geni_value'});
auto_add_sa($cred->{'geni_value'});
}
}
}
return $result;
......@@ -353,13 +355,20 @@ sub CheckCredentials($)
sub FilterFields($$)
{
my ($blob, $filterList) = @_;
my $hasFilter = 0;
if (defined($filterList)) {
$hasFilter = 1;
}
my $filter = {};
foreach my $item ( @{ $filterList } ) {
$filter->{$item} = 1;
if ($hasFilter)
{
foreach my $item ( @{ $filterList } ) {
$filter->{$item} = 1;
}
}
my $result = {};
foreach my $key (keys(%{ $blob })) {
if (defined($filter) && exists($filter->{$key})) {
if (! $hasFilter || exists($filter->{$key})) {
$result->{$key} = $blob->{$key};
}
}
......@@ -375,6 +384,7 @@ sub GetMatchFilter($)
if (exists($options->{'match'})) {
push(@{ $match }, getMaybeArray($options->{'match'}->{'MEMBER_URN'}));
push(@{ $match }, getMaybeArray($options->{'match'}->{'MEMBER_UID'}));
push(@{ $match }, getMaybeArray($options->{'match'}->{'SLICE_URN'}));
}
......
......@@ -49,12 +49,14 @@ use GeniRegistry;
use emutil;
use Data::Dumper;
my $coder = Frontier::RPC2->new('use_objects' => 1);
sub GetVersion()
{
my $blob = {
"VERSION" => "0.1",
"SERVICES" => ["SLICE", "SLICE_INFO", "SLICE_MEMBER"],
"CREDENTIAL_TYPES" => ["SFA"],
"VERSION" => $coder->string("0.1"),
"SERVICES" => ["SLICE", "SLIVER_INFO", "SLICE_MEMBER"],
"CREDENTIAL_TYPES" => ["SFA"], # => [$coder->string("3")]],
"ROLES" => ["AUTHORITY", "ADMIN", "MEMBER"]
};
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
......@@ -91,8 +93,8 @@ sub CreateSlice($$)
my $sliceCred = GeniCredential->CreateFromSigned(GeniResponse::value($response));
my $blob = {
"SLICE_URN" => $sliceCred->target_urn(),
"SLICE_EXPIRATION" => $sliceCred->expires(),
"SLICE_CREDENTIAL" => GeniResponse::value($response)
"SLICE_EXPIRATION" => $sliceCred->expires()
# ,"SLICE_CREDENTIAL" => GeniResponse::value($response)
};
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
}
......@@ -114,24 +116,24 @@ sub LookupSlices()
my $members = {};
if (defined($match)) {
print STDERR "-- DEFINED\n";
foreach my $key (@{ $match }) {
my $slice = GeniSlice->Lookup($key, 0);
print STDERR "-- foreach\n";
my $slice = GeniSlice->Lookup($key);
if (defined($slice)) {
my $blob = {};
GeniStd::addField($blob, "SLICE_URN", $slice->urn(),
$filter);
GeniStd::addField($blob, "SLICE_UID", $slice->uid(),
$filter);
GeniStd::addField($blob, "SLICE_CREATION", $slice->created(),
$filter);
GeniStd::addField($blob, "SLICE_EXPIRATION", $slice->expires(),
$filter);
GeniStd::addField($blob, "EXPIRED", "False",
$filter);
GeniStd::addField($blob, "SLICE_NAME", $slice->hrn(),
$filter);
GeniStd::addField($blob, "SLICE_DESCRIPTION", "A Slice",
$filter);
print STDERR "-- found slice\n";
my $completeblob = {
"SLICE_URN" => $slice->urn(),
"SLICE_UID" => $slice->uuid(),
"SLICE_CREATION" => $slice->created(),
"SLICE_EXPIRATION" => $slice->expires(),
"SLICE_EXPIRED" => "False",
"SLICE_NAME" => $slice->hrn(),
"SLICE_DESCRIPTION" => "A Slice",
"SLICE_PROJECT_URN" => "Unimplemented"
};
my $blob = GeniStd::FilterFields($completeblob, $filter);
$members->{$slice->urn()} = $blob;
}
}
}
......@@ -155,14 +157,14 @@ sub GetCredentials()
return GeniResponse->MalformedArgsResponse('Requires a slice urn, a list of credentials, and an options field');
}
my $credential = GeniSA::GetCredential($slice_urn);
my $credential = GeniSA::GetCredential({ "urn" => $slice_urn });
return $credential
if (GeniResponse::IsResponse($credential));
if (GeniResponse::IsError($credential));
my $blob = {
"geni_type" => "sfa",
"geni_type" => "3",
"geni_credential" => GeniResponse::value($credential)
"geni_type" => "geni_sfa",
"geni_version" => $coder->string("3"),
"geni_value" => $credential->{"value"}
};
return GeniResponse->Create(GENIRESPONSE_SUCCESS, [$blob]);
......
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