Commit 1c9ab4d6 authored by Srikanth Chikkulapelly's avatar Srikanth Chikkulapelly
Browse files

Added PolicyExists API in GeniXML.pm.in and defined namespace constants in...

Added PolicyExists API in GeniXML.pm.in and defined namespace constants in GeniUtil.pm.in and fixed a minor bug in serializing extensions in Genicredential.
parent 2da35c7a
......@@ -32,7 +32,7 @@ use Time::Local;
use overload ('""' => 'Stringify');
# Exported variables
use vars qw(@EXPORT_OK $LOCALSA_FLAG $LOCALCM_FLAG $LOCALMA_FLAG $EXTENSIONS_NS $EXTENSIONS_PREFIX);
use vars qw(@EXPORT_OK $LOCALSA_FLAG $LOCALCM_FLAG $LOCALMA_FLAG);
# Configure variables
my $TB = "@prefix@";
......@@ -46,11 +46,6 @@ my $VERIFYCRED = "$TB/sbin/verifygenicred";
my $NFREE = "$TB/bin/nfree";
my $OPENSSL = "/usr/bin/openssl";
#Extensions namespace URI.
# TODO: pick the right NS URI, prefix and update here.
$EXTENSIONS_NS = "";
$EXTENSIONS_PREFIX = "";
# Signing flags
$LOCALSA_FLAG = 1;
$LOCALCM_FLAG = 2;
......@@ -438,7 +433,7 @@ sub Sign($$)
}
$cap_xml .= "</privileges>\n";
$cap_xml .= GeniXML::Serialize($self->{'extensions'});
$cap_xml .= $self->{'extensions'};
# Every one gets a new unique index, which is used in the xml:id below.
my $idx = TBGetUniqueIndex('next_ticket', 1);
......
......@@ -11,7 +11,7 @@ use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = "Exporter";
@EXPORT = qw(NewUUID GENI_PURGEFLAG FindHostname);
@EXPORT = qw(NewUUID GENI_PURGEFLAG FindHostname $EXTENSIONS_NS $EXTENSIONS_PREFIX);
use English;
use Data::Dumper;
......@@ -28,6 +28,11 @@ my $OUTERBOSS_NODENAME = "@OUTERBOSS_NODENAME@";
my $user = "geniuser";
my $group = "GeniSlices";
#Extensions namespace URI.
# TODO: pick the right NS URI, prefix and update here.
$EXTENSIONS_NS = "";
$EXTENSIONS_PREFIX = "";
sub GENI_PURGEFLAG() { return 1; }
#
......
......@@ -11,13 +11,14 @@ use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = "Exporter";
@EXPORT = qw(Parse ParseFile FindNodes FindNodesNS FindFirst FindElement FindAttr IsLanNode IsLocalNode GetNodeId GetVirtualId GetManagerId SetText GetText CreateDocument AddElement);
@EXPORT = qw(Parse ParseFile FindNodes FindNodesNS FindFirst FindElement FindAttr IsLanNode IsLocalNode GetNodeId GetVirtualId GetManagerId SetText GetText CreateDocument AddElement PolicyExists);
use English;
use XML::LibXML;
use XML::LibXML::XPathContext;
use XML::LibXML::NodeList;
use GeniHRN;
use GeniUtil;
use Carp qw(cluck carp);
# Configure variables
......@@ -317,5 +318,26 @@ sub RemoveChild($$)
}
}
# checks for the existense of policy in extensions of the given
# credential.
sub PolicyExists($$)
{
my ($policy, $credential) = @_;
my $exists = 0;
return 0
if (!ref($credential) or !defined(policy));
my $policies = GeniXML::FindNodesNS("//n:policy_exceptions/*",
$credential->{'extensions'}, $GeniUtil::EXTENSIONS_NS);
foreach my $epolicy ($policies->get_nodelist) {
if ($policy eq $epolicy->string_value) {
$exists = 1;
last;
}
}
return $exists;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
Supports Markdown
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