Commit 4cde32f8 authored by Jonathon Duerig's avatar Jonathon Duerig

Print canonicalized strings as output. If you don't the namespaces->prefix...

Print canonicalized strings as output. If you don't the namespaces->prefix bindings won't always be printed if you print out a fragment.
parent b67f5f15
......@@ -663,7 +663,7 @@ sub GetManifest($$)
return $manifest
if (!$asxml);
$xml = $manifest->toString();
$xml = $manifest->toStringC14N();
return $xml;
}
......
......@@ -691,7 +691,7 @@ sub GetTicketAuxAux($$$$$$$$)
}
}
print $rspec->toString();
print $rspec->toStringC14N();
foreach my $ref (GeniXML::FindNodes("n:node", $rspec)->get_nodelist()) {
my $resource_uuid = GeniXML::GetNodeId($ref);
......@@ -1150,7 +1150,7 @@ sub GetTicketAuxAux($$$$$$$$)
}
unlink($tmpfile);
print $solution->toString();
print $solution->toStringC14N();
foreach my $ref (GeniXML::FindNodes("n:node",
$solution)->get_nodelist()) {
......@@ -1239,7 +1239,7 @@ sub GetTicketAuxAux($$$$$$$$)
goto bad;
}
print $rspec->toString();
print $rspec->toStringC14N();
# Nalloc might fail if the node gets picked up by someone else.
if (@nodeids && !$impotent) {
......@@ -1273,7 +1273,8 @@ sub GetTicketAuxAux($$$$$$$$)
#
# Create a new ticket.
#
my $newticket = GeniTicket->Create($authority, $user, $rspec->toString());
my $newticket = GeniTicket->Create($authority, $user,
$rspec->toStringC14N());
if (!defined($newticket)) {
$response =
GeniResponse->Create(GENIRESPONSE_ERROR, undef,
......@@ -1558,7 +1559,7 @@ sub SliverWorkAux($$$$$$$)
my @freelinks= ();
my $needplabslice = 0;
print $rspec->toString();
print $rspec->toStringC14N();
#
# Find current slivers and save.
......@@ -2264,7 +2265,7 @@ sub SliverWorkAux($$$$$$$)
}
# The Manifest.
my $manifest = $rspec->toString();
my $manifest = $rspec->toStringC14N();
#
# Move this elsewhere.
......@@ -2610,7 +2611,7 @@ sub StartSliver($)
}
if (defined($manifest)) {
print $manifest->toString();
print $manifest->toStringC14N();
#
# This is not signed, so have to be very careful about using
......@@ -3400,7 +3401,7 @@ sub SliverTicket($)
POSIX::strftime("20%y-%m-%dT%H:%M:%S",
gmtime(str2time($slice->expires()))));
my $rspec_xml = $rspec->toString();
my $rspec_xml = $rspec->toStringC14N();
#
# Create a new ticket.
......@@ -4072,7 +4073,7 @@ sub UpdateManifest($)
}
}
my $manifest = $rspec->toString();
my $manifest = $rspec->toStringC14N();
#
# Move this elsewhere.
......
......@@ -408,7 +408,7 @@ sub DeleteSliver($)
$response = GeniResponse->Create(GENIRESPONSE_ERROR);
goto bad;
}
my $ticket = GeniTicket->Create($authority, $user, $manifest->toString());
my $ticket = GeniTicket->Create($authority, $user, $manifest->toStringC14N());
if (!defined($ticket)) {
print STDERR "Could not create new ticket for $slice\n";
$response = GeniResponse->Create(GENIRESPONSE_ERROR);
......
......@@ -431,7 +431,7 @@ sub Sign($$)
if ($self->extensions()->size() > 0) {
$cap_xml .= "<extensions>\n";
foreach my $node ($self->extensions()->get_nodelist()) {
$cap_xml .= $node->toString();
$cap_xml .= $node->toStringC14N();
}
$cap_xml .= "</extensions>\n";
}
......
......@@ -320,7 +320,7 @@ sub UpdateManifest($$)
return -1;
}
my $manifest_idx = $self->manifest_idx();
my $manifest_string = $manifest->toString();
my $manifest_string = $manifest->toStringC14N();
my $query_result =
DBQueryWarn("update geni_manifests set ".
......@@ -363,7 +363,7 @@ sub GetTicket($$$$)
gmtime(time() + (3600*6))));
}
my $rspec_string = $rspec->toString();
my $rspec_string = $rspec->toStringC14N();
#
# Load the SA cert to act as caller context.
......
......@@ -197,7 +197,7 @@ sub Create($$$$$$$$$)
push(@insert_data, "slice_uuid='$slice_uuid'");
if (defined($rspec)) {
my $rspec_string = $rspec->toString();
my $rspec_string = $rspec->toStringC14N();
my $safe_rspec = DBQuoteSpecial($rspec_string);
push(@insert_data, "rspec_string=$safe_rspec");
......@@ -301,7 +301,7 @@ sub GetManifest($$)
return $manifest
if (!$asxml);
my $xml = $self->rspec()->toString();
my $xml = $self->rspec()->toStringC14N();
return $xml;
}
......@@ -665,9 +665,9 @@ sub Create($$$$$$)
#
# Add this stuff to the rspec (which becomes the manifest).
#
$rspec->setAttribute("sliver_uuid", $sliver_uuid);
$rspec->setAttribute("hostname", $hostname);
$rspec->setAttribute("sshdport", $sshdport) if (defined($sshdport));
GeniXML::SetText("sliver_uuid", $rspec, $sliver_uuid);
GeniXML::SetText("hostname", $rspec, $hostname);
GeniXML::SetText("sshdport", $rspec, $sshdport) if (defined($sshdport));
return GeniSliver->Create($slice, $user, $sliver_uuid, $resource_uuid,
"Node", $resource_id, $hrn, $nickname, $rspec);
......
......@@ -578,7 +578,7 @@ sub rspecXML($)
return undef
if (!defined($self->rspec()));
return $self->rspec()->toString();
return $self->rspec()->toStringC14N();
}
#
......@@ -710,7 +710,7 @@ sub RunSigner($$)
my $target_cert = $self->target_cert()->cert();
my $owner_cert = $self->owner_cert()->cert();
my $ticket_uuid = $self->{'ticket_uuid'};
my $rspec_xml = $self->rspec()->toString();
my $rspec_xml = $self->rspec()->toStringC14N();
# Convert to GMT.
$expires = POSIX::strftime("20%y-%m-%dT%H:%M:%S",
......@@ -803,7 +803,7 @@ sub Release($$)
my $resource_uuid = GeniXML::GetNodeId($ref);
if (!defined($resource_uuid)) {
print STDERR "No resource id for node in ticket\n";
print $ref->toString();
print $ref->toStringC14N();
return -1;
}
......@@ -878,7 +878,7 @@ sub ReleaseHolding($$)
my $resource_uuid = GeniXML::GetNodeId($ref);
if (!defined($resource_uuid)) {
print STDERR "No resource id for node in ticket\n";
print $ref->toString();
print $ref->toStringC14N();
return -1;
}
......
......@@ -68,7 +68,7 @@ sub NewSliver($$$$)
}
}
if (defined($sliver->rspec())) {
my $rspec_string = $sliver->rspec()->toString();
my $rspec_string = $sliver->rspec()->toStringC14N();
my $safe_rspec = DBQuoteSpecial($rspec_string);
push(@insert_data, "rspec_string=$safe_rspec");
......@@ -310,7 +310,7 @@ sub NewManifest($$$)
my @insert_data = ();
my $aggregate_uuid = $aggregate->uuid();
my $manifest_string = $manifest->toString();
my $manifest_string = $manifest->toStringC14N();
my $safe_manifest = DBQuoteSpecial($manifest_string);
# Insert into DB.
......
......@@ -36,7 +36,7 @@ sub Parse($)
$doc = $parser->parse_string($xml);
};
if ($@) {
carp("Failed to parse xml string: $@\n");
carp("Failed to parse xml string: $@\nXML: $xml\n\n");
return undef;
} else {
return $doc->documentElement();
......@@ -52,7 +52,7 @@ sub ParseFile($)
$doc = $parser->parse_file($file);
};
if ($@) {
carp("Failed to parse xml string: $@\n");
carp("Failed to parse xml string: $@");
return undef;
} else {
return $doc->documentElement();
......
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